Skip to content

Commit 102c8bb

Browse files
authored
Add config for updating equipment on player actions (#12275)
1 parent f4f2755 commit 102c8bb

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch

+12-12
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@
577577

578578
this.player.connection.send(new ClientboundSetHeldSlotPacket(inventory.selected));
579579
this.player.inventoryMenu.broadcastChanges();
580-
+ this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
580+
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
581581
}
582582
}
583583

@@ -1103,7 +1103,7 @@
11031103
+ }
11041104
+ // CraftBukkit end
11051105
this.player.stopUsingItem();
1106-
+ this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
1106+
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
11071107
}
11081108

11091109
return;
@@ -1125,21 +1125,21 @@
11251125
+ }
11261126
+ // CraftBukkit end
11271127
this.player.drop(false);
1128-
+ this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
1128+
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
11291129
}
11301130

11311131
return;
11321132
case DROP_ALL_ITEMS:
11331133
if (!this.player.isSpectator()) {
11341134
this.player.drop(true);
1135-
+ this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
1135+
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
11361136
}
11371137

11381138
return;
11391139
case RELEASE_USE_ITEM:
11401140
- this.player.releaseUsingItem();
11411141
+ if (this.player.getUseItem() == this.player.getItemInHand(this.player.getUsedItemHand())) this.player.releaseUsingItem(); // Paper - validate use item before processing release
1142-
+ this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
1142+
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
11431143
return;
11441144
case START_DESTROY_BLOCK:
11451145
case ABORT_DESTROY_BLOCK:
@@ -1172,7 +1172,7 @@
11721172
+ }
11731173
+ }
11741174
+ // Paper end - Send block entities after destroy prediction
1175-
+ this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
1175+
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
11761176
return;
11771177
default:
11781178
throw new IllegalArgumentException("Invalid player action");
@@ -1247,7 +1247,7 @@
12471247

12481248
this.player.connection.send(new ClientboundBlockUpdatePacket(serverLevel, blockPos));
12491249
this.player.connection.send(new ClientboundBlockUpdatePacket(serverLevel, blockPos.relative(direction)));
1250-
+ this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
1250+
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
12511251
} else {
12521252
LOGGER.warn(
12531253
"Rejecting UseItemOnPacket from {}: Location {} too far away from hit block {}.",
@@ -1397,7 +1397,7 @@
13971397

13981398
this.player.getInventory().selected = packet.getSlot();
13991399
this.player.resetLastActionTime();
1400-
+ this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
1400+
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
14011401
} else {
14021402
LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
14031403
+ this.disconnect(Component.literal("Invalid hotbar selection (Hacking?)"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // CraftBukkit // Paper - kick event cause
@@ -2004,7 +2004,7 @@
20042004
+ });
20052005
+ }
20062006
+ // Paper end - PlayerUseUnknownEntityEvent
2007-
+ this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
2007+
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
20082008
}
20092009
}
20102010

@@ -2410,7 +2410,7 @@
24102410
} else {
24112411
this.player.containerMenu.broadcastChanges();
24122412
}
2413-
+ this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
2413+
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
24142414
}
24152415
}
24162416
}
@@ -2487,7 +2487,7 @@
24872487
if (flag) {
24882488
this.player.containerMenu.broadcastChanges();
24892489
}
2490-
+ this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
2490+
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
24912491
}
24922492
}
24932493
}
@@ -2536,7 +2536,7 @@
25362536
this.player.inventoryMenu.getSlot(packet.slotNum()).setByPlayer(itemStack);
25372537
this.player.inventoryMenu.setRemoteSlot(packet.slotNum(), itemStack);
25382538
this.player.inventoryMenu.broadcastChanges();
2539-
+ this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
2539+
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes.
25402540
} else if (flag && flag2) {
25412541
if (this.dropSpamThrottler.isUnderThreshold()) {
25422542
this.dropSpamThrottler.increment();

paper-server/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java

+2
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ public class UnsupportedSettings extends ConfigurationPart {
184184
public boolean skipVanillaDamageTickWhenShieldBlocked = false;
185185
@Comment("This setting controls what compression format is used for region files.")
186186
public CompressionFormat compressionFormat = CompressionFormat.ZLIB;
187+
@Comment("This setting controls if equipment should be updated when handling certain player actions.")
188+
public boolean updateEquipmentOnPlayerActions = true;
187189

188190
public enum CompressionFormat {
189191
GZIP,

0 commit comments

Comments
 (0)