Advertisement
Guest User

Untitled

a guest
Dec 5th, 2015
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.77 KB | None | 0 0
  1. package thelasttocraft.common.mobs;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. import net.minecraft.entity.EntityCreature;
  6. import net.minecraft.entity.SharedMonsterAttributes;
  7. import net.minecraft.entity.ai.EntityAIAttackOnCollide;
  8. import net.minecraft.entity.ai.EntityAIEatGrass;
  9. import net.minecraft.entity.ai.EntityAIHurtByTarget;
  10. import net.minecraft.entity.ai.EntityAILeapAtTarget;
  11. import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
  12. import net.minecraft.entity.ai.EntityAISwimming;
  13. import net.minecraft.entity.ai.EntityAIWander;
  14. import net.minecraft.entity.monster.EntityMob;
  15. import net.minecraft.entity.passive.EntitySheep;
  16. import net.minecraft.entity.player.EntityPlayer;
  17. import net.minecraft.init.Blocks;
  18. import net.minecraft.item.Item;
  19. import net.minecraft.item.ItemStack;
  20. import net.minecraft.world.IBlockAccess;
  21. import net.minecraft.world.World;
  22. import net.minecraftforge.common.IShearable;
  23.  
  24. public class EntityTLTCZombieSheep extends EntityMob implements IShearable{
  25.  
  26. public EntityTLTCZombieSheep(World p_i1738_1_) {
  27. super(p_i1738_1_);
  28. this.setSize(0.9F, 1.3F);
  29. this.getNavigator().setAvoidsWater(true);
  30. this.tasks.addTask(0, new EntityAISwimming(this));
  31. this.tasks.addTask(1, new EntityAIWander(this, 1.0D));
  32. this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.0D, false));
  33. this.tasks.addTask(3, new EntityAIEatGrass(this));
  34. this.tasks.addTask(4, new EntityAILeapAtTarget(this, 1.0F));
  35. this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
  36. this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));
  37. }
  38.  
  39. public boolean isAIEnable()
  40. {
  41. return true;
  42. }
  43.  
  44. protected void applyEntityAttributes()
  45. {
  46. super.applyEntityAttributes();
  47. this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(10.0D);
  48. this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.7D);
  49. this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(3.0D);
  50. this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(16.0D);
  51. }
  52.  
  53. protected String getLivingSound()
  54. {
  55. return "mob.sheep.say";
  56. }
  57.  
  58. protected String getHurtSound()
  59. {
  60. return "mob.sheep.say";
  61. }
  62.  
  63. protected String getDeathSound()
  64. {
  65. return "mob.sheep.say";
  66. }
  67.  
  68. @Override
  69. public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int z) {
  70. return !getSheared();
  71. }
  72.  
  73. public boolean getSheared()
  74. {
  75. return (this.dataWatcher.getWatchableObjectByte(16) & 16) != 0;
  76. }
  77.  
  78. public void setSheared(boolean p_70893_1_)
  79. {
  80. byte b0 = this.dataWatcher.getWatchableObjectByte(16);
  81.  
  82. if (p_70893_1_)
  83. {
  84. this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 16)));
  85. }
  86. else
  87. {
  88. this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -17)));
  89. }
  90. }
  91.  
  92. protected void dropFewItems(boolean p_70628_1_, int p_70628_2_)
  93. {
  94. if (!this.getSheared())
  95. {
  96. this.entityDropItem(new ItemStack(Item.getItemFromBlock(Blocks.wool), 1), 0.0F);
  97. }
  98. }
  99.  
  100. protected Item getDropItem()
  101. {
  102. return Item.getItemFromBlock(Blocks.wool);
  103. }
  104.  
  105. @Override
  106. public ArrayList<ItemStack> onSheared(ItemStack item, IBlockAccess world, int x, int y, int z, int fortune) {
  107. ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
  108. setSheared(true);
  109. int i = 1 + rand.nextInt(3);
  110. for (int j = 0; j < i; j++)
  111. {
  112. ret.add(new ItemStack(Blocks.wool, 1));
  113. }
  114. this.playSound("mob.sheep.shear", 1.0F, 1.0F);
  115. return ret;
  116. }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement