001 /** 002 * Interface for living entities 003 * @author 004 */ 005 public class LivingEntity extends BaseEntity { 006 /** 007 * Interface for living entities 008 */ 009 public LivingEntity() { 010 } 011 012 /** 013 * Interface for living entities 014 * @param livingEntity 015 */ 016 public LivingEntity(mj livingEntity) { 017 super(livingEntity); 018 } 019 020 /** 021 * Returns the entity we're wrapping. 022 * @return 023 */ 024 public mj getEntity() { 025 return (mj)entity; 026 } 027 028 /** 029 * Returns the entity's health. 030 * 031 * @return health 032 */ 033 public int getHealth() { 034 return getEntity().aZ; 035 } 036 037 /** 038 * Increase entity health. 039 * @param health 040 * amount of health to increase the players health with. 041 */ 042 public void increaseHealth(int health) { 043 getEntity().c(health); 044 } 045 046 /** 047 * Sets the entity's health. 048 * 20 = max health 049 * 1 = 1/2 heart 050 * 2 = 1 heart 051 * 052 * @param health 053 */ 054 public void setHealth(int health) { 055 if (health < -1) 056 health = -1; 057 if (health > 20) 058 health = 20; 059 getEntity().aZ = health; 060 } 061 062 /** 063 * Get the amount of ticks this entity is dead. 064 * 20 ticks per second. 065 * @return 066 */ 067 public int getDeathTicks() { 068 return getEntity().be; 069 } 070 071 /** 072 * Set the amount of ticks this entity is dead. 073 * 20 ticks per second. 074 * 075 * @param ticks 076 */ 077 public void setDeathTicks(int ticks) { 078 getEntity().be = ticks; 079 } 080 081 /** 082 * Get the amount of ticks this entity will not take damage. (unless it heals) 083 * 20 ticks per second. 084 * 085 * @return 086 */ 087 public int getBaseNoDamageTicks() { 088 return getEntity().aF; 089 } 090 091 /** 092 * Set the amount of ticks this entity will not take damage. (until it heals) 093 * 20 ticks per second. 094 * 095 * @param ticks 096 */ 097 public void setBaseNoDamageTicks(int ticks) { 098 getEntity().aF = ticks; 099 } 100 101 /** 102 * Get the current maximum damage taken during this NoDamageTime 103 * 104 * @return 105 */ 106 public int getLastDamage() { 107 return getEntity().bv; 108 } 109 110 /** 111 * Set the current maximum damage taken during this NoDamageTime 112 * (if any damage is higher than this number the difference will be added) 113 * 114 * @param amount 115 */ 116 public void setLastDamage(int amount) { 117 getEntity().bv = amount; 118 } 119 }