Skip to content

Commit be8889d

Browse files
committed
getSelected to getSelectedItem
1 parent fd4c6f1 commit be8889d

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

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

+10-10
Original file line numberDiff line numberDiff line change
@@ -1766,13 +1766,13 @@
17661766
+ return entity != this.player.getBukkitEntity() && this.player.getBukkitEntity().canSee(entity) && !handle.isSpectator() && handle.isPickable() && !handle.isPassengerOfSameVehicle(this.player);
17671767
+ });
17681768
+ if (result == null) {
1769-
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND);
1769+
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelectedItem(), InteractionHand.MAIN_HAND);
17701770
+ } else { // Paper start - Call interact event
17711771
+ GameType gameType = this.player.gameMode.getGameModeForPlayer();
17721772
+ if (gameType == GameType.ADVENTURE && result.getHitBlock() != null) {
1773-
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, ((org.bukkit.craftbukkit.block.CraftBlock) result.getHitBlock()).getPosition(), org.bukkit.craftbukkit.block.CraftBlock.blockFaceToNotch(result.getHitBlockFace()), this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND);
1773+
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, ((org.bukkit.craftbukkit.block.CraftBlock) result.getHitBlock()).getPosition(), org.bukkit.craftbukkit.block.CraftBlock.blockFaceToNotch(result.getHitBlockFace()), this.player.getInventory().getSelectedItem(), InteractionHand.MAIN_HAND);
17741774
+ } else if (gameType != GameType.CREATIVE && result.getHitEntity() != null && origin.toVector().distanceSquared(result.getHitPosition()) > this.player.entityInteractionRange() * this.player.entityInteractionRange()) {
1775-
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND);
1775+
+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelectedItem(), InteractionHand.MAIN_HAND);
17761776
+ }
17771777
+ } // Paper end - Call interact event
17781778
+
@@ -1908,22 +1908,22 @@
19081908
- {
19091909
+ // CraftBukkit start
19101910
+ boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEAD && target instanceof net.minecraft.world.entity.Mob;
1911-
+ Item origItem = ServerGamePacketListenerImpl.this.player.getInventory().getSelected() == null ? null : ServerGamePacketListenerImpl.this.player.getInventory().getSelected().getItem();
1911+
+ Item origItem = ServerGamePacketListenerImpl.this.player.getInventory().getSelectedItem().isEmpty() ? null : ServerGamePacketListenerImpl.this.player.getInventory().getSelectedItem().getItem();
19121912
+
19131913
+ ServerGamePacketListenerImpl.this.cserver.getPluginManager().callEvent(event);
19141914
+
19151915
+ // Entity in bucket - SPIGOT-4048 and SPIGOT-6859a
1916-
+ if ((target instanceof Bucketable && target instanceof LivingEntity && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelected() == null || ServerGamePacketListenerImpl.this.player.getInventory().getSelected().getItem() != origItem)) {
1916+
+ if ((target instanceof Bucketable && target instanceof LivingEntity && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelectedItem().isEmpty() || ServerGamePacketListenerImpl.this.player.getInventory().getSelectedItem().getItem() != origItem)) {
19171917
+ target.resendPossiblyDesyncedEntityData(ServerGamePacketListenerImpl.this.player); // Paper - The entire mob gets deleted, so resend it
19181918
+ ServerGamePacketListenerImpl.this.player.containerMenu.sendAllDataToRemote();
19191919
+ }
19201920
+
1921-
+ if (triggerLeashUpdate && (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelected() == null || ServerGamePacketListenerImpl.this.player.getInventory().getSelected().getItem() != origItem)) {
1921+
+ if (triggerLeashUpdate && (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelectedItem().isEmpty() || ServerGamePacketListenerImpl.this.player.getInventory().getSelectedItem().getItem() != origItem)) {
19221922
+ // Refresh the current leash state
19231923
+ ServerGamePacketListenerImpl.this.send(new net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket(target, ((net.minecraft.world.entity.Mob) target).getLeashHolder()));
19241924
+ }
19251925
+
1926-
+ if (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelected() == null || ServerGamePacketListenerImpl.this.player.getInventory().getSelected().getItem() != origItem) {
1926+
+ if (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelectedItem().isEmpty() || ServerGamePacketListenerImpl.this.player.getInventory().getSelectedItem().getItem() != origItem) {
19271927
+ // Refresh the current entity metadata
19281928
+ target.refreshEntityData(ServerGamePacketListenerImpl.this.player);
19291929
+ // SPIGOT-7136 - Allays
@@ -2276,13 +2276,13 @@
22762276
+ if (this.player.containerMenu.quickcraftSlots.size() == 1) {
22772277
+ int index = containerMenu.quickcraftSlots.iterator().next().index;
22782278
+ containerMenu.resetQuickCraft();
2279-
+ this.handleContainerClick(new ServerboundContainerClickPacket(packet.getContainerId(), packet.getStateId(), index, containerMenu.quickcraftType, net.minecraft.world.inventory.ClickType.PICKUP, packet.getCarriedItem(), packet.getChangedSlots()));
2279+
+ this.handleContainerClick(new ServerboundContainerClickPacket(packet.containerId(), packet.stateId(), (short) index, (byte) containerMenu.quickcraftType, net.minecraft.world.inventory.ClickType.PICKUP, packet.changedSlots(), packet.carriedItem()));
22802280
+ return;
22812281
+ }
22822282
+ }
22832283
+ }
22842284
+ // Paper end - Fix CraftBukkit drag system
2285-
+ this.player.containerMenu.clicked(slotNum, packet.buttonNum(), packet.getClickType(), this.player);
2285+
+ this.player.containerMenu.clicked(slotNum, packet.buttonNum(), packet.clickType(), this.player);
22862286
+ break;
22872287
+ case PICKUP_ALL:
22882288
+ click = ClickType.DOUBLE_CLICK;
@@ -2353,7 +2353,7 @@
23532353
+ switch (event.getResult()) {
23542354
+ case ALLOW:
23552355
+ case DEFAULT:
2356-
+ this.player.containerMenu.clicked(slotNum, packet.buttonNum(), packet.getClickType(), this.player);
2356+
+ this.player.containerMenu.clicked(slotNum, packet.buttonNum(), packet.clickType(), this.player);
23572357
+ break;
23582358
+ case DENY:
23592359
+ /* Needs enum constructor in InventoryAction

paper-server/patches/sources/net/minecraft/world/level/block/Block.java.patch

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
if (level instanceof ServerLevel) {
6363
getDrops(state, (ServerLevel)level, pos, blockEntity, entity, tool).forEach(stack -> popResource(level, pos, stack));
6464
- state.spawnAfterBreak((ServerLevel)level, pos, tool, true);
65-
+ state.spawnAfterBreak((ServerLevel)level, pos, tool, true, dropExperience); // Paper - Properly handle xp dropping
65+
+ state.spawnAfterBreak((ServerLevel)level, pos, tool, dropExperience); // Paper - Properly handle xp dropping
6666
}
6767
}
6868

0 commit comments

Comments
 (0)