From 6e7b387e6ad1b945152c7652c4862463c7edf3ab Mon Sep 17 00:00:00 2001 From: WayofTime Date: Thu, 29 Mar 2018 16:05:56 -0400 Subject: [PATCH] Added additional effects to the Sentient Bow when aspected to different Will types. --- changelog.txt | 1 + .../projectile/EntitySentientArrow.java | 113 +++++++-- .../bloodmagic/item/soul/ItemSentientBow.java | 228 +++++++++++------- 3 files changed, 245 insertions(+), 97 deletions(-) diff --git a/changelog.txt b/changelog.txt index e27942ad..4716494f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -8,6 +8,7 @@ Version 2.2.8 - Added a new (slightly WIP?) array, the Turret Array: - Place an array on top of an inventory with arrows and then place a bow and an arrow in the array. The array will target enemies greater than 3 blocks away and less than 32, using any arrows in the inventory. - Increased the max number of items transferable by the Master Routing Node in its system to 64 per second. Will revisit this limit if I figure out a less silly upgrade system. +- Added additional effects to the Sentient Bow when aspected to different Will types. ------------------------------------------------------ Version 2.2.7 diff --git a/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySentientArrow.java b/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySentientArrow.java index b4950f64..1e91024e 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySentientArrow.java +++ b/src/main/java/WayofTime/bloodmagic/entity/projectile/EntitySentientArrow.java @@ -1,41 +1,59 @@ package WayofTime.bloodmagic.entity.projectile; -import WayofTime.bloodmagic.util.Constants; -import WayofTime.bloodmagic.soul.EnumDemonWillType; -import WayofTime.bloodmagic.soul.PlayerDemonWillHandler; +import java.util.Locale; + import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.IMob; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityTippedArrow; import net.minecraft.init.Items; +import net.minecraft.init.MobEffects; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.PotionEffect; import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; +import WayofTime.bloodmagic.soul.EnumDemonWillType; +import WayofTime.bloodmagic.soul.PlayerDemonWillHandler; +import WayofTime.bloodmagic.util.Constants; -import java.util.Locale; - -public class EntitySentientArrow extends EntityTippedArrow { +public class EntitySentientArrow extends EntityTippedArrow +{ public double reimbursedAmountOnHit = 0; public EnumDemonWillType type = EnumDemonWillType.DEFAULT; + public int currentLevel = 0; + public float[] destructiveExplosionRadius = { 0.5f, 1, 1.5f, 2, 2.5f, 3, 3.5f }; + public int[] poisonDuration = { 50, 100, 150, 80, 120, 160, 200 }; + public int[] poisonLevel = { 0, 0, 0, 1, 1, 1, 1 }; + public int[] levitationDuration = { 20, 40, 60, 80, 100, 120, 160 }; + public int[] levitationLevel = { 0, 0, 0, 1, 1, 1, 2 }; + public int[] slownessDuration = { 40, 60, 100, 150, 200, 250, 300 }; + public int[] slownessLevel = { 0, 0, 0, 1, 1, 1, 2 }; - public EntitySentientArrow(World worldIn) { + public EntitySentientArrow(World worldIn) + { super(worldIn); } - public EntitySentientArrow(World worldIn, double x, double y, double z) { + public EntitySentientArrow(World worldIn, double x, double y, double z) + { super(worldIn, x, y, z); } - public EntitySentientArrow(World worldIn, EntityLivingBase shooter, EnumDemonWillType type, double reinburseAmount) { + public EntitySentientArrow(World worldIn, EntityLivingBase shooter, EnumDemonWillType type, double reinburseAmount, int currentLevel) + { super(worldIn, shooter); this.reimbursedAmountOnHit = reinburseAmount; this.type = type; + this.currentLevel = currentLevel; } - public void reimbursePlayer(EntityLivingBase hitEntity, float damage) { - if (this.shootingEntity instanceof EntityPlayer) { - if (hitEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(hitEntity instanceof IMob)) { + public void reimbursePlayer(EntityLivingBase hitEntity, float damage) + { + if (this.shootingEntity instanceof EntityPlayer) + { + if (hitEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(hitEntity instanceof IMob)) + { return; } @@ -44,23 +62,88 @@ public class EntitySentientArrow extends EntityTippedArrow { } @Override - public void writeEntityToNBT(NBTTagCompound tag) { + protected void arrowHit(EntityLivingBase living) + { + super.arrowHit(living); + + switch (type) + { + case CORROSIVE: + living.addPotionEffect(new PotionEffect(MobEffects.POISON, currentLevel >= 0 ? poisonDuration[currentLevel] : 0, currentLevel >= 0 ? poisonLevel[currentLevel] : 0)); + break; + case DEFAULT: + break; + case DESTRUCTIVE: + this.world.createExplosion(this, this.posX, this.posY, this.posZ, currentLevel >= 0 ? destructiveExplosionRadius[currentLevel] : 0, false); + break; + case STEADFAST: + living.addPotionEffect(new PotionEffect(MobEffects.LEVITATION, currentLevel >= 0 ? levitationDuration[currentLevel] : 0, currentLevel >= 0 ? levitationLevel[currentLevel] : 0)); + break; + case VENGEFUL: + living.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, currentLevel >= 0 ? slownessDuration[currentLevel] : 0, currentLevel >= 0 ? slownessLevel[currentLevel] : 0)); + break; + default: + break; + } + } + + @Override + public void onUpdate() + { + super.onUpdate(); + + if (!this.world.isRemote && this.inGround && this.timeInGround > 0) + { + switch (type) + { + case DESTRUCTIVE: + this.world.createExplosion(this, this.posX, this.posY, this.posZ, currentLevel >= 0 ? destructiveExplosionRadius[currentLevel] : 0, false); + this.setDead(); + break; + case CORROSIVE: + break; + case DEFAULT: + break; + case STEADFAST: + break; + case VENGEFUL: + break; + default: + break; + } + } +// else if (this.inGround && this.timeInGround != 0 && !this.customPotionEffects.isEmpty() && this.timeInGround >= 600) +// { +// this.world.setEntityState(this, (byte)0); +// this.potion = PotionTypes.EMPTY; +// this.customPotionEffects.clear(); +// this.dataManager.set(COLOR, Integer.valueOf(-1)); +// } + } + + @Override + public void writeEntityToNBT(NBTTagCompound tag) + { super.writeEntityToNBT(tag); tag.setDouble("reimbursement", reimbursedAmountOnHit); + tag.setInteger("currentLevel", currentLevel); tag.setString(Constants.NBT.WILL_TYPE, type.toString()); } @Override - public void readEntityFromNBT(NBTTagCompound tag) { + public void readEntityFromNBT(NBTTagCompound tag) + { super.readEntityFromNBT(tag); reimbursedAmountOnHit = tag.getDouble("reimbursement"); type = EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH)); + currentLevel = tag.getInteger("currentLevel"); } @Override - protected ItemStack getArrowStack() { + protected ItemStack getArrowStack() + { return new ItemStack(Items.ARROW); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java index b4b104bc..70e48450 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java @@ -40,56 +40,68 @@ import java.util.Locale; public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentientTool, IVariantProvider//, IMeshProvider { - public static int[] soulBracket = new int[]{16, 60, 200, 400, 1000}; - public static double[] defaultDamageAdded = new double[]{0.25, 0.5, 0.75, 1, 1.25}; - public static float[] velocityAdded = new float[]{0.25f, 0.5f, 0.75f, 1, 1.25f}; - public static double[] soulDrainPerSwing = new double[]{0.05, 0.1, 0.2, 0.4, 0.75}; //TODO - public static double[] soulDrop = new double[]{2, 4, 7, 10, 13}; - public static double[] staticDrop = new double[]{1, 1, 2, 3, 3}; + public static int[] soulBracket = new int[] { 16, 60, 200, 400, 1000, 2000, 4000 }; + public static double[] defaultDamageAdded = new double[] { 0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75 }; + public static float[] velocityAdded = new float[] { 0.25f, 0.5f, 0.75f, 1, 1.25f, 1.5f, 1.75f }; + public static double[] soulDrainPerSwing = new double[] { 0.05, 0.1, 0.2, 0.4, 0.75, 1, 1.5 }; //TODO + public static double[] soulDrop = new double[] { 2, 4, 7, 10, 13, 16, 24 }; + public static double[] staticDrop = new double[] { 1, 1, 2, 3, 3, 3, 4 }; - public ItemSentientBow() { + public ItemSentientBow() + { super(); setUnlocalizedName(BloodMagic.MODID + ".sentientBow"); setCreativeTab(BloodMagic.TAB_BM); - this.addPropertyOverride(new ResourceLocation("pull"), new IItemPropertyGetter() { + this.addPropertyOverride(new ResourceLocation("pull"), new IItemPropertyGetter() + { @SideOnly(Side.CLIENT) - public float apply(ItemStack stack, World world, EntityLivingBase entityIn) { - if (entityIn == null) { + public float apply(ItemStack stack, World world, EntityLivingBase entityIn) + { + if (entityIn == null) + { return 0.0F; - } else { + } else + { ItemStack itemstack = entityIn.getActiveItemStack(); return !itemstack.isEmpty() && itemstack.getItem() == RegistrarBloodMagicItems.SENTIENT_BOW ? (float) (stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) / 20.0F : 0.0F; } } }); - this.addPropertyOverride(new ResourceLocation("pulling"), new IItemPropertyGetter() { + this.addPropertyOverride(new ResourceLocation("pulling"), new IItemPropertyGetter() + { @SideOnly(Side.CLIENT) - public float apply(ItemStack stack, World world, EntityLivingBase entityIn) { + public float apply(ItemStack stack, World world, EntityLivingBase entityIn) + { return entityIn != null && entityIn.isHandActive() && entityIn.getActiveItemStack() == stack ? 1.0F : 0.0F; } }); - this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() { + this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() + { @SideOnly(Side.CLIENT) - public float apply(ItemStack stack, World world, EntityLivingBase entityIn) { + public float apply(ItemStack stack, World world, EntityLivingBase entityIn) + { return ((ItemSentientBow) RegistrarBloodMagicItems.SENTIENT_BOW).getCurrentType(stack).ordinal(); } }); } @Override - public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { + public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) + { return RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL == repair.getItem() || super.getIsRepairable(toRepair, repair); } - public void recalculatePowers(ItemStack stack, World world, EntityPlayer player) { + public void recalculatePowers(ItemStack stack, World world, EntityPlayer player) + { EnumDemonWillType type = PlayerDemonWillHandler.getLargestWillType(player); double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player); recalculatePowers(stack, type, soulsRemaining); } - public void recalculatePowers(ItemStack stack, EnumDemonWillType type, double will) { + public void recalculatePowers(ItemStack stack, EnumDemonWillType type, double will) + { this.setCurrentType(stack, will > 0 ? type : EnumDemonWillType.DEFAULT); - int level = getLevel(stack, will); + int level = getLevel(will); // double drain = level >= 0 ? soulDrainPerSwing[level] : 0; @@ -108,10 +120,13 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien setDamageAdded(stack, level >= 0 ? getDamageModifier(type, level) : 0); } - private int getLevel(ItemStack stack, double soulsRemaining) { + private int getLevel(double soulsRemaining) + { int lvl = -1; - for (int i = 0; i < soulBracket.length; i++) { - if (soulsRemaining >= soulBracket[i]) { + for (int i = 0; i < soulBracket.length; i++) + { + if (soulsRemaining >= soulBracket[i]) + { lvl = i; } } @@ -120,42 +135,49 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien } @Override - public EnumDemonWillType getCurrentType(ItemStack stack) { + public EnumDemonWillType getCurrentType(ItemStack stack) + { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); - if (!tag.hasKey(Constants.NBT.WILL_TYPE)) { + if (!tag.hasKey(Constants.NBT.WILL_TYPE)) + { return EnumDemonWillType.DEFAULT; } return EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH)); } - public double getDamageModifier(EnumDemonWillType type, int willBracket) { - switch (type) { - case VENGEFUL: - return 0; - case DEFAULT: - case CORROSIVE: - case DESTRUCTIVE: - case STEADFAST: - return defaultDamageAdded[willBracket]; + public double getDamageModifier(EnumDemonWillType type, int willBracket) + { + switch (type) + { + case VENGEFUL: + return 0; + case DEFAULT: + case CORROSIVE: + case DESTRUCTIVE: + case STEADFAST: + return defaultDamageAdded[willBracket]; } return 0; } - public float getVelocityModifier(EnumDemonWillType type, int willBracket) { - switch (type) { - case VENGEFUL: - return velocityAdded[willBracket]; - default: - return 0; + public float getVelocityModifier(EnumDemonWillType type, int willBracket) + { + switch (type) + { + case VENGEFUL: + return velocityAdded[willBracket]; + default: + return 0; } } - public void setDamageAdded(ItemStack stack, double damage) { + public void setDamageAdded(ItemStack stack, double damage) + { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -163,7 +185,8 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien tag.setDouble("damage", damage); } - public double getDamageAdded(ItemStack stack) { + public double getDamageAdded(ItemStack stack) + { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -171,7 +194,8 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien return tag.getDouble("damage"); } - public void setVelocityOfArrow(ItemStack stack, float velocity) { + public void setVelocityOfArrow(ItemStack stack, float velocity) + { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -179,19 +203,22 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien tag.setFloat("velocity", velocity); } - public float getVelocityOfArrow(ItemStack stack) { + public float getVelocityOfArrow(ItemStack stack) + { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); - if (tag.hasKey("velocity")) { + if (tag.hasKey("velocity")) + { return tag.getFloat("velocity"); } return 3; } - public void setCurrentType(ItemStack stack, EnumDemonWillType type) { + public void setCurrentType(ItemStack stack, EnumDemonWillType type) + { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -199,14 +226,16 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien tag.setString(Constants.NBT.WILL_TYPE, type.toString()); } - public double getDrainOfActivatedBow(ItemStack stack) { + public double getDrainOfActivatedBow(ItemStack stack) + { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN); } - public void setDrainOfActivatedBow(ItemStack stack, double drain) { + public void setDrainOfActivatedBow(ItemStack stack, double drain) + { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -214,14 +243,16 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien tag.setDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN, drain); } - public double getStaticDropOfActivatedBow(ItemStack stack) { + public double getStaticDropOfActivatedBow(ItemStack stack) + { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP); } - public void setStaticDropOfActivatedBow(ItemStack stack, double drop) { + public void setStaticDropOfActivatedBow(ItemStack stack, double drop) + { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -229,14 +260,16 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien tag.setDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP, drop); } - public double getDropOfActivatedBow(ItemStack stack) { + public double getDropOfActivatedBow(ItemStack stack) + { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); return tag.getDouble(Constants.NBT.SOUL_SWORD_DROP); } - public void setDropOfActivatedBow(ItemStack stack, double drop) { + public void setDropOfActivatedBow(ItemStack stack, double drop) + { NBTHelper.checkNBT(stack); NBTTagCompound tag = stack.getTagCompound(); @@ -245,24 +278,28 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien } @Override - public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) + { ItemStack stack = player.getHeldItem(hand); this.recalculatePowers(stack, world, player); return super.onItemRightClick(world, player, hand); } @Override - public void gatherVariants(@Nonnull Int2ObjectMap variants) { + public void gatherVariants(@Nonnull Int2ObjectMap variants) + { variants.put(0, "inventory"); } - public EntityTippedArrow getArrowEntity(World world, ItemStack stack, EntityLivingBase target, EntityLivingBase user, float velocity) { + public EntityTippedArrow getArrowEntity(World world, ItemStack stack, EntityLivingBase target, EntityLivingBase user, float velocity) + { EnumDemonWillType type = this.getCurrentType(stack); double amount = user instanceof EntityPlayer ? (this.getDropOfActivatedBow(stack) * world.rand.nextDouble() + this.getStaticDropOfActivatedBow(stack)) : 0; float newArrowVelocity = velocity * getVelocityOfArrow(stack); - EntitySentientArrow entityArrow = new EntitySentientArrow(world, user, type, amount); + double soulsRemaining = user instanceof EntityPlayer ? (PlayerDemonWillHandler.getTotalDemonWill(type, (EntityPlayer) user)) : 0; + EntitySentientArrow entityArrow = new EntitySentientArrow(world, user, type, amount, getLevel(soulsRemaining)); double d0 = target.posX - user.posX; double d1 = target.getEntityBoundingBox().minY + (double) (target.height / 3.0F) - entityArrow.posY; @@ -270,12 +307,14 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2); entityArrow.shoot(d0, d1 + d3 * 0.05, d2, newArrowVelocity, 0); - if (newArrowVelocity == 0) { + if (newArrowVelocity == 0) + { world.playSound(null, user.getPosition(), SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.NEUTRAL, 0.4F, 1.0F); return null; } - if (velocity == 1.0F) { + if (velocity == 1.0F) + { entityArrow.setIsCritical(true); } @@ -285,11 +324,13 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien int k = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack); - if (k > 0) { + if (k > 0) + { entityArrow.setKnockbackStrength(k); } - if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0) { + if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0) + { entityArrow.setFire(100); } @@ -299,8 +340,10 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien } @Override - public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase entityLiving, int timeLeft) { - if (entityLiving instanceof EntityPlayer) { + public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase entityLiving, int timeLeft) + { + if (entityLiving instanceof EntityPlayer) + { EntityPlayer player = (EntityPlayer) entityLiving; boolean flag = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, stack) > 0; ItemStack itemstack = this.getFiredArrow(player); @@ -310,17 +353,21 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien if (i < 0) return; - if (itemstack != null || flag) { - if (itemstack == null) { + if (itemstack != null || flag) + { + if (itemstack == null) + { itemstack = new ItemStack(Items.ARROW); } float arrowVelocity = getArrowVelocity(i); - if ((double) arrowVelocity >= 0.1D) { + if ((double) arrowVelocity >= 0.1D) + { boolean flag1 = flag && itemstack.getItem() == Items.ARROW; //Forge: Fix consuming custom arrows. - if (!world.isRemote) { + if (!world.isRemote) + { this.recalculatePowers(stack, world, player); EnumDemonWillType type = this.getCurrentType(stack); @@ -331,15 +378,18 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien double amount = (this.getDropOfActivatedBow(stack) * world.rand.nextDouble() + this.getStaticDropOfActivatedBow(stack)); float newArrowVelocity = arrowVelocity * getVelocityOfArrow(stack); - EntitySentientArrow entityArrow = new EntitySentientArrow(world, entityLiving, type, amount); + double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player); + EntitySentientArrow entityArrow = new EntitySentientArrow(world, entityLiving, type, amount, getLevel(soulsRemaining)); entityArrow.shoot(player, player.rotationPitch, player.rotationYaw, 0.0F, newArrowVelocity, 1.0F); - if (newArrowVelocity == 0) { + if (newArrowVelocity == 0) + { world.playSound(null, player.getPosition(), SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.NEUTRAL, 0.4F, 1.0F); return; } - if (arrowVelocity == 1.0F) { + if (arrowVelocity == 1.0F) + { entityArrow.setIsCritical(true); } @@ -349,17 +399,20 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien int k = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack); - if (k > 0) { + if (k > 0) + { entityArrow.setKnockbackStrength(k); } - if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0) { + if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0) + { entityArrow.setFire(100); } stack.damageItem(1, player); - if (flag1) { + if (flag1) + { entityArrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY; } @@ -368,10 +421,12 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + arrowVelocity * 0.5F); - if (!flag1) { + if (!flag1) + { itemstack.shrink(1); - if (itemstack.isEmpty()) { + if (itemstack.isEmpty()) + { player.inventory.deleteStack(itemstack); } } @@ -382,16 +437,22 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien } } - protected ItemStack getFiredArrow(EntityPlayer player) { - if (this.isArrow(player.getHeldItem(EnumHand.OFF_HAND))) { + protected ItemStack getFiredArrow(EntityPlayer player) + { + if (this.isArrow(player.getHeldItem(EnumHand.OFF_HAND))) + { return player.getHeldItem(EnumHand.OFF_HAND); - } else if (this.isArrow(player.getHeldItem(EnumHand.MAIN_HAND))) { + } else if (this.isArrow(player.getHeldItem(EnumHand.MAIN_HAND))) + { return player.getHeldItem(EnumHand.MAIN_HAND); - } else { - for (int i = 0; i < player.inventory.getSizeInventory(); ++i) { + } else + { + for (int i = 0; i < player.inventory.getSizeInventory(); ++i) + { ItemStack itemstack = player.inventory.getStackInSlot(i); - if (this.isArrow(itemstack)) { + if (this.isArrow(itemstack)) + { return itemstack; } } @@ -401,14 +462,17 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien } @Override - public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player) { + public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player) + { World world = player.getEntityWorld(); - if (!world.isRemote) { + if (!world.isRemote) + { this.recalculatePowers(droppedStack, world, player); EnumDemonWillType type = this.getCurrentType(droppedStack); double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player); - if (soulsRemaining < 1024) { + if (soulsRemaining < 1024) + { return false; }