geforkt von Mirrors/Paper
Implement entity max health methods. Adds BUKKIT-266
By: feildmaster <admin@feildmaster.com>
Dieser Commit ist enthalten in:
Ursprung
f1cc082ee0
Commit
8dcc915237
@ -4,6 +4,7 @@ import net.minecraft.server.EntityComplexPart;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.entity.EnderDragonPart;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class CraftEnderDragonPart extends CraftComplexPart implements EnderDragonPart {
|
||||
public CraftEnderDragonPart(CraftServer server, EntityComplexPart entity) {
|
||||
@ -24,4 +25,32 @@ public class CraftEnderDragonPart extends CraftComplexPart implements EnderDrago
|
||||
public String toString() {
|
||||
return "CraftEnderDragonPart";
|
||||
}
|
||||
|
||||
public void damage(int amount) {
|
||||
getParent().damage(amount);
|
||||
}
|
||||
|
||||
public void damage(int amount, Entity source) {
|
||||
getParent().damage(amount, source);
|
||||
}
|
||||
|
||||
public int getHealth() {
|
||||
return getParent().getHealth();
|
||||
}
|
||||
|
||||
public void setHealth(int health) {
|
||||
getParent().setHealth(health);
|
||||
}
|
||||
|
||||
public int getMaxHealth() {
|
||||
return getParent().getMaxHealth();
|
||||
}
|
||||
|
||||
public void setMaxHealth(int health) {
|
||||
getParent().setMaxHealth(health);
|
||||
}
|
||||
|
||||
public void resetMaxHealth() {
|
||||
getParent().resetMaxHealth();
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,21 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
}
|
||||
|
||||
public int getMaxHealth() {
|
||||
return getHandle().getMaxHealth();
|
||||
return getHandle().maxHealth;
|
||||
}
|
||||
|
||||
public void setMaxHealth(int amount) {
|
||||
Validate.isTrue(amount > 0, "Max health must be greater than 0");
|
||||
|
||||
getHandle().maxHealth = amount;
|
||||
|
||||
if (getHealth() > amount) {
|
||||
setHealth(amount);
|
||||
}
|
||||
}
|
||||
|
||||
public void resetMaxHealth() {
|
||||
setMaxHealth(getHandle().getMaxHealth());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
@ -941,4 +941,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setMaxHealth(int amount) {
|
||||
super.setMaxHealth(amount);
|
||||
getHandle().m(); // Update health
|
||||
}
|
||||
|
||||
public void resetMaxHealth() {
|
||||
super.resetMaxHealth();
|
||||
getHandle().m(); // Update health
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren