Guest User

Untitled

a guest
Jan 22nd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.15 KB | None | 0 0
  1. package net.minecraft.src;
  2.  
  3. import java.util.List;
  4.  
  5. public class MoNature_EntityDruid extends EntityMob
  6. {
  7.  
  8.     public MoNature_EntityDruid(World world)
  9.     {
  10.         super(world);
  11.         texture = "/MoOres/DruidSkin.png";
  12.         setSize(1.5F, 1.9F);
  13.         targetedEntity = null;
  14.         isImmuneToFire = true;
  15.         angerLevel = 0;
  16.     }
  17.     public void writeEntityToNBT(NBTTagCompound nbttagcompound)
  18.     {
  19.         super.writeEntityToNBT(nbttagcompound);
  20.         nbttagcompound.setShort("Anger", (short)angerLevel);
  21.     }
  22.  
  23.     public void readEntityFromNBT(NBTTagCompound nbttagcompound)
  24.     {
  25.         super.readEntityFromNBT(nbttagcompound);
  26.         angerLevel = nbttagcompound.getShort("Anger");
  27.     }
  28.     protected Entity findPlayerToAttack()
  29.     {
  30.         if(angerLevel == 0)
  31.         {
  32.             return null;
  33.         } else
  34.         {
  35.             return super.findPlayerToAttack();
  36.         }
  37.     }
  38.     public boolean attackEntityFrom(DamageSource damagesource, int i)
  39.     {
  40.         Entity entity = damagesource.getEntity();
  41.         if(entity instanceof EntityPlayer)
  42.         {
  43.             List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(2D, 2D, 2D));
  44.             for(int j = 0; j < list.size(); j++)
  45.             {
  46.                 Entity entity1 = (Entity)list.get(j);
  47.                 if(entity1 instanceof MoNature_EntityDruid)
  48.                 {
  49.                     MoNature_EntityDruid entitypigzombie = (MoNature_EntityDruid)entity1;
  50.                     entitypigzombie.becomeAngryAt(entity);
  51.                 }
  52.             }
  53.  
  54.             becomeAngryAt(entity);
  55.         }
  56.         return super.attackEntityFrom(damagesource, i);
  57.     }
  58.     private void becomeAngryAt(Entity entity)
  59.     {
  60.         entityToAttack = entity;
  61.         angerLevel = 400 + rand.nextInt(400);
  62.     }
  63.     public void onLivingUpdate(){
  64.         super.onLivingUpdate();
  65.         if(entityToAttack!=null){
  66.         ModLoader.getMinecraftInstance().theWorld.setRainStrength(1F);
  67.         }
  68.     }
  69.     protected void updateEntityActionState()
  70.     {
  71.         if(targetedEntity != null && targetedEntity.isDead)
  72.         {
  73.             targetedEntity = null;
  74.         }
  75.         if(targetedEntity == null)
  76.         {
  77.             targetedEntity = worldObj.getClosestPlayerToEntity(this, 100D);
  78.         }
  79.         double d4 = 64D;
  80.         if(targetedEntity != null && targetedEntity.getDistanceSqToEntity(this) < d4 * d4)
  81.         {
  82.             double d5 = targetedEntity.posX - posX;
  83.             double d6 = (targetedEntity.boundingBox.minY + (double)(targetedEntity.height / 2.0F)) - (posY + (double)(height / 2.0F));
  84.             double d7 = targetedEntity.posZ - posZ;
  85.             renderYawOffset = rotationYaw = (-(float)Math.atan2(d5, d7) * 180F) / 3.141593F;
  86.             if(canEntityBeSeen(targetedEntity))
  87.             {
  88.                 {
  89.                     EntityLightningBolt entityfireball = new EntityLightningBolt(worldObj, d5, d6, d7);
  90.                     double d8 = 4D;
  91.                     Vec3D vec3d = getLook(1.0F);
  92.                     entityfireball.posX = posX + vec3d.xCoord * d8;
  93.                     entityfireball.posY = posY + (double)(height / 2.0F) + 0.5D;
  94.                     entityfireball.posZ = posZ + vec3d.zCoord * d8;
  95.                     worldObj.entityJoinedWorld(entityfireball);
  96.                 }
  97.             }
  98.         } else
  99.         {
  100.             renderYawOffset = rotationYaw = (-(float)Math.atan2(motionX, motionZ) * 180F) / 3.141593F;
  101.         }
  102.     }
  103.     protected String getLivingSound()
  104.     {
  105.         return null;
  106.     }
  107.  
  108.     protected String getHurtSound()
  109.     {
  110.         return null;
  111.     }
  112.  
  113.     protected String getDeathSound()
  114.     {
  115.         return null;
  116.     }
  117.  
  118.     protected float getSoundVolume()
  119.     {
  120.         return 0.4F;
  121.     }
  122.     public ItemStack getHeldItem()
  123.     {
  124.         return defaultHeldItem;
  125.     }
  126.  
  127.     protected int getDropItemId()
  128.     {
  129.         return 352;
  130.     }
  131.     private static final ItemStack defaultHeldItem;
  132.  
  133.     static
  134.     {
  135.         defaultHeldItem = new ItemStack(Item.stick, 1);
  136.     }
  137.     private int angerLevel;
  138.     private Entity targetedEntity;
  139. }
Add Comment
Please, Sign In to add comment