diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch index f90bdf49bb..b488a912bd 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch @@ -141,9 +141,9 @@ + } + // Paper end - Share random for entities to make them more random + public org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason; // Paper - Entity#getEntitySpawnReason - -+ private CraftEntity bukkitEntity; + ++ private CraftEntity bukkitEntity; + + public CraftEntity getBukkitEntity() { + if (this.bukkitEntity == null) { + this.bukkitEntity = CraftEntity.getEntity(this.level.getCraftServer(), this); @@ -538,17 +538,15 @@ if (!this.level().isClientSide() || this.isControlledByLocalInstance()) { Entity.MovementEmission entity_movementemission = this.getMovementEmission(); -@@ -1131,8 +1455,22 @@ - - protected SoundEvent getSwimHighSpeedSplashSound() { +@@ -1133,6 +1457,20 @@ return SoundEvents.GENERIC_SPLASH; -+ } -+ + } + + // CraftBukkit start - Add delegate methods + public SoundEvent getSwimSound0() { + return this.getSwimSound(); - } - ++ } ++ + public SoundEvent getSwimSplashSound0() { + return this.getSwimSplashSound(); + } @@ -891,17 +889,19 @@ protected abstract void readAdditionalSaveData(CompoundTag nbt); protected abstract void addAdditionalSaveData(CompoundTag nbt); -@@ -2153,9 +2654,22 @@ +@@ -2153,9 +2654,23 @@ if (stack.isEmpty()) { return null; } else { +- ItemEntity entityitem = new ItemEntity(world, this.getX(), this.getY() + (double) yOffset, this.getZ(), stack); + // CraftBukkit start - Capture drops for death event + if (this instanceof net.minecraft.world.entity.LivingEntity && !((net.minecraft.world.entity.LivingEntity) this).forceDrops) { -+ ((net.minecraft.world.entity.LivingEntity) this).drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(stack)); ++ ((net.minecraft.world.entity.LivingEntity) this).drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(stack)); // Paper - mirror so we can destroy it later + return null; + } + // CraftBukkit end - ItemEntity entityitem = new ItemEntity(world, this.getX(), this.getY() + (double) yOffset, this.getZ(), stack); ++ ItemEntity entityitem = new ItemEntity(world, this.getX(), this.getY() + (double) yOffset, this.getZ(), stack.copy()); // Paper - copy so we can destroy original ++ stack.setCount(0); // Paper - destroy this item - if this ever leaks due to game bugs, ensure it doesn't dupe entityitem.setDefaultPickUpDelay(); + // CraftBukkit start @@ -914,7 +914,7 @@ world.addFreshEntity(entityitem); return entityitem; } -@@ -2184,6 +2698,12 @@ +@@ -2184,6 +2699,12 @@ if (this.isAlive() && this instanceof Leashable leashable) { if (leashable.getLeashHolder() == player) { if (!this.level().isClientSide()) { @@ -927,7 +927,7 @@ if (player.hasInfiniteMaterials()) { leashable.removeLeash(); } else { -@@ -2200,6 +2720,13 @@ +@@ -2200,6 +2721,13 @@ if (itemstack.is(Items.LEAD) && leashable.canHaveALeashAttachedToIt()) { if (!this.level().isClientSide()) { @@ -941,7 +941,7 @@ leashable.setLeashedTo(player, true); } -@@ -2265,7 +2792,7 @@ +@@ -2265,7 +2793,7 @@ } public boolean showVehicleHealth() { @@ -950,7 +950,7 @@ } public boolean startRiding(Entity entity, boolean force) { -@@ -2273,7 +2800,7 @@ +@@ -2273,7 +2801,7 @@ return false; } else if (!entity.couldAcceptPassenger()) { return false; @@ -959,7 +959,7 @@ return false; } else { for (Entity entity1 = entity; entity1.vehicle != null; entity1 = entity1.vehicle) { -@@ -2285,11 +2812,32 @@ +@@ -2285,11 +2813,32 @@ if (!force && (!this.canRide(entity) || !entity.canAddPassenger(this))) { return false; } else { @@ -993,7 +993,7 @@ this.vehicle = entity; this.vehicle.addPassenger(this); entity.getIndirectPassengersStream().filter((entity2) -> { -@@ -2314,19 +2862,30 @@ +@@ -2314,19 +2863,30 @@ } public void removeVehicle() { @@ -1026,7 +1026,7 @@ protected void addPassenger(Entity passenger) { if (passenger.getVehicle() != this) { throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)"); -@@ -2349,21 +2908,53 @@ +@@ -2349,21 +2909,53 @@ } } @@ -1086,7 +1086,7 @@ } protected boolean canAddPassenger(Entity passenger) { -@@ -2464,7 +3055,7 @@ +@@ -2464,7 +3056,7 @@ if (teleporttransition != null) { ServerLevel worldserver1 = teleporttransition.newLevel(); @@ -1095,7 +1095,7 @@ this.teleport(teleporttransition); } } -@@ -2547,7 +3138,7 @@ +@@ -2547,7 +3139,7 @@ } public boolean isCrouching() { @@ -1104,7 +1104,7 @@ } public boolean isSprinting() { -@@ -2563,7 +3154,7 @@ +@@ -2563,7 +3155,7 @@ } public boolean isVisuallySwimming() { @@ -1113,7 +1113,7 @@ } public boolean isVisuallyCrawling() { -@@ -2571,6 +3162,13 @@ +@@ -2571,6 +3163,13 @@ } public void setSwimming(boolean swimming) { @@ -1127,7 +1127,7 @@ this.setSharedFlag(4, swimming); } -@@ -2609,6 +3207,7 @@ +@@ -2609,6 +3208,7 @@ @Nullable public PlayerTeam getTeam() { @@ -1135,7 +1135,7 @@ return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName()); } -@@ -2624,8 +3223,12 @@ +@@ -2624,8 +3224,12 @@ return this.getTeam() != null ? this.getTeam().isAlliedTo(team) : false; } @@ -1149,7 +1149,7 @@ } public boolean getSharedFlag(int index) { -@@ -2644,7 +3247,7 @@ +@@ -2644,7 +3248,7 @@ } public int getMaxAirSupply() { @@ -1158,7 +1158,7 @@ } public int getAirSupply() { -@@ -2652,7 +3255,18 @@ +@@ -2652,7 +3256,18 @@ } public void setAirSupply(int air) { @@ -1178,7 +1178,7 @@ } public int getTicksFrozen() { -@@ -2679,11 +3293,40 @@ +@@ -2679,11 +3294,40 @@ public void thunderHit(ServerLevel world, LightningBolt lightning) { this.setRemainingFireTicks(this.remainingFireTicks + 1); @@ -1221,7 +1221,7 @@ } public void onAboveBubbleCol(boolean drag) { -@@ -2713,7 +3356,7 @@ +@@ -2713,7 +3357,7 @@ this.resetFallDistance(); } @@ -1230,7 +1230,7 @@ return true; } -@@ -2818,7 +3461,7 @@ +@@ -2818,7 +3462,7 @@ public String toString() { String s = this.level() == null ? "~NULL~" : this.level().toString(); @@ -1239,8 +1239,16 @@ } public final boolean isInvulnerableToBase(DamageSource damageSource) { -@@ -2852,6 +3495,26 @@ +@@ -2850,8 +3494,34 @@ + public Entity teleport(TeleportTransition teleportTarget) { + Level world = this.level(); ++ // Paper start - Fix item duplication and teleport issues ++ if ((!this.isAlive() || !this.valid) && (teleportTarget.newLevel() != world)) { ++ LOGGER.warn("Illegal Entity Teleport " + this + " to " + teleportTarget.newLevel() + ":" + teleportTarget.position(), new Throwable()); ++ return null; ++ } ++ // Paper end - Fix item duplication and teleport issues if (world instanceof ServerLevel worldserver) { if (!this.isRemoved()) { + // CraftBukkit start @@ -1266,8 +1274,15 @@ ServerLevel worldserver1 = teleportTarget.newLevel(); boolean flag = worldserver1.dimension() != worldserver.dimension(); -@@ -2920,8 +3583,12 @@ +@@ -2918,10 +3588,19 @@ + gameprofilerfiller.pop(); + return null; } else { ++ // Paper start - Fix item duplication and teleport issues ++ if (this instanceof Leashable leashable) { ++ leashable.dropLeash(); // Paper drop lead ++ } ++ // Paper end - Fix item duplication and teleport issues entity.restoreFrom(this); this.removeAfterChangingDimensions(); + // CraftBukkit start - Forward the CraftEntity to the new entity @@ -1280,7 +1295,7 @@ Iterator iterator1 = list1.iterator(); while (iterator1.hasNext()) { -@@ -2947,7 +3614,7 @@ +@@ -2947,7 +3626,7 @@ } private void sendTeleportTransitionToRidingPlayers(TeleportTransition teleportTarget) { @@ -1289,7 +1304,7 @@ Iterator iterator = this.getIndirectPassengers().iterator(); while (iterator.hasNext()) { -@@ -2995,8 +3662,9 @@ +@@ -2995,8 +3674,9 @@ } protected void removeAfterChangingDimensions() { @@ -1300,7 +1315,7 @@ leashable.removeLeash(); } -@@ -3006,6 +3674,20 @@ +@@ -3006,11 +3686,26 @@ return PortalShape.getRelativePosition(portalRect, portalAxis, this.position(), this.getDimensions(this.getPose())); } @@ -1321,7 +1336,13 @@ public boolean canUsePortal(boolean allowVehicles) { return (allowVehicles || !this.isPassenger()) && this.isAlive(); } -@@ -3134,10 +3816,16 @@ + + public boolean canTeleport(Level from, Level to) { ++ if (!this.isAlive() || !this.valid) return false; // Paper - Fix item duplication and teleport issues + if (from.dimension() == Level.END && to.dimension() == Level.OVERWORLD) { + Iterator iterator = this.getPassengers().iterator(); + +@@ -3134,10 +3829,16 @@ return (Boolean) this.entityData.get(Entity.DATA_CUSTOM_NAME_VISIBLE); } @@ -1341,7 +1362,7 @@ return entity != null; } -@@ -3187,7 +3875,7 @@ +@@ -3187,7 +3888,7 @@ /** @deprecated */ @Deprecated protected void fixupDimensions() { @@ -1350,7 +1371,7 @@ EntityDimensions entitysize = this.getDimensions(entitypose); this.dimensions = entitysize; -@@ -3196,7 +3884,7 @@ +@@ -3196,7 +3897,7 @@ public void refreshDimensions() { EntityDimensions entitysize = this.dimensions; @@ -1359,7 +1380,7 @@ EntityDimensions entitysize1 = this.getDimensions(entitypose); this.dimensions = entitysize1; -@@ -3258,10 +3946,29 @@ +@@ -3258,10 +3959,29 @@ } public final void setBoundingBox(AABB boundingBox) { @@ -1391,7 +1412,7 @@ return this.getDimensions(pose).eyeHeight(); } -@@ -3335,7 +4042,7 @@ +@@ -3335,7 +4055,7 @@ } @Nullable @@ -1400,7 +1421,7 @@ return null; } -@@ -3435,7 +4142,7 @@ +@@ -3435,7 +4155,7 @@ } public boolean isControlledByLocalInstance() { @@ -1409,7 +1430,7 @@ if (entityliving instanceof Player entityhuman) { return entityhuman.isLocalPlayer(); -@@ -3445,7 +4152,7 @@ +@@ -3445,7 +4165,7 @@ } public boolean isControlledByClient() { @@ -1418,7 +1439,7 @@ return entityliving != null && entityliving.isControlledByClient(); } -@@ -3463,7 +4170,7 @@ +@@ -3463,7 +4183,7 @@ return new Vec3((double) f1 * d2 / (double) f3, 0.0D, (double) f2 * d2 / (double) f3); } @@ -1427,7 +1448,7 @@ return new Vec3(this.getX(), this.getBoundingBox().maxY, this.getZ()); } -@@ -3488,9 +4195,38 @@ +@@ -3488,9 +4208,38 @@ public int getFireImmuneTicks() { return 1; } @@ -1467,7 +1488,7 @@ } public void lookAt(EntityAnchorArgument.Anchor anchorPoint, Vec3 target) { -@@ -3551,6 +4287,11 @@ +@@ -3551,6 +4300,11 @@ vec3d = vec3d.add(vec3d1); ++k1; } @@ -1479,7 +1500,7 @@ } } } -@@ -3613,7 +4354,7 @@ +@@ -3613,7 +4367,7 @@ return new ClientboundAddEntityPacket(this, entityTrackerEntry); } @@ -1488,7 +1509,7 @@ return this.type.getDimensions(); } -@@ -3818,8 +4559,16 @@ +@@ -3818,8 +4572,16 @@ @Override public final void setRemoved(Entity.RemovalReason reason) { @@ -1506,7 +1527,7 @@ } if (this.removalReason.shouldDestroy()) { -@@ -3827,8 +4576,8 @@ +@@ -3827,8 +4589,8 @@ } this.getPassengers().forEach(Entity::stopRiding); @@ -1517,7 +1538,7 @@ } public void unsetRemoved() { -@@ -3887,7 +4636,7 @@ +@@ -3887,7 +4649,7 @@ } public Vec3 getKnownMovement() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch index 139f86199e..9751a45194 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch @@ -66,7 +66,7 @@ public int lastHurtByPlayerTime; protected boolean dead; protected int noActionTime; -@@ -260,7 +285,29 @@ +@@ -260,6 +285,28 @@ protected boolean skipDropExperience; private final EnumMap>> activeLocationDependentEnchantments; protected float appliedScale; @@ -79,7 +79,7 @@ + public boolean bukkitPickUpLoot; + public org.bukkit.craftbukkit.entity.CraftLivingEntity getBukkitLivingEntity() { return (org.bukkit.craftbukkit.entity.CraftLivingEntity) super.getBukkitEntity(); } // Paper + public boolean silentDeath = false; // Paper - mark entity as dying silently for cancellable death event - ++ + @Override + public float getBukkitYaw() { + return this.getYHeadRot(); @@ -92,10 +92,9 @@ + ++this.noActionTime; // Above all the floats + } + // Spigot end -+ + protected LivingEntity(EntityType type, Level world) { super(type, world); - this.lastHandItemStacks = NonNullList.withSize(2, ItemStack.EMPTY); @@ -276,7 +323,9 @@ this.activeLocationDependentEnchantments = new EnumMap(EquipmentSlot.class); this.appliedScale = 1.0F; @@ -783,9 +782,9 @@ + // Paper start + org.bukkit.event.entity.EntityDeathEvent deathEvent = this.dropAllDeathLoot(worldserver, damageSource); + if (deathEvent == null || !deathEvent.isCancelled()) { -+ if (entityliving != null) { -+ entityliving.awardKillScore(this, damageSource); -+ } ++ //if (entityliving != null) { // Paper - Fix item duplication and teleport issues; moved to be run earlier in #dropAllDeathLoot before destroying the drop items in CraftEventFactory#callEntityDeathEvent ++ // entityliving.awardKillScore(this, damageSource); ++ //} + // Paper start - clear equipment if event is not cancelled + if (this instanceof Mob) { + for (EquipmentSlot slot : this.clearedEquipmentSlots) { @@ -860,7 +859,7 @@ this.level().addFreshEntity(entityitem); } } -@@ -1527,27 +1854,55 @@ +@@ -1527,27 +1854,60 @@ } } @@ -883,8 +882,13 @@ this.dropCustomDeathLoot(world, damageSource, flag); + this.clearEquipmentSlots = prev; // Paper } -+ // CraftBukkit start - Call death event -+ org.bukkit.event.entity.EntityDeathEvent deathEvent = CraftEventFactory.callEntityDeathEvent(this, damageSource, this.drops); // Paper ++ // CraftBukkit start - Call death event // Paper start - call advancement triggers with correct entity equipment ++ org.bukkit.event.entity.EntityDeathEvent deathEvent = CraftEventFactory.callEntityDeathEvent(this, damageSource, this.drops, () -> { ++ final LivingEntity entityliving = this.getKillCredit(); ++ if (entityliving != null) { ++ entityliving.awardKillScore(this, damageSource); ++ } ++ }); // Paper end + this.postDeathDropItems(deathEvent); // Paper + this.drops = new ArrayList<>(); + // CraftBukkit end @@ -921,7 +925,7 @@ protected void dropCustomDeathLoot(ServerLevel world, DamageSource source, boolean causedByPlayer) {} public long getLootTableSeed() { -@@ -1612,19 +1967,35 @@ +@@ -1612,19 +1972,35 @@ } public void knockback(double strength, double x, double z) { @@ -964,7 +968,7 @@ } } -@@ -1683,6 +2054,20 @@ +@@ -1683,6 +2059,20 @@ return new LivingEntity.Fallsounds(SoundEvents.GENERIC_SMALL_FALL, SoundEvents.GENERIC_BIG_FALL); } @@ -985,7 +989,7 @@ public Optional getLastClimbablePos() { return this.lastClimbablePos; } -@@ -1757,9 +2142,14 @@ +@@ -1757,9 +2147,14 @@ int i = this.calculateFallDamage(fallDistance, damageMultiplier); if (i > 0) { @@ -1001,7 +1005,7 @@ return true; } else { return flag; -@@ -1830,7 +2220,7 @@ +@@ -1830,7 +2225,7 @@ protected float getDamageAfterArmorAbsorb(DamageSource source, float amount) { if (!source.is(DamageTypeTags.BYPASSES_ARMOR)) { @@ -1010,7 +1014,7 @@ amount = CombatRules.getDamageAfterAbsorb(this, amount, source, (float) this.getArmorValue(), (float) this.getAttributeValue(Attributes.ARMOR_TOUGHNESS)); } -@@ -1841,7 +2231,8 @@ +@@ -1841,7 +2236,8 @@ if (source.is(DamageTypeTags.BYPASSES_EFFECTS)) { return amount; } else { @@ -1020,7 +1024,7 @@ int i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5; int j = 25 - i; float f1 = amount * (float) j; -@@ -1884,18 +2275,154 @@ +@@ -1884,18 +2280,154 @@ } } @@ -1047,7 +1051,7 @@ + }; + float freezingModifier = freezing.apply((double) f).floatValue(); + f += freezingModifier; - ++ + com.google.common.base.Function hardHat = new com.google.common.base.Function() { + @Override + public Double apply(Double f) { @@ -1059,7 +1063,7 @@ + }; + float hardHatModifier = hardHat.apply((double) f).floatValue(); + f += hardHatModifier; -+ + + com.google.common.base.Function blocking = new com.google.common.base.Function() { + @Override + public Double apply(Double f) { @@ -1184,7 +1188,7 @@ if (entity instanceof ServerPlayer) { ServerPlayer entityplayer = (ServerPlayer) entity; -@@ -1904,13 +2431,48 @@ +@@ -1904,13 +2436,48 @@ } } @@ -1237,7 +1241,7 @@ } public CombatTracker getCombatTracker() { -@@ -1935,8 +2497,18 @@ +@@ -1935,8 +2502,18 @@ } public final void setArrowCount(int stuckArrowCount) { @@ -1257,7 +1261,7 @@ public final int getStingerCount() { return (Integer) this.entityData.get(LivingEntity.DATA_STINGER_COUNT_ID); -@@ -1999,7 +2571,7 @@ +@@ -1999,7 +2576,7 @@ this.playSound(soundeffect, this.getSoundVolume(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); } @@ -1266,7 +1270,7 @@ this.setHealth(0.0F); this.die(this.damageSources().generic()); } -@@ -2182,6 +2754,12 @@ +@@ -2182,6 +2759,12 @@ public abstract ItemStack getItemBySlot(EquipmentSlot slot); @@ -1279,7 +1283,7 @@ public abstract void setItemSlot(EquipmentSlot slot, ItemStack stack); public Iterable getHandSlots() { -@@ -2494,7 +3072,7 @@ +@@ -2494,7 +3077,7 @@ } @@ -1288,7 +1292,7 @@ Vec3 vec3d1 = this.getRiddenInput(controllingPlayer, movementInput); this.tickRidden(controllingPlayer, vec3d1); -@@ -2507,13 +3085,13 @@ +@@ -2507,13 +3090,13 @@ } @@ -1305,7 +1309,7 @@ return this.getSpeed(); } -@@ -2571,7 +3149,7 @@ +@@ -2571,7 +3154,7 @@ double d1 = Mth.clamp(motion.z, -0.15000000596046448D, 0.15000000596046448D); double d2 = Math.max(motion.y, -0.15000000596046448D); @@ -1314,7 +1318,7 @@ d2 = 0.0D; } -@@ -2586,7 +3164,7 @@ +@@ -2586,7 +3169,7 @@ } protected float getFlyingSpeed() { @@ -1323,7 +1327,7 @@ } public float getSpeed() { -@@ -2634,7 +3212,7 @@ +@@ -2634,7 +3217,7 @@ } } @@ -1332,7 +1336,7 @@ if (this.tickCount % 20 == 0) { this.getCombatTracker().recheckStatus(); } -@@ -2741,7 +3319,7 @@ +@@ -2741,7 +3324,7 @@ this.elytraAnimationState.tick(); } @@ -1341,15 +1345,14 @@ Map map = this.collectEquipmentChanges(); if (map != null) { -@@ -2778,10 +3356,17 @@ +@@ -2778,10 +3361,17 @@ throw new MatchException((String) null, (Throwable) null); } - ItemStack itemstack2 = itemstack1; -- -- itemstack = this.getItemBySlot(enumitemslot); + ItemStack itemstack2 = itemstack1; final ItemStack oldEquipment = itemstack2; // Paper - PlayerArmorChangeEvent - obfhelper -+ + +- itemstack = this.getItemBySlot(enumitemslot); + itemstack = this.getItemBySlot(enumitemslot); final ItemStack newEquipment = itemstack;// Paper - PlayerArmorChangeEvent - obfhelper if (this.equipmentHasChanged(itemstack2, itemstack)) { + // Paper start - PlayerArmorChangeEvent @@ -1362,7 +1365,7 @@ if (map == null) { map = Maps.newEnumMap(EquipmentSlot.class); } -@@ -2974,8 +3559,10 @@ +@@ -2974,8 +3564,10 @@ } else if (this.isInLava() && (!this.onGround() || d3 > d4)) { this.jumpInLiquid(FluidTags.LAVA); } else if ((this.onGround() || flag && d3 <= d4) && this.noJumpDelay == 0) { @@ -1373,7 +1376,7 @@ } } else { this.noJumpDelay = 0; -@@ -3000,7 +3587,7 @@ +@@ -3000,7 +3592,7 @@ { LivingEntity entityliving = this.getControllingPassenger(); @@ -1382,7 +1385,7 @@ if (this.isAlive()) { this.travelRidden(entityhuman, vec3d1); break label112; -@@ -3063,6 +3650,7 @@ +@@ -3063,6 +3655,7 @@ this.checkSlowFallDistance(); if (!this.level().isClientSide) { if (!this.canGlide()) { @@ -1390,7 +1393,7 @@ this.setSharedFlag(7, false); return; } -@@ -3113,12 +3701,26 @@ +@@ -3113,12 +3706,26 @@ Level world = this.level(); if (!(world instanceof ServerLevel worldserver)) { @@ -1419,7 +1422,7 @@ if (i > 0 && list.size() > i - 1 && this.random.nextInt(4) == 0) { int j = 0; -@@ -3138,10 +3740,12 @@ +@@ -3138,10 +3745,12 @@ } Iterator iterator1 = list.iterator(); @@ -1434,7 +1437,7 @@ this.doPush(entity1); } } -@@ -3190,9 +3794,15 @@ +@@ -3190,9 +3799,15 @@ @Override public void stopRiding() { @@ -1451,7 +1454,7 @@ if (entity != null && entity != this.getVehicle() && !this.level().isClientSide) { this.dismountVehicle(entity); } -@@ -3305,15 +3915,22 @@ +@@ -3305,15 +3920,22 @@ @Override public boolean isPickable() { @@ -1476,7 +1479,7 @@ public float getYHeadRot() { return this.yHeadRot; } -@@ -3342,7 +3959,7 @@ +@@ -3342,7 +3964,7 @@ } public final void setAbsorptionAmount(float absorptionAmount) { @@ -1485,7 +1488,7 @@ } protected void internalSetAbsorptionAmount(float absorptionAmount) { -@@ -3410,9 +4027,14 @@ +@@ -3410,9 +4032,14 @@ } public void startUsingItem(InteractionHand hand) { @@ -1501,7 +1504,7 @@ this.useItem = itemstack; this.useItemRemaining = itemstack.getUseDuration(this); if (!this.level().isClientSide) { -@@ -3483,13 +4105,49 @@ +@@ -3483,13 +4110,49 @@ this.releaseUsingItem(); } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { @@ -1552,7 +1555,7 @@ } } -@@ -3544,12 +4202,69 @@ +@@ -3544,12 +4207,69 @@ if (this.isUsingItem() && !this.useItem.isEmpty()) { Item item = this.useItem.getItem(); @@ -1623,7 +1626,7 @@ public boolean isSuppressingSlidingDownLadder() { return this.isShiftKeyDown(); } -@@ -3568,12 +4283,18 @@ +@@ -3568,12 +4288,18 @@ } public boolean randomTeleport(double x, double y, double z, boolean particleEffects) { @@ -1644,7 +1647,7 @@ Level world = this.level(); if (world.hasChunkAt(blockposition)) { -@@ -3592,18 +4313,43 @@ +@@ -3592,18 +4318,43 @@ } if (flag2) { @@ -1692,7 +1695,7 @@ world.broadcastEntityEvent(this, (byte) 46); } -@@ -3613,7 +4359,7 @@ +@@ -3613,7 +4364,7 @@ entitycreature.getNavigation().stop(); } @@ -1701,7 +1704,7 @@ } } -@@ -3706,7 +4452,7 @@ +@@ -3706,7 +4457,7 @@ } public void stopSleeping() { @@ -1710,7 +1713,7 @@ Level world = this.level(); java.util.Objects.requireNonNull(world); -@@ -3718,9 +4464,9 @@ +@@ -3718,9 +4469,9 @@ this.level().setBlock(blockposition, (BlockState) iblockdata.setValue(BedBlock.OCCUPIED, false), 3); Vec3 vec3d = (Vec3) BedBlock.findStandUpPosition(this.getType(), this.level(), blockposition, enumdirection, this.getYRot()).orElseGet(() -> { @@ -1722,7 +1725,7 @@ }); Vec3 vec3d1 = Vec3.atBottomCenterOf(blockposition).subtract(vec3d).normalize(); float f = (float) Mth.wrapDegrees(Mth.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D); -@@ -3740,7 +4486,7 @@ +@@ -3740,7 +4491,7 @@ @Nullable public Direction getBedOrientation() { @@ -1731,7 +1734,7 @@ return blockposition != null ? BedBlock.getBedOrientation(this.level(), blockposition) : null; } -@@ -3905,7 +4651,7 @@ +@@ -3905,7 +4656,7 @@ public float maxUpStep() { float f = (float) this.getAttributeValue(Attributes.STEP_HEIGHT); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch index e2ed55cf75..094a00ec1b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch @@ -355,7 +355,7 @@ itemstack = (ItemStack) this.handItems.get(i); if (!itemstack.isEmpty()) { - Block.popResource(this.level(), this.blockPosition().above(), itemstack); -+ this.drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops ++ this.drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack)); // CraftBukkit - add to drops // Paper - mirror so we can destroy it later - though this call site was safe this.handItems.set(i, ItemStack.EMPTY); } } @@ -364,7 +364,7 @@ itemstack = (ItemStack) this.armorItems.get(i); if (!itemstack.isEmpty()) { - Block.popResource(this.level(), this.blockPosition().above(), itemstack); -+ this.drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops ++ this.drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack)); // CraftBukkit - add to drops // Paper - mirror so we can destroy it later - though this call site was safe this.armorItems.set(i, ItemStack.EMPTY); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 74f33aeb61..f482fc14e1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -903,6 +903,11 @@ public class CraftEventFactory { } public static EntityDeathEvent callEntityDeathEvent(net.minecraft.world.entity.LivingEntity victim, DamageSource damageSource, List drops) { + // Paper start + return CraftEventFactory.callEntityDeathEvent(victim, damageSource, drops, com.google.common.util.concurrent.Runnables.doNothing()); + } + public static EntityDeathEvent callEntityDeathEvent(net.minecraft.world.entity.LivingEntity victim, DamageSource damageSource, List drops, Runnable lootCheck) { + // Paper end CraftLivingEntity entity = (CraftLivingEntity) victim.getBukkitEntity(); CraftDamageSource bukkitDamageSource = new CraftDamageSource(damageSource); CraftWorld world = (CraftWorld) entity.getWorld(); @@ -917,11 +922,13 @@ public class CraftEventFactory { playDeathSound(victim, event); // Paper end victim.expToDrop = event.getDroppedExp(); + lootCheck.run(); // Paper - advancement triggers before destroying items for (org.bukkit.inventory.ItemStack stack : event.getDrops()) { if (stack == null || stack.getType() == Material.AIR || stack.getAmount() == 0) continue; - world.dropItem(entity.getLocation(), stack); + world.dropItem(entity.getLocation(), stack); // Paper - note: dropItem already clones due to this being bukkit -> NMS + if (stack instanceof CraftItemStack) stack.setAmount(0); // Paper - destroy this item - if this ever leaks due to game bugs, ensure it doesn't dupe, but don't nuke bukkit stacks of manually added items } return event;