A bit more work on the ranged aspects of the Sentient Specter - Allowed it to inherit the abilities of the Sentient Bow

This commit is contained in:
WayofTime 2016-08-15 21:52:54 -04:00
parent 38f4ea6bac
commit 5953a5a0cf
5 changed files with 116 additions and 50 deletions

View file

@ -23,7 +23,7 @@ public class RenderSentientSpecter extends RenderBiped<EntitySentientSpecter>
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));

View file

@ -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();

View file

@ -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<EntityAnimal>(this, EntityAnimal.class, false));
// this.targetTasks.addTask(8, new EntityAINearestAttackableTarget<EntityCreature>(this, EntityCreature.class, true));
}
@Override
@ -213,17 +213,28 @@ public class EntitySentientSpecter extends EntityMob implements IEntityOwnable
}
}
public void attackEntityWithRangedAttack(EntityLivingBase target, float p_82196_2_)
public void attackEntityWithRangedAttack(EntityLivingBase target, float velocity)
{
ItemStack heldStack = this.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND);
if (heldStack != null && heldStack.getItem() == ModItems.sentientBow)
{
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, (float) (14 - this.worldObj.getDifficulty().getDifficultyId() * 4));
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) (p_82196_2_ * 2.0F) + this.rand.nextGaussian() * 0.25D + (double) ((float) this.worldObj.getDifficulty().getDifficultyId() * 0.11F));
entitytippedarrow.setDamage((double) (velocity * 2.0F) + this.rand.nextGaussian() * 0.25D + (double) ((float) this.worldObj.getDifficulty().getDifficultyId() * 0.11F));
if (i > 0)
{
@ -243,12 +254,7 @@ public class EntitySentientSpecter extends EntityMob implements IEntityOwnable
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
if (true) //TODO: Add potion effects to the arrows
{
entitytippedarrow.addEffect(new PotionEffect(MobEffects.SLOWNESS, 600));
}
@ -256,6 +262,7 @@ public class EntitySentientSpecter extends EntityMob implements IEntityOwnable
this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
this.worldObj.spawnEntityInWorld(entitytippedarrow);
}
}
public boolean isTamed()
{

View file

@ -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)
{

View file

@ -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);
}