2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/entity/player/EntityHuman.java
|
|
|
|
+++ b/net/minecraft/world/entity/player/EntityHuman.java
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -113,6 +113,19 @@
|
2021-03-15 23:00:00 +01:00
|
|
|
import net.minecraft.world.scores.ScoreboardTeam;
|
|
|
|
import net.minecraft.world.scores.ScoreboardTeamBase;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
2021-03-03 22:28:05 +01:00
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
2019-04-23 04:00:00 +02:00
|
|
|
+import org.bukkit.craftbukkit.util.CraftVector;
|
2018-07-30 11:29:03 +02:00
|
|
|
+import org.bukkit.entity.Item;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.entity.Player;
|
2017-05-14 04:00:00 +02:00
|
|
|
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
2021-03-03 22:28:05 +01:00
|
|
|
+import org.bukkit.event.entity.EntityExhaustionEvent;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.event.player.PlayerDropItemEvent;
|
2014-12-06 22:27:04 +01:00
|
|
|
+import org.bukkit.event.player.PlayerVelocityEvent;
|
2014-11-25 22:32:16 +01:00
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
|
|
|
public abstract class EntityHuman extends EntityLiving {
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
public static final String UUID_PREFIX_OFFLINE_PLAYER = "OfflinePlayer:";
|
|
|
|
@@ -126,7 +139,8 @@
|
|
|
|
public static final float SWIMMING_BB_HEIGHT = 0.6F;
|
|
|
|
public static final float DEFAULT_EYE_HEIGHT = 1.62F;
|
|
|
|
public static final EntitySize STANDING_DIMENSIONS = EntitySize.b(0.6F, 1.8F);
|
|
|
|
- private static final Map<EntityPose, EntitySize> POSES = ImmutableMap.builder().put(EntityPose.STANDING, EntityHuman.STANDING_DIMENSIONS).put(EntityPose.SLEEPING, EntityHuman.SLEEPING_DIMENSIONS).put(EntityPose.FALL_FLYING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SWIMMING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SPIN_ATTACK, EntitySize.b(0.6F, 0.6F)).put(EntityPose.CROUCHING, EntitySize.b(0.6F, 1.5F)).put(EntityPose.DYING, EntitySize.c(0.2F, 0.2F)).build();
|
2019-04-23 04:00:00 +02:00
|
|
|
+ // CraftBukkit - decompile error
|
2021-06-11 07:00:00 +02:00
|
|
|
+ private static final Map<EntityPose, EntitySize> POSES = ImmutableMap.<EntityPose, EntitySize>builder().put(EntityPose.STANDING, EntityHuman.STANDING_DIMENSIONS).put(EntityPose.SLEEPING, EntityHuman.SLEEPING_DIMENSIONS).put(EntityPose.FALL_FLYING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SWIMMING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SPIN_ATTACK, EntitySize.b(0.6F, 0.6F)).put(EntityPose.CROUCHING, EntitySize.b(0.6F, 1.5F)).put(EntityPose.DYING, EntitySize.c(0.2F, 0.2F)).build();
|
|
|
|
private static final int FLY_ACHIEVEMENT_SPEED = 25;
|
|
|
|
private static final DataWatcherObject<Float> DATA_PLAYER_ABSORPTION_ID = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.FLOAT);
|
|
|
|
private static final DataWatcherObject<Integer> DATA_SCORE_ID = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.INT);
|
|
|
|
@@ -136,10 +150,10 @@
|
|
|
|
protected static final DataWatcherObject<NBTTagCompound> DATA_SHOULDER_RIGHT = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.COMPOUND_TAG);
|
|
|
|
private long timeEntitySatOnShoulder;
|
|
|
|
private final PlayerInventory inventory = new PlayerInventory(this);
|
|
|
|
- protected InventoryEnderChest enderChestInventory = new InventoryEnderChest();
|
|
|
|
+ protected InventoryEnderChest enderChestInventory = new InventoryEnderChest(this); // CraftBukkit - add "this" to constructor
|
|
|
|
public final ContainerPlayer inventoryMenu;
|
|
|
|
public Container containerMenu;
|
2014-11-25 22:32:16 +01:00
|
|
|
- protected FoodMetaData foodData = new FoodMetaData();
|
|
|
|
+ protected FoodMetaData foodData = new FoodMetaData(this); // CraftBukkit - add "this" to constructor
|
2021-06-11 07:00:00 +02:00
|
|
|
protected int jumpTriggerTime;
|
|
|
|
public float oBob;
|
|
|
|
public float bob;
|
|
|
|
@@ -166,6 +180,16 @@
|
2016-11-17 02:41:03 +01:00
|
|
|
@Nullable
|
2021-06-11 07:00:00 +02:00
|
|
|
public EntityFishingHook fishing;
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ public boolean fauxSleeping;
|
2015-06-06 11:33:48 +02:00
|
|
|
+ public int oldLevel = -1;
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public CraftHumanEntity getBukkitEntity() {
|
|
|
|
+ return (CraftHumanEntity) super.getBukkitEntity();
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2020-08-11 23:00:00 +02:00
|
|
|
public EntityHuman(World world, BlockPosition blockposition, float f, GameProfile gameprofile) {
|
2018-07-15 02:00:00 +02:00
|
|
|
super(EntityTypes.PLAYER, world);
|
2021-06-11 07:00:00 +02:00
|
|
|
this.lastItemInMainHand = ItemStack.EMPTY;
|
|
|
|
@@ -304,7 +328,7 @@
|
2018-07-20 08:04:37 +02:00
|
|
|
ItemStack itemstack = this.getEquipment(EnumItemSlot.HEAD);
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
if (itemstack.a(Items.TURTLE_HELMET) && !this.a((Tag) TagsFluid.WATER)) {
|
2018-07-20 08:04:37 +02:00
|
|
|
- this.addEffect(new MobEffect(MobEffects.WATER_BREATHING, 200, 0, false, false, true));
|
|
|
|
+ this.addEffect(new MobEffect(MobEffects.WATER_BREATHING, 200, 0, false, false, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TURTLE_HELMET); // CraftBukkit
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2021-06-11 07:00:00 +02:00
|
|
|
@@ -496,7 +520,8 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
if (this.level.getDifficulty() == EnumDifficulty.PEACEFUL && this.level.getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
|
|
|
|
if (this.getHealth() < this.getMaxHealth() && this.tickCount % 20 == 0) {
|
2014-11-25 22:32:16 +01:00
|
|
|
- this.heal(1.0F);
|
|
|
|
+ // CraftBukkit - added regain reason of "REGEN" for filtering purposes.
|
|
|
|
+ this.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN);
|
|
|
|
}
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
if (this.foodData.c() && this.tickCount % 10 == 0) {
|
|
|
|
@@ -545,7 +570,7 @@
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!list1.isEmpty()) {
|
|
|
|
- this.c((Entity) SystemUtils.a((List) list1, this.random));
|
|
|
|
+ this.c((Entity) SystemUtils.a(list1, this.random)); // CraftBukkit - decompile error
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-06 16:00:00 +02:00
|
|
|
@@ -684,6 +709,30 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
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);
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - fire PlayerDropItemEvent
|
|
|
|
+ Player player = (Player) this.getBukkitEntity();
|
2018-07-30 11:29:03 +02:00
|
|
|
+ Item drop = (Item) entityitem.getBukkitEntity();
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
|
|
|
+ PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
|
2021-06-11 13:33:49 +02:00
|
|
|
+ this.level.getCraftServer().getPluginManager().callEvent(event);
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand();
|
|
|
|
+ if (flag1 && (cur == null || cur.getAmount() == 0)) {
|
|
|
|
+ // The complete stack was dropped
|
|
|
|
+ player.getInventory().setItemInHand(drop.getItemStack());
|
2017-12-02 22:55:19 +01:00
|
|
|
+ } else if (flag1 && cur.isSimilar(drop.getItemStack()) && cur.getAmount() < cur.getMaxStackSize() && drop.getItemStack().getAmount() == 1) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // Only one item is dropped
|
|
|
|
+ cur.setAmount(cur.getAmount() + 1);
|
|
|
|
+ player.getInventory().setItemInHand(cur);
|
|
|
|
+ } else {
|
|
|
|
+ // Fallback
|
|
|
|
+ player.getInventory().addItem(drop.getItemStack());
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2019-04-23 04:00:00 +02:00
|
|
|
return entityitem;
|
|
|
|
}
|
|
|
|
}
|
2021-07-06 16:00:00 +02:00
|
|
|
@@ -810,16 +859,17 @@
|
2019-08-24 16:43:43 +02:00
|
|
|
if (this.isInvulnerable(damagesource)) {
|
|
|
|
return false;
|
2021-06-11 07:00:00 +02:00
|
|
|
} else if (this.abilities.invulnerable && !damagesource.ignoresInvulnerability()) {
|
2019-08-24 16:43:43 +02:00
|
|
|
+ this.forceExplosionKnockback = true; // SPIGOT-5258 - Make invulnerable players get knockback from explosions
|
|
|
|
return false;
|
|
|
|
} else {
|
2021-06-11 07:00:00 +02:00
|
|
|
this.noActionTime = 0;
|
|
|
|
if (this.dV()) {
|
2019-04-23 04:00:00 +02:00
|
|
|
return false;
|
|
|
|
} else {
|
2017-06-11 04:20:18 +02:00
|
|
|
- this.releaseShoulderEntities();
|
|
|
|
+ // this.releaseShoulderEntities(); // CraftBukkit - moved down
|
2021-06-11 07:00:00 +02:00
|
|
|
if (damagesource.w()) {
|
|
|
|
if (this.level.getDifficulty() == EnumDifficulty.PEACEFUL) {
|
2014-11-25 22:32:16 +01:00
|
|
|
- f = 0.0F;
|
|
|
|
+ return false; // CraftBukkit - f = 0.0f -> return false
|
|
|
|
}
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
if (this.level.getDifficulty() == EnumDifficulty.EASY) {
|
2021-07-06 16:00:00 +02:00
|
|
|
@@ -831,7 +881,13 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-09 03:43:49 +02:00
|
|
|
- return f == 0.0F ? false : super.damageEntity(damagesource, f);
|
2017-06-11 04:20:18 +02:00
|
|
|
+ // CraftBukkit start - Don't filter out 0 damage
|
|
|
|
+ boolean damaged = super.damageEntity(damagesource, f);
|
|
|
|
+ if (damaged) {
|
|
|
|
+ this.releaseShoulderEntities();
|
|
|
|
+ }
|
|
|
|
+ return damaged;
|
|
|
|
+ // CraftBukkit end
|
2016-06-09 03:43:49 +02:00
|
|
|
}
|
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2021-07-06 16:00:00 +02:00
|
|
|
@@ -851,10 +907,29 @@
|
2016-11-17 02:41:03 +01:00
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
public boolean a(EntityHuman entityhuman) {
|
2018-12-13 01:00:00 +01:00
|
|
|
- ScoreboardTeamBase scoreboardteambase = this.getScoreboardTeam();
|
|
|
|
- ScoreboardTeamBase scoreboardteambase1 = entityhuman.getScoreboardTeam();
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - Change to check OTHER player's scoreboard team according to API
|
|
|
|
+ // To summarize this method's logic, it's "Can parameter hurt this"
|
|
|
|
+ org.bukkit.scoreboard.Team team;
|
|
|
|
+ if (entityhuman instanceof EntityPlayer) {
|
|
|
|
+ EntityPlayer thatPlayer = (EntityPlayer) entityhuman;
|
|
|
|
+ team = thatPlayer.getBukkitEntity().getScoreboard().getPlayerTeam(thatPlayer.getBukkitEntity());
|
|
|
|
+ if (team == null || team.allowFriendlyFire()) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // This should never be called, but is implemented anyway
|
2021-06-11 13:33:49 +02:00
|
|
|
+ org.bukkit.OfflinePlayer thisPlayer = entityhuman.level.getCraftServer().getOfflinePlayer(entityhuman.getName());
|
|
|
|
+ team = entityhuman.level.getCraftServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(thisPlayer);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ if (team == null || team.allowFriendlyFire()) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return scoreboardteambase == null ? true : (!scoreboardteambase.isAlly(scoreboardteambase1) ? true : scoreboardteambase.allowFriendlyFire());
|
|
|
|
+ if (this instanceof EntityPlayer) {
|
|
|
|
+ return !team.hasPlayer(((EntityPlayer) this).getBukkitEntity());
|
|
|
|
+ }
|
2021-06-11 13:33:49 +02:00
|
|
|
+ return !team.hasPlayer(this.level.getCraftServer().getOfflinePlayer(this.getName()));
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2021-07-06 16:00:00 +02:00
|
|
|
@@ -896,8 +971,13 @@
|
2020-06-25 02:00:00 +02:00
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
+ // CraftBukkit start
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
|
|
|
- protected void damageEntity0(DamageSource damagesource, float f) {
|
2016-02-29 22:32:46 +01:00
|
|
|
+ protected boolean damageEntity0(DamageSource damagesource, float f) { // void -> boolean
|
2014-11-25 22:32:16 +01:00
|
|
|
+ if (true) {
|
2016-02-29 22:32:46 +01:00
|
|
|
+ return super.damageEntity0(damagesource, f);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
if (!this.isInvulnerable(damagesource)) {
|
2016-02-29 22:32:46 +01:00
|
|
|
f = this.applyArmorModifier(damagesource, f);
|
|
|
|
f = this.applyMagicModifier(damagesource, f);
|
2021-07-06 16:00:00 +02:00
|
|
|
@@ -912,7 +992,7 @@
|
2021-03-03 22:28:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2021-07-06 16:00:00 +02:00
|
|
|
@@ -923,6 +1003,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+ return false; // CraftBukkit
|
|
|
|
}
|
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
@Override
|
2021-07-06 16:00:00 +02:00
|
|
|
@@ -1082,7 +1163,7 @@
|
2020-04-23 03:13:40 +02:00
|
|
|
|
|
|
|
f *= 0.2F + f2 * f2 * 0.8F;
|
|
|
|
f1 *= f2;
|
2020-06-25 02:00:00 +02:00
|
|
|
- this.resetAttackCooldown();
|
|
|
|
+ // this.resetAttackCooldown(); // CraftBukkit - Moved to EntityLiving to reset the cooldown after the damage is dealt
|
2020-04-23 03:13:40 +02:00
|
|
|
if (f > 0.0F || f1 > 0.0F) {
|
|
|
|
boolean flag = f2 > 0.9F;
|
|
|
|
boolean flag1 = false;
|
2021-07-06 16:00:00 +02:00
|
|
|
@@ -1121,8 +1202,15 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
if (entity instanceof EntityLiving) {
|
|
|
|
f3 = ((EntityLiving) entity).getHealth();
|
|
|
|
if (j > 0 && !entity.isBurning()) {
|
|
|
|
- flag4 = true;
|
2016-03-10 21:01:33 +01:00
|
|
|
- entity.setOnFire(1);
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item
|
|
|
|
+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 1);
|
|
|
|
+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
2016-02-29 22:32:46 +01:00
|
|
|
+ if (!combustEvent.isCancelled()) {
|
|
|
|
+ flag4 = true;
|
2019-01-11 01:41:32 +01:00
|
|
|
+ entity.setOnFire(combustEvent.getDuration(), false);
|
2016-02-29 22:32:46 +01:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
2016-03-10 21:01:33 +01:00
|
|
|
|
2021-07-06 16:00:00 +02:00
|
|
|
@@ -1150,8 +1238,11 @@
|
2016-03-31 13:50:58 +02:00
|
|
|
EntityLiving entityliving = (EntityLiving) iterator.next();
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
if (entityliving != this && entityliving != entity && !this.p(entityliving) && (!(entityliving instanceof EntityArmorStand) || !((EntityArmorStand) entityliving).isMarker()) && this.f((Entity) entityliving) < 9.0D) {
|
2016-03-31 13:50:58 +02:00
|
|
|
+ // CraftBukkit start - Only apply knockback if the damage hits
|
2016-12-23 12:39:33 +01:00
|
|
|
+ if (entityliving.damageEntity(DamageSource.playerAttack(this).sweep(), f4)) {
|
2021-06-11 07:00:00 +02:00
|
|
|
entityliving.p(0.4000000059604645D, (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F)));
|
2016-12-20 21:00:00 +01:00
|
|
|
- entityliving.damageEntity(DamageSource.playerAttack(this), f4);
|
2016-03-31 13:50:58 +02:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-06 16:00:00 +02:00
|
|
|
@@ -1160,9 +1251,26 @@
|
2014-12-06 22:27:04 +01:00
|
|
|
}
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
if (entity instanceof EntityPlayer && entity.hurtMarked) {
|
2014-12-06 22:27:04 +01:00
|
|
|
+ // CraftBukkit start - Add Velocity Event
|
|
|
|
+ boolean cancelled = false;
|
|
|
|
+ Player player = (Player) entity.getBukkitEntity();
|
2019-04-23 04:00:00 +02:00
|
|
|
+ org.bukkit.util.Vector velocity = CraftVector.toBukkit(vec3d);
|
2014-12-06 22:27:04 +01:00
|
|
|
+
|
2014-12-07 12:26:58 +01:00
|
|
|
+ PlayerVelocityEvent event = new PlayerVelocityEvent(player, velocity.clone());
|
2021-06-11 13:33:49 +02:00
|
|
|
+ level.getCraftServer().getPluginManager().callEvent(event);
|
2014-12-06 22:27:04 +01:00
|
|
|
+
|
|
|
|
+ if (event.isCancelled()) {
|
|
|
|
+ cancelled = true;
|
|
|
|
+ } else if (!velocity.equals(event.getVelocity())) {
|
2015-07-20 21:42:30 +02:00
|
|
|
+ player.setVelocity(event.getVelocity());
|
2014-12-06 22:27:04 +01:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!cancelled) {
|
2021-06-11 07:00:00 +02:00
|
|
|
((EntityPlayer) entity).connection.sendPacket(new PacketPlayOutEntityVelocity(entity));
|
|
|
|
entity.hurtMarked = false;
|
2019-04-23 04:00:00 +02:00
|
|
|
entity.setMot(vec3d);
|
2014-12-06 22:27:04 +01:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
if (flag2) {
|
2021-07-06 16:00:00 +02:00
|
|
|
@@ -1207,7 +1315,14 @@
|
2016-02-29 22:32:46 +01:00
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
this.a(StatisticList.DAMAGE_DEALT, Math.round(f5 * 10.0F));
|
2014-11-25 22:32:16 +01:00
|
|
|
if (j > 0) {
|
|
|
|
- entity.setOnFire(j * 4);
|
|
|
|
+ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item
|
|
|
|
+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), j * 4);
|
|
|
|
+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
|
|
|
|
+
|
|
|
|
+ if (!combustEvent.isCancelled()) {
|
2019-07-21 03:45:05 +02:00
|
|
|
+ entity.setOnFire(combustEvent.getDuration(), false);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
if (this.level instanceof WorldServer && f5 > 2.0F) {
|
2021-07-06 16:00:00 +02:00
|
|
|
@@ -1217,12 +1332,17 @@
|
2021-03-03 22:28:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- this.applyExhaustion(0.1F);
|
|
|
|
+ this.applyExhaustion(0.1F, EntityExhaustionEvent.ExhaustionReason.ATTACK); // CraftBukkit - EntityExhaustionEvent
|
|
|
|
} else {
|
2021-06-11 07:00:00 +02:00
|
|
|
this.level.playSound((EntityHuman) null, this.locX(), this.locY(), this.locZ(), SoundEffects.PLAYER_ATTACK_NODAMAGE, this.getSoundCategory(), 1.0F, 1.0F);
|
2016-11-20 04:13:21 +01:00
|
|
|
if (flag4) {
|
|
|
|
entity.extinguish();
|
|
|
|
}
|
|
|
|
+ // CraftBukkit start - resync on cancelled event
|
|
|
|
+ if (this instanceof EntityPlayer) {
|
|
|
|
+ ((EntityPlayer) this).getBukkitEntity().updateInventory();
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-06 16:00:00 +02:00
|
|
|
@@ -1295,6 +1415,12 @@
|
2021-06-11 07:00:00 +02:00
|
|
|
public void a(ItemStack itemstack, ItemStack itemstack1, ClickAction clickaction) {}
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
public Either<EntityHuman.EnumBedResult, Unit> sleep(BlockPosition blockposition) {
|
|
|
|
+ // CraftBukkit start
|
2019-04-23 04:00:00 +02:00
|
|
|
+ return this.sleep(blockposition, false);
|
2019-01-02 04:41:31 +01:00
|
|
|
+ }
|
|
|
|
+
|
2019-04-23 04:00:00 +02:00
|
|
|
+ public Either<EntityHuman.EnumBedResult, Unit> sleep(BlockPosition blockposition, boolean force) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit end
|
2019-12-10 23:00:00 +01:00
|
|
|
this.entitySleep(blockposition);
|
2021-06-11 07:00:00 +02:00
|
|
|
this.sleepCounter = 0;
|
2020-06-25 02:00:00 +02:00
|
|
|
return Either.right(Unit.INSTANCE);
|
2021-07-06 16:00:00 +02:00
|
|
|
@@ -1379,9 +1505,9 @@
|
2021-03-03 22:28:05 +01:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2021-07-06 16:00:00 +02:00
|
|
|
@@ -1415,7 +1541,11 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
this.setMot(vec3d2.x, d3 * 0.6D, vec3d2.z);
|
2021-06-11 07:00:00 +02:00
|
|
|
this.flyingSpeed = f;
|
2017-11-27 23:33:40 +01:00
|
|
|
this.fallDistance = 0.0F;
|
|
|
|
- this.setFlag(7, false);
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (getFlag(7) && !org.bukkit.craftbukkit.event.CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) {
|
|
|
|
+ this.setFlag(7, false);
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
} else {
|
2020-08-11 23:00:00 +02:00
|
|
|
super.g(vec3d);
|
2017-11-27 23:33:40 +01:00
|
|
|
}
|
2021-07-06 16:00:00 +02:00
|
|
|
@@ -1450,19 +1580,19 @@
|
2021-06-11 07:00:00 +02:00
|
|
|
i = Math.round((float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
|
2021-03-03 22:28:05 +01:00
|
|
|
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)) {
|
2021-06-11 07:00:00 +02:00
|
|
|
i = Math.round((float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
|
2021-03-03 22:28:05 +01:00
|
|
|
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()) {
|
2021-06-11 07:00:00 +02:00
|
|
|
i = Math.round((float) Math.sqrt(d0 * d0 + d2 * d2) * 100.0F);
|
2021-03-03 22:28:05 +01:00
|
|
|
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) {
|
2021-07-06 16:00:00 +02:00
|
|
|
@@ -1473,13 +1603,13 @@
|
2021-03-03 22:28:05 +01:00
|
|
|
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
|
2021-06-11 07:00:00 +02:00
|
|
|
} else if (this.isCrouching()) {
|
2021-03-03 22:28:05 +01:00
|
|
|
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()) {
|
2021-07-06 16:00:00 +02:00
|
|
|
@@ -1545,12 +1675,24 @@
|
2019-12-10 23:00:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void startGliding() {
|
2020-01-25 01:30:39 +01:00
|
|
|
- this.setFlag(7, true);
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callToggleGlideEvent(this, true).isCancelled()) {
|
|
|
|
+ this.setFlag(7, true);
|
|
|
|
+ } else {
|
|
|
|
+ // SPIGOT-5542: must toggle like below
|
|
|
|
+ this.setFlag(7, true);
|
|
|
|
+ this.setFlag(7, false);
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2019-12-10 23:00:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void stopGliding() {
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) {
|
|
|
|
this.setFlag(7, true);
|
|
|
|
this.setFlag(7, false);
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-07-06 16:00:00 +02:00
|
|
|
@@ -1640,10 +1782,21 @@
|
2021-06-11 07:00:00 +02:00
|
|
|
return this.experienceLevel >= 30 ? 112 + (this.experienceLevel - 30) * 9 : (this.experienceLevel >= 15 ? 37 + (this.experienceLevel - 15) * 5 : 7 + this.experienceLevel * 2);
|
2021-03-03 22:28:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
+ // CraftBukkit start
|
|
|
|
public void applyExhaustion(float f) {
|
|
|
|
+ this.applyExhaustion(f, EntityExhaustionEvent.ExhaustionReason.UNKNOWN);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void applyExhaustion(float f, EntityExhaustionEvent.ExhaustionReason reason) {
|
|
|
|
+ // CraftBukkit end
|
2021-06-11 07:00:00 +02:00
|
|
|
if (!this.abilities.invulnerable) {
|
|
|
|
if (!this.level.isClientSide) {
|
2021-03-03 22:28:05 +01:00
|
|
|
- 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
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2021-07-06 16:00:00 +02:00
|
|
|
@@ -1720,15 +1873,22 @@
|
2020-12-21 08:30:48 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ this.setSlot(enumitemslot, itemstack, false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean silent) {
|
|
|
|
+ // CraftBukkit end
|
2021-06-11 07:00:00 +02:00
|
|
|
this.f(itemstack);
|
2020-12-21 08:30:48 +01:00
|
|
|
if (enumitemslot == EnumItemSlot.MAINHAND) {
|
2021-01-16 02:00:00 +01:00
|
|
|
- this.playEquipSound(itemstack);
|
|
|
|
+ this.playEquipSound(itemstack, silent); // CraftBukkit
|
2021-06-11 07:00:00 +02:00
|
|
|
this.inventory.items.set(this.inventory.selected, itemstack);
|
2020-12-21 08:30:48 +01:00
|
|
|
} else if (enumitemslot == EnumItemSlot.OFFHAND) {
|
2021-01-16 02:00:00 +01:00
|
|
|
- this.playEquipSound(itemstack);
|
|
|
|
+ this.playEquipSound(itemstack, silent); // CraftBukkit
|
2021-06-11 07:00:00 +02:00
|
|
|
this.inventory.offhand.set(0, itemstack);
|
2020-12-21 08:30:48 +01:00
|
|
|
} else if (enumitemslot.a() == EnumItemSlot.Function.ARMOR) {
|
2021-01-16 02:00:00 +01:00
|
|
|
- this.playEquipSound(itemstack);
|
|
|
|
+ this.playEquipSound(itemstack, silent); // CraftBukkit
|
2020-12-21 08:30:48 +01:00
|
|
|
this.inventory.armor.set(enumitemslot.b(), itemstack);
|
|
|
|
}
|
|
|
|
|
2021-07-06 16:00:00 +02:00
|
|
|
@@ -1769,26 +1929,31 @@
|
2017-05-14 04:00:00 +02:00
|
|
|
|
|
|
|
protected void releaseShoulderEntities() {
|
2021-06-11 07:00:00 +02:00
|
|
|
if (this.timeEntitySatOnShoulder + 20L < this.level.getTime()) {
|
2019-07-20 01:00:00 +02:00
|
|
|
- this.spawnEntityFromShoulder(this.getShoulderEntityLeft());
|
|
|
|
- this.setShoulderEntityLeft(new NBTTagCompound());
|
|
|
|
- this.spawnEntityFromShoulder(this.getShoulderEntityRight());
|
|
|
|
- this.setShoulderEntityRight(new NBTTagCompound());
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (this.spawnEntityFromShoulder(this.getShoulderEntityLeft())) {
|
|
|
|
+ this.setShoulderEntityLeft(new NBTTagCompound());
|
|
|
|
+ }
|
|
|
|
+ if (this.spawnEntityFromShoulder(this.getShoulderEntityRight())) {
|
|
|
|
+ this.setShoulderEntityRight(new NBTTagCompound());
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2017-05-14 04:00:00 +02:00
|
|
|
}
|
|
|
|
|
2019-07-20 01:00:00 +02:00
|
|
|
- private void spawnEntityFromShoulder(NBTTagCompound nbttagcompound) {
|
|
|
|
+ private boolean spawnEntityFromShoulder(NBTTagCompound nbttagcompound) { // CraftBukkit void->boolean
|
2021-06-11 07:00:00 +02:00
|
|
|
if (!this.level.isClientSide && !nbttagcompound.isEmpty()) {
|
|
|
|
- EntityTypes.a(nbttagcompound, this.level).ifPresent((entity) -> {
|
|
|
|
+ return EntityTypes.a(nbttagcompound, this.level).map((entity) -> { // CraftBukkit
|
2019-04-23 04:00:00 +02:00
|
|
|
if (entity instanceof EntityTameableAnimal) {
|
2021-06-11 07:00:00 +02:00
|
|
|
((EntityTameableAnimal) entity).setOwnerUUID(this.uuid);
|
2019-04-23 04:00:00 +02:00
|
|
|
}
|
2017-05-14 04:00:00 +02:00
|
|
|
|
2019-12-10 23:00:00 +01:00
|
|
|
entity.setPosition(this.locX(), this.locY() + 0.699999988079071D, this.locZ());
|
2021-06-11 07:00:00 +02:00
|
|
|
- ((WorldServer) this.level).addEntitySerialized(entity);
|
2019-04-23 04:00:00 +02:00
|
|
|
- });
|
2021-06-11 07:00:00 +02:00
|
|
|
+ return ((WorldServer) this.level).addEntitySerialized(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); // CraftBukkit
|
2019-04-23 04:00:00 +02:00
|
|
|
+ }).orElse(true); // CraftBukkit
|
2017-05-14 04:00:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
+ return true; // CraftBukkit
|
|
|
|
}
|
|
|
|
|
2019-06-02 11:51:26 +02:00
|
|
|
@Override
|