@@ -1,16 +1,18 @@
|
||||
--- a/net/minecraft/server/EntityHuman.java
|
||||
+++ b/net/minecraft/server/EntityHuman.java
|
||||
@@ -16,10 +16,22 @@
|
||||
@@ -16,10 +16,24 @@
|
||||
import java.util.function.Predicate;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.craftbukkit.util.CraftVector;
|
||||
+import org.bukkit.entity.Item;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||
+import org.bukkit.event.entity.EntityExhaustionEvent;
|
||||
+import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
+import org.bukkit.event.player.PlayerVelocityEvent;
|
||||
+// CraftBukkit end
|
||||
@@ -24,7 +26,7 @@
|
||||
private static final DataWatcherObject<Float> c = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.c);
|
||||
private static final DataWatcherObject<Integer> d = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.b);
|
||||
protected static final DataWatcherObject<Byte> bi = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a);
|
||||
@@ -28,10 +40,10 @@
|
||||
@@ -28,10 +42,10 @@
|
||||
protected static final DataWatcherObject<NBTTagCompound> bl = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p);
|
||||
private long e;
|
||||
public final PlayerInventory inventory = new PlayerInventory(this);
|
||||
@@ -37,7 +39,7 @@
|
||||
protected int br;
|
||||
public float bs;
|
||||
public float bt;
|
||||
@@ -57,6 +69,16 @@
|
||||
@@ -57,6 +71,16 @@
|
||||
@Nullable
|
||||
public EntityFishingHook hookedFish;
|
||||
|
||||
@@ -54,7 +56,7 @@
|
||||
public EntityHuman(World world, BlockPosition blockposition, float f, GameProfile gameprofile) {
|
||||
super(EntityTypes.PLAYER, world);
|
||||
this.bL = ItemStack.b;
|
||||
@@ -194,7 +216,7 @@
|
||||
@@ -194,7 +218,7 @@
|
||||
ItemStack itemstack = this.getEquipment(EnumItemSlot.HEAD);
|
||||
|
||||
if (itemstack.getItem() == Items.TURTLE_HELMET && !this.a((Tag) TagsFluid.WATER)) {
|
||||
@@ -63,7 +65,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -359,7 +381,8 @@
|
||||
@@ -359,7 +383,8 @@
|
||||
|
||||
if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL && this.world.getGameRules().getBoolean(GameRules.NATURAL_REGENERATION)) {
|
||||
if (this.getHealth() < this.getMaxHealth() && this.ticksLived % 20 == 0) {
|
||||
@@ -73,7 +75,7 @@
|
||||
}
|
||||
|
||||
if (this.foodData.c() && this.ticksLived % 10 == 0) {
|
||||
@@ -544,6 +567,30 @@
|
||||
@@ -544,6 +569,30 @@
|
||||
entityitem.setMot((double) (-f3 * f2 * 0.3F) + Math.cos((double) f5) * (double) f6, (double) (-f1 * 0.3F + 0.1F + (this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (f4 * f2 * 0.3F) + Math.sin((double) f5) * (double) f6);
|
||||
}
|
||||
|
||||
@@ -104,7 +106,7 @@
|
||||
return entityitem;
|
||||
}
|
||||
}
|
||||
@@ -670,16 +717,17 @@
|
||||
@@ -670,16 +719,17 @@
|
||||
if (this.isInvulnerable(damagesource)) {
|
||||
return false;
|
||||
} else if (this.abilities.isInvulnerable && !damagesource.ignoresInvulnerability()) {
|
||||
@@ -124,7 +126,7 @@
|
||||
}
|
||||
|
||||
if (this.world.getDifficulty() == EnumDifficulty.EASY) {
|
||||
@@ -691,7 +739,13 @@
|
||||
@@ -691,7 +741,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +141,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -706,10 +760,29 @@
|
||||
@@ -706,10 +762,29 @@
|
||||
}
|
||||
|
||||
public boolean a(EntityHuman entityhuman) {
|
||||
@@ -172,7 +174,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -746,8 +819,13 @@
|
||||
@@ -746,8 +821,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +189,16 @@
|
||||
if (!this.isInvulnerable(damagesource)) {
|
||||
f = this.applyArmorModifier(damagesource, f);
|
||||
f = this.applyMagicModifier(damagesource, f);
|
||||
@@ -773,6 +851,7 @@
|
||||
@@ -762,7 +842,7 @@
|
||||
}
|
||||
|
||||
if (f != 0.0F) {
|
||||
- this.applyExhaustion(damagesource.getExhaustionCost());
|
||||
+ this.applyExhaustion(damagesource.getExhaustionCost(), EntityExhaustionEvent.ExhaustionReason.DAMAGED); // CraftBukkit - EntityExhaustionEvent
|
||||
float f3 = this.getHealth();
|
||||
|
||||
this.setHealth(this.getHealth() - f);
|
||||
@@ -773,6 +853,7 @@
|
||||
|
||||
}
|
||||
}
|
||||
@@ -195,7 +206,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -932,7 +1011,7 @@
|
||||
@@ -932,7 +1013,7 @@
|
||||
|
||||
f *= 0.2F + f2 * f2 * 0.8F;
|
||||
f1 *= f2;
|
||||
@@ -204,7 +215,7 @@
|
||||
if (f > 0.0F || f1 > 0.0F) {
|
||||
boolean flag = f2 > 0.9F;
|
||||
boolean flag1 = false;
|
||||
@@ -971,8 +1050,15 @@
|
||||
@@ -971,8 +1052,15 @@
|
||||
if (entity instanceof EntityLiving) {
|
||||
f3 = ((EntityLiving) entity).getHealth();
|
||||
if (j > 0 && !entity.isBurning()) {
|
||||
@@ -222,7 +233,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1000,8 +1086,11 @@
|
||||
@@ -1000,8 +1088,11 @@
|
||||
EntityLiving entityliving = (EntityLiving) iterator.next();
|
||||
|
||||
if (entityliving != this && entityliving != entity && !this.r(entityliving) && (!(entityliving instanceof EntityArmorStand) || !((EntityArmorStand) entityliving).isMarker()) && this.h((Entity) entityliving) < 9.0D) {
|
||||
@@ -235,7 +246,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1010,9 +1099,26 @@
|
||||
@@ -1010,9 +1101,26 @@
|
||||
}
|
||||
|
||||
if (entity instanceof EntityPlayer && entity.velocityChanged) {
|
||||
@@ -262,7 +273,7 @@
|
||||
}
|
||||
|
||||
if (flag2) {
|
||||
@@ -1057,7 +1163,14 @@
|
||||
@@ -1057,7 +1165,14 @@
|
||||
|
||||
this.a(StatisticList.DAMAGE_DEALT, Math.round(f5 * 10.0F));
|
||||
if (j > 0) {
|
||||
@@ -278,7 +289,14 @@
|
||||
}
|
||||
|
||||
if (this.world instanceof WorldServer && f5 > 2.0F) {
|
||||
@@ -1073,6 +1186,11 @@
|
||||
@@ -1067,12 +1182,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
- this.applyExhaustion(0.1F);
|
||||
+ this.applyExhaustion(0.1F, EntityExhaustionEvent.ExhaustionReason.ATTACK); // CraftBukkit - EntityExhaustionEvent
|
||||
} else {
|
||||
this.world.playSound((EntityHuman) null, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_PLAYER_ATTACK_NODAMAGE, this.getSoundCategory(), 1.0F, 1.0F);
|
||||
if (flag4) {
|
||||
entity.extinguish();
|
||||
}
|
||||
@@ -290,7 +308,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1133,6 +1251,12 @@
|
||||
@@ -1133,6 +1253,12 @@
|
||||
}
|
||||
|
||||
public Either<EntityHuman.EnumBedResult, Unit> sleep(BlockPosition blockposition) {
|
||||
@@ -303,7 +321,19 @@
|
||||
this.entitySleep(blockposition);
|
||||
this.sleepTicks = 0;
|
||||
return Either.right(Unit.INSTANCE);
|
||||
@@ -1253,7 +1377,11 @@
|
||||
@@ -1217,9 +1343,9 @@
|
||||
super.jump();
|
||||
this.a(StatisticList.JUMP);
|
||||
if (this.isSprinting()) {
|
||||
- this.applyExhaustion(0.2F);
|
||||
+ this.applyExhaustion(0.2F, EntityExhaustionEvent.ExhaustionReason.JUMP_SPRINT); // CraftBukkit - EntityExhaustionEvent
|
||||
} else {
|
||||
- this.applyExhaustion(0.05F);
|
||||
+ this.applyExhaustion(0.05F, EntityExhaustionEvent.ExhaustionReason.JUMP); // CraftBukkit - EntityExhaustionEvent
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1253,7 +1379,11 @@
|
||||
this.setMot(vec3d2.x, d3 * 0.6D, vec3d2.z);
|
||||
this.aE = f;
|
||||
this.fallDistance = 0.0F;
|
||||
@@ -316,7 +346,47 @@
|
||||
} else {
|
||||
super.g(vec3d);
|
||||
}
|
||||
@@ -1383,12 +1511,24 @@
|
||||
@@ -1288,19 +1418,19 @@
|
||||
i = Math.round(MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
|
||||
if (i > 0) {
|
||||
this.a(StatisticList.SWIM_ONE_CM, i);
|
||||
- this.applyExhaustion(0.01F * (float) i * 0.01F);
|
||||
+ this.applyExhaustion(0.01F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.SWIM); // CraftBukkit - EntityExhaustionEvent
|
||||
}
|
||||
} else if (this.a((Tag) TagsFluid.WATER)) {
|
||||
i = Math.round(MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
|
||||
if (i > 0) {
|
||||
this.a(StatisticList.WALK_UNDER_WATER_ONE_CM, i);
|
||||
- this.applyExhaustion(0.01F * (float) i * 0.01F);
|
||||
+ this.applyExhaustion(0.01F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK_UNDERWATER); // CraftBukkit - EntityExhaustionEvent
|
||||
}
|
||||
} else if (this.isInWater()) {
|
||||
i = Math.round(MathHelper.sqrt(d0 * d0 + d2 * d2) * 100.0F);
|
||||
if (i > 0) {
|
||||
this.a(StatisticList.WALK_ON_WATER_ONE_CM, i);
|
||||
- this.applyExhaustion(0.01F * (float) i * 0.01F);
|
||||
+ this.applyExhaustion(0.01F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK_ON_WATER); // CraftBukkit - EntityExhaustionEvent
|
||||
}
|
||||
} else if (this.isClimbing()) {
|
||||
if (d1 > 0.0D) {
|
||||
@@ -1311,13 +1441,13 @@
|
||||
if (i > 0) {
|
||||
if (this.isSprinting()) {
|
||||
this.a(StatisticList.SPRINT_ONE_CM, i);
|
||||
- this.applyExhaustion(0.1F * (float) i * 0.01F);
|
||||
+ this.applyExhaustion(0.1F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.SPRINT); // CraftBukkit - EntityExhaustionEvent
|
||||
} else if (this.bz()) {
|
||||
this.a(StatisticList.CROUCH_ONE_CM, i);
|
||||
- this.applyExhaustion(0.0F * (float) i * 0.01F);
|
||||
+ this.applyExhaustion(0.0F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.CROUCH); // CraftBukkit - EntityExhaustionEvent
|
||||
} else {
|
||||
this.a(StatisticList.WALK_ONE_CM, i);
|
||||
- this.applyExhaustion(0.0F * (float) i * 0.01F);
|
||||
+ this.applyExhaustion(0.0F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK); // CraftBukkit - EntityExhaustionEvent
|
||||
}
|
||||
}
|
||||
} else if (this.isGliding()) {
|
||||
@@ -1383,12 +1513,24 @@
|
||||
}
|
||||
|
||||
public void startGliding() {
|
||||
@@ -342,7 +412,30 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1555,14 +1695,21 @@
|
||||
@@ -1478,10 +1620,21 @@
|
||||
return this.expLevel >= 30 ? 112 + (this.expLevel - 30) * 9 : (this.expLevel >= 15 ? 37 + (this.expLevel - 15) * 5 : 7 + this.expLevel * 2);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
public void applyExhaustion(float f) {
|
||||
+ this.applyExhaustion(f, EntityExhaustionEvent.ExhaustionReason.UNKNOWN);
|
||||
+ }
|
||||
+
|
||||
+ public void applyExhaustion(float f, EntityExhaustionEvent.ExhaustionReason reason) {
|
||||
+ // CraftBukkit end
|
||||
if (!this.abilities.isInvulnerable) {
|
||||
if (!this.world.isClientSide) {
|
||||
- this.foodData.a(f);
|
||||
+ // CraftBukkit start
|
||||
+ EntityExhaustionEvent event = CraftEventFactory.callPlayerExhaustionEvent(this, reason, f);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ this.foodData.a(event.getExhaustion()); // PAIL rename addExhaustion
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1555,14 +1708,21 @@
|
||||
|
||||
@Override
|
||||
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
||||
@@ -367,7 +460,7 @@
|
||||
this.inventory.armor.set(enumitemslot.b(), itemstack);
|
||||
}
|
||||
|
||||
@@ -1603,26 +1750,31 @@
|
||||
@@ -1603,26 +1763,31 @@
|
||||
|
||||
protected void releaseShoulderEntities() {
|
||||
if (this.e + 20L < this.world.getTime()) {
|
||||
|
||||
Reference in New Issue
Block a user