Finish PlayerPickItemEvent

This commit is contained in:
Nassim Jahnke 2024-12-05 10:27:55 +01:00
parent bb4fb5334e
commit ae060b31f0
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F
16 changed files with 64 additions and 58 deletions

View File

@ -6,10 +6,10 @@ Subject: [PATCH] Add PlayerPickItemEvent
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerPickItemEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerPickItemEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..d7e10652918e453838a3a983f089ef4727d0bfe2
index 0000000000000000000000000000000000000000..e9b968ebd771b9d4c94d7b219ea2b68c1f871733
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/player/PlayerPickItemEvent.java
@@ -0,0 +1,93 @@
@@ -0,0 +1,97 @@
+package io.papermc.paper.event.player;
+
+import com.google.common.base.Preconditions;
@ -67,20 +67,24 @@ index 0000000000000000000000000000000000000000..d7e10652918e453838a3a983f089ef47
+
+ /**
+ * Returns the slot in which the item that will be put into the players hotbar is located.
+ * <p>
+ * Returns {@code -1} if the item is not in the player's inventory and should be spawned in if in creative mode.
+ *
+ * @return player inventory slot (0-35 inclusive)
+ * @return player inventory slot (0-35 inclusive, or {@code -1} not taken from the inventory)
+ */
+ public @Range(from = 0, to = 35) int getSourceSlot() {
+ public @Range(from = -1, to = 35) int getSourceSlot() {
+ return this.sourceSlot;
+ }
+
+ /**
+ * Change the source slot from which the item that will be put in the players hotbar will be taken.
+ * <p>
+ * If set to {@code -1} and the player is in creative mode, the item will be spawned in.
+ *
+ * @param sourceSlot player inventory slot (0-35 inclusive)
+ * @param sourceSlot player inventory slot (0-35 inclusive, or {@code -1} not taken from the inventory)
+ */
+ public void setSourceSlot(final @Range(from = 0, to = 35) int sourceSlot) {
+ Preconditions.checkArgument(sourceSlot >= 0 && sourceSlot <= 35, "Source slot must be in range of the player's inventory slot");
+ public void setSourceSlot(final @Range(from = -1, to = 35) int sourceSlot) {
+ Preconditions.checkArgument(sourceSlot >= -1 && sourceSlot <= 35, "Source slot must be in range of the player's inventory slot");
+ this.sourceSlot = sourceSlot;
+ }
+

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Add PlayerPickItemEvent
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index a2c404e4cd808a3a676ae3808852e4105bdc9af4..755b43f5b247361f234430e1fd40a662415540c3 100644
index a2c404e4cd808a3a676ae3808852e4105bdc9af4..b5a960f9d1b169a6a39e3ab289e4abf161c3ac2c 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -994,15 +994,24 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -994,15 +994,25 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
if (stack.isItemEnabled(this.player.level().enabledFeatures())) {
Inventory playerinventory = this.player.getInventory();
int i = playerinventory.findSlotMatchingItem(stack);
@ -20,19 +20,21 @@ index a2c404e4cd808a3a676ae3808852e4105bdc9af4..755b43f5b247361f234430e1fd40a662
+ if (!event.callEvent()) {
+ return;
+ }
+ // Paper end - Add PlayerPickItemEvent
+ i = event.getSourceSlot();
if (i != -1) {
if (Inventory.isHotbarSlot(i)) {
- if (Inventory.isHotbarSlot(i)) {
- playerinventory.selected = i;
+ playerinventory.selected = event.getTargetSlot(); // Paper - Add target slot
+ if (Inventory.isHotbarSlot(i) && Inventory.isHotbarSlot(event.getTargetSlot())) {
+ playerinventory.selected = event.getTargetSlot();
} else {
- playerinventory.pickSlot(i);
+ playerinventory.pickSlot(i, event.getTargetSlot()); // Paper - Add target slot
+ playerinventory.pickSlot(i, event.getTargetSlot());
}
} else if (this.player.hasInfiniteMaterials()) {
- playerinventory.addAndPickItem(stack);
+ playerinventory.addAndPickItem(stack, event.getTargetSlot()); // Paper - Add target slot
+ playerinventory.addAndPickItem(stack, event.getTargetSlot());
+ // Paper end - Add PlayerPickItemEvent
}
this.player.connection.send(new ClientboundSetHeldSlotPacket(playerinventory.selected));

View File

@ -10,7 +10,7 @@ Co-authored-by: Minecrell <minecrell@minecrell.net>
Co-authored-by: Newwind <support@newwindserver.com>
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index a5eaac3fb6d949098a9fca20d9dbff59c56773ed..bfaf2cc79afebb0b51f6eb7081de2230546752ef 100644
index 07f14652768d4715eb9053b5a8381816a61b0d28..9eb5848b02fed596af8d5d99d9e5aaf1f1a34a76 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -458,6 +458,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player {
@ -22,10 +22,10 @@ index a5eaac3fb6d949098a9fca20d9dbff59c56773ed..bfaf2cc79afebb0b51f6eb7081de2230
this.containerMenu.findSlot(this.getInventory(), this.getInventory().selected).ifPresent(s -> {
this.containerSynchronizer.sendSlotChange(this.containerMenu, s, this.getMainHandItem());
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 755b43f5b247361f234430e1fd40a662415540c3..c892e12ea0d6408bde20402f18868d4d3f3e4f65 100644
index b5a960f9d1b169a6a39e3ab289e4abf161c3ac2c..b682a766b1e085509d741d6a831a65bf49b6907f 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2812,10 +2812,11 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2813,10 +2813,11 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
// Refresh the current entity metadata
entity.refreshEntityData(ServerGamePacketListenerImpl.this.player);
// SPIGOT-7136 - Allays
@ -40,7 +40,7 @@ index 755b43f5b247361f234430e1fd40a662415540c3..c892e12ea0d6408bde20402f18868d4d
if (event.isCancelled()) {
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index aa317a143e2c38a0385a83651a78403401a75d9e..1c070437ef763b56791d61b8c36e623c3dc80649 100644
index 96c252a797a971f36ccaf83ee00da27cf38a2f6c..098a526fdfe92e452f06b66189cd9cbd821198eb 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2783,8 +2783,9 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Add slot sanity checks in container clicks
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index c892e12ea0d6408bde20402f18868d4d3f3e4f65..76fdf92b933b5fbb21eb511932fdf8e299a44377 100644
index b682a766b1e085509d741d6a831a65bf49b6907f..c442743e70e1985dc596ba948fa97f0475a4c11e 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -3075,6 +3075,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -3076,6 +3076,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
break;
case SWAP:
if ((packet.getButtonNum() >= 0 && packet.getButtonNum() < 9) || packet.getButtonNum() == 40) {

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Add CartographyItemEvent
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 76fdf92b933b5fbb21eb511932fdf8e299a44377..e9478fed28995a3ce5527e80232203eed503104c 100644
index c442743e70e1985dc596ba948fa97f0475a4c11e..367df4b4bc9506469c68fcab2ef196d88abf7f97 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -3197,6 +3197,19 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -3198,6 +3198,19 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
}
}

View File

@ -2328,10 +2328,10 @@ index ebe6a002d883721d80cbfcc004064e8a57934a56..cce0e570c8217c8e7cc81642d303e1b9
this.setPvpAllowed(dedicatedserverproperties.pvp);
this.setFlightAllowed(dedicatedserverproperties.allowFlight);
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index a13c199446423dbc807f916157bb7cac33229389..929cd59b8f27d7b708054d80e764a11d6551f060 100644
index 4186bcf9f0ee21fba1c643b7da5b596f87f2dc92..a5ff6d2d4648f3ed4860b8812c6af48cdd6884fa 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2489,30 +2489,20 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2490,30 +2490,20 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
}
}

View File

@ -209,10 +209,10 @@ index ce3e359ed2b29674aa89a714ee1fb0875d83595d..d5bc702f2676b1b7a32c8f3a4a349fc2
((LivingEntity) this.entity).detectEquipmentUpdatesPublic(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending
}
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 929cd59b8f27d7b708054d80e764a11d6551f060..1afe77b2aea43a51e2e99284c86d93a5bd4d1ee7 100644
index a5ff6d2d4648f3ed4860b8812c6af48cdd6884fa..ed4b69bc1875f1d90b02166d62078137c41e07a5 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2817,7 +2817,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2818,7 +2818,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
entity.refreshEntityData(ServerGamePacketListenerImpl.this.player);
// SPIGOT-7136 - Allays
if (entity instanceof Allay || entity instanceof net.minecraft.world.entity.animal.horse.AbstractHorse) { // Paper - Fix horse armor desync

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Deprecate InvAction#HOTBAR_MOVE_AND_READD
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 1afe77b2aea43a51e2e99284c86d93a5bd4d1ee7..bef4687218c4ee7a7c03a7027fb92fcad403c37c 100644
index ed4b69bc1875f1d90b02166d62078137c41e07a5..401f4a071847cb987dbff3ae0e989d3a04fd9a7d 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -3089,14 +3089,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -3090,14 +3090,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
Slot clickedSlot = this.player.containerMenu.getSlot(packet.getSlotNum());
if (clickedSlot.mayPickup(this.player)) {
ItemStack hotbar = this.player.getInventory().getItem(packet.getButtonNum());

View File

@ -83,10 +83,10 @@ index f2dd272a01b4e946a6746865d55ebc9861f8361b..5d189ba60d40f5c42b2dacc339594ed0
}
}
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index bef4687218c4ee7a7c03a7027fb92fcad403c37c..43cf3510750ca3a1be8c61afaa94b0f8e2127eb5 100644
index 401f4a071847cb987dbff3ae0e989d3a04fd9a7d..719e9e4df3b833c4ac0418f7db913c45a1020b44 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2025,6 +2025,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2026,6 +2026,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
}
if (cancelled) {
@ -94,7 +94,7 @@ index bef4687218c4ee7a7c03a7027fb92fcad403c37c..43cf3510750ca3a1be8c61afaa94b0f8
this.player.getBukkitEntity().updateInventory(); // SPIGOT-2524
return;
}
@@ -2803,7 +2804,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2804,7 +2805,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
// Entity in bucket - SPIGOT-4048 and SPIGOT-6859a
if ((entity instanceof Bucketable && entity instanceof LivingEntity && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelected() == null || ServerGamePacketListenerImpl.this.player.getInventory().getSelected().getItem() != origItem)) {
@ -136,7 +136,7 @@ index 0a328ec362c3c21b5b8634f8fba844b143a24509..2d4baf17b1994647fd91083850363a36
}
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 4f43f7892debfb59308d81b2647867c8b1f1b007..89e898e14c0a6388bbd76a2f74828cf6cd46e7a9 100644
index f4701ead72ca871792b599903e61cc94392067c3..717c1a43352d48e8b0744cf1dcf31d6754428b1f 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -599,13 +599,45 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess

View File

@ -12,10 +12,10 @@ This value however may be too low in high latency environments.
The patch exposes a new configuration option to configure said value.
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 43cf3510750ca3a1be8c61afaa94b0f8e2127eb5..a582eeaa63a4f5018898fc9a1f9a5efb2664fa59 100644
index 719e9e4df3b833c4ac0418f7db913c45a1020b44..7d1f62e5ff87c946e03211af8e93e68f44945d41 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2788,7 +2788,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2789,7 +2789,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
AABB axisalignedbb = entity.getBoundingBox();

View File

@ -10,10 +10,10 @@ public net.minecraft.world.inventory.AbstractContainerMenu quickcraftType
public net.minecraft.world.inventory.AbstractContainerMenu resetQuickCraft()V
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index a582eeaa63a4f5018898fc9a1f9a5efb2664fa59..71a314d3d38df0e982aef631ce50bd3b27bd6b20 100644
index 7d1f62e5ff87c946e03211af8e93e68f44945d41..1d55650b44ebd9f8f1b968db6ec9a239072b1fa5 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -3147,6 +3147,25 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -3148,6 +3148,25 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
}
break;
case QUICK_CRAFT:

View File

@ -9,10 +9,10 @@ In the case where multiple messages from different players are being processed i
This also applies to the last seen state of the server, which becomes inconsistent in the same way as the message signature cache and would cause any messages sent to be rejected by the server too.
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 71a314d3d38df0e982aef631ce50bd3b27bd6b20..12b2776dd0caa37214a025ea360a8e60e1783653 100644
index 1d55650b44ebd9f8f1b968db6ec9a239072b1fa5..db5398cf02034075a857b8606b247cbc667542c0 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2728,8 +2728,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2729,8 +2729,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
return;
}
// CraftBukkit end

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Fix PlayerCommandPreprocessEvent on signed commands
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 12b2776dd0caa37214a025ea360a8e60e1783653..51f9e899b56342008a21449e92199da2d4b9389d 100644
index db5398cf02034075a857b8606b247cbc667542c0..dffaf05fe84809e1597451244e729a9d1a85d8e2 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2255,24 +2255,32 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2256,24 +2256,32 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(this.getCraftPlayer(), command, new LazyPlayerSet(this.server));
this.cserver.getPluginManager().callEvent(event);

View File

@ -74,7 +74,7 @@ index fc242acade3ff06c9213428cde103cf078216382..b0bc66dc7248aae691dcab68b925b52a
return this.server.isSingleplayerOwner(this.playerProfile());
}
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 51f9e899b56342008a21449e92199da2d4b9389d..5dc2d70fc024ebea971ba536e8493a4ee56c4957 100644
index dffaf05fe84809e1597451244e729a9d1a85d8e2..864c9203f65c24d288d9ac1d39e8b5fc84da18e5 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -767,7 +767,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@ -95,7 +95,7 @@ index 51f9e899b56342008a21449e92199da2d4b9389d..5dc2d70fc024ebea971ba536e8493a4e
return;
}
// Paper end
@@ -1224,14 +1224,14 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -1225,14 +1225,14 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
if (byteTotal > byteAllowed) {
ServerGamePacketListenerImpl.LOGGER.warn("{} tried to send a book too large. Book size: {} - Allowed: {} - Pages: {}", this.player.getScoreboardName(), byteTotal, byteAllowed, pageList.size());
@ -112,7 +112,7 @@ index 51f9e899b56342008a21449e92199da2d4b9389d..5dc2d70fc024ebea971ba536e8493a4e
return;
}
this.lastBookTick = MinecraftServer.currentTick;
@@ -2364,7 +2364,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2365,7 +2365,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
private void tryHandleChat(String s, Runnable runnable, boolean sync) { // CraftBukkit
if (ServerGamePacketListenerImpl.isChatMessageIllegal(s)) {
@ -121,7 +121,7 @@ index 51f9e899b56342008a21449e92199da2d4b9389d..5dc2d70fc024ebea971ba536e8493a4e
} else if (this.player.isRemoved() || this.player.getChatVisibility() == ChatVisiblity.HIDDEN) { // CraftBukkit - dead men tell no tales
this.send(new ClientboundSystemChatPacket(Component.translatable("chat.disabled.options").withStyle(ChatFormatting.RED), false));
} else {
@@ -2387,7 +2387,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2388,7 +2388,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
if (optional.isEmpty()) {
ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString());
@ -130,7 +130,7 @@ index 51f9e899b56342008a21449e92199da2d4b9389d..5dc2d70fc024ebea971ba536e8493a4e
}
return optional;
@@ -2558,7 +2558,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2559,7 +2559,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
// this.chatSpamThrottler.increment();
if (!this.chatSpamThrottler.isIncrementAndUnderThreshold() && !this.server.getPlayerList().isOp(this.player.getGameProfile()) && !this.server.isSingleplayerOwner(this.player.getGameProfile())) {
// CraftBukkit end
@ -139,7 +139,7 @@ index 51f9e899b56342008a21449e92199da2d4b9389d..5dc2d70fc024ebea971ba536e8493a4e
}
}
@@ -2570,7 +2570,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2571,7 +2571,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
synchronized (this.lastSeenMessages) {
if (!this.lastSeenMessages.applyOffset(packet.offset())) {
ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString());
@ -148,7 +148,7 @@ index 51f9e899b56342008a21449e92199da2d4b9389d..5dc2d70fc024ebea971ba536e8493a4e
}
}
@@ -2723,7 +2723,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -2724,7 +2724,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
}
if (i > 4096) {
@ -157,7 +157,7 @@ index 51f9e899b56342008a21449e92199da2d4b9389d..5dc2d70fc024ebea971ba536e8493a4e
}
}
@@ -3334,7 +3334,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -3335,7 +3335,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
// Paper start - auto recipe limit
if (!org.bukkit.Bukkit.isPrimaryThread()) {
if (!this.recipeSpamPackets.isIncrementAndUnderThreshold()) {

View File

@ -8,7 +8,7 @@ Move collision logic to just the hasNewCollision call instead of getCubes + hasN
Feature patch
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 5dc2d70fc024ebea971ba536e8493a4ee56c4957..68ab52dfdc5599143ce53c930064ef35cd3e2362 100644
index 864c9203f65c24d288d9ac1d39e8b5fc84da18e5..9090df6431758a143a6b29be34eb5e60d5af4561 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -579,7 +579,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@ -89,7 +89,7 @@ index 5dc2d70fc024ebea971ba536e8493a4ee56c4957..68ab52dfdc5599143ce53c930064ef35
}
@Override
@@ -1451,7 +1485,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -1452,7 +1486,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
}
}
@ -98,7 +98,7 @@ index 5dc2d70fc024ebea971ba536e8493a4ee56c4957..68ab52dfdc5599143ce53c930064ef35
d6 = d0 - this.lastGoodX; // Paper - diff on change, used for checking large move vectors above
d7 = d1 - this.lastGoodY; // Paper - diff on change, used for checking large move vectors above
@@ -1493,6 +1527,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -1494,6 +1528,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
this.player.move(MoverType.PLAYER, new Vec3(d6, d7, d8));
this.player.onGround = packet.isOnGround(); // CraftBukkit - SPIGOT-5810, SPIGOT-5835, SPIGOT-6828: reset by this.player.move
@ -106,7 +106,7 @@ index 5dc2d70fc024ebea971ba536e8493a4ee56c4957..68ab52dfdc5599143ce53c930064ef35
// Paper start - prevent position desync
if (this.awaitingPositionFromClient != null) {
return; // ... thanks Mojang for letting move calls teleport across dimensions.
@@ -1523,7 +1558,17 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -1524,7 +1559,17 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
}
// Paper start - Add fail move event
@ -125,7 +125,7 @@ index 5dc2d70fc024ebea971ba536e8493a4ee56c4957..68ab52dfdc5599143ce53c930064ef35
if (teleportBack) {
io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.CLIPPED_INTO_BLOCK,
toX, toY, toZ, toYaw, toPitch, false);
@@ -1647,7 +1692,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -1648,7 +1693,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
private boolean updateAwaitingTeleport() {
if (this.awaitingPositionFromClient != null) {
@ -134,7 +134,7 @@ index 5dc2d70fc024ebea971ba536e8493a4ee56c4957..68ab52dfdc5599143ce53c930064ef35
this.awaitingTeleportTime = this.tickCount;
this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
}
@@ -1660,6 +1705,33 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -1661,6 +1706,33 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
}
}

View File

@ -10,10 +10,10 @@ now leads to an IOOB.
patch uses instead.
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 68ab52dfdc5599143ce53c930064ef35cd3e2362..2fbe3d8722eeacc3b27ce38145aeffa610f9daab 100644
index 9090df6431758a143a6b29be34eb5e60d5af4561..84fa24880d02dc7ba1ec8bda3575be38447fd4b2 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -3353,7 +3353,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -3354,7 +3354,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
case PLACE_SOME:
case PLACE_ONE:
case SWAP_WITH_CURSOR:
@ -22,7 +22,7 @@ index 68ab52dfdc5599143ce53c930064ef35cd3e2362..2fbe3d8722eeacc3b27ce38145aeffa6
this.player.connection.send(new ClientboundContainerSetSlotPacket(this.player.containerMenu.containerId, this.player.inventoryMenu.incrementStateId(), packet.getSlotNum(), this.player.containerMenu.getSlot(packet.getSlotNum()).getItem()));
break;
// Modified clicked only
@@ -3365,7 +3365,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -3366,7 +3366,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
case DROP_ALL_CURSOR:
case DROP_ONE_CURSOR:
case CLONE_STACK:
@ -31,7 +31,7 @@ index 68ab52dfdc5599143ce53c930064ef35cd3e2362..2fbe3d8722eeacc3b27ce38145aeffa6
break;
// Nothing
case NOTHING:
@@ -3543,7 +3543,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -3544,7 +3544,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
// Reset the slot
if (packet.slotNum() >= 0) {
this.player.connection.send(new ClientboundContainerSetSlotPacket(this.player.inventoryMenu.containerId, this.player.inventoryMenu.incrementStateId(), packet.slotNum(), this.player.inventoryMenu.getSlot(packet.slotNum()).getItem()));