Update Paper and readd chunk ban patch

This commit is contained in:
Telesphoreo 2024-06-16 16:01:51 -05:00
parent ae4eb94393
commit c5b33792e6
3 changed files with 179 additions and 17 deletions

View File

@ -8,18 +8,3 @@
# To import classes from the vanilla Minecraft jar use `minecraft` as the artifactId: # To import classes from the vanilla Minecraft jar use `minecraft` as the artifactId:
# minecraft net.minecraft.world.level.entity.LevelEntityGetterAdapter # minecraft net.minecraft.world.level.entity.LevelEntityGetterAdapter
# minecraft net/minecraft/world/level/entity/LevelEntityGetter.java # minecraft net/minecraft/world/level/entity/LevelEntityGetter.java
minecraft net.minecraft.network.chat.FormattedText
minecraft net.minecraft.network.chat.contents.TranslatableContents.java
minecraft net.minecraft.network.chat.HoverEvent
minecraft net.minecraft.world.item.KnowledgeBookItem
minecraft net.minecraft.network.chat.contents.NbtContents
minecraft net.minecraft.network.chat.contents.EntityDataSource
minecraft net.minecraft.network.chat.contents.DataSource
minecraft net.minecraft.nbt.SnbtPrinterTagVisitor
minecraft net.minecraft.nbt.StringTagVisitor
minecraft net.minecraft.nbt.TextComponentTagVisitor
minecraft net.minecraft.world.level.block.entity.StructureBlockEntity
minecraft net.minecraft.world.ContainerHelper
minecraft net.minecraft.advancements.critereon.MinMaxBounds
minecraft net.minecraft.network.protocol.game.ServerboundSetCommandMinecartPacket
minecraft net.minecraft.world.entity.boss.enderdragon.phases.DragonChargePlayerPhase

View File

@ -2,7 +2,7 @@ group=me.totalfreedom.scissors
version=1.20.6-R0.1-SNAPSHOT version=1.20.6-R0.1-SNAPSHOT
mcVersion=1.20.6 mcVersion=1.20.6
paperRef=79e2cb620ef03539390d97940824b38b707918f5 paperRef=fe7043e19e5c3990cc2d859cd1f126ab2a3ce85a
org.gradle.caching=true org.gradle.caching=true
org.gradle.parallel=true org.gradle.parallel=true

View File

@ -0,0 +1,177 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Sun, 16 Jun 2024 15:38:49 -0500
Subject: [PATCH] Add more fallback code for chunk bans
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java
index 5d3e739d28d394ed59fe0003245cc55ac62e6087..7189525e573be6d5023c6b34fded8bd1259293f9 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java
@@ -1,11 +1,17 @@
package net.minecraft.network.protocol.game;
import java.util.function.BiFunction;
+import java.util.stream.Collectors;
+
+import me.totalfreedom.scissors.NbtUtility;
+import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.RegistryFriendlyByteBuf;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.SignedMessageBody;
import net.minecraft.network.codec.ByteBufCodecs;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.network.protocol.Packet;
@@ -36,6 +42,23 @@ public class ClientboundBlockEntityDataPacket implements Packet<ClientGamePacket
return create(blockEntity, BlockEntity::getUpdateTag);
}
+ // Scissors start - Handle large packets disconnecting client
+ @Override
+ public boolean hasLargePacketFallback() {
+ return true;
+ }
+
+ @Override
+ public boolean packetTooLarge(net.minecraft.network.Connection manager) {
+ if (NbtUtility.isTooLarge(this.tag))
+ {
+ this.tag.getAllKeys().forEach(tag::remove);
+ }
+ manager.send(new ClientboundBlockEntityDataPacket(pos, this.type, this.tag));
+ return true;
+ }
+ // Scissors end - Handle large packets disconnecting client
+
public ClientboundBlockEntityDataPacket(BlockPos pos, BlockEntityType<?> blockEntityType, CompoundTag nbt) {
this.pos = pos;
this.type = blockEntityType;
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetSlotPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetSlotPacket.java
index 63f6a2437da9363786b55af0a7cbc5373232d35b..38e8e3e58821da896851a42d6088bc70857ae7e1 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetSlotPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetSlotPacket.java
@@ -43,6 +43,19 @@ public class ClientboundContainerSetSlotPacket implements Packet<ClientGamePacke
return GamePacketTypes.CLIENTBOUND_CONTAINER_SET_SLOT;
}
+ // Scissors start - Handle large packets disconnecting client
+ @Override
+ public boolean hasLargePacketFallback() {
+ return true;
+ }
+
+ @Override
+ public boolean packetTooLarge(net.minecraft.network.Connection manager) {
+ manager.send(new ClientboundContainerSetSlotPacket(this.containerId, this.stateId, this.slot, ItemStack.EMPTY));
+ return true;
+ }
+ // Scissors end - Handle large packets disconnecting client
+
@Override
public void handle(ClientGamePacketListener listener) {
listener.handleContainerSetSlot(this);
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundMapItemDataPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundMapItemDataPacket.java
index 466dc69d8c06766733a6164fa5c911e902493a23..b89bf65249f3741d32a49de230ffaef2daeb8505 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundMapItemDataPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundMapItemDataPacket.java
@@ -36,6 +36,19 @@ public record ClientboundMapItemDataPacket(
this(mapId, scale, locked, decorations != null ? Optional.of(List.copyOf(decorations)) : Optional.empty(), Optional.ofNullable(updateData));
}
+ // Scissors start - Handle large packets disconnecting client
+ @Override
+ public boolean hasLargePacketFallback() {
+ return true;
+ }
+
+ @Override
+ public boolean packetTooLarge(net.minecraft.network.Connection manager) {
+ manager.send(new ClientboundMapItemDataPacket(mapId, scale, locked, Optional.empty(), Optional.empty()));
+ return true;
+ }
+ // Scissors end - Handle large packets disconnecting client
+
@Override
public PacketType<ClientboundMapItemDataPacket> type() {
return GamePacketTypes.CLIENTBOUND_MAP_ITEM_DATA;
@@ -46,6 +59,8 @@ public record ClientboundMapItemDataPacket(
listener.handleMapItemData(this);
}
+
+
public void applyToMap(MapItemSavedData mapState) {
this.decorations.ifPresent(mapState::addClientSideDecorations);
this.colorPatch.ifPresent(updateData -> updateData.applyToMap(mapState));
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerChatPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerChatPacket.java
index 37ab438ab37b9235666ae69376509bdde7722d87..cd1d0efec72c83e0f2bbc7ffcb5d2d3b8385f4fe 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerChatPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerChatPacket.java
@@ -1,7 +1,10 @@
package net.minecraft.network.protocol.game;
+import java.util.Optional;
import java.util.UUID;
import javax.annotation.Nullable;
+
+import net.minecraft.ChatFormatting;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.chat.ChatType;
@@ -39,6 +42,19 @@ public record ClientboundPlayerChatPacket(
);
}
+ // Scissors start - Handle large packets disconnecting client
+ @Override
+ public boolean hasLargePacketFallback() {
+ return true;
+ }
+
+ @Override
+ public boolean packetTooLarge(net.minecraft.network.Connection manager) {
+ manager.send(new ClientboundPlayerChatPacket(sender, index, signature, body, Component.empty().append("** Message too large **").withStyle(ChatFormatting.RED), filterMask, chatType));
+ return true;
+ }
+ // Scissors end - Handle large packets disconnecting client
+
private void write(RegistryFriendlyByteBuf buf) {
buf.writeUUID(this.sender);
buf.writeVarInt(this.index);
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetEquipmentPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetEquipmentPacket.java
index 3945ca04ede578121b370592482ac917f2d4cf96..f05678ab6fc598da0416c6e0c68bc30a1beef139 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetEquipmentPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetEquipmentPacket.java
@@ -2,6 +2,8 @@ package net.minecraft.network.protocol.game;
import com.google.common.collect.Lists;
import com.mojang.datafixers.util.Pair;
+
+import java.util.Collections;
import java.util.List;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.network.codec.StreamCodec;
@@ -44,6 +46,19 @@ public class ClientboundSetEquipmentPacket implements Packet<ClientGamePacketLis
} while ((i & -128) != 0);
}
+ // Scissors start - Handle large packets disconnecting client
+ @Override
+ public boolean hasLargePacketFallback() {
+ return true;
+ }
+
+ @Override
+ public boolean packetTooLarge(net.minecraft.network.Connection manager) {
+ manager.send(new ClientboundSetEquipmentPacket(entity, Collections.emptyList()));
+ return true;
+ }
+ // Scissors end - Handle large packets disconnecting client
+
private void write(RegistryFriendlyByteBuf buf) {
buf.writeVarInt(this.entity);
int i = this.slots.size();