diff --git a/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderSentientSpecter.java b/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderSentientSpecter.java index ec32cddd..38416f92 100644 --- a/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderSentientSpecter.java +++ b/src/main/java/WayofTime/bloodmagic/client/render/entity/RenderSentientSpecter.java @@ -23,7 +23,7 @@ public class RenderSentientSpecter extends RenderBiped public RenderSentientSpecter(RenderManager renderManager) { - super(renderManager, new ModelBiped(0.0F), 0.1F); + super(renderManager, new ModelBiped(0.0F), 0); this.addLayer(new LayerBipedArmor(this)); this.addLayer(new LayerHeldItem(this)); this.addLayer(new LayerArrow(this)); diff --git a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIAttackRangedBow.java b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIAttackRangedBow.java index ebc0919d..de8423df 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIAttackRangedBow.java +++ b/src/main/java/WayofTime/bloodmagic/entity/ai/EntityAIAttackRangedBow.java @@ -59,7 +59,6 @@ public class EntityAIAttackRangedBow extends EntityAIBase public void startExecuting() { super.startExecuting(); -// this.entity.setSwingingArms(true); } /** @@ -68,7 +67,6 @@ public class EntityAIAttackRangedBow extends EntityAIBase public void resetTask() { super.startExecuting(); -// this.entity.setSwingingArms(false); this.seeTime = 0; this.attackTime = -1; this.entity.resetActiveHand(); diff --git a/src/main/java/WayofTime/bloodmagic/entity/mob/EntitySentientSpecter.java b/src/main/java/WayofTime/bloodmagic/entity/mob/EntitySentientSpecter.java index 3746518d..3675975b 100644 --- a/src/main/java/WayofTime/bloodmagic/entity/mob/EntitySentientSpecter.java +++ b/src/main/java/WayofTime/bloodmagic/entity/mob/EntitySentientSpecter.java @@ -23,7 +23,6 @@ import net.minecraft.entity.passive.EntityWolf; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityTippedArrow; import net.minecraft.init.Enchantments; -import net.minecraft.init.Items; import net.minecraft.init.MobEffects; import net.minecraft.init.SoundEvents; import net.minecraft.inventory.EntityEquipmentSlot; @@ -35,7 +34,6 @@ import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.potion.PotionEffect; import net.minecraft.server.management.PreYggdrasilConverter; -import net.minecraft.util.EnumHand; import net.minecraft.util.SoundEvent; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; @@ -45,6 +43,8 @@ import WayofTime.bloodmagic.entity.ai.EntityAIAttackRangedBow; import WayofTime.bloodmagic.entity.ai.EntityAIFollowOwner; import WayofTime.bloodmagic.entity.ai.EntityAIOwnerHurtByTarget; import WayofTime.bloodmagic.entity.ai.EntityAIOwnerHurtTarget; +import WayofTime.bloodmagic.item.soul.ItemSentientBow; +import WayofTime.bloodmagic.registry.ModItems; import com.google.common.base.Optional; @@ -77,7 +77,7 @@ public class EntitySentientSpecter extends EntityMob implements IEntityOwnable this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true, new Class[0])); this.setCombatTask(); -// this.targetTasks.addTask(8, new EntityAINearestAttackableTarget(this, EntityAnimal.class, false)); +// this.targetTasks.addTask(8, new EntityAINearestAttackableTarget(this, EntityCreature.class, true)); } @Override @@ -213,48 +213,55 @@ public class EntitySentientSpecter extends EntityMob implements IEntityOwnable } } - public void attackEntityWithRangedAttack(EntityLivingBase target, float p_82196_2_) + public void attackEntityWithRangedAttack(EntityLivingBase target, float velocity) { - EntityTippedArrow entitytippedarrow = new EntityTippedArrow(this.worldObj, this); //TODO: Change to an arrow created by the Sentient Bow - double d0 = target.posX - this.posX; - double d1 = target.getEntityBoundingBox().minY + (double) (target.height / 3.0F) - entitytippedarrow.posY; - double d2 = target.posZ - this.posZ; - double d3 = (double) MathHelper.sqrt_double(d0 * d0 + d2 * d2); - entitytippedarrow.setThrowableHeading(d0, d1 + d3 * 0.2, d2, 1.6F, (float) (14 - this.worldObj.getDifficulty().getDifficultyId() * 4)); - int i = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.POWER, this); - int j = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.PUNCH, this); - entitytippedarrow.setDamage((double) (p_82196_2_ * 2.0F) + this.rand.nextGaussian() * 0.25D + (double) ((float) this.worldObj.getDifficulty().getDifficultyId() * 0.11F)); - - if (i > 0) + ItemStack heldStack = this.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND); + if (heldStack != null && heldStack.getItem() == ModItems.sentientBow) { - entitytippedarrow.setDamage(entitytippedarrow.getDamage() + (double) i * 0.5D + 0.5D); + EntityTippedArrow arrowEntity = ((ItemSentientBow) heldStack.getItem()).getArrowEntity(worldObj, heldStack, target, this, velocity); + if (arrowEntity != null) + { + this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); + this.worldObj.spawnEntityInWorld(arrowEntity); + } + } else + { + EntityTippedArrow entitytippedarrow = new EntityTippedArrow(this.worldObj, this); //TODO: Change to an arrow created by the Sentient Bow + double d0 = target.posX - this.posX; + double d1 = target.getEntityBoundingBox().minY + (double) (target.height / 3.0F) - entitytippedarrow.posY; + double d2 = target.posZ - this.posZ; + double d3 = (double) MathHelper.sqrt_double(d0 * d0 + d2 * d2); + entitytippedarrow.setThrowableHeading(d0, d1 + d3 * 0.2, d2, 1.6F, 0); //TODO: Yes, it is an accurate arrow. Don't be hatin' + int i = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.POWER, this); + int j = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.PUNCH, this); + entitytippedarrow.setDamage((double) (velocity * 2.0F) + this.rand.nextGaussian() * 0.25D + (double) ((float) this.worldObj.getDifficulty().getDifficultyId() * 0.11F)); + + if (i > 0) + { + entitytippedarrow.setDamage(entitytippedarrow.getDamage() + (double) i * 0.5D + 0.5D); + } + + if (j > 0) + { + entitytippedarrow.setKnockbackStrength(j); + } + + boolean burning = this.isBurning(); + burning = burning || EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.FLAME, this) > 0; + + if (burning) + { + entitytippedarrow.setFire(100); + } + + if (true) //TODO: Add potion effects to the arrows + { + entitytippedarrow.addEffect(new PotionEffect(MobEffects.SLOWNESS, 600)); + } + + this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); + this.worldObj.spawnEntityInWorld(entitytippedarrow); } - - if (j > 0) - { - entitytippedarrow.setKnockbackStrength(j); - } - - boolean burning = this.isBurning(); - burning = burning || EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.FLAME, this) > 0; - - if (burning) - { - entitytippedarrow.setFire(100); - } - - ItemStack itemstack = this.getHeldItem(EnumHand.OFF_HAND); - - if (itemstack != null && itemstack.getItem() == Items.TIPPED_ARROW) - { - entitytippedarrow.setPotionEffect(itemstack); - } else if (true) //TODO: Add potion effects to the arrows - { - entitytippedarrow.addEffect(new PotionEffect(MobEffects.SLOWNESS, 600)); - } - - this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F)); - this.worldObj.spawnEntityInWorld(entitytippedarrow); } public boolean isTamed() diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java index 9a8e93bd..2e8ef9da 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientBow.java @@ -2,14 +2,13 @@ package WayofTime.bloodmagic.item.soul; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.monster.EntitySlime; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.entity.projectile.EntityTippedArrow; import net.minecraft.init.Enchantments; import net.minecraft.init.Items; import net.minecraft.init.SoundEvents; import net.minecraft.item.IItemPropertyGetter; -import net.minecraft.item.ItemArrow; import net.minecraft.item.ItemBow; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -18,6 +17,7 @@ import net.minecraft.util.ActionResult; import net.minecraft.util.EnumHand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundCategory; +import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -87,8 +87,13 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool//, IMeshP { EnumDemonWillType type = PlayerDemonWillHandler.getLargestWillType(player); double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player); - this.setCurrentType(stack, soulsRemaining > 0 ? type : EnumDemonWillType.DEFAULT); - int level = getLevel(stack, soulsRemaining); + recalculatePowers(stack, type, soulsRemaining); + } + + public void recalculatePowers(ItemStack stack, EnumDemonWillType type, double will) + { + this.setCurrentType(stack, will > 0 ? type : EnumDemonWillType.DEFAULT); + int level = getLevel(stack, will); // double drain = level >= 0 ? soulDrainPerSwing[level] : 0; @@ -271,6 +276,54 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool//, IMeshP return super.onItemRightClick(stack, world, player, hand); } + 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); + entityArrow.setAim(user, user.rotationPitch, user.rotationYaw, 0.0F, newArrowVelocity, 1.0F); + + double d0 = target.posX - user.posX; + double d1 = target.getEntityBoundingBox().minY + (double) (target.height / 3.0F) - entityArrow.posY; + double d2 = target.posZ - user.posZ; + double d3 = (double) MathHelper.sqrt_double(d0 * d0 + d2 * d2); + entityArrow.setThrowableHeading(d0, d1 + d3 * 0.05, d2, 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) + { + entityArrow.setIsCritical(true); + } + + int j = EnchantmentHelper.getEnchantmentLevel(Enchantments.POWER, stack); + + entityArrow.setDamage(entityArrow.getDamage() + this.getDamageAdded(stack) + (j > 0 ? j * 0.5 + 0.5 : 0)); + + int k = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack); + + if (k > 0) + { + entityArrow.setKnockbackStrength(k); + } + + if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0) + { + entityArrow.setFire(100); + } + + entityArrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY; + + return entityArrow; + } + @Override public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase entityLiving, int timeLeft) { diff --git a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientSword.java b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientSword.java index 0a238787..cfc91067 100644 --- a/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientSword.java +++ b/src/main/java/WayofTime/bloodmagic/item/soul/ItemSentientSword.java @@ -253,7 +253,15 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM specterEntity.setPosition(player.posX, player.posY, player.posZ); world.spawnEntityInWorld(specterEntity); System.out.println("Spawning Specter..."); - specterEntity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(ModItems.sentientBow)); + + ItemStack bowStack = new ItemStack(ModItems.sentientBow); + ((ItemSentientBow) ModItems.sentientBow).recalculatePowers(bowStack, EnumDemonWillType.DEFAULT, 1025); + + specterEntity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, bowStack); + specterEntity.setItemStackToSlot(EntityEquipmentSlot.HEAD, new ItemStack(ModItems.sentientArmourHelmet)); + specterEntity.setItemStackToSlot(EntityEquipmentSlot.CHEST, new ItemStack(ModItems.sentientArmourChest)); + specterEntity.setItemStackToSlot(EntityEquipmentSlot.LEGS, new ItemStack(ModItems.sentientArmourLegs)); + specterEntity.setItemStackToSlot(EntityEquipmentSlot.FEET, new ItemStack(ModItems.sentientArmourBoots)); specterEntity.setOwner(player); specterEntity.setTamed(true); }