GenuineSounds

Persistent Corpses

Jun 10th, 2012
222
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. protected boolean isCorpse;
  2.  
  3. @Override
  4. public void onEntityUpdate() {
  5.     if (this.isCorpse)
  6.         this.corpseTimer();
  7.     else
  8.         super.onEntityUpdate();
  9. }
  10.  
  11. @Override
  12. protected int getDropItemId() {
  13.     this.corpseTimer();
  14.     return super.getDropItemId();
  15. }
  16.  
  17. protected void corpseTimer() {
  18.     if (!this.isCorpse && this.health <= 0)
  19.         this.isCorpse = true;
  20.     if (this.isCorpse) {
  21.         // This keeps the corpse on the ground after it dies.
  22.         if (this.deathTime >= 18)
  23.             this.deathTime = 18;
  24.     }
  25. }
  26.  
  27. @Override
  28. public void readEntityFromNBT(NBTTagCompound nbt) {
  29.     super.readEntityFromNBT(nbt);
  30.     this.isCorpse = nbt.getBoolean("Corpse");
  31. }
  32.  
  33. @Override
  34. public void writeEntityToNBT(NBTTagCompound nbt) {
  35.     super.writeEntityToNBT(nbt);
  36.     nbt.setBoolean("Corpse", this.isCorpse);
  37. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment