diff options
author | MiniDigger | Martin <[email protected]> | 2024-01-14 11:04:49 +0100 |
---|---|---|
committer | MiniDigger | Martin <[email protected]> | 2024-01-14 11:04:49 +0100 |
commit | bee74680e607c2e29b038329f62181238911cd83 (patch) | |
tree | 708fd1a4a0227d9071243adf2a42d5e9e96cde4a /patch-remap/mache-vineflower-stripped/net/minecraft/network | |
parent | 0a44692ef6ff6e255d48eb3ba1bb114166eafda9 (diff) | |
download | Paper-bee74680e607c2e29b038329f62181238911cd83.tar.gz Paper-bee74680e607c2e29b038329f62181238911cd83.zip |
add remapped patches as a testsoftspoon
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/network')
14 files changed, 342 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/network/Connection.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/network/Connection.java.patch new file mode 100644 index 0000000000..43f5c67ab8 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/network/Connection.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/network/Connection.java ++++ b/net/minecraft/network/Connection.java +@@ -97,6 +105,7 @@ + private volatile Component delayedDisconnect; + @Nullable + BandwidthDebugMonitor bandwidthDebugMonitor; ++ public String hostname = ""; // CraftBukkit - add field + + public Connection(PacketFlow receiving) { + this.receiving = receiving; diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/network/FriendlyByteBuf.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/network/FriendlyByteBuf.java.patch new file mode 100644 index 0000000000..471c61ca94 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/network/FriendlyByteBuf.java.patch @@ -0,0 +1,54 @@ +--- a/net/minecraft/network/FriendlyByteBuf.java ++++ b/net/minecraft/network/FriendlyByteBuf.java +@@ -80,6 +81,8 @@ + import org.joml.Quaternionf; + import org.joml.Vector3f; + ++import org.bukkit.craftbukkit.inventory.CraftItemStack; // CraftBukkit ++ + public class FriendlyByteBuf extends ByteBuf { + public static final int DEFAULT_NBT_QUOTA = 2097152; + private final ByteBuf source; +@@ -536,8 +586,8 @@ + try { + NbtIo.writeAnyTag(tag, new ByteBufOutputStream(this)); + return this; +- } catch (IOException var3) { +- throw new EncoderException(var3); ++ } catch (Exception ioexception) { // CraftBukkit - IOException -> Exception ++ throw new EncoderException(ioexception); + } + } + +@@ -562,7 +614,7 @@ + } + + public FriendlyByteBuf writeItem(ItemStack stack) { +- if (stack.isEmpty()) { ++ if (stack.isEmpty() || stack.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem() + this.writeBoolean(false); + } else { + this.writeBoolean(true); +@@ -584,11 +638,17 @@ + if (!this.readBoolean()) { + return ItemStack.EMPTY; + } else { +- Item item = this.readById(BuiltInRegistries.ITEM); +- int _byte = this.readByte(); +- ItemStack itemStack = new ItemStack(item, _byte); +- itemStack.setTag(this.readNbt()); +- return itemStack; ++ Item item = (Item) this.readById((IdMap) BuiltInRegistries.ITEM); ++ byte b0 = this.readByte(); ++ ItemStack itemstack = new ItemStack(item, b0); ++ ++ itemstack.setTag(this.readNbt()); ++ // CraftBukkit start ++ if (itemstack.getTag() != null) { ++ CraftItemStack.setItemMeta(itemstack, CraftItemStack.getItemMeta(itemstack)); ++ } ++ // CraftBukkit end ++ return itemstack; + } + } + diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/network/chat/Component.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/network/chat/Component.java.patch new file mode 100644 index 0000000000..81502c0e4c --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/network/chat/Component.java.patch @@ -0,0 +1,27 @@ +--- a/net/minecraft/network/chat/Component.java ++++ b/net/minecraft/network/chat/Component.java +@@ -33,8 +34,23 @@ + import net.minecraft.resources.ResourceLocation; + import net.minecraft.util.FormattedCharSequence; + import net.minecraft.world.level.ChunkPos; ++// CraftBukkit start ++import java.util.stream.Stream; ++// CraftBukkit end + +-public interface Component extends Message, FormattedText { ++public interface Component extends Message, FormattedText, Iterable<Component> { // CraftBukkit ++ ++ // CraftBukkit start ++ default Stream<Component> stream() { ++ return com.google.common.collect.Streams.concat(new Stream[]{Stream.of(this), this.getSiblings().stream().flatMap(Component::stream)}); ++ } ++ ++ @Override ++ default Iterator<Component> iterator() { ++ return this.stream().iterator(); ++ } ++ // CraftBukkit end ++ + Style getStyle(); + + ComponentContents getContents(); diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/network/chat/TextColor.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/network/chat/TextColor.java.patch new file mode 100644 index 0000000000..cb8af9e589 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/network/chat/TextColor.java.patch @@ -0,0 +1,36 @@ +--- a/net/minecraft/network/chat/TextColor.java ++++ b/net/minecraft/network/chat/TextColor.java +@@ -15,15 +16,18 @@ + public final class TextColor { + private static final String CUSTOM_COLOR_PREFIX = "#"; + public static final Codec<TextColor> CODEC = Codec.STRING.comapFlatMap(TextColor::parseColor, TextColor::serialize); +- private static final Map<ChatFormatting, TextColor> LEGACY_FORMAT_TO_COLOR = Stream.of(ChatFormatting.values()) +- .filter(ChatFormatting::isColor) +- .collect(ImmutableMap.toImmutableMap(Function.identity(), chatFormatting -> new TextColor(chatFormatting.getColor(), chatFormatting.getName()))); +- private static final Map<String, TextColor> NAMED_COLORS = LEGACY_FORMAT_TO_COLOR.values() +- .stream() +- .collect(ImmutableMap.toImmutableMap(textColor -> textColor.name, Function.identity())); ++ private static final Map<ChatFormatting, TextColor> LEGACY_FORMAT_TO_COLOR = (Map) Stream.of(ChatFormatting.values()).filter(ChatFormatting::isColor).collect(ImmutableMap.toImmutableMap(Function.identity(), (enumchatformat) -> { ++ return new TextColor(enumchatformat.getColor(), enumchatformat.getName(), enumchatformat); // CraftBukkit ++ })); ++ private static final Map<String, TextColor> NAMED_COLORS = (Map) TextColor.LEGACY_FORMAT_TO_COLOR.values().stream().collect(ImmutableMap.toImmutableMap((chathexcolor) -> { ++ return chathexcolor.name; ++ }, Function.identity())); + private final int value; + @Nullable +- private final String name; ++ public final String name; ++ // CraftBukkit start ++ @Nullable ++ public final ChatFormatting format; + + private TextColor(int value, String name) { + this.value = value & 16777215; +@@ -34,6 +40,7 @@ + this.value = value & 16777215; + this.name = null; + } ++ // CraftBukkit end + + public int getValue() { + return this.value; diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/PacketUtils.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/PacketUtils.java.patch new file mode 100644 index 0000000000..9c3a79df96 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/PacketUtils.java.patch @@ -0,0 +1,65 @@ +--- a/net/minecraft/network/protocol/PacketUtils.java ++++ b/net/minecraft/network/protocol/PacketUtils.java +@@ -4,8 +4,14 @@ + import net.minecraft.CrashReport; + import net.minecraft.ReportedException; + import net.minecraft.network.PacketListener; +-import net.minecraft.server.RunningOnDifferentThreadException; ++import net.minecraft.server.CancelledPacketHandleException; ++import org.slf4j.Logger; ++ ++// CraftBukkit start ++import net.minecraft.server.MinecraftServer; + import net.minecraft.server.level.ServerLevel; ++import net.minecraft.server.network.ServerCommonPacketListenerImpl; ++// CraftBukkit end + import net.minecraft.util.thread.BlockableEventLoop; + import org.slf4j.Logger; + +@@ -18,17 +26,19 @@ + + public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T processor, BlockableEventLoop<?> executor) throws RunningOnDifferentThreadException { + if (!executor.isSameThread()) { +- executor.executeIfPossible( +- () -> { +- if (processor.shouldHandleMessage(packet)) { +- try { +- packet.handle(processor); +- } catch (Exception var6) { +- if (var6 instanceof ReportedException reportedException && reportedException.getCause() instanceof OutOfMemoryError +- || processor.shouldPropagateHandlingExceptions()) { +- if (var6 instanceof ReportedException reportedException1) { +- processor.fillCrashReport(reportedException1.getReport()); +- throw var6; ++ executor.executeIfPossible(() -> { ++ if (MinecraftServer.getServer().hasStopped() || (processor instanceof ServerCommonPacketListenerImpl && ((ServerCommonPacketListenerImpl) processor).processedDisconnect)) return; // CraftBukkit, MC-142590 ++ if (processor.shouldHandleMessage(packet)) { ++ try { ++ packet.handle(processor); ++ } catch (Exception exception) { ++ label25: ++ { ++ if (exception instanceof ReportedException) { ++ ReportedException reportedexception = (ReportedException) exception; ++ ++ if (reportedexception.getCause() instanceof OutOfMemoryError) { ++ break label25; + } + + CrashReport crashReport = CrashReport.forThrowable(var6, "Main thread packet handler"); +@@ -42,8 +63,13 @@ + LOGGER.debug("Ignoring packet due to disconnection: {}", packet); + } + } +- ); +- throw RunningOnDifferentThreadException.RUNNING_ON_DIFFERENT_THREAD; ++ ++ }); ++ throw CancelledPacketHandleException.RUNNING_ON_DIFFERENT_THREAD; ++ // CraftBukkit start - SPIGOT-5477, MC-142590 ++ } else if (MinecraftServer.getServer().hasStopped() || (processor instanceof ServerCommonPacketListenerImpl && ((ServerCommonPacketListenerImpl) processor).processedDisconnect)) { ++ throw CancelledPacketHandleException.RUNNING_ON_DIFFERENT_THREAD; ++ // CraftBukkit end + } + } + } diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch new file mode 100644 index 0000000000..ecaab61eb6 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java.patch @@ -0,0 +1,48 @@ +--- a/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java ++++ b/net/minecraft/network/protocol/common/ServerboundCustomPayloadPacket.java +@@ -11,11 +12,7 @@ + + public record ServerboundCustomPayloadPacket(CustomPacketPayload payload) implements Packet<ServerCommonPacketListener> { + private static final int MAX_PAYLOAD_SIZE = 32767; +- private static final Map<ResourceLocation, FriendlyByteBuf.Reader<? extends CustomPacketPayload>> KNOWN_TYPES = ImmutableMap.<ResourceLocation, FriendlyByteBuf.Reader<? extends CustomPacketPayload>>builder( +- +- ) +- .put(BrandPayload.ID, BrandPayload::new) +- .build(); ++ private static final Map<ResourceLocation, FriendlyByteBuf.a<? extends CustomPacketPayload>> KNOWN_TYPES = ImmutableMap.<ResourceLocation, FriendlyByteBuf.a<? extends CustomPacketPayload>>builder().build(); // CraftBukkit - no special handling + + public ServerboundCustomPayloadPacket(FriendlyByteBuf friendlyByteBuf) { + this(readPayload(friendlyByteBuf.readResourceLocation(), friendlyByteBuf)); +@@ -26,11 +24,13 @@ + return (CustomPacketPayload)(reader != null ? reader.apply(friendlyByteBuf) : readUnknownPayload(resourceLocation, friendlyByteBuf)); + } + +- private static DiscardedPayload readUnknownPayload(ResourceLocation resourceLocation, FriendlyByteBuf friendlyByteBuf) { +- int i = friendlyByteBuf.readableBytes(); ++ private static UnknownPayload readUnknownPayload(ResourceLocation minecraftkey, FriendlyByteBuf packetdataserializer) { // CraftBukkit ++ int i = packetdataserializer.readableBytes(); ++ + if (i >= 0 && i <= 32767) { +- friendlyByteBuf.skipBytes(i); +- return new DiscardedPayload(resourceLocation); ++ // CraftBukkit start ++ return new UnknownPayload(minecraftkey, packetdataserializer.readBytes(i)); ++ // CraftBukkit end + } else { + throw new IllegalArgumentException("Payload may not be larger than 32767 bytes"); + } +@@ -46,4 +45,14 @@ + public void handle(ServerCommonPacketListener handler) { + handler.handleCustomPayload(this); + } ++ ++ // CraftBukkit start ++ public record UnknownPayload(ResourceLocation id, io.netty.buffer.ByteBuf data) implements CustomPacketPayload { ++ ++ @Override ++ public void write(FriendlyByteBuf packetdataserializer) { ++ packetdataserializer.writeBytes(data); ++ } ++ } ++ // CraftBukkit end + } diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java.patch new file mode 100644 index 0000000000..11f0359b0a --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java ++++ b/net/minecraft/network/protocol/game/ClientboundInitializeBorderPacket.java +@@ -26,8 +27,10 @@ + } + + public ClientboundInitializeBorderPacket(WorldBorder worldBorder) { +- this.newCenterX = worldBorder.getCenterX(); +- this.newCenterZ = worldBorder.getCenterZ(); ++ // CraftBukkit start - multiply out nether border ++ this.newCenterX = worldBorder.getCenterX() * worldBorder.world.dimensionType().coordinateScale(); ++ this.newCenterZ = worldBorder.getCenterZ() * worldBorder.world.dimensionType().coordinateScale(); ++ // CraftBukkit end + this.oldSize = worldBorder.getSize(); + this.newSize = worldBorder.getLerpTarget(); + this.lerpTime = worldBorder.getLerpRemainingTime(); diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java.patch new file mode 100644 index 0000000000..01382a5fae --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java.patch @@ -0,0 +1,33 @@ +--- a/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java ++++ b/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java +@@ -23,13 +22,26 @@ + this.states = new BlockState[size]; + int i = 0; + +- for (short s : positions) { +- this.positions[i] = s; +- this.states[i] = section.getBlockState(SectionPos.sectionRelativeX(s), SectionPos.sectionRelativeY(s), SectionPos.sectionRelativeZ(s)); +- i++; ++ this.positions = new short[i]; ++ this.states = new IBlockData[i]; ++ int j = 0; ++ ++ for (ShortIterator shortiterator = positions.iterator(); shortiterator.hasNext(); ++j) { ++ short short0 = (Short) shortiterator.next(); ++ ++ this.positions[j] = short0; ++ this.states[j] = (section != null) ? section.getBlockState(SectionPos.sectionRelativeX(short0), SectionPos.sectionRelativeY(short0), SectionPos.sectionRelativeZ(short0)) : net.minecraft.world.level.block.Blocks.AIR.defaultBlockState(); // CraftBukkit - SPIGOT-6076, Mojang bug when empty chunk section notified + } + } + ++ // CraftBukkit start - Add constructor ++ public ClientboundSectionBlocksUpdatePacket(SectionPos sectionposition, ShortSet shortset, IBlockData[] states) { ++ this.sectionPos = sectionposition; ++ this.positions = shortset.toShortArray(); ++ this.states = states; ++ } ++ // CraftBukkit end ++ + public ClientboundSectionBlocksUpdatePacket(FriendlyByteBuf buffer) { + this.sectionPos = SectionPos.of(buffer.readLong()); + int varInt = buffer.readVarInt(); diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java.patch new file mode 100644 index 0000000000..5f90f331a9 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java.patch @@ -0,0 +1,15 @@ +--- a/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java ++++ b/net/minecraft/network/protocol/game/ClientboundSetBorderCenterPacket.java +@@ -9,8 +10,10 @@ + private final double newCenterZ; + + public ClientboundSetBorderCenterPacket(WorldBorder worldBorder) { +- this.newCenterX = worldBorder.getCenterX(); +- this.newCenterZ = worldBorder.getCenterZ(); ++ // CraftBukkit start - multiply out nether border ++ this.newCenterX = worldBorder.getCenterX() * (worldBorder.world != null ? worldBorder.world.dimensionType().coordinateScale() : 1.0); ++ this.newCenterZ = worldBorder.getCenterZ() * (worldBorder.world != null ? worldBorder.world.dimensionType().coordinateScale() : 1.0); ++ // CraftBukkit end + } + + public ClientboundSetBorderCenterPacket(FriendlyByteBuf buffer) { diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java.patch new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java.patch @@ -0,0 +1 @@ + diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java.patch new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/game/ServerboundUseItemOnPacket.java.patch @@ -0,0 +1 @@ + diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java.patch new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/game/ServerboundUseItemPacket.java.patch @@ -0,0 +1 @@ + diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/network/protocol/handshake/ClientIntentionPacket.java.patch @@ -0,0 +1 @@ + diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/network/syncher/SynchedEntityData.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/network/syncher/SynchedEntityData.java.patch new file mode 100644 index 0000000000..a1f82288d1 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/network/syncher/SynchedEntityData.java.patch @@ -0,0 +1,35 @@ +--- a/net/minecraft/network/syncher/SynchedEntityData.java ++++ b/net/minecraft/network/syncher/SynchedEntityData.java +@@ -132,6 +148,13 @@ + } + } + ++ // CraftBukkit start - add method from above ++ public <T> void markDirty(EntityDataAccessor<T> datawatcherobject) { ++ this.getItem(datawatcherobject).setDirty(true); ++ this.isDirty = true; ++ } ++ // CraftBukkit end ++ + public boolean isDirty() { + return this.isDirty; + } +@@ -220,6 +244,18 @@ + return this.itemsById.isEmpty(); + } + ++ // CraftBukkit start ++ public void refresh(ServerPlayer to) { ++ if (!this.isEmpty()) { ++ List<SynchedEntityData.DataValue<?>> list = this.getNonDefaultValues(); ++ ++ if (list != null) { ++ to.connection.send(new ClientboundSetEntityDataPacket(this.entity.getId(), list)); ++ } ++ } ++ } ++ // CraftBukkit end ++ + public static class DataItem<T> { + final EntityDataAccessor<T> accessor; + T value; |