From 1523212d4eb850f0d7b1be46308ac53e2825f859 Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Wed, 30 Oct 2024 17:07:49 +0100 Subject: [PATCH] don't resend effects when PlayerItemConsumeEvent is cancelled --- .../0992-Properly-resend-entities.patch | 52 ++++--------------- ...tityDamageEvents-before-actuallyHurt.patch | 2 +- .../1019-Check-dead-flag-in-isAlive.patch | 2 +- .../1032-Void-damage-configuration-API.patch | 2 +- .../1038-Moonrise-optimisation-patches.patch | 4 +- .../1042-Improved-Watchdog-Support.patch | 2 +- ...-Incremental-chunk-and-player-saving.patch | 4 +- .../server/1051-Lag-compensation-ticks.patch | 2 +- 8 files changed, 20 insertions(+), 50 deletions(-) diff --git a/patches/server/0992-Properly-resend-entities.patch b/patches/server/0992-Properly-resend-entities.patch index 2b67ccc75f..4fe85b0191 100644 --- a/patches/server/0992-Properly-resend-entities.patch +++ b/patches/server/0992-Properly-resend-entities.patch @@ -102,7 +102,7 @@ index 52eafd99ed63f5fc9596225cf45175b1287f20a1..e5db85f858ab376b225172e22b92b841 } diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 751fc4b0fe60c6d26ea0f768f3d66031a4bad963..700ab5ef2f8ab1466c4f659cd34679dc809efbaf 100644 +index 751fc4b0fe60c6d26ea0f768f3d66031a4bad963..f6eed6cb2bd69c15aa36a8d8d9abdfda6d4a0622 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -396,7 +396,7 @@ public abstract class PlayerList { @@ -114,25 +114,6 @@ index 751fc4b0fe60c6d26ea0f768f3d66031a4bad963..700ab5ef2f8ab1466c4f659cd34679dc this.sendLevelInfo(player, worldserver1); -@@ -907,12 +907,17 @@ public abstract class PlayerList { - } - - public void sendActiveEffects(LivingEntity entity, ServerGamePacketListenerImpl networkHandler) { -+ // Paper start - collect packets -+ this.sendActiveEffects(entity, networkHandler::send); -+ } -+ public void sendActiveEffects(LivingEntity entity, java.util.function.Consumer> packetConsumer) { -+ // Paper end - collect packets - Iterator iterator = entity.getActiveEffects().iterator(); - - while (iterator.hasNext()) { - MobEffectInstance mobeffect = (MobEffectInstance) iterator.next(); - -- networkHandler.send(new ClientboundUpdateMobEffectPacket(entity.getId(), mobeffect, false)); -+ packetConsumer.accept(new ClientboundUpdateMobEffectPacket(entity.getId(), mobeffect, false)); // Paper - collect packets - } - - } diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java index 7fbaaed892b39ca920b15e08d6c44943a69a35d7..ddfc4818f091802e5999c6b99e5bc57c6f370648 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java @@ -186,7 +167,7 @@ index 7fbaaed892b39ca920b15e08d6c44943a69a35d7..ddfc4818f091802e5999c6b99e5bc57c public boolean equals(Object object) { return object instanceof Entity ? ((Entity) object).id == this.id : false; diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 22f520414442c05986cc620208afaa895d8ee4fa..5e4716158da891216acc835f2560f980f527c66f 100644 +index 22f520414442c05986cc620208afaa895d8ee4fa..d19a9aa8f73b3a07e7d3d63efa5d411add163fa4 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -4029,6 +4029,11 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -201,6 +182,15 @@ index 22f520414442c05986cc620208afaa895d8ee4fa..5e4716158da891216acc835f2560f980 private void updatingUsingItem() { if (this.isUsingItem()) { if (ItemStack.isSameItem(this.getItemInHand(this.getUsedItemHand()), this.useItem)) { +@@ -4164,7 +4169,7 @@ public abstract class LivingEntity extends Entity implements Attackable { + this.stopUsingItem(); // Paper - event is using an item, clear active item to reset its use + // Update client + Consumable consumable = this.useItem.get(DataComponents.CONSUMABLE); +- if (consumable != null) { ++ if (false && consumable != null) { // Paper + consumable.cancelUsingItem(entityPlayer, this.useItem); + } + entityPlayer.getBukkitEntity().updateInventory(); diff --git a/src/main/java/net/minecraft/world/entity/animal/Bucketable.java b/src/main/java/net/minecraft/world/entity/animal/Bucketable.java index 5a12f4c1de2d020e84af933d491397b38d227824..4eca5996a867086be22d22d99db81ab001467516 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Bucketable.java @@ -215,26 +205,6 @@ index 5a12f4c1de2d020e84af933d491397b38d227824..4eca5996a867086be22d22d99db81ab0 return Optional.of(InteractionResult.FAIL); } entity.playSound(((Bucketable) entity).getPickupSound(), 1.0F, 1.0F); -diff --git a/src/main/java/net/minecraft/world/item/component/SuspiciousStewEffects.java b/src/main/java/net/minecraft/world/item/component/SuspiciousStewEffects.java -index 04760d8ba7c560bd9d11191c666715ae8c3e4bff..768f90682cd10045c16337fecc2702f57dfe8a50 100644 ---- a/src/main/java/net/minecraft/world/item/component/SuspiciousStewEffects.java -+++ b/src/main/java/net/minecraft/world/item/component/SuspiciousStewEffects.java -@@ -47,9 +47,14 @@ public record SuspiciousStewEffects(List effects) i - // CraftBukkit start - @Override - public void cancelUsingItem(net.minecraft.server.level.ServerPlayer entityplayer, ItemStack itemstack) { -+ final List> packets = new java.util.ArrayList<>(); // Paper - bundlize packets - for (SuspiciousStewEffects.Entry suspicioussteweffects_a : this.effects) { -- entityplayer.connection.send(new net.minecraft.network.protocol.game.ClientboundRemoveMobEffectPacket(entityplayer.getId(), suspicioussteweffects_a.effect())); -+ packets.add(new net.minecraft.network.protocol.game.ClientboundRemoveMobEffectPacket(entityplayer.getId(), suspicioussteweffects_a.effect())); // Paper - bundlize packets - } -+ // Paper start - bundlize packets -+ entityplayer.server.getPlayerList().sendActiveEffects(entityplayer, packets::add); -+ entityplayer.connection.send(new net.minecraft.network.protocol.game.ClientboundBundlePacket(packets)); -+ // Paper end - bundlize packets - } - // CraftBukkit end - diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 7536ab5c22d97a074c08a95fff6bc756d61e387d..b0e49ad831f1ebc6b126bf82c5fddaebffb91312 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java diff --git a/patches/server/1001-Only-call-EntityDamageEvents-before-actuallyHurt.patch b/patches/server/1001-Only-call-EntityDamageEvents-before-actuallyHurt.patch index 9a4b699009..4dfe84dde1 100644 --- a/patches/server/1001-Only-call-EntityDamageEvents-before-actuallyHurt.patch +++ b/patches/server/1001-Only-call-EntityDamageEvents-before-actuallyHurt.patch @@ -12,7 +12,7 @@ This patch moves the invocation directly before the #actuallyHurt calls, respective invulnerable timings. diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 5e4716158da891216acc835f2560f980f527c66f..ad536c76010957650814b293fc8220ac525c13f1 100644 +index d19a9aa8f73b3a07e7d3d63efa5d411add163fa4..14420fb1ab7f77ef649a86d4fb58e747e4bab0cd 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -1489,12 +1489,7 @@ public abstract class LivingEntity extends Entity implements Attackable { diff --git a/patches/server/1019-Check-dead-flag-in-isAlive.patch b/patches/server/1019-Check-dead-flag-in-isAlive.patch index e2836e5738..b4ac221ddf 100644 --- a/patches/server/1019-Check-dead-flag-in-isAlive.patch +++ b/patches/server/1019-Check-dead-flag-in-isAlive.patch @@ -15,7 +15,7 @@ Also, even if the plugin is responsibly checking !isDead() before modifying heal I am currently unable to replicate, these "revived" entities can still appear diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index ad536c76010957650814b293fc8220ac525c13f1..ceaba7b82e9ff73a14fdef046e63b07c4d0fd5e9 100644 +index 14420fb1ab7f77ef649a86d4fb58e747e4bab0cd..3cc0b820363e748bca7f8770239b38f3845dd6a6 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -2145,7 +2145,7 @@ public abstract class LivingEntity extends Entity implements Attackable { diff --git a/patches/server/1032-Void-damage-configuration-API.patch b/patches/server/1032-Void-damage-configuration-API.patch index dd9e6079b9..e570f4305a 100644 --- a/patches/server/1032-Void-damage-configuration-API.patch +++ b/patches/server/1032-Void-damage-configuration-API.patch @@ -20,7 +20,7 @@ index ddfc4818f091802e5999c6b99e5bc57c6f370648..e5466be840ef32e4fa17c0e9446c4d0b && (!(this instanceof Player player) || !player.getAbilities().invulnerable))) { // Paper end - Configurable nether ceiling damage diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index ceaba7b82e9ff73a14fdef046e63b07c4d0fd5e9..2914be5f6681c513bf2878a92c0c60ad997852dc 100644 +index 3cc0b820363e748bca7f8770239b38f3845dd6a6..a7a2306433014f45e2a448ebe125b668cc49b3d1 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -2700,7 +2700,7 @@ public abstract class LivingEntity extends Entity implements Attackable { diff --git a/patches/server/1038-Moonrise-optimisation-patches.patch b/patches/server/1038-Moonrise-optimisation-patches.patch index c40f783855..6faf764e05 100644 --- a/patches/server/1038-Moonrise-optimisation-patches.patch +++ b/patches/server/1038-Moonrise-optimisation-patches.patch @@ -28026,10 +28026,10 @@ index b7d29389a357f142237cecd75f8ca91cf1eb6b5b..e4b0dc3121101d54394a0c3a413dabf8 this.generatingStep = generationStep; this.cache = chunks; diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 700ab5ef2f8ab1466c4f659cd34679dc809efbaf..b28b23c69512b054e856388f2f94d27d35347b8c 100644 +index f6eed6cb2bd69c15aa36a8d8d9abdfda6d4a0622..1ada5a98169027cbb04f6bc37c96245c17d44c1e 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -1420,7 +1420,7 @@ public abstract class PlayerList { +@@ -1415,7 +1415,7 @@ public abstract class PlayerList { public void setViewDistance(int viewDistance) { this.viewDistance = viewDistance; diff --git a/patches/server/1042-Improved-Watchdog-Support.patch b/patches/server/1042-Improved-Watchdog-Support.patch index d19dc9a173..77dc664f28 100644 --- a/patches/server/1042-Improved-Watchdog-Support.patch +++ b/patches/server/1042-Improved-Watchdog-Support.patch @@ -302,7 +302,7 @@ index bf2bae3166df06be240dbbeecce16a24c85897a9..c06863578c5d654706d93e73059d89c1 } diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index b28b23c69512b054e856388f2f94d27d35347b8c..88f40e54fa3b78d82261e06f941ef42587d52c25 100644 +index 1ada5a98169027cbb04f6bc37c96245c17d44c1e..9c474f3e603c6c274610e15f184468dc640b5eb0 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -553,7 +553,7 @@ public abstract class PlayerList { diff --git a/patches/server/1048-Incremental-chunk-and-player-saving.patch b/patches/server/1048-Incremental-chunk-and-player-saving.patch index 9494da1fd0..239e73fd15 100644 --- a/patches/server/1048-Incremental-chunk-and-player-saving.patch +++ b/patches/server/1048-Incremental-chunk-and-player-saving.patch @@ -97,7 +97,7 @@ index 8ceeebb561046933cba0725e15732fa074226884..8c9148426f23cbbdfaf7ae66657d1a62 private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_Y = 10; private static final int FLY_STAT_RECORDING_SPEED = 25; diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 88f40e54fa3b78d82261e06f941ef42587d52c25..cf42042c754b30e41c0ec8a6a15195369bdbd199 100644 +index 9c474f3e603c6c274610e15f184468dc640b5eb0..0856313f8da044bf021bf04f5ef67a17f4a9f7c6 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -518,6 +518,7 @@ public abstract class PlayerList { @@ -108,7 +108,7 @@ index 88f40e54fa3b78d82261e06f941ef42587d52c25..cf42042c754b30e41c0ec8a6a1519536 this.playerIo.save(player); ServerStatsCounter serverstatisticmanager = (ServerStatsCounter) player.getStats(); // CraftBukkit -@@ -1152,9 +1153,21 @@ public abstract class PlayerList { +@@ -1147,9 +1148,21 @@ public abstract class PlayerList { } public void saveAll() { diff --git a/patches/server/1051-Lag-compensation-ticks.patch b/patches/server/1051-Lag-compensation-ticks.patch index a919d8ba47..61cc0cc048 100644 --- a/patches/server/1051-Lag-compensation-ticks.patch +++ b/patches/server/1051-Lag-compensation-ticks.patch @@ -63,7 +63,7 @@ index 504c996220b278c194c93e001a3b326d549868ec..a96f859a5d0c6ec692d4627a69f3c9ee if (this.hasDelayedDestroy) { diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 2914be5f6681c513bf2878a92c0c60ad997852dc..0831d69d6ac1aa112dfe8243b01adcf5e8eba6a0 100644 +index a7a2306433014f45e2a448ebe125b668cc49b3d1..e3b81e5b2591fde8e15dfd0bee393000dd633096 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java @@ -4050,6 +4050,10 @@ public abstract class LivingEntity extends Entity implements Attackable {