aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/player/Player.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/player/Player.java.patch')
-rw-r--r--patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/player/Player.java.patch560
1 files changed, 560 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/player/Player.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/player/Player.java.patch
new file mode 100644
index 0000000000..0a462b50bf
--- /dev/null
+++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/player/Player.java.patch
@@ -0,0 +1,560 @@
+--- a/net/minecraft/world/entity/player/Player.java
++++ b/net/minecraft/world/entity/player/Player.java
+@@ -111,6 +112,16 @@
+ import net.minecraft.world.scores.Scoreboard;
+ import net.minecraft.world.scores.Team;
+ import org.slf4j.Logger;
++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.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
+
+ public abstract class Player extends LivingEntity {
+ private static final Logger LOGGER = LogUtils.getLogger();
+@@ -143,10 +148,10 @@
+ protected static final EntityDataAccessor<CompoundTag> DATA_SHOULDER_RIGHT = SynchedEntityData.defineId(Player.class, EntityDataSerializers.COMPOUND_TAG);
+ private long timeEntitySatOnShoulder;
+ private final Inventory inventory = new Inventory(this);
+- protected PlayerEnderChestContainer enderChestInventory = new PlayerEnderChestContainer();
++ protected PlayerEnderChestContainer enderChestInventory = new PlayerEnderChestContainer(this); // CraftBukkit - add "this" to constructor
+ public final InventoryMenu inventoryMenu;
+ public AbstractContainerMenu containerMenu;
+- protected FoodData foodData = new FoodData();
++ protected FoodData foodData = new FoodData(this); // CraftBukkit - add "this" to constructor
+ protected int jumpTriggerTime;
+ public float oBob;
+ public float bob;
+@@ -175,6 +180,16 @@
+ public FishingHook fishing;
+ protected float hurtDir;
+
++ // CraftBukkit start
++ public boolean fauxSleeping;
++ public int oldLevel = -1;
++
++ @Override
++ public CraftHumanEntity getBukkitEntity() {
++ return (CraftHumanEntity) super.getBukkitEntity();
++ }
++ // CraftBukkit end
++
+ public Player(Level level, BlockPos pos, float yRot, GameProfile gameProfile) {
+ super(EntityType.PLAYER, level);
+ this.setUUID(gameProfile.getId());
+@@ -315,9 +331,10 @@
+ }
+
+ private void turtleHelmetTick() {
+- ItemStack itemBySlot = this.getItemBySlot(EquipmentSlot.HEAD);
+- if (itemBySlot.is(Items.TURTLE_HELMET) && !this.isEyeInFluid(FluidTags.WATER)) {
+- this.addEffect(new MobEffectInstance(MobEffects.WATER_BREATHING, 200, 0, false, false, true));
++ ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD);
++
++ if (itemstack.is(Items.TURTLE_HELMET) && !this.isEyeInFluid(FluidTags.WATER)) {
++ this.addEffect(new MobEffectInstance(MobEffects.WATER_BREATHING, 200, 0, false, false, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TURTLE_HELMET); // CraftBukkit
+ }
+ }
+
+@@ -485,8 +504,14 @@
+ public void rideTick() {
+ if (!this.level().isClientSide && this.wantsToStopRiding() && this.isPassenger()) {
+ this.stopRiding();
+- this.setShiftKeyDown(false);
+- } else {
++ // CraftBukkit start - SPIGOT-7316: no longer passenger, dismount and return
++ if (!this.isPassenger()) {
++ this.setShiftKeyDown(false);
++ return;
++ }
++ }
++ {
++ // CraftBukkit end
+ super.rideTick();
+ this.oBob = this.bob;
+ this.bob = 0.0F;
+@@ -508,7 +533,8 @@
+
+ if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.level().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
+ if (this.getHealth() < this.getMaxHealth() && this.tickCount % 20 == 0) {
+- this.heal(1.0F);
++ // CraftBukkit - added regain reason of "REGEN" for filtering purposes.
++ this.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN);
+ }
+
+ if (this.foodData.needsFood() && this.tickCount % 10 == 0) {
+@@ -670,7 +694,14 @@
+
+ @Nullable
+ public ItemEntity drop(ItemStack droppedItem, boolean dropAround, boolean includeThrowerName) {
+- if (droppedItem.isEmpty()) {
++ // CraftBukkit start - SPIGOT-2942: Add boolean to call event
++ return drop(droppedItem, dropAround, includeThrowerName, true);
++ }
++
++ @Nullable
++ public ItemEntity drop(ItemStack itemstack, boolean flag, boolean flag1, boolean callEvent) {
++ // CraftBukkit end
++ if (itemstack.isEmpty()) {
+ return null;
+ } else {
+ if (this.level().isClientSide) {
+@@ -703,7 +735,34 @@
+ );
+ }
+
+- return itemEntity;
++ // CraftBukkit start - fire PlayerDropItemEvent
++ if (!callEvent) { // SPIGOT-2942: Add boolean to call event
++ return entityitem;
++ }
++ org.bukkit.entity.Player player = (org.bukkit.entity.Player) this.getBukkitEntity();
++ Item drop = (Item) entityitem.getBukkitEntity();
++
++ PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
++ this.level().getCraftServer().getPluginManager().callEvent(event);
++
++ 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());
++ } else if (flag1 && cur.isSimilar(drop.getItemStack()) && cur.getAmount() < cur.getMaxStackSize() && drop.getItemStack().getAmount() == 1) {
++ // 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
++
++ return entityitem;
+ }
+ }
+
+@@ -837,12 +912,12 @@
+ return false;
+ } else {
+ if (!this.level().isClientSide) {
+- this.removeEntitiesOnShoulder();
++ // this.removeEntitiesOnShoulder(); // CraftBukkit - moved down
+ }
+
+ if (source.scalesWithDifficulty()) {
+ if (this.level().getDifficulty() == Difficulty.PEACEFUL) {
+- amount = 0.0F;
++ return false; // CraftBukkit - f = 0.0f -> return false
+ }
+
+ if (this.level().getDifficulty() == Difficulty.EASY) {
+@@ -854,7 +929,13 @@
+ }
+ }
+
+- return amount != 0.0F && super.hurt(source, amount);
++ // CraftBukkit start - Don't filter out 0 damage
++ boolean damaged = super.hurt(source, amount);
++ if (damaged) {
++ this.removeEntitiesOnShoulder();
++ }
++ return damaged;
++ // CraftBukkit end
+ }
+ }
+ }
+@@ -873,9 +955,29 @@
+ }
+
+ public boolean canHarmPlayer(Player other) {
+- Team team = this.getTeam();
+- Team team1 = other.getTeam();
+- return team == null || !team.isAlliedTo(team1) || team.isAllowFriendlyFire();
++ // 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 (other instanceof ServerPlayer) {
++ ServerPlayer thatPlayer = (ServerPlayer) other;
++ team = thatPlayer.getBukkitEntity().getScoreboard().getPlayerTeam(thatPlayer.getBukkitEntity());
++ if (team == null || team.allowFriendlyFire()) {
++ return true;
++ }
++ } else {
++ // This should never be called, but is implemented anyway
++ org.bukkit.OfflinePlayer thisPlayer = other.level().getCraftServer().getOfflinePlayer(other.getScoreboardName());
++ team = other.level().getCraftServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(thisPlayer);
++ if (team == null || team.allowFriendlyFire()) {
++ return true;
++ }
++ }
++
++ if (this instanceof ServerPlayer) {
++ return !team.hasPlayer(((ServerPlayer) this).getBukkitEntity());
++ }
++ return !team.hasPlayer(this.level().getCraftServer().getOfflinePlayer(this.getScoreboardName()));
++ // CraftBukkit end
+ }
+
+ @Override
+@@ -913,29 +1019,38 @@
+ }
+ }
+
++ // CraftBukkit start
+ @Override
+- protected void actuallyHurt(DamageSource damageSrc, float damageAmount) {
+- if (!this.isInvulnerableTo(damageSrc)) {
+- damageAmount = this.getDamageAfterArmorAbsorb(damageSrc, damageAmount);
+- damageAmount = this.getDamageAfterMagicAbsorb(damageSrc, damageAmount);
+- float var7 = Math.max(damageAmount - this.getAbsorptionAmount(), 0.0F);
+- this.setAbsorptionAmount(this.getAbsorptionAmount() - (damageAmount - var7));
+- float f1 = damageAmount - var7;
+- if (f1 > 0.0F && f1 < 3.4028235E37F) {
+- this.awardStat(Stats.DAMAGE_ABSORBED, Math.round(f1 * 10.0F));
++ protected boolean damageEntity0(DamageSource damagesource, float f) { // void -> boolean
++ if (true) {
++ return super.damageEntity0(damagesource, f);
++ }
++ // CraftBukkit end
++ if (!this.isInvulnerableTo(damagesource)) {
++ f = this.getDamageAfterArmorAbsorb(damagesource, f);
++ f = this.getDamageAfterMagicAbsorb(damagesource, f);
++ float f1 = f;
++
++ f = Math.max(f - this.getAbsorptionAmount(), 0.0F);
++ this.setAbsorptionAmount(this.getAbsorptionAmount() - (f1 - f));
++ float f2 = f1 - f;
++
++ if (f2 > 0.0F && f2 < 3.4028235E37F) {
++ this.awardStat(Stats.DAMAGE_ABSORBED, Math.round(f2 * 10.0F));
+ }
+
+- if (var7 != 0.0F) {
+- this.causeFoodExhaustion(damageSrc.getFoodExhaustion());
+- this.getCombatTracker().recordDamage(damageSrc, var7);
+- this.setHealth(this.getHealth() - var7);
+- if (var7 < 3.4028235E37F) {
+- this.awardStat(Stats.DAMAGE_TAKEN, Math.round(var7 * 10.0F));
++ if (f != 0.0F) {
++ this.causeFoodExhaustion(damagesource.getFoodExhaustion(), EntityExhaustionEvent.ExhaustionReason.DAMAGED); // CraftBukkit - EntityExhaustionEvent
++ this.getCombatTracker().recordDamage(damagesource, f);
++ this.setHealth(this.getHealth() - f);
++ if (f < 3.4028235E37F) {
++ this.awardStat(Stats.DAMAGE_TAKEN, Math.round(f * 10.0F));
+ }
+
+ this.gameEvent(GameEvent.ENTITY_DAMAGE);
+ }
+ }
++ return false; // CraftBukkit
+ }
+
+ @Override
+@@ -1107,12 +1211,13 @@
+ damageBonus = EnchantmentHelper.getDamageBonus(this.getMainHandItem(), MobType.UNDEFINED);
+ }
+
+- float attackStrengthScale = this.getAttackStrengthScale(0.5F);
+- float var21 = f * (0.2F + attackStrengthScale * attackStrengthScale * 0.8F);
+- float var23 = damageBonus * attackStrengthScale;
+- this.resetAttackStrengthTicker();
+- if (var21 > 0.0F || var23 > 0.0F) {
+- boolean flag = attackStrengthScale > 0.9F;
++ float f2 = this.getAttackStrengthScale(0.5F);
++
++ f *= 0.2F + f2 * f2 * 0.8F;
++ f1 *= f2;
++ // this.resetAttackCooldown(); // CraftBukkit - Moved to EntityLiving to reset the cooldown after the damage is dealt
++ if (f > 0.0F || f1 > 0.0F) {
++ boolean flag = f2 > 0.9F;
+ boolean flag1 = false;
+ int i = 0;
+ int var24 = i + EnchantmentHelper.getKnockbackBonus(this);
+@@ -1150,10 +1252,17 @@
+ boolean flag4 = false;
+ int fireAspect = EnchantmentHelper.getFireAspect(this);
+ if (target instanceof LivingEntity) {
+- f1 = ((LivingEntity)target).getHealth();
+- if (fireAspect > 0 && !target.isOnFire()) {
+- flag4 = true;
+- target.setSecondsOnFire(1);
++ f3 = ((LivingEntity) target).getHealth();
++ if (j > 0 && !target.isOnFire()) {
++ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item
++ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), target.getBukkitEntity(), 1);
++ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
++
++ if (!combustEvent.isCancelled()) {
++ flag4 = true;
++ target.setSecondsOnFire(combustEvent.getDuration(), false);
++ }
++ // CraftBukkit end
+ }
+ }
+
+@@ -1183,19 +1286,15 @@
+ if (flag3) {
+ float f2 = 1.0F + EnchantmentHelper.getSweepingDamageRatio(this) * f;
+
+- for (LivingEntity livingEntity : this.level()
+- .getEntitiesOfClass(LivingEntity.class, target.getBoundingBox().inflate(1.0, 0.25, 1.0))) {
+- if (livingEntity != this
+- && livingEntity != target
+- && !this.isAlliedTo(livingEntity)
+- && (!(livingEntity instanceof ArmorStand) || !((ArmorStand)livingEntity).isMarker())
+- && this.distanceToSqr(livingEntity) < 9.0) {
+- livingEntity.knockback(
+- 0.4F,
+- (double)Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)),
+- (double)(-Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)))
+- );
+- livingEntity.hurt(this.damageSources().playerAttack(this), f2);
++ while (iterator.hasNext()) {
++ LivingEntity entityliving = (LivingEntity) iterator.next();
++
++ if (entityliving != this && entityliving != target && !this.isAlliedTo((Entity) entityliving) && (!(entityliving instanceof ArmorStand) || !((ArmorStand) entityliving).isMarker()) && this.distanceToSqr((Entity) entityliving) < 9.0D) {
++ // CraftBukkit start - Only apply knockback if the damage hits
++ if (entityliving.hurt(this.damageSources().playerAttack(this).sweep(), f4)) {
++ entityliving.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)));
++ }
++ // CraftBukkit end
+ }
+ }
+
+@@ -1205,9 +1303,26 @@
+ }
+
+ if (target instanceof ServerPlayer && target.hurtMarked) {
+- ((ServerPlayer)target).connection.send(new ClientboundSetEntityMotionPacket(target));
++ // CraftBukkit start - Add Velocity Event
++ boolean cancelled = false;
++ org.bukkit.entity.Player player = (org.bukkit.entity.Player) target.getBukkitEntity();
++ org.bukkit.util.Vector velocity = CraftVector.toBukkit(vec3d);
++
++ PlayerVelocityEvent event = new PlayerVelocityEvent(player, velocity.clone());
++ this.level().getCraftServer().getPluginManager().callEvent(event);
++
++ if (event.isCancelled()) {
++ cancelled = true;
++ } else if (!velocity.equals(event.getVelocity())) {
++ player.setVelocity(event.getVelocity());
++ }
++
++ if (!cancelled) {
++ ((ServerPlayer) target).connection.send(new ClientboundSetEntityMotionPacket(target));
+ target.hurtMarked = false;
+- target.setDeltaMovement(deltaMovement);
++ target.setDeltaMovement(vec3d);
++ }
++ // CraftBukkit end
+ }
+
+ if (flag2) {
+@@ -1250,10 +1363,18 @@
+ }
+
+ if (target instanceof LivingEntity) {
+- float f3 = f1 - ((LivingEntity)target).getHealth();
+- this.awardStat(Stats.DAMAGE_DEALT, Math.round(f3 * 10.0F));
+- if (fireAspect > 0) {
+- target.setSecondsOnFire(fireAspect * 4);
++ float f5 = f3 - ((LivingEntity) target).getHealth();
++
++ this.awardStat(Stats.DAMAGE_DEALT, Math.round(f5 * 10.0F));
++ if (j > 0) {
++ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item
++ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), target.getBukkitEntity(), j * 4);
++ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
++
++ if (!combustEvent.isCancelled()) {
++ target.setSecondsOnFire(combustEvent.getDuration(), false);
++ }
++ // CraftBukkit end
+ }
+
+ if (this.level() instanceof ServerLevel && f3 > 2.0F) {
+@@ -1263,13 +1384,18 @@
+ }
+ }
+
+- this.causeFoodExhaustion(0.1F);
++ this.causeFoodExhaustion(0.1F, EntityExhaustionEvent.ExhaustionReason.ATTACK); // CraftBukkit - EntityExhaustionEvent
+ } else {
+ this.level()
+ .playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F);
+ if (flag4) {
+ target.clearFire();
+ }
++ // CraftBukkit start - resync on cancelled event
++ if (this instanceof ServerPlayer) {
++ ((ServerPlayer) this).getBukkitEntity().updateInventory();
++ }
++ // CraftBukkit end
+ }
+ }
+ }
+@@ -1344,7 +1471,13 @@
+ }
+
+ public Either<Player.BedSleepingProblem, Unit> startSleepInBed(BlockPos bedPos) {
+- this.startSleeping(bedPos);
++ // CraftBukkit start
++ return this.startSleepInBed(bedPos, false);
++ }
++
++ public Either<Player.BedSleepingProblem, Unit> startSleepInBed(BlockPos blockposition, boolean force) {
++ // CraftBukkit end
++ this.startSleeping(blockposition);
+ this.sleepCounter = 0;
+ return Either.right(Unit.INSTANCE);
+ }
+@@ -1441,9 +1564,9 @@
+ super.jumpFromGround();
+ this.awardStat(Stats.JUMP);
+ if (this.isSprinting()) {
+- this.causeFoodExhaustion(0.2F);
++ this.causeFoodExhaustion(0.2F, EntityExhaustionEvent.ExhaustionReason.JUMP_SPRINT); // CraftBukkit - EntityExhaustionEvent
+ } else {
+- this.causeFoodExhaustion(0.05F);
++ this.causeFoodExhaustion(0.05F, EntityExhaustionEvent.ExhaustionReason.JUMP); // CraftBukkit - EntityExhaustionEvent
+ }
+ }
+
+@@ -1466,7 +1593,11 @@
+ Vec3 deltaMovement1 = this.getDeltaMovement();
+ this.setDeltaMovement(deltaMovement1.x, d * 0.6, deltaMovement1.z);
+ this.resetFallDistance();
+- this.setSharedFlag(7, false);
++ // CraftBukkit start
++ if (getSharedFlag(7) && !org.bukkit.craftbukkit.event.CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) {
++ this.setSharedFlag(7, false);
++ }
++ // CraftBukkit end
+ } else {
+ super.travel(travelVector);
+ }
+@@ -1516,12 +1650,24 @@
+ }
+
+ public void startFallFlying() {
+- this.setSharedFlag(7, true);
++ // CraftBukkit start
++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callToggleGlideEvent(this, true).isCancelled()) {
++ this.setSharedFlag(7, true);
++ } else {
++ // SPIGOT-5542: must toggle like below
++ this.setSharedFlag(7, true);
++ this.setSharedFlag(7, false);
++ }
++ // CraftBukkit end
+ }
+
+ public void stopFallFlying() {
++ // CraftBukkit start
++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) {
+ this.setSharedFlag(7, true);
+ this.setSharedFlag(7, false);
++ }
++ // CraftBukkit end
+ }
+
+ @Override
+@@ -1630,10 +1781,21 @@
+ }
+ }
+
++ // CraftBukkit start
+ public void causeFoodExhaustion(float exhaustion) {
++ this.causeFoodExhaustion(exhaustion, EntityExhaustionEvent.ExhaustionReason.UNKNOWN);
++ }
++
++ public void causeFoodExhaustion(float f, EntityExhaustionEvent.ExhaustionReason reason) {
++ // CraftBukkit end
+ if (!this.abilities.invulnerable) {
+ if (!this.level().isClientSide) {
+- this.foodData.addExhaustion(exhaustion);
++ // CraftBukkit start
++ EntityExhaustionEvent event = CraftEventFactory.callPlayerExhaustionEvent(this, reason, f);
++ if (!event.isCancelled()) {
++ this.foodData.addExhaustion(event.getExhaustion());
++ }
++ // CraftBukkit end
+ }
+ }
+ }
+@@ -1723,13 +1881,20 @@
+
+ @Override
+ public void setItemSlot(EquipmentSlot slot, ItemStack stack) {
+- this.verifyEquippedItem(stack);
+- if (slot == EquipmentSlot.MAINHAND) {
+- this.onEquipItem(slot, this.inventory.items.set(this.inventory.selected, stack), stack);
+- } else if (slot == EquipmentSlot.OFFHAND) {
+- this.onEquipItem(slot, this.inventory.offhand.set(0, stack), stack);
+- } else if (slot.getType() == EquipmentSlot.Type.ARMOR) {
+- this.onEquipItem(slot, this.inventory.armor.set(slot.getIndex(), stack), stack);
++ // CraftBukkit start
++ setItemSlot(slot, stack, false);
++ }
++
++ @Override
++ public void setItemSlot(EquipmentSlot enumitemslot, ItemStack itemstack, boolean silent) {
++ // CraftBukkit end
++ this.verifyEquippedItem(itemstack);
++ if (enumitemslot == EquipmentSlot.MAINHAND) {
++ this.onEquipItem(enumitemslot, (ItemStack) this.inventory.items.set(this.inventory.selected, itemstack), itemstack, silent); // CraftBukkit
++ } else if (enumitemslot == EquipmentSlot.OFFHAND) {
++ this.onEquipItem(enumitemslot, (ItemStack) this.inventory.offhand.set(0, itemstack), itemstack, silent); // CraftBukkit
++ } else if (enumitemslot.getType() == EquipmentSlot.Function.ARMOR) {
++ this.onEquipItem(enumitemslot, (ItemStack) this.inventory.armor.set(enumitemslot.getIndex(), itemstack), itemstack, silent); // CraftBukkit
+ }
+ }
+
+@@ -1765,24 +1933,30 @@
+
+ protected void removeEntitiesOnShoulder() {
+ if (this.timeEntitySatOnShoulder + 20L < this.level().getGameTime()) {
+- this.respawnEntityOnShoulder(this.getShoulderEntityLeft());
+- this.setShoulderEntityLeft(new CompoundTag());
+- this.respawnEntityOnShoulder(this.getShoulderEntityRight());
+- this.setShoulderEntityRight(new CompoundTag());
++ // CraftBukkit start
++ if (this.respawnEntityOnShoulder(this.getShoulderEntityLeft())) {
++ this.setShoulderEntityLeft(new CompoundTag());
++ }
++ if (this.respawnEntityOnShoulder(this.getShoulderEntityRight())) {
++ this.setShoulderEntityRight(new CompoundTag());
++ }
++ // CraftBukkit end
+ }
+ }
+
+- private void respawnEntityOnShoulder(CompoundTag entityCompound) {
+- if (!this.level().isClientSide && !entityCompound.isEmpty()) {
+- EntityType.create(entityCompound, this.level()).ifPresent(entity -> {
++ private boolean respawnEntityOnShoulder(CompoundTag nbttagcompound) { // CraftBukkit void->boolean
++ if (!this.level().isClientSide && !nbttagcompound.isEmpty()) {
++ return EntityType.create(nbttagcompound, this.level()).map((entity) -> { // CraftBukkit
+ if (entity instanceof TamableAnimal) {
+ ((TamableAnimal)entity).setOwnerUUID(this.uuid);
+ }
+
+- entity.setPos(this.getX(), this.getY() + 0.7F, this.getZ());
+- ((ServerLevel)this.level()).addWithUUID(entity);
+- });
++ entity.setPos(this.getX(), this.getY() + 0.699999988079071D, this.getZ());
++ return ((ServerLevel) this.level()).addWithUUID(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); // CraftBukkit
++ }).orElse(true); // CraftBukkit
+ }
++
++ return true; // CraftBukkit
+ }
+
+ @Override