|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
--- a/net/minecraft/server/network/PlayerConnection.java
|
|
|
|
|
+++ b/net/minecraft/server/network/PlayerConnection.java
|
|
|
|
|
@@ -185,6 +185,71 @@
|
|
|
|
|
@@ -185,6 +185,72 @@
|
|
|
|
|
import net.minecraft.world.phys.shapes.VoxelShapes;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
|
|
|
|
@ -29,6 +29,7 @@
|
|
|
|
|
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
|
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
|
|
|
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
|
|
|
|
+import org.bukkit.craftbukkit.inventory.CraftItemType;
|
|
|
|
|
+import org.bukkit.craftbukkit.util.CraftChatMessage;
|
|
|
|
|
+import org.bukkit.craftbukkit.util.CraftLocation;
|
|
|
|
|
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
|
|
|
@ -72,7 +73,7 @@
|
|
|
|
|
public class PlayerConnection implements ServerPlayerConnection, TickablePacketListener, PacketListenerPlayIn {
|
|
|
|
|
|
|
|
|
|
static final Logger LOGGER = LogUtils.getLogger();
|
|
|
|
|
@@ -201,7 +266,9 @@
|
|
|
|
|
@@ -201,7 +267,9 @@
|
|
|
|
|
private long keepAliveTime;
|
|
|
|
|
private boolean keepAlivePending;
|
|
|
|
|
private long keepAliveChallenge;
|
|
|
|
@ -83,7 +84,7 @@
|
|
|
|
|
private int dropSpamTickCount;
|
|
|
|
|
private double firstGoodX;
|
|
|
|
|
private double firstGoodY;
|
|
|
|
|
@@ -247,8 +314,31 @@
|
|
|
|
|
@@ -247,8 +315,31 @@
|
|
|
|
|
this.keepAliveTime = SystemUtils.getMillis();
|
|
|
|
|
entityplayer.getTextFilter().join();
|
|
|
|
|
this.signedMessageDecoder = minecraftserver.enforceSecureProfile() ? SignedMessageChain.b.REJECT_ALL : SignedMessageChain.b.unsigned(entityplayer.getUUID());
|
|
|
|
@ -116,7 +117,7 @@
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void tick() {
|
|
|
|
|
@@ -303,7 +393,7 @@
|
|
|
|
|
@@ -303,7 +394,7 @@
|
|
|
|
|
this.server.getProfiler().push("keepAlive");
|
|
|
|
|
long i = SystemUtils.getMillis();
|
|
|
|
|
|
|
|
|
@ -125,7 +126,7 @@
|
|
|
|
|
if (this.keepAlivePending) {
|
|
|
|
|
this.disconnect(IChatBaseComponent.translatable("disconnect.timeout"));
|
|
|
|
|
} else {
|
|
|
|
|
@@ -315,15 +405,21 @@
|
|
|
|
|
@@ -315,15 +406,21 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.server.getProfiler().pop();
|
|
|
|
@ -147,7 +148,7 @@
|
|
|
|
|
this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.idling"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -347,16 +443,67 @@
|
|
|
|
|
@@ -347,16 +444,67 @@
|
|
|
|
|
return this.server.isSingleplayerOwner(this.player.getGameProfile());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -216,7 +217,7 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private <T, R> CompletableFuture<R> filterTextPacket(T t0, BiFunction<ITextFilter, T, CompletableFuture<R>> bifunction) {
|
|
|
|
|
@@ -420,7 +567,34 @@
|
|
|
|
|
@@ -420,7 +568,34 @@
|
|
|
|
|
double d9 = entity.getDeltaMovement().lengthSqr();
|
|
|
|
|
double d10 = d6 * d6 + d7 * d7 + d8 * d8;
|
|
|
|
|
|
|
|
|
@ -252,7 +253,7 @@
|
|
|
|
|
PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8});
|
|
|
|
|
this.connection.send(new PacketPlayOutVehicleMove(entity));
|
|
|
|
|
return;
|
|
|
|
|
@@ -460,14 +634,72 @@
|
|
|
|
|
@@ -460,14 +635,72 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
entity.absMoveTo(d3, d4, d5, f, f1);
|
|
|
|
@ -325,7 +326,7 @@
|
|
|
|
|
this.player.serverLevel().getChunkSource().move(this.player);
|
|
|
|
|
this.player.checkMovementStatistics(this.player.getX() - d0, this.player.getY() - d1, this.player.getZ() - d2);
|
|
|
|
|
this.clientVehicleIsFloating = d11 >= -0.03125D && !flag1 && !this.server.isFlightAllowed() && !entity.isNoGravity() && this.noBlocksAround(entity);
|
|
|
|
|
@@ -501,6 +733,7 @@
|
|
|
|
|
@@ -501,6 +734,7 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.awaitingPositionFromClient = null;
|
|
|
|
@ -333,7 +334,7 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@@ -508,7 +741,7 @@
|
|
|
|
|
@@ -508,7 +742,7 @@
|
|
|
|
|
@Override
|
|
|
|
|
public void handleRecipeBookSeenRecipePacket(PacketPlayInRecipeDisplayed packetplayinrecipedisplayed) {
|
|
|
|
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinrecipedisplayed, this, this.player.serverLevel());
|
|
|
|
@ -342,7 +343,7 @@
|
|
|
|
|
RecipeBookServer recipebookserver = this.player.getRecipeBook();
|
|
|
|
|
|
|
|
|
|
Objects.requireNonNull(recipebookserver);
|
|
|
|
|
@@ -538,6 +771,12 @@
|
|
|
|
|
@@ -538,6 +772,12 @@
|
|
|
|
|
@Override
|
|
|
|
|
public void handleCustomCommandSuggestions(PacketPlayInTabComplete packetplayintabcomplete) {
|
|
|
|
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayintabcomplete, this, this.player.serverLevel());
|
|
|
|
@ -355,7 +356,7 @@
|
|
|
|
|
StringReader stringreader = new StringReader(packetplayintabcomplete.getCommand());
|
|
|
|
|
|
|
|
|
|
if (stringreader.canRead() && stringreader.peek() == '/') {
|
|
|
|
|
@@ -547,6 +786,7 @@
|
|
|
|
|
@@ -547,6 +787,7 @@
|
|
|
|
|
ParseResults<CommandListenerWrapper> parseresults = this.server.getCommands().getDispatcher().parse(stringreader, this.player.createCommandSourceStack());
|
|
|
|
|
|
|
|
|
|
this.server.getCommands().getDispatcher().getCompletionSuggestions(parseresults).thenAccept((suggestions) -> {
|
|
|
|
@ -363,7 +364,7 @@
|
|
|
|
|
this.connection.send(new PacketPlayOutTabComplete(packetplayintabcomplete.getId(), suggestions));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
@@ -792,6 +1032,13 @@
|
|
|
|
|
@@ -792,6 +1033,13 @@
|
|
|
|
|
|
|
|
|
|
if (container instanceof ContainerMerchant) {
|
|
|
|
|
ContainerMerchant containermerchant = (ContainerMerchant) container;
|
|
|
|
@ -377,7 +378,7 @@
|
|
|
|
|
|
|
|
|
|
if (!containermerchant.stillValid(this.player)) {
|
|
|
|
|
PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, containermerchant);
|
|
|
|
|
@@ -806,6 +1053,13 @@
|
|
|
|
|
@@ -806,6 +1054,13 @@
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void handleEditBook(PacketPlayInBEdit packetplayinbedit) {
|
|
|
|
@ -391,7 +392,7 @@
|
|
|
|
|
int i = packetplayinbedit.getSlot();
|
|
|
|
|
|
|
|
|
|
if (PlayerInventory.isHotbarSlot(i) || i == 40) {
|
|
|
|
|
@@ -814,7 +1068,7 @@
|
|
|
|
|
@@ -814,7 +1069,7 @@
|
|
|
|
|
|
|
|
|
|
Objects.requireNonNull(list);
|
|
|
|
|
optional.ifPresent(list::add);
|
|
|
|
@ -400,7 +401,7 @@
|
|
|
|
|
|
|
|
|
|
Objects.requireNonNull(list);
|
|
|
|
|
stream.forEach(list::add);
|
|
|
|
|
@@ -832,7 +1086,7 @@
|
|
|
|
|
@@ -832,7 +1087,7 @@
|
|
|
|
|
ItemStack itemstack = this.player.getInventory().getItem(i);
|
|
|
|
|
|
|
|
|
|
if (itemstack.is(Items.WRITABLE_BOOK)) {
|
|
|
|
@ -409,7 +410,7 @@
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -857,16 +1111,16 @@
|
|
|
|
|
@@ -857,16 +1112,16 @@
|
|
|
|
|
|
|
|
|
|
this.updateBookPages(list, (s) -> {
|
|
|
|
|
return IChatBaseComponent.ChatSerializer.toJson(IChatBaseComponent.literal(s));
|
|
|
|
@ -430,7 +431,7 @@
|
|
|
|
|
return NBTTagString.valueOf((String) unaryoperator.apply(filteredtext.filteredOrEmpty()));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@@ -892,6 +1146,7 @@
|
|
|
|
|
@@ -892,6 +1147,7 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
itemstack.addTagElement("pages", nbttaglist);
|
|
|
|
@ -438,7 +439,7 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@@ -928,7 +1183,7 @@
|
|
|
|
|
@@ -928,7 +1184,7 @@
|
|
|
|
|
} else {
|
|
|
|
|
WorldServer worldserver = this.player.serverLevel();
|
|
|
|
|
|
|
|
|
@ -447,7 +448,7 @@
|
|
|
|
|
if (this.tickCount == 0) {
|
|
|
|
|
this.resetPosition();
|
|
|
|
|
}
|
|
|
|
|
@@ -938,7 +1193,7 @@
|
|
|
|
|
@@ -938,7 +1194,7 @@
|
|
|
|
|
this.awaitingTeleportTime = this.tickCount;
|
|
|
|
|
this.teleport(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
|
|
|
|
|
}
|
|
|
|
@ -456,7 +457,7 @@
|
|
|
|
|
} else {
|
|
|
|
|
this.awaitingTeleportTime = this.tickCount;
|
|
|
|
|
double d0 = clampHorizontal(packetplayinflying.getX(this.player.getX()));
|
|
|
|
|
@@ -950,7 +1205,15 @@
|
|
|
|
|
@@ -950,7 +1206,15 @@
|
|
|
|
|
if (this.player.isPassenger()) {
|
|
|
|
|
this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1);
|
|
|
|
|
this.player.serverLevel().getChunkSource().move(this.player);
|
|
|
|
@ -472,7 +473,7 @@
|
|
|
|
|
double d3 = this.player.getX();
|
|
|
|
|
double d4 = this.player.getY();
|
|
|
|
|
double d5 = this.player.getZ();
|
|
|
|
|
@@ -969,15 +1232,33 @@
|
|
|
|
|
@@ -969,15 +1233,33 @@
|
|
|
|
|
++this.receivedMovePacketCount;
|
|
|
|
|
int i = this.receivedMovePacketCount - this.knownMovePacketCount;
|
|
|
|
|
|
|
|
|
@ -508,7 +509,7 @@
|
|
|
|
|
PlayerConnection.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;
|
|
|
|
|
@@ -998,6 +1279,7 @@
|
|
|
|
|
@@ -998,6 +1280,7 @@
|
|
|
|
|
boolean flag1 = this.player.verticalCollisionBelow;
|
|
|
|
|
|
|
|
|
|
this.player.move(EnumMoveType.PLAYER, new Vec3D(d6, d7, d8));
|
|
|
|
@ -516,7 +517,7 @@
|
|
|
|
|
double d11 = d7;
|
|
|
|
|
|
|
|
|
|
d6 = d0 - this.player.getX();
|
|
|
|
|
@@ -1016,9 +1298,70 @@
|
|
|
|
|
@@ -1016,9 +1299,70 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!this.player.noPhysics && !this.player.isSleeping() && (flag2 && worldserver.noCollision(this.player, axisalignedbb) || this.isPlayerCollidingWithAnythingNew(worldserver, axisalignedbb, d0, d1, d2))) {
|
|
|
|
@ -588,7 +589,7 @@
|
|
|
|
|
this.player.absMoveTo(d0, d1, d2, f, f1);
|
|
|
|
|
this.clientIsFloating = d11 >= -0.03125D && !flag1 && this.player.gameMode.getGameModeForPlayer() != EnumGamemode.SPECTATOR && !this.server.isFlightAllowed() && !this.player.getAbilities().mayfly && !this.player.hasEffect(MobEffects.LEVITATION) && !this.player.isFallFlying() && !this.player.isAutoSpinAttack() && this.noBlocksAround(this.player);
|
|
|
|
|
this.player.serverLevel().getChunkSource().move(this.player);
|
|
|
|
|
@@ -1059,11 +1402,68 @@
|
|
|
|
|
@@ -1059,11 +1403,68 @@
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -658,7 +659,7 @@
|
|
|
|
|
double d3 = set.contains(RelativeMovement.X) ? this.player.getX() : 0.0D;
|
|
|
|
|
double d4 = set.contains(RelativeMovement.Y) ? this.player.getY() : 0.0D;
|
|
|
|
|
double d5 = set.contains(RelativeMovement.Z) ? this.player.getZ() : 0.0D;
|
|
|
|
|
@@ -1075,6 +1475,14 @@
|
|
|
|
|
@@ -1075,6 +1476,14 @@
|
|
|
|
|
this.awaitingTeleport = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -673,7 +674,7 @@
|
|
|
|
|
this.awaitingTeleportTime = this.tickCount;
|
|
|
|
|
this.player.absMoveTo(d0, d1, d2, f, f1);
|
|
|
|
|
this.player.connection.send(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport));
|
|
|
|
|
@@ -1083,6 +1491,7 @@
|
|
|
|
|
@@ -1083,6 +1492,7 @@
|
|
|
|
|
@Override
|
|
|
|
|
public void handlePlayerAction(PacketPlayInBlockDig packetplayinblockdig) {
|
|
|
|
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockdig, this, this.player.serverLevel());
|
|
|
|
@ -681,7 +682,7 @@
|
|
|
|
|
BlockPosition blockposition = packetplayinblockdig.getPos();
|
|
|
|
|
|
|
|
|
|
this.player.resetLastActionTime();
|
|
|
|
|
@@ -1093,14 +1502,46 @@
|
|
|
|
|
@@ -1093,14 +1503,46 @@
|
|
|
|
|
if (!this.player.isSpectator()) {
|
|
|
|
|
ItemStack itemstack = this.player.getItemInHand(EnumHand.OFF_HAND);
|
|
|
|
|
|
|
|
|
@ -730,7 +731,7 @@
|
|
|
|
|
this.player.drop(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1138,6 +1579,7 @@
|
|
|
|
|
@@ -1138,6 +1580,7 @@
|
|
|
|
|
@Override
|
|
|
|
|
public void handleUseItemOn(PacketPlayInUseItem packetplayinuseitem) {
|
|
|
|
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseitem, this, this.player.serverLevel());
|
|
|
|
@ -738,7 +739,7 @@
|
|
|
|
|
this.player.connection.ackBlockChangesUpTo(packetplayinuseitem.getSequence());
|
|
|
|
|
WorldServer worldserver = this.player.serverLevel();
|
|
|
|
|
EnumHand enumhand = packetplayinuseitem.getHand();
|
|
|
|
|
@@ -1161,6 +1603,7 @@
|
|
|
|
|
@@ -1161,6 +1604,7 @@
|
|
|
|
|
|
|
|
|
|
if (blockposition.getY() < i) {
|
|
|
|
|
if (this.awaitingPositionFromClient == null && this.player.distanceToSqr((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.mayInteract(this.player, blockposition)) {
|
|
|
|
@ -746,7 +747,7 @@
|
|
|
|
|
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItemOn(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
|
|
|
|
|
|
|
|
|
|
if (enumdirection == EnumDirection.UP && !enuminteractionresult.consumesAction() && blockposition.getY() >= i - 1 && wasBlockPlacementAttempt(this.player, itemstack)) {
|
|
|
|
|
@@ -1189,6 +1632,7 @@
|
|
|
|
|
@@ -1189,6 +1633,7 @@
|
|
|
|
|
@Override
|
|
|
|
|
public void handleUseItem(PacketPlayInBlockPlace packetplayinblockplace) {
|
|
|
|
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinblockplace, this, this.player.serverLevel());
|
|
|
|
@ -754,7 +755,7 @@
|
|
|
|
|
this.ackBlockChangesUpTo(packetplayinblockplace.getSequence());
|
|
|
|
|
WorldServer worldserver = this.player.serverLevel();
|
|
|
|
|
EnumHand enumhand = packetplayinblockplace.getHand();
|
|
|
|
|
@@ -1196,6 +1640,49 @@
|
|
|
|
|
@@ -1196,6 +1641,49 @@
|
|
|
|
|
|
|
|
|
|
this.player.resetLastActionTime();
|
|
|
|
|
if (!itemstack.isEmpty() && itemstack.isItemEnabled(worldserver.enabledFeatures())) {
|
|
|
|
@ -804,7 +805,7 @@
|
|
|
|
|
EnumInteractionResult enuminteractionresult = this.player.gameMode.useItem(this.player, worldserver, itemstack, enumhand);
|
|
|
|
|
|
|
|
|
|
if (enuminteractionresult.shouldSwing()) {
|
|
|
|
|
@@ -1216,7 +1703,7 @@
|
|
|
|
|
@@ -1216,7 +1704,7 @@
|
|
|
|
|
Entity entity = packetplayinspectate.getEntity(worldserver);
|
|
|
|
|
|
|
|
|
|
if (entity != null) {
|
|
|
|
@ -813,7 +814,7 @@
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -1231,6 +1718,7 @@
|
|
|
|
|
@@ -1231,6 +1719,7 @@
|
|
|
|
|
PlayerConnection.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getName());
|
|
|
|
|
this.disconnect(IChatBaseComponent.translatable("multiplayer.requiredTexturePrompt.disconnect"));
|
|
|
|
|
}
|
|
|
|
@ -821,7 +822,7 @@
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1252,12 +1740,27 @@
|
|
|
|
|
@@ -1252,12 +1741,27 @@
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onDisconnect(IChatBaseComponent ichatbasecomponent) {
|
|
|
|
@ -850,7 +851,7 @@
|
|
|
|
|
this.player.getTextFilter().leave();
|
|
|
|
|
if (this.isSingleplayerOwner()) {
|
|
|
|
|
PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out");
|
|
|
|
|
@@ -1280,6 +1783,15 @@
|
|
|
|
|
@@ -1280,6 +1784,15 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void send(Packet<?> packet, @Nullable PacketSendListener packetsendlistener) {
|
|
|
|
@ -866,7 +867,7 @@
|
|
|
|
|
try {
|
|
|
|
|
this.connection.send(packet, packetsendlistener);
|
|
|
|
|
} catch (Throwable throwable) {
|
|
|
|
|
@@ -1296,7 +1808,16 @@
|
|
|
|
|
@@ -1296,7 +1809,16 @@
|
|
|
|
|
@Override
|
|
|
|
|
public void handleSetCarriedItem(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
|
|
|
|
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinhelditemslot, this, this.player.serverLevel());
|
|
|
|
@ -883,7 +884,7 @@
|
|
|
|
|
if (this.player.getInventory().selected != packetplayinhelditemslot.getSlot() && this.player.getUsedItemHand() == EnumHand.MAIN_HAND) {
|
|
|
|
|
this.player.stopUsingItem();
|
|
|
|
|
}
|
|
|
|
|
@@ -1305,18 +1826,25 @@
|
|
|
|
|
@@ -1305,18 +1827,25 @@
|
|
|
|
|
this.player.resetLastActionTime();
|
|
|
|
|
} else {
|
|
|
|
|
PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString());
|
|
|
|
@ -910,7 +911,7 @@
|
|
|
|
|
PlayerChatMessage playerchatmessage;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
@@ -1334,9 +1862,9 @@
|
|
|
|
|
@@ -1334,9 +1863,9 @@
|
|
|
|
|
PlayerChatMessage playerchatmessage1 = playerchatmessage.withUnsignedContent((IChatBaseComponent) completablefuture1.join()).filter(((FilteredText) completablefuture.join()).mask());
|
|
|
|
|
|
|
|
|
|
this.broadcastChatMessage(playerchatmessage1);
|
|
|
|
@ -922,7 +923,7 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1351,6 +1879,12 @@
|
|
|
|
|
@@ -1351,6 +1880,12 @@
|
|
|
|
|
|
|
|
|
|
if (optional.isPresent()) {
|
|
|
|
|
this.server.submit(() -> {
|
|
|
|
@ -935,7 +936,7 @@
|
|
|
|
|
this.performChatCommand(serverboundchatcommandpacket, (LastSeenMessages) optional.get());
|
|
|
|
|
this.detectRateSpam();
|
|
|
|
|
});
|
|
|
|
|
@@ -1360,12 +1894,25 @@
|
|
|
|
|
@@ -1360,12 +1895,25 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void performChatCommand(ServerboundChatCommandPacket serverboundchatcommandpacket, LastSeenMessages lastseenmessages) {
|
|
|
|
@ -963,7 +964,7 @@
|
|
|
|
|
} catch (SignedMessageChain.a signedmessagechain_a) {
|
|
|
|
|
this.handleMessageDecodeFailure(signedmessagechain_a);
|
|
|
|
|
return;
|
|
|
|
|
@@ -1373,10 +1920,10 @@
|
|
|
|
|
@@ -1373,10 +1921,10 @@
|
|
|
|
|
|
|
|
|
|
CommandSigningContext.a commandsigningcontext_a = new CommandSigningContext.a(map);
|
|
|
|
|
|
|
|
|
@ -976,7 +977,7 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void handleMessageDecodeFailure(SignedMessageChain.a signedmessagechain_a) {
|
|
|
|
|
@@ -1417,7 +1964,7 @@
|
|
|
|
|
@@ -1417,7 +1965,7 @@
|
|
|
|
|
} else {
|
|
|
|
|
Optional<LastSeenMessages> optional = this.unpackAndApplyLastSeen(lastseenmessages_b);
|
|
|
|
|
|
|
|
|
@ -985,7 +986,7 @@
|
|
|
|
|
this.send(new ClientboundSystemChatPacket(IChatBaseComponent.translatable("chat.disabled.options").withStyle(EnumChatFormat.RED), false));
|
|
|
|
|
return Optional.empty();
|
|
|
|
|
} else {
|
|
|
|
|
@@ -1465,6 +2012,116 @@
|
|
|
|
|
@@ -1465,6 +2013,116 @@
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1102,7 +1103,7 @@
|
|
|
|
|
private PlayerChatMessage getSignedMessage(PacketPlayInChat packetplayinchat, LastSeenMessages lastseenmessages) throws SignedMessageChain.a {
|
|
|
|
|
SignedMessageBody signedmessagebody = new SignedMessageBody(packetplayinchat.message(), packetplayinchat.timeStamp(), packetplayinchat.salt(), lastseenmessages);
|
|
|
|
|
|
|
|
|
|
@@ -1472,13 +2129,33 @@
|
|
|
|
|
@@ -1472,13 +2130,33 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void broadcastChatMessage(PlayerChatMessage playerchatmessage) {
|
|
|
|
@ -1139,7 +1140,7 @@
|
|
|
|
|
this.disconnect(IChatBaseComponent.translatable("disconnect.spam"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1500,13 +2177,62 @@
|
|
|
|
|
@@ -1500,13 +2178,62 @@
|
|
|
|
|
@Override
|
|
|
|
|
public void handleAnimate(PacketPlayInArmAnimation packetplayinarmanimation) {
|
|
|
|
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinarmanimation, this, this.player.serverLevel());
|
|
|
|
@ -1202,7 +1203,7 @@
|
|
|
|
|
this.player.resetLastActionTime();
|
|
|
|
|
Entity entity;
|
|
|
|
|
IJumpable ijumpable;
|
|
|
|
|
@@ -1588,6 +2314,12 @@
|
|
|
|
|
@@ -1588,6 +2315,12 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void sendPlayerChatMessage(PlayerChatMessage playerchatmessage, ChatMessageType.a chatmessagetype_a) {
|
|
|
|
@ -1215,7 +1216,7 @@
|
|
|
|
|
this.send(new ClientboundPlayerChatPacket(playerchatmessage.link().sender(), playerchatmessage.link().index(), playerchatmessage.signature(), playerchatmessage.signedBody().pack(this.messageSignatureCache), playerchatmessage.unsignedContent(), playerchatmessage.filterMask(), chatmessagetype_a.toNetwork(this.player.level().registryAccess())));
|
|
|
|
|
this.addPendingMessage(playerchatmessage);
|
|
|
|
|
}
|
|
|
|
|
@@ -1603,6 +2335,7 @@
|
|
|
|
|
@@ -1603,6 +2336,7 @@
|
|
|
|
|
@Override
|
|
|
|
|
public void handleInteract(PacketPlayInUseEntity packetplayinuseentity) {
|
|
|
|
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinuseentity, this, this.player.serverLevel());
|
|
|
|
@ -1223,7 +1224,7 @@
|
|
|
|
|
final WorldServer worldserver = this.player.serverLevel();
|
|
|
|
|
final Entity entity = packetplayinuseentity.getTarget(worldserver);
|
|
|
|
|
|
|
|
|
|
@@ -1617,13 +2350,51 @@
|
|
|
|
|
@@ -1617,13 +2351,51 @@
|
|
|
|
|
|
|
|
|
|
if (axisalignedbb.distanceToSqr(this.player.getEyePosition()) < PlayerConnection.MAX_INTERACTION_DISTANCE) {
|
|
|
|
|
packetplayinuseentity.dispatch(new PacketPlayInUseEntity.c() {
|
|
|
|
@ -1276,7 +1277,7 @@
|
|
|
|
|
if (enuminteractionresult.consumesAction()) {
|
|
|
|
|
CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(PlayerConnection.this.player, itemstack1, entity);
|
|
|
|
|
if (enuminteractionresult.shouldSwing()) {
|
|
|
|
|
@@ -1636,23 +2407,29 @@
|
|
|
|
|
@@ -1636,23 +2408,29 @@
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onInteraction(EnumHand enumhand) {
|
|
|
|
@ -1309,7 +1310,7 @@
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
PlayerConnection.this.disconnect(IChatBaseComponent.translatable("multiplayer.disconnect.invalid_entity_attacked"));
|
|
|
|
|
@@ -1675,14 +2452,14 @@
|
|
|
|
|
@@ -1675,14 +2453,14 @@
|
|
|
|
|
case PERFORM_RESPAWN:
|
|
|
|
|
if (this.player.wonGame) {
|
|
|
|
|
this.player.wonGame = false;
|
|
|
|
@ -1326,7 +1327,7 @@
|
|
|
|
|
if (this.server.isHardcore()) {
|
|
|
|
|
this.player.setGameMode(EnumGamemode.SPECTATOR);
|
|
|
|
|
((GameRules.GameRuleBoolean) this.player.level().getGameRules().getRule(GameRules.RULE_SPECTATORSGENERATECHUNKS)).set(false, this.server);
|
|
|
|
|
@@ -1698,15 +2475,21 @@
|
|
|
|
|
@@ -1698,15 +2476,21 @@
|
|
|
|
|
@Override
|
|
|
|
|
public void handleContainerClose(PacketPlayInCloseWindow packetplayinclosewindow) {
|
|
|
|
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinclosewindow, this, this.player.serverLevel());
|
|
|
|
@ -1350,7 +1351,7 @@
|
|
|
|
|
this.player.containerMenu.sendAllDataToRemote();
|
|
|
|
|
} else if (!this.player.containerMenu.stillValid(this.player)) {
|
|
|
|
|
PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu);
|
|
|
|
|
@@ -1719,7 +2502,284 @@
|
|
|
|
|
@@ -1719,7 +2503,284 @@
|
|
|
|
|
boolean flag = packetplayinwindowclick.getStateId() != this.player.containerMenu.getStateId();
|
|
|
|
|
|
|
|
|
|
this.player.containerMenu.suppressRemoteUpdates();
|
|
|
|
@ -1525,7 +1526,7 @@
|
|
|
|
|
+ ItemStack cursor = this.player.containerMenu.getCarried();
|
|
|
|
|
+ action = InventoryAction.NOTHING;
|
|
|
|
|
+ // Quick check for if we have any of the item
|
|
|
|
|
+ if (inventory.getTopInventory().contains(CraftMagicNumbers.getMaterial(cursor.getItem())) || inventory.getBottomInventory().contains(CraftMagicNumbers.getMaterial(cursor.getItem()))) {
|
|
|
|
|
+ if (inventory.getTopInventory().contains(CraftItemType.minecraftToBukkit(cursor.getItem())) || inventory.getBottomInventory().contains(CraftItemType.minecraftToBukkit(cursor.getItem()))) {
|
|
|
|
|
+ action = InventoryAction.COLLECT_TO_CURSOR;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
@ -1636,7 +1637,7 @@
|
|
|
|
|
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.getChangedSlots()).iterator();
|
|
|
|
|
|
|
|
|
|
while (objectiterator.hasNext()) {
|
|
|
|
|
@@ -1749,9 +2809,18 @@
|
|
|
|
|
@@ -1749,9 +2810,18 @@
|
|
|
|
|
if (!this.player.containerMenu.stillValid(this.player)) {
|
|
|
|
|
PlayerConnection.LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu);
|
|
|
|
|
} else {
|
|
|
|
@ -1657,7 +1658,7 @@
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -1759,6 +2828,7 @@
|
|
|
|
|
@@ -1759,6 +2829,7 @@
|
|
|
|
|
@Override
|
|
|
|
|
public void handleContainerButtonClick(PacketPlayInEnchantItem packetplayinenchantitem) {
|
|
|
|
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinenchantitem, this, this.player.serverLevel());
|
|
|
|
@ -1665,7 +1666,7 @@
|
|
|
|
|
this.player.resetLastActionTime();
|
|
|
|
|
if (this.player.containerMenu.containerId == packetplayinenchantitem.getContainerId() && !this.player.isSpectator()) {
|
|
|
|
|
if (!this.player.containerMenu.stillValid(this.player)) {
|
|
|
|
|
@@ -1801,6 +2871,43 @@
|
|
|
|
|
@@ -1801,6 +2872,43 @@
|
|
|
|
|
|
|
|
|
|
boolean flag1 = packetplayinsetcreativeslot.getSlotNum() >= 1 && packetplayinsetcreativeslot.getSlotNum() <= 45;
|
|
|
|
|
boolean flag2 = itemstack.isEmpty() || itemstack.getDamageValue() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty();
|
|
|
|
@ -1709,7 +1710,7 @@
|
|
|
|
|
|
|
|
|
|
if (flag1 && flag2) {
|
|
|
|
|
this.player.inventoryMenu.getSlot(packetplayinsetcreativeslot.getSlotNum()).setByPlayer(itemstack);
|
|
|
|
|
@@ -1823,6 +2930,7 @@
|
|
|
|
|
@@ -1823,6 +2931,7 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateSignText(PacketPlayInUpdateSign packetplayinupdatesign, List<FilteredText> list) {
|
|
|
|
@ -1717,7 +1718,7 @@
|
|
|
|
|
this.player.resetLastActionTime();
|
|
|
|
|
WorldServer worldserver = this.player.serverLevel();
|
|
|
|
|
BlockPosition blockposition = packetplayinupdatesign.getPos();
|
|
|
|
|
@@ -1843,6 +2951,7 @@
|
|
|
|
|
@@ -1843,6 +2952,7 @@
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void handleKeepAlive(PacketPlayInKeepAlive packetplayinkeepalive) {
|
|
|
|
@ -1725,7 +1726,7 @@
|
|
|
|
|
if (this.keepAlivePending && packetplayinkeepalive.getId() == this.keepAliveChallenge) {
|
|
|
|
|
int i = (int) (SystemUtils.getMillis() - this.keepAliveTime);
|
|
|
|
|
|
|
|
|
|
@@ -1857,7 +2966,17 @@
|
|
|
|
|
@@ -1857,7 +2967,17 @@
|
|
|
|
|
@Override
|
|
|
|
|
public void handlePlayerAbilities(PacketPlayInAbilities packetplayinabilities) {
|
|
|
|
|
PlayerConnectionUtils.ensureRunningOnSameThread(packetplayinabilities, this, this.player.serverLevel());
|
|
|
|
@ -1744,7 +1745,7 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@@ -1866,8 +2985,50 @@
|
|
|
|
|
@@ -1866,8 +2986,50 @@
|
|
|
|
|
this.player.updateOptions(packetplayinsettings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|