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