Advertisement
Guest User

EntityArrowClass

a guest
Apr 20th, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 25.67 KB | None | 0 0
  1. package yesodmod.general.entity;
  2.  
  3. import cpw.mods.fml.relauncher.Side;
  4. import cpw.mods.fml.relauncher.SideOnly;
  5.  
  6. import java.util.List;
  7.  
  8. import yesodmod.general.item.YesodItem;
  9. import net.minecraft.block.Block;
  10. import net.minecraft.block.material.Material;
  11. import net.minecraft.enchantment.EnchantmentHelper;
  12. import net.minecraft.entity.Entity;
  13. import net.minecraft.entity.EntityLivingBase;
  14. import net.minecraft.entity.IProjectile;
  15. import net.minecraft.entity.monster.EntityEnderman;
  16. import net.minecraft.entity.player.EntityPlayer;
  17. import net.minecraft.entity.player.EntityPlayerMP;
  18. import net.minecraft.init.Items;
  19. import net.minecraft.item.ItemStack;
  20. import net.minecraft.nbt.NBTTagCompound;
  21. import net.minecraft.network.play.server.S2BPacketChangeGameState;
  22. import net.minecraft.util.AxisAlignedBB;
  23. import net.minecraft.util.DamageSource;
  24. import net.minecraft.util.MathHelper;
  25. import net.minecraft.util.MovingObjectPosition;
  26. import net.minecraft.util.Vec3;
  27. import net.minecraft.world.World;
  28.  
  29. public class EntityExplosiveArrow extends Entity implements IProjectile
  30. {
  31.     private int field_145791_d = -1;
  32.     private int field_145792_e = -1;
  33.     private int field_145789_f = -1;
  34.     private Block field_145790_g;
  35.     private int inData;
  36.     private boolean inGround;
  37.     /** 1 if the player can pick up the arrow */
  38.     public int canBePickedUp;
  39.     /** Seems to be some sort of timer for animating an arrow. */
  40.     public int arrowShake;
  41.     /** The owner of this arrow. */
  42.     public Entity shootingEntity;
  43.     private int ticksInGround;
  44.     private int ticksInAir;
  45.     private double damage = 2.0D;
  46.     /** The amount of knockback an arrow applies when it hits a mob. */
  47.     private int knockbackStrength;
  48.     private static final String __OBFID = "CL_00001715";
  49.  
  50.     public EntityExplosiveArrow(World p_i1753_1_)
  51.     {
  52.         super(p_i1753_1_);
  53.         this.renderDistanceWeight = 10.0D;
  54.         this.setSize(0.5F, 0.5F);
  55.     }
  56.  
  57.     public EntityExplosiveArrow(World p_i1754_1_, double p_i1754_2_, double p_i1754_4_, double p_i1754_6_)
  58.     {
  59.         super(p_i1754_1_);
  60.         this.renderDistanceWeight = 10.0D;
  61.         this.setSize(0.5F, 0.5F);
  62.         this.setPosition(p_i1754_2_, p_i1754_4_, p_i1754_6_);
  63.         this.yOffset = 0.0F;
  64.     }
  65.  
  66.     public EntityExplosiveArrow(World p_i1755_1_, EntityLivingBase p_i1755_2_, EntityLivingBase p_i1755_3_, float p_i1755_4_, float p_i1755_5_)
  67.     {
  68.         super(p_i1755_1_);
  69.         this.renderDistanceWeight = 10.0D;
  70.         this.shootingEntity = p_i1755_2_;
  71.  
  72.         if (p_i1755_2_ instanceof EntityPlayer)
  73.         {
  74.             this.canBePickedUp = 1;
  75.         }
  76.  
  77.         this.posY = p_i1755_2_.posY + (double)p_i1755_2_.getEyeHeight() - 0.10000000149011612D;
  78.         double d0 = p_i1755_3_.posX - p_i1755_2_.posX;
  79.         double d1 = p_i1755_3_.boundingBox.minY + (double)(p_i1755_3_.height / 3.0F) - this.posY;
  80.         double d2 = p_i1755_3_.posZ - p_i1755_2_.posZ;
  81.         double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2);
  82.  
  83.         if (d3 >= 1.0E-7D)
  84.         {
  85.             float f2 = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F;
  86.             float f3 = (float)(-(Math.atan2(d1, d3) * 180.0D / Math.PI));
  87.             double d4 = d0 / d3;
  88.             double d5 = d2 / d3;
  89.             this.setLocationAndAngles(p_i1755_2_.posX + d4, this.posY, p_i1755_2_.posZ + d5, f2, f3);
  90.             this.yOffset = 0.0F;
  91.             float f4 = (float)d3 * 0.2F;
  92.             this.setThrowableHeading(d0, d1 + (double)f4, d2, p_i1755_4_, p_i1755_5_);
  93.         }
  94.     }
  95.  
  96.     public EntityExplosiveArrow(World p_i1756_1_, EntityLivingBase p_i1756_2_, float p_i1756_3_)
  97.     {
  98.         super(p_i1756_1_);
  99.         this.renderDistanceWeight = 10.0D;
  100.         this.shootingEntity = p_i1756_2_;
  101.  
  102.         if (p_i1756_2_ instanceof EntityPlayer)
  103.         {
  104.             this.canBePickedUp = 1;
  105.         }
  106.  
  107.         this.setSize(0.5F, 0.5F);
  108.         this.setLocationAndAngles(p_i1756_2_.posX, p_i1756_2_.posY + (double)p_i1756_2_.getEyeHeight(), p_i1756_2_.posZ, p_i1756_2_.rotationYaw, p_i1756_2_.rotationPitch);
  109.         this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
  110.         this.posY -= 0.10000000149011612D;
  111.         this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
  112.         this.setPosition(this.posX, this.posY, this.posZ);
  113.         this.yOffset = 0.0F;
  114.         this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
  115.         this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
  116.         this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI));
  117.         this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, p_i1756_3_ * 1.5F, 1.0F);
  118.     }
  119.  
  120.     protected void entityInit()
  121.     {
  122.         this.dataWatcher.addObject(16, Byte.valueOf((byte)0));
  123.     }
  124.  
  125.     /**
  126.      * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction.
  127.      */
  128.     public void setThrowableHeading(double p_70186_1_, double p_70186_3_, double p_70186_5_, float p_70186_7_, float p_70186_8_)
  129.     {
  130.         float f2 = MathHelper.sqrt_double(p_70186_1_ * p_70186_1_ + p_70186_3_ * p_70186_3_ + p_70186_5_ * p_70186_5_);
  131.         p_70186_1_ /= (double)f2;
  132.         p_70186_3_ /= (double)f2;
  133.         p_70186_5_ /= (double)f2;
  134.         p_70186_1_ += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)p_70186_8_;
  135.         p_70186_3_ += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)p_70186_8_;
  136.         p_70186_5_ += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)p_70186_8_;
  137.         p_70186_1_ *= (double)p_70186_7_;
  138.         p_70186_3_ *= (double)p_70186_7_;
  139.         p_70186_5_ *= (double)p_70186_7_;
  140.         this.motionX = p_70186_1_;
  141.         this.motionY = p_70186_3_;
  142.         this.motionZ = p_70186_5_;
  143.         float f3 = MathHelper.sqrt_double(p_70186_1_ * p_70186_1_ + p_70186_5_ * p_70186_5_);
  144.         this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(p_70186_1_, p_70186_5_) * 180.0D / Math.PI);
  145.         this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(p_70186_3_, (double)f3) * 180.0D / Math.PI);
  146.         this.ticksInGround = 0;
  147.     }
  148.  
  149.     /**
  150.      * Sets the position and rotation. Only difference from the other one is no bounding on the rotation. Args: posX,
  151.      * posY, posZ, yaw, pitch
  152.      */
  153.     @SideOnly(Side.CLIENT)
  154.     public void setPositionAndRotation2(double p_70056_1_, double p_70056_3_, double p_70056_5_, float p_70056_7_, float p_70056_8_, int p_70056_9_)
  155.     {
  156.         this.setPosition(p_70056_1_, p_70056_3_, p_70056_5_);
  157.         this.setRotation(p_70056_7_, p_70056_8_);
  158.     }
  159.  
  160.     /**
  161.      * Sets the velocity to the args. Args: x, y, z
  162.      */
  163.     @SideOnly(Side.CLIENT)
  164.     public void setVelocity(double p_70016_1_, double p_70016_3_, double p_70016_5_)
  165.     {
  166.         this.motionX = p_70016_1_;
  167.         this.motionY = p_70016_3_;
  168.         this.motionZ = p_70016_5_;
  169.  
  170.         if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
  171.         {
  172.             float f = MathHelper.sqrt_double(p_70016_1_ * p_70016_1_ + p_70016_5_ * p_70016_5_);
  173.             this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(p_70016_1_, p_70016_5_) * 180.0D / Math.PI);
  174.             this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(p_70016_3_, (double)f) * 180.0D / Math.PI);
  175.             this.prevRotationPitch = this.rotationPitch;
  176.             this.prevRotationYaw = this.rotationYaw;
  177.             this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
  178.             this.ticksInGround = 0;
  179.         }
  180.     }
  181.  
  182.     /**
  183.      * Called to update the entity's position/logic.
  184.      */
  185.     public void onUpdate()
  186.     {
  187.         super.onUpdate();
  188.  
  189.         if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F)
  190.         {
  191.             float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
  192.             this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
  193.             this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f) * 180.0D / Math.PI);
  194.         }
  195.  
  196.         Block block = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
  197.  
  198.         if (block.getMaterial() != Material.air)
  199.         {
  200.             block.setBlockBoundsBasedOnState(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
  201.             AxisAlignedBB axisalignedbb = block.getCollisionBoundingBoxFromPool(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f);
  202.  
  203.             if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(this.posX, this.posY, this.posZ)))
  204.             {
  205.                 this.inGround = true;
  206.             }
  207.         }
  208.  
  209.         if (this.arrowShake > 0)
  210.         {
  211.             --this.arrowShake;
  212.         }
  213.  
  214.         if (this.inGround)
  215.         {
  216.             int j = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f);
  217.  
  218.             if (block == this.field_145790_g && j == this.inData)
  219.             {
  220.                 ++this.ticksInGround;
  221.  
  222.                 if (this.ticksInGround == 1200)
  223.                 {
  224.                     this.setDead();
  225.                 }
  226.             }
  227.             else
  228.             {
  229.                 this.inGround = false;
  230.                 this.motionX *= (double)(this.rand.nextFloat() * 0.2F);
  231.                 this.motionY *= (double)(this.rand.nextFloat() * 0.2F);
  232.                 this.motionZ *= (double)(this.rand.nextFloat() * 0.2F);
  233.                 this.ticksInGround = 0;
  234.                 this.ticksInAir = 0;
  235.             }
  236.         }
  237.         else
  238.         {
  239.             ++this.ticksInAir;
  240.             Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
  241.             Vec3 vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
  242.             MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec31, vec3, false, true, false);
  243.             vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
  244.             vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
  245.  
  246.             if (movingobjectposition != null)
  247.             {
  248.                 vec3 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
  249.             }
  250.  
  251.             Entity entity = null;
  252.             List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
  253.             double d0 = 0.0D;
  254.             int i;
  255.             float f1;
  256.  
  257.             for (i = 0; i < list.size(); ++i)
  258.             {
  259.                 Entity entity1 = (Entity)list.get(i);
  260.  
  261.                 if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5))
  262.                 {
  263.                     f1 = 0.3F;
  264.                     AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand((double)f1, (double)f1, (double)f1);
  265.                     MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3);
  266.  
  267.                     if (movingobjectposition1 != null)
  268.                     {
  269.                         double d1 = vec31.distanceTo(movingobjectposition1.hitVec);
  270.  
  271.                         if (d1 < d0 || d0 == 0.0D)
  272.                         {
  273.                             entity = entity1;
  274.                             d0 = d1;
  275.                         }
  276.                     }
  277.                 }
  278.             }
  279.  
  280.             if (entity != null)
  281.             {
  282.                 movingobjectposition = new MovingObjectPosition(entity);
  283.             }
  284.  
  285.             if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer)
  286.             {
  287.                 EntityPlayer entityplayer = (EntityPlayer)movingobjectposition.entityHit;
  288.  
  289.                 if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer)this.shootingEntity).canAttackPlayer(entityplayer))
  290.                 {
  291.                     movingobjectposition = null;
  292.                 }
  293.             }
  294.  
  295.             float f2;
  296.             float f4;
  297.  
  298.             if (movingobjectposition != null)
  299.             {
  300.                 if (movingobjectposition.entityHit != null)
  301.                 {  
  302.                     f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
  303.                     int k = MathHelper.ceiling_double_int((double)f2 * this.damage);
  304.                     this.worldObj.createExplosion(this, movingobjectposition.entityHit.posX, movingobjectposition.entityHit.posY, movingobjectposition.entityHit.posZ, 3F, true);
  305.                    
  306.                     if (this.getIsCritical())
  307.                     {
  308.                         k += this.rand.nextInt(k / 2 + 2);
  309.                     }
  310.  
  311.                     DamageSource damagesource = null;
  312.  
  313.                     if (this.shootingEntity == null)
  314.                     {
  315.                         damagesource = DamageSource.causeThrownDamage(this, this);                        
  316.                     }
  317.                     else
  318.                     {
  319.                         damagesource = DamageSource.causeThrownDamage(this, this.shootingEntity);                    
  320.                     }
  321.  
  322.                     if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman))
  323.                     {
  324.                         movingobjectposition.entityHit.setFire(5);
  325.                     }
  326.                    
  327.                     if (movingobjectposition.entityHit.attackEntityFrom(damagesource, (float)k))
  328.                     {
  329.                         if (movingobjectposition.entityHit instanceof EntityLivingBase)
  330.                         {
  331.                             EntityLivingBase entitylivingbase = (EntityLivingBase)movingobjectposition.entityHit;
  332.  
  333.                             if (!this.worldObj.isRemote)
  334.                             {
  335.                                 entitylivingbase.setArrowCountInEntity(entitylivingbase.getArrowCountInEntity() + 1);
  336.                             }
  337.  
  338.                             if (this.knockbackStrength > 0)
  339.                             {
  340.                                 f4 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
  341.  
  342.                                 if (f4 > 0.0F)
  343.                                 {
  344.                                     movingobjectposition.entityHit.addVelocity(this.motionX * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4, 0.1D, this.motionZ * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4);
  345.                                 }
  346.                             }
  347.  
  348.                             if (this.shootingEntity != null && this.shootingEntity instanceof EntityLivingBase)
  349.                             {
  350.                                 EnchantmentHelper.func_151384_a(entitylivingbase, this.shootingEntity);
  351.                                 EnchantmentHelper.func_151385_b((EntityLivingBase)this.shootingEntity, entitylivingbase);
  352.                             }
  353.  
  354.                             if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP)
  355.                             {
  356.                                 ((EntityPlayerMP)this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F));
  357.                             }
  358.                         }
  359.  
  360.                         this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
  361.  
  362.                         if (!(movingobjectposition.entityHit instanceof EntityEnderman))
  363.                         {
  364.                             this.setDead();
  365.                         }
  366.                     }
  367.                     else
  368.                     {
  369.                         this.motionX *= -0.10000000149011612D;
  370.                         this.motionY *= -0.10000000149011612D;
  371.                         this.motionZ *= -0.10000000149011612D;
  372.                         this.rotationYaw += 180.0F;
  373.                         this.prevRotationYaw += 180.0F;
  374.                         this.ticksInAir = 0;
  375.                     }
  376.                 }
  377.                 else
  378.                 {
  379.                     this.field_145791_d = movingobjectposition.blockX;
  380.                     this.field_145792_e = movingobjectposition.blockY;
  381.                     this.field_145789_f = movingobjectposition.blockZ;
  382.                     this.field_145790_g = this.worldObj.getBlock(this.field_145791_d, this.field_145792_e, this.field_145789_f);
  383.                     this.inData = this.worldObj.getBlockMetadata(this.field_145791_d, this.field_145792_e, this.field_145789_f);
  384.                     this.motionX = (double)((float)(movingobjectposition.hitVec.xCoord - this.posX));
  385.                     this.motionY = (double)((float)(movingobjectposition.hitVec.yCoord - this.posY));
  386.                     this.motionZ = (double)((float)(movingobjectposition.hitVec.zCoord - this.posZ));
  387.                     f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
  388.                     this.posX -= this.motionX / (double)f2 * 0.05000000074505806D;
  389.                     this.posY -= this.motionY / (double)f2 * 0.05000000074505806D;
  390.                     this.posZ -= this.motionZ / (double)f2 * 0.05000000074505806D;
  391.                     this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
  392.                     this.inGround = true;
  393.                     this.arrowShake = 7;
  394.                     this.setIsCritical(false);
  395.  
  396.                     if (this.field_145790_g.getMaterial() != Material.air)
  397.                     {
  398.                         this.field_145790_g.onEntityCollidedWithBlock(this.worldObj, this.field_145791_d, this.field_145792_e, this.field_145789_f, this);
  399.                        //modifica terreno
  400.                         //this.worldObj.createExplosion(this, movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ, 3F, true);
  401.                         //this.setDead();
  402.                     }
  403.                 }
  404.             }
  405.  
  406.             if (this.getIsCritical())
  407.             {
  408.                 for (i = 0; i < 4; ++i)
  409.                 {
  410.                     this.worldObj.spawnParticle("crit", this.posX + this.motionX * (double)i / 4.0D, this.posY + this.motionY * (double)i / 4.0D, this.posZ + this.motionZ * (double)i / 4.0D, -this.motionX, -this.motionY + 0.2D, -this.motionZ);
  411.                 }
  412.             }
  413.  
  414.             this.posX += this.motionX;
  415.             this.posY += this.motionY;
  416.             this.posZ += this.motionZ;
  417.             f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
  418.             this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
  419.  
  420.             for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f2) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
  421.             {
  422.                 ;
  423.             }
  424.  
  425.             while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
  426.             {
  427.                 this.prevRotationPitch += 360.0F;
  428.             }
  429.  
  430.             while (this.rotationYaw - this.prevRotationYaw < -180.0F)
  431.             {
  432.                 this.prevRotationYaw -= 360.0F;
  433.             }
  434.  
  435.             while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
  436.             {
  437.                 this.prevRotationYaw += 360.0F;
  438.             }
  439.  
  440.             this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F;
  441.             this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
  442.             float f3 = 0.99F;
  443.             f1 = 0.05F;
  444.  
  445.             if (this.isInWater())
  446.             {
  447.                 for (int l = 0; l < 4; ++l)
  448.                 {
  449.                     f4 = 0.25F;
  450.                     this.worldObj.spawnParticle("bubble", this.posX - this.motionX * (double)f4, this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, this.motionY, this.motionZ);
  451.                 }
  452.  
  453.                 f3 = 0.8F;
  454.             }
  455.  
  456.             if (this.isWet())
  457.             {
  458.                 this.extinguish();
  459.             }
  460.  
  461.             this.motionX *= (double)f3;
  462.             this.motionY *= (double)f3;
  463.             this.motionZ *= (double)f3;
  464.             this.motionY -= (double)f1;
  465.             this.setPosition(this.posX, this.posY, this.posZ);
  466.             this.func_145775_I();
  467.         }
  468.     }
  469.  
  470.     /**
  471.      * (abstract) Protected helper method to write subclass entity data to NBT.
  472.      */
  473.     public void writeEntityToNBT(NBTTagCompound p_70014_1_)
  474.     {
  475.         p_70014_1_.setShort("xTile", (short)this.field_145791_d);
  476.         p_70014_1_.setShort("yTile", (short)this.field_145792_e);
  477.         p_70014_1_.setShort("zTile", (short)this.field_145789_f);
  478.         p_70014_1_.setShort("life", (short)this.ticksInGround);
  479.         p_70014_1_.setByte("inTile", (byte)Block.getIdFromBlock(this.field_145790_g));
  480.         p_70014_1_.setByte("inData", (byte)this.inData);
  481.         p_70014_1_.setByte("shake", (byte)this.arrowShake);
  482.         p_70014_1_.setByte("inGround", (byte)(this.inGround ? 1 : 0));
  483.         p_70014_1_.setByte("pickup", (byte)this.canBePickedUp);
  484.         p_70014_1_.setDouble("damage", this.damage);
  485.     }
  486.  
  487.     /**
  488.      * (abstract) Protected helper method to read subclass entity data from NBT.
  489.      */
  490.     public void readEntityFromNBT(NBTTagCompound p_70037_1_)
  491.     {
  492.         this.field_145791_d = p_70037_1_.getShort("xTile");
  493.         this.field_145792_e = p_70037_1_.getShort("yTile");
  494.         this.field_145789_f = p_70037_1_.getShort("zTile");
  495.         this.ticksInGround = p_70037_1_.getShort("life");
  496.         this.field_145790_g = Block.getBlockById(p_70037_1_.getByte("inTile") & 255);
  497.         this.inData = p_70037_1_.getByte("inData") & 255;
  498.         this.arrowShake = p_70037_1_.getByte("shake") & 255;
  499.         this.inGround = p_70037_1_.getByte("inGround") == 1;
  500.  
  501.         if (p_70037_1_.hasKey("damage", 99))
  502.         {
  503.             this.damage = p_70037_1_.getDouble("damage");
  504.         }
  505.  
  506.         if (p_70037_1_.hasKey("pickup", 99))
  507.         {
  508.             this.canBePickedUp = p_70037_1_.getByte("pickup");
  509.         }
  510.         else if (p_70037_1_.hasKey("player", 99))
  511.         {
  512.             this.canBePickedUp = p_70037_1_.getBoolean("player") ? 1 : 0;
  513.         }
  514.     }
  515.  
  516.     /**
  517.      * Called by a player entity when they collide with an entity
  518.      */
  519.     public void onCollideWithPlayer(EntityPlayer p_70100_1_)
  520.     {
  521.         if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0)
  522.         {
  523.             boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && p_70100_1_.capabilities.isCreativeMode;
  524.  
  525.             if (this.canBePickedUp == 1 && !p_70100_1_.inventory.addItemStackToInventory(new ItemStack(YesodItem.ExplosiveArrow, 1)))
  526.             {
  527.                 flag = false;
  528.             }
  529.  
  530.             if (flag)
  531.             {
  532.                 this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
  533.                 p_70100_1_.onItemPickup(this, 1);
  534.                 this.setDead();
  535.             }
  536.         }
  537.     }
  538.  
  539.     /**
  540.      * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to
  541.      * prevent them from trampling crops
  542.      */
  543.     protected boolean canTriggerWalking()
  544.     {
  545.         return false;
  546.     }
  547.  
  548.     @SideOnly(Side.CLIENT)
  549.     public float getShadowSize()
  550.     {
  551.         return 0.0F;
  552.     }
  553.  
  554.     public void setDamage(double p_70239_1_)
  555.     {
  556.         this.damage = p_70239_1_;
  557.     }
  558.  
  559.     public double getDamage()
  560.     {
  561.         return this.damage;
  562.     }
  563.  
  564.     /**
  565.      * Sets the amount of knockback the arrow applies when it hits a mob.
  566.      */
  567.     public void setKnockbackStrength(int p_70240_1_)
  568.     {
  569.         this.knockbackStrength = p_70240_1_;
  570.     }
  571.  
  572.     /**
  573.      * If returns false, the item will not inflict any damage against entities.
  574.      */
  575.     public boolean canAttackWithItem()
  576.     {
  577.         return false;
  578.     }
  579.  
  580.     /**
  581.      * Whether the arrow has a stream of critical hit particles flying behind it.
  582.      */
  583.     public void setIsCritical(boolean p_70243_1_)
  584.     {
  585.         byte b0 = this.dataWatcher.getWatchableObjectByte(16);
  586.  
  587.         if (p_70243_1_)
  588.         {
  589.             this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 1)));
  590.         }
  591.         else
  592.         {
  593.             this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -2)));
  594.         }
  595.     }
  596.  
  597.     /**
  598.      * Whether the arrow has a stream of critical hit particles flying behind it.
  599.      */
  600.     public boolean getIsCritical()
  601.     {
  602.         byte b0 = this.dataWatcher.getWatchableObjectByte(16);
  603.         return (b0 & 1) != 0;
  604.     }
  605. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement