Advertisement
Corosus

Untitled

Aug 3rd, 2011
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. package net.minecraft.src;
  2.  
  3. import java.util.List;
  4. import net.minecraft.src.Entity;
  5. import net.minecraft.src.EntityPlayer;
  6. import net.minecraft.src.EntityZombie;
  7. import net.minecraft.src.Item;
  8. import net.minecraft.src.ItemStack;
  9. import net.minecraft.src.NBTTagCompound;
  10. import net.minecraft.src.World;
  11.  
  12. public class EntityPigZombie extends EntityZombie {
  13.  
  14. private int angerLevel = 0;
  15. private int randomSoundDelay = 0;
  16. private static final ItemStack defaultHeldItem = new ItemStack(Item.swordGold, 1);
  17.  
  18.  
  19. public EntityPigZombie(World var1) {
  20. super(var1);
  21. this.texture = "/mob/pigzombie.png";
  22. this.moveSpeed = 0.5F;
  23. this.attackStrength = 5;
  24. this.isImmuneToFire = true;
  25. }
  26.  
  27. public void onUpdate() {
  28. this.moveSpeed = this.playerToAttack != null?0.95F:0.5F;
  29. if(this.randomSoundDelay > 0 && --this.randomSoundDelay == 0) {
  30. this.worldObj.playSoundAtEntity(this, "mob.zombiepig.zpigangry", this.getSoundVolume() * 2.0F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) * 1.8F);
  31. }
  32.  
  33. super.onUpdate();
  34. }
  35.  
  36. public boolean getCanSpawnHere() {
  37. return this.worldObj.difficultySetting > 0 && this.worldObj.checkIfAABBIsClear(this.boundingBox) && this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).size() == 0 && !this.worldObj.getIsAnyLiquid(this.boundingBox);
  38. }
  39.  
  40. public void writeEntityToNBT(NBTTagCompound var1) {
  41. super.writeEntityToNBT(var1);
  42. var1.setShort("Anger", (short)this.angerLevel);
  43. }
  44.  
  45. public void readEntityFromNBT(NBTTagCompound var1) {
  46. super.readEntityFromNBT(var1);
  47. this.angerLevel = var1.getShort("Anger");
  48. }
  49.  
  50. protected Entity findPlayerToAttack() {
  51. return this.angerLevel == 0?null:super.findPlayerToAttack();
  52. }
  53.  
  54. public void onLivingUpdate() {
  55. super.onLivingUpdate();
  56. }
  57.  
  58. public boolean attackEntityFrom(Entity var1, int var2) {
  59. if(var1 instanceof EntityPlayer) {
  60. List var3 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(32.0D, 32.0D, 32.0D));
  61.  
  62. for(int var4 = 0; var4 < var3.size(); ++var4) {
  63. Entity var5 = (Entity)var3.get(var4);
  64. if(var5 instanceof EntityPigZombie) {
  65. EntityPigZombie var6 = (EntityPigZombie)var5;
  66. var6.becomeAngryAt(var1);
  67. }
  68. }
  69.  
  70. this.becomeAngryAt(var1);
  71. }
  72.  
  73. return super.attackEntityFrom(var1, var2);
  74. }
  75.  
  76. private void becomeAngryAt(Entity var1) {
  77. this.playerToAttack = var1;
  78. this.angerLevel = 400 + this.rand.nextInt(400);
  79. this.randomSoundDelay = this.rand.nextInt(40);
  80. }
  81.  
  82. protected String getLivingSound() {
  83. return "mob.zombiepig.zpig";
  84. }
  85.  
  86. protected String getHurtSound() {
  87. return "mob.zombiepig.zpighurt";
  88. }
  89.  
  90. protected String getDeathSound() {
  91. return "mob.zombiepig.zpigdeath";
  92. }
  93.  
  94. protected int getDropItemId() {
  95. return Item.porkCooked.shiftedIndex;
  96. }
  97.  
  98. public ItemStack getHeldItem() {
  99. return defaultHeldItem;
  100. }
  101.  
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement