Backport patches from 1.19.4

This commit is contained in:
Luna 2023-04-28 18:36:42 -03:00
parent 661bd58103
commit bb4cd701fc
8 changed files with 313 additions and 166 deletions

View File

@ -0,0 +1,165 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: ayunami2000 <spwilliamsiam@gmail.com>
Date: Mon, 28 Mar 2022 17:02:21 -0400
Subject: [PATCH] Block server-side chunkbans
diff --git a/src/main/java/net/minecraft/network/PacketEncoder.java b/src/main/java/net/minecraft/network/PacketEncoder.java
index b039a32b805fc02033fa862a1c40c4a51639e69a..b2227f01bc90351a4a3f73fa835dd89bde15632e 100644
--- a/src/main/java/net/minecraft/network/PacketEncoder.java
+++ b/src/main/java/net/minecraft/network/PacketEncoder.java
@@ -5,8 +5,22 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import io.papermc.paper.adventure.PaperAdventure; // Paper
import java.io.IOException;
+import java.util.Collections;
+import net.minecraft.ChatFormatting;
+import net.minecraft.core.NonNullList;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.PacketFlow;
+import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
+import net.minecraft.network.protocol.game.ClientboundChatPacket;
+import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket;
+import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
+import net.minecraft.network.protocol.game.ClientboundLevelChunkPacket;
+import net.minecraft.network.protocol.game.ClientboundMapItemDataPacket;
+import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket;
+import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
+import net.minecraft.world.item.ItemStack;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
@@ -21,6 +35,23 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
this.flow = side;
}
+ // Scissors start
+ private static int tryWrite(Packet packet, FriendlyByteBuf friendlyByteBuf, ChannelHandlerContext channelHandlerContext, int i) {
+ friendlyByteBuf.writeVarInt(i);
+ friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(PaperAdventure.LOCALE_ATTRIBUTE).get();
+
+ int j = friendlyByteBuf.writerIndex();
+ packet.write(friendlyByteBuf);
+ int k = friendlyByteBuf.writerIndex() - j;
+ int packetLength = friendlyByteBuf.readableBytes();
+ if (k > 8388608 || packetLength > MAX_PACKET_SIZE) {
+ throw new SkipPacketException(new IllegalArgumentException("Packet too big (is " + k + "): " + packet));
+ }
+
+ return k;
+ }
+ // Scissors end
+
@Override
protected void encode(ChannelHandlerContext channelHandlerContext, Packet<?> packet, ByteBuf byteBuf) throws Exception {
ConnectionProtocol connectionProtocol = channelHandlerContext.channel().attr(Connection.ATTRIBUTE_PROTOCOL).get();
@@ -36,35 +67,68 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
throw new IOException("Can't serialize unregistered packet");
} else {
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(byteBuf);
- friendlyByteBuf.writeVarInt(integer);
- friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(PaperAdventure.LOCALE_ATTRIBUTE).get(); // Paper
-
+ // Scissors start
+ int k;
try {
- int i = friendlyByteBuf.writerIndex();
- packet.write(friendlyByteBuf);
- int j = friendlyByteBuf.writerIndex() - i;
- if (j > 8388608) {
- throw new IllegalArgumentException("Packet too big (is " + j + ", should be less than 8388608): " + packet);
- }
+ k = tryWrite(packet, friendlyByteBuf, channelHandlerContext, integer);
} catch (Throwable var9) {
- LOGGER.error("Packet encoding of packet ID {} threw (skippable? {})", integer, packet.isSkippable(), var9); // Paper - WHAT WAS IT? WHO DID THIS TO YOU? WHAT DID YOU SEE?
- if (packet.isSkippable()) {
- throw new SkipPacketException(var9);
- } else {
- throw var9;
+ packet = capPacket(packet, integer);
+ if (packet == null) {
+ throw new SkipPacketException(new IllegalArgumentException("Packet too big: " + packet));
}
+ friendlyByteBuf.clear();
+ k = tryWrite(packet, friendlyByteBuf, channelHandlerContext, integer);
}
-
- // Paper start
- int packetLength = friendlyByteBuf.readableBytes();
- if (packetLength > MAX_PACKET_SIZE) {
- throw new PacketTooLargeException(packet, packetLength);
- }
- // Paper end
+ // Scissors end
}
}
}
+ // Scissors start
+ private static Packet capPacket(Packet packet, int i)
+ {
+ if (packet instanceof ClientboundBlockEntityDataPacket blockEntityDataPacket)
+ {
+ packet = new ClientboundBlockEntityDataPacket(blockEntityDataPacket.getPos(), blockEntityDataPacket.getType(), new CompoundTag());
+ }
+ else if (packet instanceof ClientboundLevelChunkPacket chunkPacket)
+ {
+ chunkPacket.clearNBT();
+ }
+ else if (packet instanceof ClientboundSetEntityDataPacket)
+ {
+ return null; // Skip
+ }
+ else if (packet instanceof ClientboundContainerSetContentPacket containerSetContentPacket)
+ {
+ packet = new ClientboundContainerSetContentPacket(containerSetContentPacket.getContainerId(), containerSetContentPacket.getStateId(), NonNullList.create(), ItemStack.EMPTY);
+ }
+ else if (packet instanceof ClientboundSetEquipmentPacket setEquipmentPacket)
+ {
+ packet = new ClientboundSetEquipmentPacket(setEquipmentPacket.getEntity(), Collections.emptyList());
+ }
+ else if (packet instanceof ClientboundContainerSetSlotPacket containerSetSlotPacket)
+ {
+ packet = new ClientboundContainerSetSlotPacket(containerSetSlotPacket.getContainerId(), containerSetSlotPacket.getStateId(), containerSetSlotPacket.getSlot(), ItemStack.EMPTY);
+ }
+ else if (packet instanceof ClientboundMapItemDataPacket mapItemDataPacket)
+ {
+ packet = new ClientboundMapItemDataPacket(mapItemDataPacket.getMapId(), mapItemDataPacket.getScale(), mapItemDataPacket.isLocked(), null, null);
+ }
+ else if (packet instanceof ClientboundChatPacket chatPacket)
+ {
+ return null;
+ }
+ else
+ {
+ LOGGER.error("Packet with ID {} was too large and was not caught. Please report this to the Scissors developers.", i);
+ return null;
+ }
+
+ return packet;
+ }
+ // Scissors end
+
// Paper start
private static int MAX_PACKET_SIZE = 2097152;
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java
index 60d72e488bc77cd913328be400ca374a873b4561..1af2260e7bab81fca24784172dd31e06e9adb1e1 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java
@@ -50,6 +50,13 @@ public class ClientboundLevelChunkPacket implements Packet<ClientGamePacketListe
}
// Paper end
+ // Scissors start
+ public void clearNBT() {
+ this.blockEntitiesTags.clear();
+ this.extraPackets.clear();
+ }
+ // Scissors end
+
// Paper start - Anti-Xray - Add chunk packet info
@Deprecated public ClientboundLevelChunkPacket(LevelChunk chunk) { this(chunk, true); } // Notice for updates: Please make sure this constructor isn't used anywhere
public ClientboundLevelChunkPacket(LevelChunk chunk, boolean modifyBlocks) {

View File

@ -1,162 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: ayunami2000 <spwilliamsiam@gmail.com>
Date: Mon, 28 Mar 2022 17:02:21 -0400
Subject: [PATCH] block server-side chunkbans
diff --git a/src/main/java/net/minecraft/network/PacketEncoder.java b/src/main/java/net/minecraft/network/PacketEncoder.java
index b039a32b805fc02033fa862a1c40c4a51639e69a..1d407ebea9ff2932f93b7d6842b0e2a4e801b48c 100644
--- a/src/main/java/net/minecraft/network/PacketEncoder.java
+++ b/src/main/java/net/minecraft/network/PacketEncoder.java
@@ -4,9 +4,17 @@ import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import io.papermc.paper.adventure.PaperAdventure; // Paper
+
import java.io.IOException;
+
+import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.PacketFlow;
+import net.minecraft.network.protocol.game.*;
+import net.minecraft.network.syncher.SynchedEntityData;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.level.chunk.LevelChunk;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
@@ -44,27 +52,93 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
packet.write(friendlyByteBuf);
int j = friendlyByteBuf.writerIndex() - i;
if (j > 8388608) {
- throw new IllegalArgumentException("Packet too big (is " + j + ", should be less than 8388608): " + packet);
+ // Scissors start
+ noKicking(friendlyByteBuf, packet, integer, channelHandlerContext);
+ //throw new IllegalArgumentException("Packet too big (is " + j + ", should be less than 8388608): " + packet);
+ // Scissors end
}
} catch (Throwable var9) {
+ // Scissors start
+ noKicking(friendlyByteBuf, packet, integer, channelHandlerContext);
+ /*
LOGGER.error("Packet encoding of packet ID {} threw (skippable? {})", integer, packet.isSkippable(), var9); // Paper - WHAT WAS IT? WHO DID THIS TO YOU? WHAT DID YOU SEE?
if (packet.isSkippable()) {
throw new SkipPacketException(var9);
} else {
throw var9;
}
+ */
+ // Scissors end
}
// Paper start
int packetLength = friendlyByteBuf.readableBytes();
if (packetLength > MAX_PACKET_SIZE) {
- throw new PacketTooLargeException(packet, packetLength);
+ // Scissors start
+ friendlyByteBuf.clear();
+ noKicking(friendlyByteBuf, packet, integer, channelHandlerContext);
+ packetLength = friendlyByteBuf.readableBytes();
+ if (packetLength > MAX_PACKET_SIZE) {
+ friendlyByteBuf.clear();
+ //throw new PacketTooLargeException(packet, packetLength);
+ }
+ //throw new PacketTooLargeException(packet, packetLength);
+ // Scissors end
}
// Paper end
}
}
}
+ // Scissors start
+ private static void noKicking(FriendlyByteBuf friendlyByteBuf, Packet packet, Integer integer, ChannelHandlerContext channelHandlerContext) {
+ // no kicking!!
+ friendlyByteBuf.clear();
+ friendlyByteBuf.writeVarInt(integer);
+ friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(PaperAdventure.LOCALE_ATTRIBUTE).get(); // Paper
+ boolean didIt = true;
+ if (packet instanceof ClientboundBlockEntityDataPacket blockEntityDataPacket) {
+ packet = new ClientboundBlockEntityDataPacket(blockEntityDataPacket.getPos(), blockEntityDataPacket.getType(), new CompoundTag());
+ } else if (packet instanceof ClientboundLevelChunkPacket chunkPacket) {
+ chunkPacket.clearNbt();
+ } else if (packet instanceof ClientboundSetEntityDataPacket entityDataPacket) {
+ friendlyByteBuf.writeVarInt(entityDataPacket.getId());
+ friendlyByteBuf.writeByte(255);
+ didIt = false;//prevent default packet writing
+ } else if (packet instanceof ClientboundContainerSetContentPacket containerSetContentPacket) {
+ containerSetContentPacket.clearNbt();
+ } else if (packet instanceof ClientboundSetEquipmentPacket setEquipmentPacket) {
+ friendlyByteBuf.writeVarInt(setEquipmentPacket.getEntity());
+ didIt = false;//prevent default
+ } else if (packet instanceof ClientboundContainerSetSlotPacket containerSetSlotPacket) {
+ //i really would rather cancel this packet entirely buuut idk how sOOOOoooo
+ friendlyByteBuf.writeByte(containerSetSlotPacket.getContainerId());
+ friendlyByteBuf.writeVarInt(containerSetSlotPacket.getStateId());
+ friendlyByteBuf.writeShort(containerSetSlotPacket.getSlot());
+ friendlyByteBuf.writeItem(ItemStack.EMPTY);
+ didIt = false;//prevent default
+ } else if (packet instanceof ClientboundMapItemDataPacket mapItemDataPacket) {
+ packet = new ClientboundMapItemDataPacket(mapItemDataPacket.getMapId(),mapItemDataPacket.getScale(),mapItemDataPacket.isLocked(),null,null);
+ } else {
+ didIt = false;
+ LOGGER.info(packet.getClass().getName() + " overflowed/errored and was not caught!!");
+ }
+ if (didIt) {
+ try {
+ int i = friendlyByteBuf.writerIndex();
+ packet.write(friendlyByteBuf);
+ int j = friendlyByteBuf.writerIndex() - i;
+ if (j > 8388608) {
+ friendlyByteBuf.clear();
+ //throw new IllegalArgumentException("Packet too big (is " + j + ", should be less than 8388608): " + packet);
+ }
+ } catch (Throwable var69) {
+ friendlyByteBuf.clear();
+ }
+ }
+ }
+ // Scissors end
+
// Paper start
private static int MAX_PACKET_SIZE = 2097152;
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java
index dbd8b9b09b82c1b75e8be9dc7416d9f0863c8c87..f71f68d1482f7e0481a95533e42e8ee5089f15ff 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java
@@ -10,7 +10,14 @@ public class ClientboundContainerSetContentPacket implements Packet<ClientGamePa
private final int containerId;
private final int stateId;
private final List<ItemStack> items;
- private final ItemStack carriedItem;
+ private ItemStack carriedItem; // Scissors - removed "final"
+
+ // Scissors start
+ public void clearNbt(){
+ this.items.clear();
+ this.carriedItem = ItemStack.EMPTY;
+ }
+ // Scissors end
public ClientboundContainerSetContentPacket(int syncId, int revision, NonNullList<ItemStack> contents, ItemStack cursorStack) {
this.containerId = syncId;
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java
index 60d72e488bc77cd913328be400ca374a873b4561..89c385c5ec88c8b51f9e118b65f3b9c2a58c7d9b 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java
@@ -50,6 +50,13 @@ public class ClientboundLevelChunkPacket implements Packet<ClientGamePacketListe
}
// Paper end
+ // Scissors start
+ public void clearNbt() {
+ this.blockEntitiesTags.clear();
+ this.extraPackets.clear();
+ }
+ // Scissors end
+
// Paper start - Anti-Xray - Add chunk packet info
@Deprecated public ClientboundLevelChunkPacket(LevelChunk chunk) { this(chunk, true); } // Notice for updates: Please make sure this constructor isn't used anywhere
public ClientboundLevelChunkPacket(LevelChunk chunk, boolean modifyBlocks) {

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Prevent velocity freeze
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
index 3a088afd8269606543ebc9fb2074eb70431fcd39..3376fee37fdf06563f7305c44bd1529254890bcb 100644 index 3a088afd8269606543ebc9fb2074eb70431fcd39..561e68806b50c417f08a20bcf87c44d117b9f41c 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java --- a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
@@ -41,9 +41,13 @@ public abstract class AbstractHurtingProjectile extends Projectile { @@ -41,9 +41,13 @@ public abstract class AbstractHurtingProjectile extends Projectile {
@ -42,9 +42,9 @@ index 3a088afd8269606543ebc9fb2074eb70431fcd39..3376fee37fdf06563f7305c44bd15292
+ return; + return;
+ } + }
+ +
+ this.xPower = xPower; + this.xPower = Math.min(Math.max(xPower, -1024), 1024);
+ this.yPower = yPower; + this.yPower = Math.min(Math.max(yPower, -1024), 1024);
+ this.zPower = zPower; + this.zPower = Math.min(Math.max(zPower, -1024), 1024);
+ } + }
+ // Scissors end + // Scissors end
+ +

View File

@ -0,0 +1,53 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Luna <lunahatesgogle@gmail.com>
Date: Sun, 2 Apr 2023 16:29:51 -0300
Subject: [PATCH] Patch large selector distance crash
diff --git a/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java b/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java
index a890f52e2214242f6e31353bb912813d00e41045..bc0e1938d6e1faca64bb041442bad9e501708fe4 100644
--- a/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java
+++ b/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java
@@ -173,7 +173,7 @@ public abstract class MinMaxBounds<T extends Number> {
return double_ == null ? null : double_ * double_;
}
- private Doubles(@Nullable Double min, @Nullable Double max) {
+ public Doubles(@Nullable Double min, @Nullable Double max) { // Scissors - private -> public
super(min, max);
this.minSq = squareOpt(min);
this.maxSq = squareOpt(max);
diff --git a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
index 0fb8f32427843f4bfd90ab88ecb3ab3e4a4fda31..c9b5f7715d4a866d477c65adb39f11cc46e5623a 100644
--- a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
+++ b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
@@ -58,9 +58,27 @@ public class EntitySelector {
this.includesEntities = includesNonPlayers;
this.worldLimited = localWorldOnly;
this.predicate = basePredicate;
- this.range = distance;
+
+ // Scissors start - Patch large selector distance crash
+ this.range = new MinMaxBounds.Doubles(
+ distance.getMin() != null ? Math.min(distance.getMin(), 1024) : null,
+ distance.getMax() != null ? Math.min(distance.getMax(), 1024) : null
+ );
this.position = positionOffset;
- this.aabb = box;
+ if (box != null) {
+ this.aabb = new AABB(
+ Math.min(Math.max(box.minX, -1024), 1025),
+ Math.min(Math.max(box.minY, -1024), 1025),
+ Math.min(Math.max(box.minZ, -1024), 1025),
+ Math.min(Math.max(box.maxX, -1024), 1025),
+ Math.min(Math.max(box.maxY, -1024), 1025),
+ Math.min(Math.max(box.maxZ, -1024), 1025),
+ false
+ );
+ } else {
+ this.aabb = null;
+ }
+ // Scissors end
this.order = sorter;
this.currentEntity = senderOnly;
this.playerName = playerName;

View File

@ -0,0 +1,23 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Luna <lunahatesgogle@gmail.com>
Date: Fri, 28 Apr 2023 18:24:09 -0300
Subject: [PATCH] Limit map decoration text length
diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java
index 3d9c3e3ec56bc1bf5719e31d169015eaf598bde3..1233c8904f6a4f91931b42a08c514d783267a4c8 100644
--- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java
+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java
@@ -14,6 +14,12 @@ public class MapDecoration {
private final Component name;
public MapDecoration(MapDecoration.Type type, byte x, byte z, byte rotation, @Nullable Component text) {
+ // Scissors start - Limit decoration text length
+ if (text != null && text.getString().length() > 32) {
+ text = null;
+ }
+ // Scissors end
+
this.type = type;
this.x = x;
this.y = z;

View File

@ -0,0 +1,23 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Luna <lunahatesgogle@gmail.com>
Date: Fri, 28 Apr 2023 18:24:55 -0300
Subject: [PATCH] Limit map decoration count
diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
index 6f64d1ce0f5b20e1579f8af64c08ef8fc4e4444b..d78036b62bb36539d3d3e1a8299af2fa60ebd379 100644
--- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
@@ -357,6 +357,12 @@ public class MapItemSavedData extends SavedData {
}
private void addDecoration(MapDecoration.Type type, @Nullable LevelAccessor world, String key, double x, double z, double rotation, @Nullable Component text) {
+ // Scissors start - Limit decoration count
+ if (this.decorations.size() > 32) {
+ return;
+ }
+ // Scissors end
+
int i = 1 << this.scale;
float f = (float) (x - (double) this.x) / (float) i;
float f1 = (float) (z - (double) this.z) / (float) i;

View File

@ -0,0 +1,26 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Luna <lunahatesgogle@gmail.com>
Date: Fri, 28 Apr 2023 18:25:56 -0300
Subject: [PATCH] Prevent player banning using duplicate UUIDs
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index a002713686e66faf0d18662586a7a236c27ca7d2..795d72084ff196c5f4a0ff4bafd3ac88257fc379 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1354,7 +1354,14 @@ public class ServerLevel extends Level implements WorldGenLevel {
if (entity != null) {
ServerLevel.LOGGER.warn("Force-added player with duplicate UUID {}", player.getUUID().toString());
entity.unRide();
- this.removePlayerImmediately((ServerPlayer) entity, Entity.RemovalReason.DISCARDED);
+
+ // Scissors start - Prevent player banning using duplicate UUIDs
+ if (entity instanceof ServerPlayer serverPlayer) {
+ this.removePlayerImmediately(serverPlayer, Entity.RemovalReason.DISCARDED);
+ } else {
+ entity.discard();
+ }
+ // Scissors end
}
this.entityManager.addNewEntity(player); // CraftBukkit - decompile error

View File

@ -0,0 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Luna <lunahatesgogle@gmail.com>
Date: Fri, 28 Apr 2023 18:32:03 -0300
Subject: [PATCH] Don't warn on duplicate entity UUIDs
diff --git a/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java b/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
index 8cb246863e06c5b95ba1442e2ec47095026c4f39..48990a8192465e11b27c072fc7d4351a6c5fb7a0 100644
--- a/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
+++ b/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
@@ -147,7 +147,7 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
return true;
}
// Paper end
- PersistentEntitySectionManager.LOGGER.warn("UUID of added entity already exists: {}", entity);
+ // Scissors - Don't warn on duplicate entity UUIDs
// Paper start
if (net.minecraft.world.level.Level.DEBUG_ENTITIES && ((Entity) entity).level.paperConfig.duplicateUUIDMode != com.destroystokyo.paper.PaperWorldConfig.DuplicateUUIDMode.NOTHING) {
if (((Entity) entity).addedToWorldStack != null) {