summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/net/minecraft/server/Entity.java4
-rw-r--r--src/main/java/net/minecraft/server/EntityEnderDragon.java2
-rw-r--r--src/main/java/net/minecraft/server/EntityHuman.java5
-rw-r--r--src/main/java/net/minecraft/server/EntityInsentient.java6
-rw-r--r--src/main/java/net/minecraft/server/EntityLiving.java24
-rw-r--r--src/main/java/net/minecraft/server/EntityPlayer.java7
-rw-r--r--src/main/java/net/minecraft/server/EntitySlime.java8
-rw-r--r--src/main/java/net/minecraft/server/EntityWitch.java2
-rw-r--r--src/main/java/net/minecraft/server/EntityWither.java2
-rw-r--r--src/main/java/net/minecraft/server/EntityWolf.java14
-rw-r--r--src/main/java/net/minecraft/server/MobEffectList.java2
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java5
12 files changed, 21 insertions, 60 deletions
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 3953bc49..06f85fdc 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -1149,10 +1149,6 @@ public abstract class Entity {
// CraftBukkit start
if (this instanceof EntityLiving) {
EntityLiving entity = (EntityLiving) this;
- // If the entity does not have a max health set yet, update it (it may have changed after loading the entity)
- if (!nbttagcompound.hasKey("Bukkit.MaxHealth")) {
- entity.maxHealth = entity.getMaxHealth();
- }
// Reset the persistence for tamed animals
if (entity instanceof EntityTameableAnimal && !isLevelAtLeast(nbttagcompound, 2) && !nbttagcompound.getBoolean("PersistenceRequired")) {
diff --git a/src/main/java/net/minecraft/server/EntityEnderDragon.java b/src/main/java/net/minecraft/server/EntityEnderDragon.java
index f776aeb3..0bd2b60b 100644
--- a/src/main/java/net/minecraft/server/EntityEnderDragon.java
+++ b/src/main/java/net/minecraft/server/EntityEnderDragon.java
@@ -304,7 +304,7 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
}
this.bC = null;
- } else if (this.ticksLived % 10 == 0 && this.getHealth() < this.maxHealth) { // CraftBukkit - this.getMaxHealth() -> this.maxHealth
+ } else if (this.ticksLived % 10 == 0 && this.getHealth() < this.getMaxHealth()) { // CraftBukkit - this.getMaxHealth() -> this.maxHealth
// CraftBukkit start
EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), 1.0D, EntityRegainHealthEvent.RegainReason.ENDER_CRYSTAL);
this.world.getServer().getPluginManager().callEvent(event);
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index 96c1f8c0..794ed476 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -351,8 +351,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen
--this.br;
}
- // CraftBukkit - this.getMaxHealth() -> this.maxHealth
- if (this.world.difficulty == 0 && this.getHealth() < this.maxHealth && this.world.getGameRules().getBoolean("naturalRegeneration") && this.ticksLived % 20 * 12 == 0) {
+ if (this.world.difficulty == 0 && this.getHealth() < this.getMaxHealth() && this.world.getGameRules().getBoolean("naturalRegeneration") && this.ticksLived % 20 * 12 == 0) {
// CraftBukkit - added regain reason of "REGEN" for filtering purposes.
this.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN);
}
@@ -1402,7 +1401,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen
}
public boolean bE() {
- return this.getHealth() > 0.0F && this.getHealth() < this.maxHealth; // CraftBukkit - this.getMaxHealth() -> this.maxHealth
+ return this.getHealth() > 0.0F && this.getHealth() < this.getMaxHealth();
}
public void a(ItemStack itemstack, int i) {
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
index 7d8f2b42..49c2c95f 100644
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
@@ -6,10 +6,6 @@ import java.util.UUID;
//CraftBukkit start
import org.bukkit.craftbukkit.event.CraftEventFactory;
-import org.bukkit.event.entity.EntityDamageByBlockEvent;
-import org.bukkit.event.entity.EntityDamageEvent;
-import org.bukkit.event.entity.EntityRegainHealthEvent;
-//CraftBukkit end
public abstract class EntityInsentient extends EntityLiving {
@@ -529,7 +525,7 @@ public abstract class EntityInsentient extends EntityLiving {
if (this.getGoalTarget() == null) {
return 3;
} else {
- int i = (int) (this.getHealth() - this.maxHealth * 0.33F); // CraftBukkit - this.getMaxHealth() -> this.maxHealth
+ int i = (int) (this.getHealth() - this.getMaxHealth() * 0.33F);
i -= (3 - this.world.difficulty) * 4;
if (i < 0) {
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 0d9ba820..0adbfcd2 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -9,7 +9,6 @@ import java.util.UUID;
// CraftBukkit start
import org.bukkit.craftbukkit.event.CraftEventFactory;
-import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent;
// CraftBukkit end
@@ -77,7 +76,6 @@ public abstract class EntityLiving extends Entity {
// CraftBukkit start
public int expToDrop;
public int maxAirTicks = 300;
- public float maxHealth;
// CraftBukkit end
public EntityLiving(World world) {
@@ -91,7 +89,6 @@ public abstract class EntityLiving extends Entity {
this.yaw = (float) (Math.random() * 3.1415927410125732D * 2.0D);
this.aP = this.yaw;
this.Y = 0.5F;
- maxHealth = this.getMaxHealth(); // CraftBukkit - We can't initialize maxHealth until this.ax() has been invoked.
}
protected void a() {
@@ -241,14 +238,6 @@ public abstract class EntityLiving extends Entity {
return 0;
}
}
-
- public float getScaledHealth() {
- if (this.maxHealth != this.getMaxHealth() && this.getHealth() > 0) {
- return this.getHealth() * this.getMaxHealth() / this.maxHealth + 1;
- } else {
- return this.getHealth();
- }
- }
// CraftBukkit end
public boolean isBaby() {
@@ -327,7 +316,6 @@ public abstract class EntityLiving extends Entity {
public void b(NBTTagCompound nbttagcompound) {
nbttagcompound.setFloat("HealF", this.getHealth());
nbttagcompound.setShort("Health", (short) ((int) Math.ceil((double) this.getHealth())));
- nbttagcompound.setFloat("Bukkit.MaxHealth", this.maxHealth); // CraftBukkit
nbttagcompound.setShort("HurtTime", (short) this.hurtTicks);
nbttagcompound.setShort("DeathTime", (short) this.deathTicks);
nbttagcompound.setShort("AttackTime", (short) this.attackTicks);
@@ -391,9 +379,9 @@ public abstract class EntityLiving extends Entity {
if (nbttagcompound.hasKey("Bukkit.MaxHealth")) {
NBTBase nbtbase = nbttagcompound.get("Bukkit.MaxHealth");
if (nbtbase.getTypeId() == 5) {
- this.maxHealth = ((NBTTagFloat) nbtbase).data;
+ this.a(GenericAttributes.a).a((double) ((NBTTagFloat) nbtbase).data);
} else if (nbtbase.getTypeId() == 3) {
- this.maxHealth = (float) ((NBTTagInt) nbtbase).data;
+ this.a(GenericAttributes.a).a((double) ((NBTTagInt) nbtbase).data);
}
}
// CraftBukkit end
@@ -404,7 +392,7 @@ public abstract class EntityLiving extends Entity {
NBTBase nbtbase = nbttagcompound.get("Health");
if (nbtbase == null) {
- this.setHealth(this.maxHealth); // CraftBukkit - this.getMaxHealth() -> this.maxHealth
+ this.setHealth(this.getMaxHealth());
} else if (nbtbase.getTypeId() == 5) {
this.setHealth(((NBTTagFloat) nbtbase).data);
} else if (nbtbase.getTypeId() == 2) {
@@ -587,12 +575,6 @@ public abstract class EntityLiving extends Entity {
if (!event.isCancelled()) {
this.setHealth((float) (this.getHealth() + event.getAmount()));
}
-
- // TODO should we be doing this anymore
- if (this.getHealth() > this.maxHealth) {
- this.setHealth(this.maxHealth);
- }
- // CraftBukkit end
}
}
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 094da966..69a76792 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -4,7 +4,6 @@ import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
@@ -234,8 +233,8 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
}
if (this.getHealth() != this.bP || this.bQ != this.foodData.a() || this.foodData.e() == 0.0F != this.bR) {
- // CraftBukkit - this.getHealth() -> this.getScaledHealth()
- this.playerConnection.sendPacket(new Packet8UpdateHealth(this.getScaledHealth(), this.foodData.a(), this.foodData.e()));
+ // CraftBukkit - this.getHealth() -> this.getScaledHealth() - Magic number 20 -> original max health
+ this.playerConnection.sendPacket(new Packet8UpdateHealth((float) (this.getHealth() * this.getMaxHealth() / 20.0D), this.foodData.a(), this.foodData.e()));
this.bP = this.getHealth();
this.bQ = this.foodData.a();
this.bR = this.foodData.e() == 0.0F;
@@ -907,7 +906,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
this.newLevel = this.expLevel;
}
- this.setHealth(this.maxHealth);
+ this.setHealth(this.getMaxHealth());
this.fireTicks = 0;
this.fallDistance = 0;
this.foodData = new FoodMetaData();
diff --git a/src/main/java/net/minecraft/server/EntitySlime.java b/src/main/java/net/minecraft/server/EntitySlime.java
index 6789d2fb..e24769b6 100644
--- a/src/main/java/net/minecraft/server/EntitySlime.java
+++ b/src/main/java/net/minecraft/server/EntitySlime.java
@@ -31,17 +31,11 @@ public class EntitySlime extends EntityInsentient implements IMonster {
// CraftBukkit - protected -> public
public void setSize(int i) {
- boolean updateMaxHealth = this.getMaxHealth() == this.maxHealth; // CraftBukkit
this.datawatcher.watch(16, new Byte((byte) i));
this.a(0.6F * (float) i, 0.6F * (float) i);
this.setPosition(this.locX, this.locY, this.locZ);
this.a(GenericAttributes.a).a((double) (i * i));
- // CraftBukkit start
- if (updateMaxHealth) {
- this.maxHealth = this.getMaxHealth();
- }
- this.setHealth(this.maxHealth);
- // CraftBukkit end
+ this.setHealth(this.getMaxHealth());
this.b = i;
}
diff --git a/src/main/java/net/minecraft/server/EntityWitch.java b/src/main/java/net/minecraft/server/EntityWitch.java
index 368652de..ff2b4268 100644
--- a/src/main/java/net/minecraft/server/EntityWitch.java
+++ b/src/main/java/net/minecraft/server/EntityWitch.java
@@ -86,7 +86,7 @@ public class EntityWitch extends EntityMonster implements IRangedEntity {
if (this.random.nextFloat() < 0.15F && this.isBurning() && !this.hasEffect(MobEffectList.FIRE_RESISTANCE)) {
short1 = 16307;
- } else if (this.random.nextFloat() < 0.05F && this.getHealth() < this.maxHealth) { // CraftBukkit - this.getMaxHealth() -> this.maxHealth
+ } else if (this.random.nextFloat() < 0.05F && this.getHealth() < this.getMaxHealth()) {
short1 = 16341;
} else if (this.random.nextFloat() < 0.25F && this.getGoalTarget() != null && !this.hasEffect(MobEffectList.FASTER_MOVEMENT) && this.getGoalTarget().e(this) > 121.0D) {
short1 = 16274;
diff --git a/src/main/java/net/minecraft/server/EntityWither.java b/src/main/java/net/minecraft/server/EntityWither.java
index bd260822..0c7af8d7 100644
--- a/src/main/java/net/minecraft/server/EntityWither.java
+++ b/src/main/java/net/minecraft/server/EntityWither.java
@@ -446,7 +446,7 @@ public class EntityWither extends EntityMonster implements IRangedEntity {
}
public boolean bR() {
- return this.getHealth() <= this.maxHealth / 2.0F; // CraftBukkit - this.getMaxHealth() -> this.maxHealth
+ return this.getHealth() <= this.getMaxHealth() / 2.0F;
}
public EnumMonsterType getMonsterType() {
diff --git a/src/main/java/net/minecraft/server/EntityWolf.java b/src/main/java/net/minecraft/server/EntityWolf.java
index d3593bc0..60f1010d 100644
--- a/src/main/java/net/minecraft/server/EntityWolf.java
+++ b/src/main/java/net/minecraft/server/EntityWolf.java
@@ -71,7 +71,7 @@ public class EntityWolf extends EntityTameableAnimal {
}
protected void bg() {
- this.datawatcher.watch(18, Float.valueOf(this.getScaledHealth())); // CraftBukkit - this.getHealth() -> this.getScaledHealth()
+ this.datawatcher.watch(18, Float.valueOf(this.getHealth()));
}
protected void a() {
@@ -100,8 +100,8 @@ public class EntityWolf extends EntityTameableAnimal {
}
protected String r() {
- // CraftBukkit - getInt(18) < 10 -> < this.maxHealth / 2
- return this.isAngry() ? "mob.wolf.growl" : (this.random.nextInt(3) == 0 ? (this.isTamed() && this.datawatcher.getFloat(18) < this.maxHealth / 2 ? "mob.wolf.whine" : "mob.wolf.panting") : "mob.wolf.bark");
+ // CraftBukkit - (getInt(18) < 10) -> (getInt(18) < this.getMaxHealth() / 2)
+ return this.isAngry() ? "mob.wolf.growl" : (this.random.nextInt(3) == 0 ? (this.isTamed() && this.datawatcher.getFloat(18) < (this.getMaxHealth() / 2) ? "mob.wolf.whine" : "mob.wolf.panting") : "mob.wolf.bark");
}
protected String aK() {
@@ -265,17 +265,11 @@ public class EntityWolf extends EntityTameableAnimal {
if (!this.world.isStatic) {
// CraftBukkit - added event call and isCancelled check.
if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) {
- boolean updateMaxHealth = this.getMaxHealth() == this.maxHealth; // CraftBukkit
this.setTamed(true);
this.setPathEntity((PathEntity) null);
this.setGoalTarget((EntityLiving) null);
this.bp.setSitting(true);
- // CraftBukkit start
- if (updateMaxHealth) {
- this.maxHealth = this.getMaxHealth();
- }
- this.setHealth(this.maxHealth);
- // CraftBukkit end
+ this.setHealth(this.getMaxHealth()); // CraftBukkit - 20.0 -> getMaxHealth()
this.setOwnerName(entityhuman.getName());
this.j(true);
this.world.broadcastEntityEffect(this, (byte) 7);
diff --git a/src/main/java/net/minecraft/server/MobEffectList.java b/src/main/java/net/minecraft/server/MobEffectList.java
index ab2432f4..dd018fdd 100644
--- a/src/main/java/net/minecraft/server/MobEffectList.java
+++ b/src/main/java/net/minecraft/server/MobEffectList.java
@@ -81,7 +81,7 @@ public class MobEffectList {
public void tick(EntityLiving entityliving, int i) {
if (this.id == REGENERATION.id) {
- if (entityliving.getHealth() < entityliving.maxHealth) { // CraftBukkit - .getMaxHealth() -> .maxHealth
+ if (entityliving.getHealth() < entityliving.getMaxHealth()) {
entityliving.heal(1.0F, RegainReason.MAGIC_REGEN); // CraftBukkit
}
} else if (this.id == POISON.id) {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
index bd00911b..da7a2af9 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
@@ -19,6 +19,7 @@ import net.minecraft.server.EntitySnowball;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.EntityPotion;
import net.minecraft.server.EntityWitherSkull;
+import net.minecraft.server.GenericAttributes;
import net.minecraft.server.MobEffect;
import net.minecraft.server.MobEffectList;
import net.minecraft.server.Packet42RemoveMobEffect;
@@ -83,13 +84,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
}
public double getMaxHealth() {
- return getHandle().maxHealth;
+ return getHandle().getMaxHealth();
}
public void setMaxHealth(double amount) {
Validate.isTrue(amount > 0, "Max health must be greater than 0");
- getHandle().maxHealth = (float) amount;
+ getHandle().a(GenericAttributes.a).a(amount);
if (getHealth() > amount) {
setHealth(amount);