Advertisement
Guest User

Untitled

a guest
Jan 28th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.41 KB | None | 0 0
  1. package com.arisux.avp.entities.mob;
  2.  
  3. import com.arisux.airi.lib.WorldUtil.Blocks.CoordData;
  4. import com.arisux.airi.lib.WorldUtil.Entities;
  5. import com.arisux.avp.AliensVsPredator;
  6. import com.arisux.avp.interfaces.IHiveSignature;
  7. import net.minecraft.entity.EntityLivingBase;
  8. import net.minecraft.entity.SharedMonsterAttributes;
  9. import net.minecraft.nbt.NBTTagCompound;
  10. import net.minecraft.world.World;
  11.  
  12. import java.util.ArrayList;
  13.  
  14. public class EntityQueen extends EntityXenomorph implements IHiveSignature
  15. {
  16.     public boolean isInStasis;
  17.     private float ovipositorSize;
  18.  
  19.     public EntityQueen(World world)
  20.     {
  21.         super(world);
  22.         this.setSize(2.0F, 4.0F);
  23.         this.isInStasis = true;
  24.         this.experienceValue = 40000;
  25.         this.jumpMovementFactor = 0.4F;
  26.         this.hurtResistantTime = 0;
  27.         this.ignoreFrustumCheck = true;
  28.         this.ovipositorSize = 0F;
  29.         this.setHiveSignature(this.getUniqueID());
  30.     }
  31.  
  32.     @Override
  33.     protected void entityInit()
  34.     {
  35.         super.entityInit();
  36.         this.dataWatcher.addObject(14, this.ovipositorSize);
  37.     }
  38.  
  39.     @Override
  40.     protected void applyEntityAttributes()
  41.     {
  42.         super.applyEntityAttributes();
  43.         this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(300.0D);
  44.         this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.400000238418579D);
  45.         this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(8.0D);
  46.     }
  47.  
  48.     @Override
  49.     public void onUpdate()
  50.     {
  51.         double prevMotionY = this.motionY;
  52.         super.onUpdate();
  53.  
  54.         if (this.motionY < prevMotionY)
  55.             this.motionY += -0.08F;
  56.  
  57.         if ((this.getAttackTarget() != null || this.getLastAttacker() != null) && this.worldObj.getWorldTime() % 40 == 0)
  58.         {
  59.             @SuppressWarnings("unchecked")
  60.             ArrayList<EntitySpeciesAlien> aliens = (ArrayList<EntitySpeciesAlien>) Entities.getEntitiesInCoordsRange(this.worldObj, EntitySpeciesAlien.class, new CoordData(this), 16);
  61.  
  62.             for (EntitySpeciesAlien alien : aliens)
  63.             {
  64.                 if (alien != null && alien.getHiveSignature() != null && !(alien instanceof EntityQueen) && alien.getHiveSignature().equals(this.getHiveSignature()))
  65.                 {
  66.                     if (this.rand.nextInt(6) == 0)
  67.                     {
  68.                         if (alien instanceof EntityOvamorph)
  69.                         {
  70.                             EntityOvamorph ovamorph = (EntityOvamorph) alien;
  71.                             ovamorph.setHatched(true);
  72.                         }
  73.                     }
  74.  
  75.                     EntityLivingBase target = this.getAttackTarget() != null ? this.getAttackTarget() : this.getLastAttacker();
  76.  
  77.                     alien.setAttackTarget(target);
  78.                     alien.getNavigator().tryMoveToEntityLiving(target, alien.getMoveHelper().getSpeed());
  79.                 }
  80.                 else if (alien != null && alien.getHiveSignature() == null)
  81.                 {
  82.                     alien.setHiveSignature(this.getHiveSignature());
  83.                 }
  84.             }
  85.         }
  86.  
  87.         if (isJumping)
  88.         {
  89.             this.addVelocity(0, 0.35D, 0);
  90.         }
  91.  
  92.         if (this.isInStasis)
  93.         {
  94.             this.ovipositorSize = this.ovipositorSize < 1.3F ? this.ovipositorSize += 0.0001F : 1.3F;
  95.             this.setOvipositorSize(this.ovipositorSize);
  96.         }
  97.  
  98.         if (this.worldObj.getWorldTime() % 10 == 0)
  99.         {
  100.             if (this.getHealth() > this.getMaxHealth() - (this.getMaxHealth() / 4))
  101.             {
  102.                 this.heal(2F);
  103.             }
  104.  
  105.             if (this.getHealth() > 0 && this.getHealth() < this.getMaxHealth() / 4 * 3)
  106.             {
  107.                 this.heal(2F);
  108.             }
  109.  
  110.             if (this.getHealth() > 0 && this.getHealth() < this.getMaxHealth() / 4 * 2)
  111.             {
  112.                 this.heal(2F);
  113.             }
  114.         }
  115.     }
  116.  
  117.     @Override
  118.     protected boolean isAIEnabled()
  119.     {
  120.         return true;
  121.     }
  122.  
  123.     @Override
  124.     protected String getHurtSound()
  125.     {
  126.         return AliensVsPredator.properties().SOUND_QUEEN_HURT;
  127.     }
  128.  
  129.     @Override
  130.     protected String getLivingSound()
  131.     {
  132.         return this.getHealth() > this.getMaxHealth() / 4 ? AliensVsPredator.properties().SOUND_QUEEN_LIVING + ".constant" : AliensVsPredator.properties().SOUND_QUEEN_LIVING;
  133.     }
  134.  
  135.     @Override
  136.     protected String getDeathSound()
  137.     {
  138.         return AliensVsPredator.properties().SOUND_QUEEN_DEATH;
  139.     }
  140.  
  141.     @Override
  142.     public void readEntityFromNBT(NBTTagCompound nbt)
  143.     {
  144.         super.readEntityFromNBT(nbt);
  145.         this.setOvipositorSize(nbt.getFloat("ovipositorSize"));
  146.     }
  147.  
  148.     @Override
  149.     public void writeEntityToNBT(NBTTagCompound nbt)
  150.     {
  151.         super.writeEntityToNBT(nbt);
  152.         nbt.setFloat("ovipositorSize", this.getOvipositorSize());
  153.     }
  154.  
  155.     public float getOvipositorSize()
  156.     {
  157.         return this.dataWatcher.getWatchableObjectFloat(14);
  158.     }
  159.  
  160.     public void setOvipositorSize(float size)
  161.     {
  162.         this.dataWatcher.updateObject(14, size);
  163.     }
  164.  
  165.     @Override
  166.     public boolean canBeCollidedWith()
  167.     {
  168.         return true;
  169.     }
  170. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement