Guest User

Untitled

a guest
Oct 3rd, 2015
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.65 KB | None | 0 0
  1. package com.robbiemilton.shade.entity;
  2.  
  3. import cpw.mods.fml.relauncher.Side;
  4. import cpw.mods.fml.relauncher.SideOnly;
  5. import net.minecraft.block.Block;
  6. import net.minecraft.block.material.Material;
  7. import net.minecraft.entity.Entity;
  8. import net.minecraft.entity.EntityLivingBase;
  9. import net.minecraft.entity.SharedMonsterAttributes;
  10. import net.minecraft.entity.ai.EntityAITargetNonTamed;
  11. import net.minecraft.entity.monster.EntityZombie;
  12. import net.minecraft.entity.monster.IMob;
  13. import net.minecraft.entity.passive.EntityWolf;
  14. import net.minecraft.entity.player.EntityPlayer;
  15. import net.minecraft.nbt.NBTTagCompound;
  16. import net.minecraft.util.ChunkCoordinates;
  17. import net.minecraft.util.DamageSource;
  18. import net.minecraft.util.MathHelper;
  19. import net.minecraft.village.Village;
  20. import net.minecraft.world.World;
  21.  
  22. public class EntityDarkKnight2 extends EntityWolf{
  23.  
  24. private int homeCheckTimer;
  25. Village villageObj;
  26. private int attackTimer;
  27.  
  28. public EntityDarkKnight2(World world) {
  29. super(world);
  30. this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntityZombie.class, 200, false));
  31. // TODO Auto-generated constructor stub
  32. }
  33.  
  34.  
  35. protected void applyEntityAttributes()
  36. {
  37. super.applyEntityAttributes();
  38. this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(100.0D);
  39. this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.25D);
  40. }
  41.  
  42. public void setposition() {
  43. // TODO Auto-generated method stub
  44.  
  45. }
  46.  
  47. public void setPosition(double d, double e, double f) {
  48. // TODO Auto-generated method stub
  49.  
  50. }
  51. @SideOnly(Side.CLIENT)
  52. public boolean getWolfShaking()
  53. {
  54. return false;
  55. }
  56. @SideOnly(Side.CLIENT)
  57. public float getShadingWhileShaking(float p_70915_1_)
  58. {
  59. return 0;
  60. }
  61.  
  62. @SideOnly(Side.CLIENT)
  63. public float getShakeAngle(float p_70923_1_, float p_70923_2_)
  64. {
  65. return 0;
  66. }
  67.  
  68. public boolean isAIEnabled()
  69. {
  70. return true;
  71. }
  72.  
  73. /**
  74. * main AI tick function, replaces updateEntityActionState
  75. */
  76. protected void updateAITick()
  77. {
  78. if (--this.homeCheckTimer <= 0)
  79. {
  80. this.homeCheckTimer = 70 + this.rand.nextInt(50);
  81. this.villageObj = this.worldObj.villageCollectionObj.findNearestVillage(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ), 32);
  82.  
  83. if (this.villageObj == null)
  84. {
  85. this.detachHome();
  86. }
  87. else
  88. {
  89. ChunkCoordinates chunkcoordinates = this.villageObj.getCenter();
  90. this.setHomeArea(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ, (int)((float)this.villageObj.getVillageRadius() * 0.6F));
  91. }
  92. }
  93.  
  94. super.updateAITick();
  95. }
  96.  
  97.  
  98. /**
  99. * Decrements the entity's air supply when underwater
  100. */
  101. protected int decreaseAirSupply(int p_70682_1_)
  102. {
  103. return p_70682_1_;
  104. }
  105.  
  106. protected void collideWithEntity(Entity p_82167_1_)
  107. {
  108. if (p_82167_1_ instanceof IMob && this.getRNG().nextInt(20) == 0)
  109. {
  110. this.setAttackTarget((EntityLivingBase)p_82167_1_);
  111. }
  112.  
  113. super.collideWithEntity(p_82167_1_);
  114. }
  115.  
  116. /**
  117. * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
  118. * use this to react to sunlight and start to burn.
  119. */
  120. public void onLivingUpdate()
  121. {
  122. super.onLivingUpdate();
  123.  
  124. if (this.attackTimer > 0)
  125. {
  126. --this.attackTimer;
  127. }
  128.  
  129.  
  130. if (this.motionX * this.motionX + this.motionZ * this.motionZ > 2.500000277905201E-7D && this.rand.nextInt(5) == 0)
  131. {
  132. int i = MathHelper.floor_double(this.posX);
  133. int j = MathHelper.floor_double(this.posY - 0.20000000298023224D - (double)this.yOffset);
  134. int k = MathHelper.floor_double(this.posZ);
  135. Block block = this.worldObj.getBlock(i, j, k);
  136.  
  137. if (block.getMaterial() != Material.air)
  138. {
  139. this.worldObj.spawnParticle("blockcrack_" + Block.getIdFromBlock(block) + "_" + this.worldObj.getBlockMetadata(i, j, k), this.posX + ((double)this.rand.nextFloat() - 0.5D) * (double)this.width, this.boundingBox.minY + 0.1D, this.posZ + ((double)this.rand.nextFloat() - 0.5D) * (double)this.width, 4.0D * ((double)this.rand.nextFloat() - 0.5D), 0.5D, ((double)this.rand.nextFloat() - 0.5D) * 4.0D);
  140. }
  141. }
  142. }
  143.  
  144. /**
  145. * Returns true if this entity can attack entities of the specified class.
  146. */
  147. public boolean canAttackClass(Class p_70686_1_)
  148. {
  149. return this.isPlayerCreated() && EntityPlayer.class.isAssignableFrom(p_70686_1_) ? false : super.canAttackClass(p_70686_1_);
  150. }
  151. /**
  152. * (abstract) Protected helper method to write subclass entity data to NBT.
  153. */
  154. public void writeEntityToNBT(NBTTagCompound p_70014_1_)
  155. {
  156. super.writeEntityToNBT(p_70014_1_);
  157. p_70014_1_.setBoolean("PlayerCreated", this.isPlayerCreated());
  158. }
  159.  
  160. /**
  161. * (abstract) Protected helper method to read subclass entity data from NBT.
  162. */
  163. public void readEntityFromNBT(NBTTagCompound p_70037_1_)
  164. {
  165. super.readEntityFromNBT(p_70037_1_);
  166. this.setPlayerCreated(p_70037_1_.getBoolean("PlayerCreated"));
  167. }
  168.  
  169. public boolean attackEntityAsMob(Entity p_70652_1_)
  170. {
  171. this.attackTimer = 10;
  172. this.worldObj.setEntityState(this, (byte)4);
  173. boolean flag = p_70652_1_.attackEntityFrom(DamageSource.causeMobDamage(this), (float)(7 + this.rand.nextInt(15)));
  174.  
  175. if (flag)
  176. {
  177. p_70652_1_.motionY += 0.4000000059604645D;
  178. }
  179.  
  180. this.playSound("mob.irongolem.throw", 1.0F, 1.0F);
  181. return flag;
  182. }
  183.  
  184. @SideOnly(Side.CLIENT)
  185. public int getAttackTimer()
  186. {
  187. return this.attackTimer;
  188. }
  189.  
  190. public boolean isPlayerCreated()
  191. {
  192. return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0;
  193. }
  194.  
  195. public void setPlayerCreated(boolean p_70849_1_)
  196. {
  197. byte b0 = this.dataWatcher.getWatchableObjectByte(16);
  198.  
  199. if (p_70849_1_)
  200. {
  201. this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 1)));
  202. }
  203. else
  204. {
  205. this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -2)));
  206. }
  207. }
  208.  
  209.  
  210. public void setTamed(boolean p_70903_1_)
  211. {
  212. super.setTamed(p_70903_1_);
  213. }
  214. }
Advertisement
Add Comment
Please, Sign In to add comment