From 92ef45d1663165d0317662ce1b58088e0cb2144d Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Fri, 13 Dec 2024 17:14:25 +0100 Subject: [PATCH] First attempt --- .../component/DataComponentPatch.java.patch | 34 +++++++------------ .../core/component/DataComponents.java.patch | 4 +-- 2 files changed, 14 insertions(+), 24 deletions(-) rename paper-server/patches/{unapplied => sources}/net/minecraft/core/component/DataComponentPatch.java.patch (62%) rename paper-server/patches/{unapplied => sources}/net/minecraft/core/component/DataComponents.java.patch (98%) diff --git a/paper-server/patches/unapplied/net/minecraft/core/component/DataComponentPatch.java.patch b/paper-server/patches/sources/net/minecraft/core/component/DataComponentPatch.java.patch similarity index 62% rename from paper-server/patches/unapplied/net/minecraft/core/component/DataComponentPatch.java.patch rename to paper-server/patches/sources/net/minecraft/core/component/DataComponentPatch.java.patch index 53846b237e..272f5afdc5 100644 --- a/paper-server/patches/unapplied/net/minecraft/core/component/DataComponentPatch.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/component/DataComponentPatch.java.patch @@ -1,33 +1,24 @@ --- a/net/minecraft/core/component/DataComponentPatch.java +++ b/net/minecraft/core/component/DataComponentPatch.java -@@ -61,7 +61,7 @@ - } +@@ -125,7 +_,13 @@ } -- return reference2objectmap; -+ return (Reference2ObjectMap) reference2objectmap; // CraftBukkit - decompile error - }); - public static final StreamCodec STREAM_CODEC = new StreamCodec() { - public DataComponentPatch decode(RegistryFriendlyByteBuf registryfriendlybytebuf) { -@@ -144,7 +144,13 @@ - } - - private static void encodeComponent(RegistryFriendlyByteBuf buf, DataComponentType type, Object value) { -- type.streamCodec().encode(buf, value); + private static void encodeComponent(RegistryFriendlyByteBuf buffer, DataComponentType component, Object value) { +- component.streamCodec().encode(buffer, (T)value); + // Paper start - codec errors of random anonymous classes are useless + try { -+ type.streamCodec().encode(buf, (T) value); // CraftBukkit - decompile error ++ component.streamCodec().encode(buffer, (T) value); // CraftBukkit - decompile error + } catch (final Exception e) { -+ throw new RuntimeException("Error encoding component " + type, e); ++ throw new RuntimeException("Error encoding component " + component, e); + } + // Paper end - codec errors of random anonymous classes are useless } }; private static final String REMOVED_PREFIX = "!"; -@@ -270,7 +276,43 @@ - private final Reference2ObjectMap, Optional> map = new Reference2ObjectArrayMap(); +@@ -230,6 +_,42 @@ - Builder() {} + Builder() { + } + + // CraftBukkit start + public void copy(DataComponentPatch orig) { @@ -45,7 +36,7 @@ + public boolean isEmpty() { + return this.map.isEmpty(); + } - ++ + @Override + public boolean equals(Object object) { + if (this == object) { @@ -64,7 +55,6 @@ + return this.map.hashCode(); + } + // CraftBukkit end -+ - public DataComponentPatch.Builder set(DataComponentType type, T value) { - this.map.put(type, Optional.of(value)); - return this; + + public DataComponentPatch.Builder set(DataComponentType component, T value) { + this.map.put(component, Optional.of(value)); diff --git a/paper-server/patches/unapplied/net/minecraft/core/component/DataComponents.java.patch b/paper-server/patches/sources/net/minecraft/core/component/DataComponents.java.patch similarity index 98% rename from paper-server/patches/unapplied/net/minecraft/core/component/DataComponents.java.patch rename to paper-server/patches/sources/net/minecraft/core/component/DataComponents.java.patch index eb470da08e..c1f061a0af 100644 --- a/paper-server/patches/unapplied/net/minecraft/core/component/DataComponents.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/component/DataComponents.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/component/DataComponents.java +++ b/net/minecraft/core/component/DataComponents.java -@@ -180,10 +180,10 @@ +@@ -180,10 +_,10 @@ "map_post_processing", builder -> builder.networkSynchronized(MapPostProcessing.STREAM_CODEC) ); public static final DataComponentType CHARGED_PROJECTILES = register( @@ -13,7 +13,7 @@ ); public static final DataComponentType POTION_CONTENTS = register( "potion_contents", builder -> builder.persistent(PotionContents.CODEC).networkSynchronized(PotionContents.STREAM_CODEC).cacheEncoding() -@@ -250,7 +250,7 @@ +@@ -250,7 +_,7 @@ "pot_decorations", builder -> builder.persistent(PotDecorations.CODEC).networkSynchronized(PotDecorations.STREAM_CODEC).cacheEncoding() ); public static final DataComponentType CONTAINER = register(