Add PlayerRecipeBookClickEvent

This commit is contained in:
JRoy 2020-06-05 18:24:06 -04:00
parent 1b1ab34ecd
commit 6a6851c040

View file

@ -48,7 +48,7 @@
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.Level;
@@ -192,11 +196,71 @@
@@ -192,11 +196,72 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
@ -57,6 +57,7 @@
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
+import org.bukkit.NamespacedKey;
import org.slf4j.Logger;
+
+// CraftBukkit start
@ -120,7 +121,7 @@
public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl implements ServerGamePacketListener, ServerPlayerConnection, TickablePacketListener {
@@ -212,6 +276,7 @@
@@ -212,6 +277,7 @@
private int tickCount;
private int ackBlockChangesUpTo = -1;
private final TickThrottler chatSpamThrottler = new TickThrottler(20, 200);
@ -128,7 +129,7 @@
private final TickThrottler dropSpamThrottler = new TickThrottler(20, 1480);
private double firstGoodX;
private double firstGoodY;
@@ -245,9 +310,10 @@
@@ -245,9 +311,10 @@
private final MessageSignatureCache messageSignatureCache = MessageSignatureCache.createDefault();
private final FutureChain chatMessageChain;
private boolean waitingForSwitchToConfig;
@ -140,7 +141,7 @@
this.chunkSender = new PlayerChunkSender(connection.isMemoryConnection());
this.player = player;
player.connection = this;
@@ -256,9 +322,25 @@
@@ -256,9 +323,25 @@
Objects.requireNonNull(server);
this.signedMessageDecoder = SignedMessageChain.Decoder.unsigned(uuid, server::enforceSecureProfile);
@ -167,7 +168,7 @@
@Override
public void tick() {
if (this.ackBlockChangesUpTo > -1) {
@@ -277,7 +359,7 @@
@@ -277,7 +360,7 @@
if (this.clientIsFloating && !this.player.isSleeping() && !this.player.isPassenger() && !this.player.isDeadOrDying()) {
if (++this.aboveGroundTickCount > this.getMaximumFlyingTicks(this.player)) {
ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked for floating too long!", this.player.getName().getString());
@ -176,7 +177,7 @@
return;
}
} else {
@@ -296,7 +378,7 @@
@@ -296,7 +379,7 @@
if (this.clientVehicleIsFloating && this.lastVehicle.getControllingPassenger() == this.player) {
if (++this.aboveGroundVehicleTickCount > this.getMaximumFlyingTicks(this.lastVehicle)) {
ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked for floating a vehicle too long!", this.player.getName().getString());
@ -185,7 +186,7 @@
return;
}
} else {
@@ -311,8 +393,10 @@
@@ -311,8 +394,10 @@
this.keepConnectionAlive();
this.chatSpamThrottler.tick();
@ -196,7 +197,7 @@
this.disconnect((Component) Component.translatable("multiplayer.disconnect.idling"));
}
@@ -376,6 +460,12 @@
@@ -376,6 +461,12 @@
@Override
public void handlePlayerInput(ServerboundPlayerInputPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -209,7 +210,7 @@
this.player.setLastClientInput(packet.input());
}
@@ -401,12 +491,19 @@
@@ -401,12 +492,19 @@
if (entity != this.player && entity.getControllingPassenger() == this.player && entity == this.lastVehicle) {
ServerLevel worldserver = this.player.serverLevel();
@ -232,7 +233,7 @@
float f = Mth.wrapDegrees(packet.yRot());
float f1 = Mth.wrapDegrees(packet.xRot());
double d6 = d3 - this.vehicleFirstGoodX;
@@ -415,7 +512,43 @@
@@ -415,7 +513,43 @@
double d9 = entity.getDeltaMovement().lengthSqr();
double d10 = d6 * d6 + d7 * d7 + d8 * d8;
@ -277,7 +278,7 @@
ServerGamePacketListenerImpl.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8});
this.send(ClientboundMoveVehiclePacket.fromEntity(entity));
return;
@@ -449,19 +582,72 @@
@@ -449,19 +583,72 @@
d10 = d6 * d6 + d7 * d7 + d8 * d8;
boolean flag2 = false;
@ -351,7 +352,7 @@
this.player.serverLevel().getChunkSource().move(this.player);
entity.recordMovementThroughBlocks(new Vec3(d0, d1, d2), entity.position());
@@ -499,6 +685,7 @@
@@ -499,6 +686,7 @@
this.lastGoodZ = this.awaitingPositionFromClient.z;
this.player.hasChangedDimension();
this.awaitingPositionFromClient = null;
@ -359,7 +360,7 @@
}
}
@@ -528,6 +715,7 @@
@@ -528,6 +716,7 @@
@Override
public void handleRecipeBookChangeSettingsPacket(ServerboundRecipeBookChangeSettingsPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -367,7 +368,7 @@
this.player.getRecipeBook().setBookSetting(packet.getBookType(), packet.isOpen(), packet.isFiltering());
}
@@ -545,21 +733,80 @@
@@ -545,21 +734,80 @@
}
@ -452,7 +453,7 @@
});
}
@@ -668,7 +915,7 @@
@@ -668,7 +916,7 @@
ItemStack itemstack = iblockdata.getCloneItemStack(worldserver, blockposition, flag);
if (!itemstack.isEmpty()) {
@ -461,7 +462,7 @@
ServerGamePacketListenerImpl.addBlockDataToItem(iblockdata, worldserver, blockposition, itemstack);
}
@@ -866,6 +1113,13 @@
@@ -866,6 +1114,13 @@
AbstractContainerMenu container = this.player.containerMenu;
if (container instanceof MerchantMenu containermerchant) {
@ -475,7 +476,7 @@
if (!containermerchant.stillValid(this.player)) {
ServerGamePacketListenerImpl.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, containermerchant);
return;
@@ -879,6 +1133,51 @@
@@ -879,6 +1134,51 @@
@Override
public void handleEditBook(ServerboundEditBookPacket packet) {
@ -527,7 +528,7 @@
int i = packet.slot();
if (Inventory.isHotbarSlot(i) || i == 40) {
@@ -899,12 +1198,16 @@
@@ -899,12 +1199,16 @@
}
private void updateBookContents(List<FilteredText> pages, int slotId) {
@ -545,7 +546,7 @@
}
}
@@ -915,12 +1218,13 @@
@@ -915,12 +1219,13 @@
ItemStack itemstack1 = itemstack.transmuteCopy(Items.WRITTEN_BOOK);
itemstack1.remove(DataComponents.WRITABLE_BOOK_CONTENT);
@ -561,7 +562,7 @@
}
}
@@ -982,22 +1286,30 @@
@@ -982,22 +1287,30 @@
} else {
ServerLevel worldserver = this.player.serverLevel();
@ -596,7 +597,7 @@
double d3 = this.player.getX();
double d4 = this.player.getY();
double d5 = this.player.getZ();
@@ -1019,15 +1331,39 @@
@@ -1019,15 +1332,39 @@
++this.receivedMovePacketCount;
int i = this.receivedMovePacketCount - this.knownMovePacketCount;
@ -609,8 +610,8 @@
+ if (i > Math.max(this.allowedPlayerTicks, 5)) {
ServerGamePacketListenerImpl.LOGGER.debug("{} is sending move packets too frequently ({} packets since last tick)", this.player.getName().getString(), i);
i = 1;
}
+ }
+
+ if (packet.hasRot || d10 > 0) {
+ this.allowedPlayerTicks -= 1;
+ } else {
@ -626,9 +627,9 @@
+ if (this.player.level().paperConfig().chunks.preventMovingIntoUnloadedChunks && (this.player.getX() != toX || this.player.getZ() != toZ) && !worldserver.areChunksLoadedForMove(this.player.getBoundingBox().expandTowards(new Vec3(toX, toY, toZ).subtract(this.player.position())))) {
+ this.internalTeleport(PositionMoveRotation.of(this.player), Collections.emptySet());
+ return;
+ }
}
+ // Paper end - Prevent moving into unloaded chunks
+
if (this.shouldCheckPlayerMovement(flag)) {
float f2 = flag ? 300.0F : 100.0F;
@ -638,7 +639,7 @@
ServerGamePacketListenerImpl.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d6, d7, d8});
this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot());
return;
@@ -1043,12 +1379,45 @@
@@ -1043,12 +1380,45 @@
boolean flag1 = d7 > 0.0D;
if (this.player.onGround() && !packet.isOnGround() && flag1) {
@ -685,7 +686,7 @@
double d11 = d7;
d6 = d0 - this.player.getX();
@@ -1061,15 +1430,81 @@
@@ -1061,15 +1431,81 @@
d10 = d6 * d6 + d7 * d7 + d8 * d8;
boolean flag3 = false;
@ -769,7 +770,7 @@
this.player.absMoveTo(d0, d1, d2, f, f1);
boolean flag4 = this.player.isAutoSpinAttack();
@@ -1119,6 +1554,7 @@
@@ -1119,6 +1555,7 @@
this.awaitingTeleportTime = this.tickCount;
this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
}
@ -777,7 +778,7 @@
return true;
} else {
@@ -1147,23 +1583,90 @@
@@ -1147,23 +1584,90 @@
}
public void teleport(double x, double y, double z, float yaw, float pitch) {
@ -871,7 +872,7 @@
if (this.player.hasClientLoaded()) {
BlockPos blockposition = packet.getPos();
@@ -1175,14 +1678,46 @@
@@ -1175,14 +1679,46 @@
if (!this.player.isSpectator()) {
ItemStack itemstack = this.player.getItemInHand(InteractionHand.OFF_HAND);
@ -920,7 +921,7 @@
this.player.drop(false);
}
@@ -1199,6 +1734,12 @@
@@ -1199,6 +1735,12 @@
case START_DESTROY_BLOCK:
case ABORT_DESTROY_BLOCK:
case STOP_DESTROY_BLOCK:
@ -933,7 +934,7 @@
this.player.gameMode.handleBlockBreakAction(blockposition, packetplayinblockdig_enumplayerdigtype, packet.getDirection(), this.player.level().getMaxY(), packet.getSequence());
this.player.connection.ackBlockChangesUpTo(packet.getSequence());
return;
@@ -1218,9 +1759,31 @@
@@ -1218,9 +1760,31 @@
}
}
@ -965,7 +966,7 @@
if (this.player.hasClientLoaded()) {
this.player.connection.ackBlockChangesUpTo(packet.getSequence());
ServerLevel worldserver = this.player.serverLevel();
@@ -1244,6 +1807,7 @@
@@ -1244,6 +1808,7 @@
if (blockposition.getY() <= i) {
if (this.awaitingPositionFromClient == null && worldserver.mayInteract(this.player, blockposition)) {
@ -973,7 +974,7 @@
InteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
if (enuminteractionresult.consumesAction()) {
@@ -1281,6 +1845,8 @@
@@ -1281,6 +1846,8 @@
@Override
public void handleUseItem(ServerboundUseItemPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -982,7 +983,7 @@
if (this.player.hasClientLoaded()) {
this.ackBlockChangesUpTo(packet.getSequence());
ServerLevel worldserver = this.player.serverLevel();
@@ -1296,6 +1862,47 @@
@@ -1296,6 +1863,47 @@
this.player.absRotateTo(f, f1);
}
@ -1030,7 +1031,7 @@
InteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
if (enuminteractionresult instanceof InteractionResult.Success) {
@@ -1321,7 +1928,7 @@
@@ -1321,7 +1929,7 @@
Entity entity = packet.getEntity(worldserver);
if (entity != null) {
@ -1039,7 +1040,7 @@
return;
}
}
@@ -1342,6 +1949,13 @@
@@ -1342,6 +1950,13 @@
@Override
public void onDisconnect(DisconnectionDetails info) {
@ -1053,7 +1054,7 @@
ServerGamePacketListenerImpl.LOGGER.info("{} lost connection: {}", this.player.getName().getString(), info.reason().getString());
this.removePlayerFromWorld();
super.onDisconnect(info);
@@ -1349,10 +1963,20 @@
@@ -1349,10 +1964,20 @@
private void removePlayerFromWorld() {
this.chatMessageChain.close();
@ -1076,7 +1077,7 @@
this.player.getTextFilter().leave();
}
@@ -1367,7 +1991,16 @@
@@ -1367,7 +1992,16 @@
@Override
public void handleSetCarriedItem(ServerboundSetCarriedItemPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -1093,7 +1094,7 @@
if (this.player.getInventory().selected != packet.getSlot() && this.player.getUsedItemHand() == InteractionHand.MAIN_HAND) {
this.player.stopUsingItem();
}
@@ -1376,11 +2009,18 @@
@@ -1376,11 +2010,18 @@
this.player.resetLastActionTime();
} else {
ServerGamePacketListenerImpl.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
@ -1112,7 +1113,7 @@
Optional<LastSeenMessages> optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages());
if (!optional.isEmpty()) {
@@ -1394,27 +2034,44 @@
@@ -1394,27 +2035,44 @@
return;
}
@ -1164,7 +1165,7 @@
ParseResults<CommandSourceStack> parseresults = this.parseCommand(command);
if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseresults)) {
@@ -1431,19 +2088,37 @@
@@ -1431,19 +2089,37 @@
if (!optional.isEmpty()) {
this.tryHandleChat(packet.command(), () -> {
@ -1206,7 +1207,7 @@
} catch (SignedMessageChain.DecodeException signedmessagechain_a) {
this.handleMessageDecodeFailure(signedmessagechain_a);
return;
@@ -1451,10 +2126,10 @@
@@ -1451,10 +2127,10 @@
CommandSigningContext.SignedArguments commandsigningcontext_a = new CommandSigningContext.SignedArguments(map);
@ -1219,7 +1220,7 @@
}
private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) {
@@ -1530,14 +2205,20 @@
@@ -1530,14 +2206,20 @@
return com_mojang_brigadier_commanddispatcher.parse(command, this.player.createCommandSourceStack());
}
@ -1244,7 +1245,7 @@
}
}
@@ -1566,6 +2247,127 @@
@@ -1566,6 +2248,127 @@
return false;
}
@ -1372,7 +1373,7 @@
private PlayerChatMessage getSignedMessage(ServerboundChatPacket packet, LastSeenMessages lastSeenMessages) throws SignedMessageChain.DecodeException {
SignedMessageBody signedmessagebody = new SignedMessageBody(packet.message(), packet.timeStamp(), packet.salt(), lastSeenMessages);
@@ -1573,13 +2375,42 @@
@@ -1573,13 +2376,42 @@
}
private void broadcastChatMessage(PlayerChatMessage message) {
@ -1420,7 +1421,7 @@
this.disconnect((Component) Component.translatable("disconnect.spam"));
}
@@ -1601,7 +2432,33 @@
@@ -1601,7 +2433,33 @@
@Override
public void handleAnimate(ServerboundSwingPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -1454,7 +1455,7 @@
this.player.swing(packet.getHand());
}
@@ -1609,6 +2466,29 @@
@@ -1609,6 +2467,29 @@
public void handlePlayerCommand(ServerboundPlayerCommandPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
if (this.player.hasClientLoaded()) {
@ -1484,7 +1485,7 @@
this.player.resetLastActionTime();
Entity entity;
PlayerRideableJumping ijumpable;
@@ -1616,6 +2496,11 @@
@@ -1616,6 +2497,11 @@
switch (packet.getAction()) {
case PRESS_SHIFT_KEY:
this.player.setShiftKeyDown(true);
@ -1496,7 +1497,7 @@
break;
case RELEASE_SHIFT_KEY:
this.player.setShiftKeyDown(false);
@@ -1691,6 +2576,12 @@
@@ -1691,6 +2577,12 @@
}
public void sendPlayerChatMessage(PlayerChatMessage message, ChatType.Bound params) {
@ -1509,7 +1510,7 @@
this.send(new ClientboundPlayerChatPacket(message.link().sender(), message.link().index(), message.signature(), message.signedBody().pack(this.messageSignatureCache), message.unsignedContent(), message.filterMask(), params));
this.addPendingMessage(message);
}
@@ -1703,6 +2594,13 @@
@@ -1703,6 +2595,13 @@
return this.connection.getRemoteAddress();
}
@ -1523,7 +1524,7 @@
public void switchToConfig() {
this.waitingForSwitchToConfig = true;
this.removePlayerFromWorld();
@@ -1718,9 +2616,17 @@
@@ -1718,9 +2617,17 @@
@Override
public void handleInteract(ServerboundInteractPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -1541,7 +1542,7 @@
this.player.resetLastActionTime();
this.player.setShiftKeyDown(packet.isUsingSecondaryAction());
@@ -1733,20 +2639,58 @@
@@ -1733,20 +2640,58 @@
if (this.player.canInteractWithEntity(axisalignedbb, 3.0D)) {
packet.dispatch(new ServerboundInteractPacket.Handler() {
@ -1604,7 +1605,7 @@
}
}
@@ -1755,19 +2699,20 @@
@@ -1755,19 +2700,20 @@
@Override
public void onInteraction(InteractionHand hand) {
@ -1628,7 +1629,7 @@
label23:
{
if (entity instanceof AbstractArrow) {
@@ -1785,6 +2730,11 @@
@@ -1785,6 +2731,11 @@
}
ServerGamePacketListenerImpl.this.player.attack(entity);
@ -1640,7 +1641,7 @@
return;
}
}
@@ -1795,7 +2745,26 @@
@@ -1795,7 +2746,26 @@
});
}
}
@ -1667,7 +1668,7 @@
}
}
@@ -1809,7 +2778,7 @@
@@ -1809,7 +2779,7 @@
case PERFORM_RESPAWN:
if (this.player.wonGame) {
this.player.wonGame = false;
@ -1676,7 +1677,7 @@
this.resetPosition();
CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD);
} else {
@@ -1817,11 +2786,11 @@
@@ -1817,11 +2787,11 @@
return;
}
@ -1690,7 +1691,7 @@
}
}
break;
@@ -1833,16 +2802,27 @@
@@ -1833,16 +2803,27 @@
@Override
public void handleContainerClose(ServerboundContainerClosePacket packet) {
@ -1720,7 +1721,7 @@
this.player.containerMenu.sendAllDataToRemote();
} else if (!this.player.containerMenu.stillValid(this.player)) {
ServerGamePacketListenerImpl.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu);
@@ -1855,7 +2835,284 @@
@@ -1855,7 +2836,284 @@
boolean flag = packet.getStateId() != this.player.containerMenu.getStateId();
this.player.containerMenu.suppressRemoteUpdates();
@ -2006,31 +2007,52 @@
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packet.getChangedSlots()).iterator();
while (objectiterator.hasNext()) {
@@ -1901,8 +3158,22 @@
@@ -1900,9 +3158,43 @@
ServerGamePacketListenerImpl.LOGGER.debug("Player {} tried to place impossible recipe {}", this.player, recipeholder.id().location());
return;
}
+ // Paper start - Add PlayerRecipeBookClickEvent
+ NamespacedKey recipeName = org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(recipeholder.id().location());
+ boolean makeAll = packet.useMaxItems();
+ com.destroystokyo.paper.event.player.PlayerRecipeBookClickEvent paperEvent = new com.destroystokyo.paper.event.player.PlayerRecipeBookClickEvent(
+ this.player.getBukkitEntity(), recipeName, makeAll
+ );
+ if (!paperEvent.callEvent()) {
+ return;
+ }
+ recipeName = paperEvent.getRecipe();
+ makeAll = paperEvent.isMakeAll();
+ if (org.bukkit.event.player.PlayerRecipeBookClickEvent.getHandlerList().getRegisteredListeners().length > 0) {
+ // Paper end - Add PlayerRecipeBookClickEvent
- RecipeBookMenu.PostPlaceAction containerrecipebook_a = containerrecipebook.handlePlacement(packet.useMaxItems(), this.player.isCreative(), recipeholder, this.player.serverLevel(), this.player.getInventory());
+ // CraftBukkit start - implement PlayerRecipeBookClickEvent
+ org.bukkit.inventory.Recipe recipe = recipeholder.toBukkitRecipe();
+ org.bukkit.inventory.Recipe recipe = this.cserver.getRecipe(recipeName); // Paper - Add PlayerRecipeBookClickEvent - forward to legacy event
+ if (recipe == null) {
+ return;
+ }
+ org.bukkit.event.player.PlayerRecipeBookClickEvent event = CraftEventFactory.callRecipeBookClickEvent(this.player, recipe, packet.useMaxItems());
+ // Paper start - Add PlayerRecipeBookClickEvent - forward to legacy event
+ org.bukkit.event.player.PlayerRecipeBookClickEvent event = CraftEventFactory.callRecipeBookClickEvent(this.player, recipe, makeAll);
+ recipeName = ((org.bukkit.Keyed) event.getRecipe()).getKey();
+ makeAll = event.isShiftClick();
+ }
+ if (!(this.player.containerMenu instanceof RecipeBookMenu)) {
+ return;
+ }
+ // Paper end - Add PlayerRecipeBookClickEvent - forward to legacy event
+ // Cast to keyed should be safe as the recipe will never be a MerchantRecipe.
+ recipeholder = this.server.getRecipeManager().byKey(CraftRecipe.toMinecraft(((org.bukkit.Keyed) event.getRecipe()).getKey())).orElse(null);
+ recipeholder = this.server.getRecipeManager().byKey(net.minecraft.resources.ResourceKey.create(net.minecraft.core.registries.Registries.RECIPE, org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(recipeName))).orElse(null); // Paper - Add PlayerRecipeBookClickEvent - forward to legacy event
+ if (recipeholder == null) {
+ return;
+ }
+
+ RecipeBookMenu.PostPlaceAction containerrecipebook_a = containerrecipebook.handlePlacement(event.isShiftClick(), this.player.isCreative(), recipeholder, this.player.serverLevel(), this.player.getInventory());
+ RecipeBookMenu.PostPlaceAction containerrecipebook_a = containerrecipebook.handlePlacement(makeAll, this.player.isCreative(), recipeholder, this.player.serverLevel(), this.player.getInventory());
+ // CraftBukkit end
+
if (containerrecipebook_a == RecipeBookMenu.PostPlaceAction.PLACE_GHOST_RECIPE) {
this.player.connection.send(new ClientboundPlaceGhostRecipePacket(this.player.containerMenu.containerId, craftingmanager_d.display().display()));
}
@@ -1917,6 +3188,7 @@
@@ -1917,6 +3209,7 @@
@Override
public void handleContainerButtonClick(ServerboundContainerButtonClickPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -2038,7 +2060,7 @@
this.player.resetLastActionTime();
if (this.player.containerMenu.containerId == packet.containerId() && !this.player.isSpectator()) {
if (!this.player.containerMenu.stillValid(this.player)) {
@@ -1945,6 +3217,43 @@
@@ -1945,7 +3238,44 @@
boolean flag1 = packet.slotNum() >= 1 && packet.slotNum() <= 45;
boolean flag2 = itemstack.isEmpty() || itemstack.getCount() <= itemstack.getMaxStackSize();
@ -2046,7 +2068,7 @@
+ // CraftBukkit start - Call click event
+ InventoryView inventory = this.player.inventoryMenu.getBukkitView();
+ org.bukkit.inventory.ItemStack item = CraftItemStack.asBukkitCopy(packet.itemStack());
+
+ SlotType type = SlotType.QUICKBAR;
+ if (flag) {
+ type = SlotType.OUTSIDE;
@ -2079,10 +2101,11 @@
+ }
+ }
+ // CraftBukkit end
+
if (flag1 && flag2) {
this.player.inventoryMenu.getSlot(packet.slotNum()).setByPlayer(itemstack);
@@ -1964,7 +3273,19 @@
this.player.inventoryMenu.setRemoteSlot(packet.slotNum(), itemstack);
@@ -1964,7 +3294,19 @@
@Override
public void handleSignUpdate(ServerboundSignUpdatePacket packet) {
@ -2103,7 +2126,7 @@
this.filterTextPacket(list).thenAcceptAsync((list1) -> {
this.updateSignText(packet, list1);
@@ -1972,6 +3293,7 @@
@@ -1972,6 +3314,7 @@
}
private void updateSignText(ServerboundSignUpdatePacket packet, List<FilteredText> signText) {
@ -2111,7 +2134,7 @@
this.player.resetLastActionTime();
ServerLevel worldserver = this.player.serverLevel();
BlockPos blockposition = packet.getPos();
@@ -1993,7 +3315,17 @@
@@ -1993,7 +3336,17 @@
@Override
public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@ -2130,7 +2153,7 @@
}
@Override
@@ -2002,6 +3334,7 @@
@@ -2002,6 +3355,7 @@
boolean flag = this.player.isModelPartShown(PlayerModelPart.HAT);
this.player.updateOptions(packet.information());
@ -2138,7 +2161,7 @@
if (this.player.isModelPartShown(PlayerModelPart.HAT) != flag) {
this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_HAT, this.player));
}
@@ -2058,7 +3391,7 @@
@@ -2058,7 +3412,7 @@
if (!this.waitingForSwitchToConfig) {
throw new IllegalStateException("Client acknowledged config, but none was requested");
} else {
@ -2147,7 +2170,7 @@
}
}
@@ -2083,8 +3416,10 @@
@@ -2083,8 +3437,10 @@
});
}