Guest User

EntityNukePrimed

a guest
Feb 21st, 2016
80
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package TheMod;
  2.  
  3. import net.minecraft.entity.Entity;
  4. import net.minecraft.entity.EntityLivingBase;
  5. import net.minecraft.nbt.NBTTagCompound;
  6. import net.minecraft.util.EnumParticleTypes;
  7. import net.minecraft.world.World;
  8.  
  9. public class EntityNukePrimed extends Entity
  10. {
  11.     /** How long the fuse is */
  12.     public int fuse;
  13.     private EntityLivingBase tntPlacedBy;
  14.     private static final String __OBFID = "CL_00001681";
  15.  
  16.     public EntityNukePrimed(World worldIn)
  17.     {
  18.         super(worldIn);
  19.         this.preventEntitySpawning = true;
  20.         this.setSize(0.98F, 0.98F);
  21.     }
  22.  
  23.     public EntityNukePrimed(World worldIn, double p_i1730_2_, double p_i1730_4_, double p_i1730_6_, EntityLivingBase p_i1730_8_)
  24.     {
  25.         this(worldIn);
  26.         this.setPosition(p_i1730_2_, p_i1730_4_, p_i1730_6_);
  27.         float f = (float)(Math.random() * Math.PI * 2.0D);
  28.         this.motionX = (double)(-((float)Math.sin((double)f)) * 0.02F);
  29.         this.motionY = 0.20000000298023224D;
  30.         this.motionZ = (double)(-((float)Math.cos((double)f)) * 0.02F);
  31.         this.fuse = 160;
  32.         this.prevPosX = p_i1730_2_;
  33.         this.prevPosY = p_i1730_4_;
  34.         this.prevPosZ = p_i1730_6_;
  35.         this.tntPlacedBy = p_i1730_8_;
  36.     }
  37.  
  38.     protected void entityInit() {}
  39.  
  40.     /**
  41.      * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to
  42.      * prevent them from trampling crops
  43.      */
  44.     protected boolean canTriggerWalking()
  45.     {
  46.         return false;
  47.     }
  48.  
  49.     /**
  50.      * Returns true if other Entities should be prevented from moving through this Entity.
  51.      */
  52.     public boolean canBeCollidedWith()
  53.     {
  54.         return !this.isDead;
  55.     }
  56.  
  57.     /**
  58.      * Called to update the entity's position/logic.
  59.      */
  60.     public void onUpdate()
  61.     {
  62.         this.prevPosX = this.posX;
  63.         this.prevPosY = this.posY;
  64.         this.prevPosZ = this.posZ;
  65.         this.motionY -= 0.03999999910593033D;
  66.         this.moveEntity(this.motionX, this.motionY, this.motionZ);
  67.         this.motionX *= 0.9800000190734863D;
  68.         this.motionY *= 0.9800000190734863D;
  69.         this.motionZ *= 0.9800000190734863D;
  70.  
  71.         if (this.onGround)
  72.         {
  73.             this.motionX *= 0.699999988079071D;
  74.             this.motionZ *= 0.699999988079071D;
  75.             this.motionY *= -0.5D;
  76.         }
  77.  
  78.         if (this.fuse-- <= 0)
  79.         {
  80.             this.setDead();
  81.  
  82.             if (!this.worldObj.isRemote)
  83.             {
  84.                 this.explode();
  85.             }
  86.         }
  87.         else
  88.         {
  89.             this.handleWaterMovement();
  90.             this.worldObj.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D, new int[0]);
  91.         }
  92.     }
  93.  
  94.     private void explode()
  95.     {
  96.         float f = 20.0F;
  97.         this.worldObj.createExplosion(this, this.posX, this.posY + (double)(this.height / 10.0F), this.posZ, f, true);
  98.     }
  99.  
  100.     /**
  101.      * (abstract) Protected helper method to write subclass entity data to NBT.
  102.      */
  103.     protected void writeEntityToNBT(NBTTagCompound tagCompound)
  104.     {
  105.         tagCompound.setByte("Fuse", (byte)this.fuse);
  106.     }
  107.  
  108.     /**
  109.      * (abstract) Protected helper method to read subclass entity data from NBT.
  110.      */
  111.     protected void readEntityFromNBT(NBTTagCompound tagCompund)
  112.     {
  113.         this.fuse = tagCompund.getByte("Fuse");
  114.     }
  115.  
  116.     /**
  117.      * returns null or the entityliving it was placed or ignited by
  118.      */
  119.     public EntityLivingBase getTntPlacedBy()
  120.     {
  121.         return this.tntPlacedBy;
  122.     }
  123.  
  124.     public float getEyeHeight()
  125.     {
  126.         return 0.0F;
  127.     }
  128. }
RAW Paste Data