mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-30 16:19:03 +01:00
First attempt
This commit is contained in:
parent
344088ae5b
commit
92ef45d166
2 changed files with 14 additions and 24 deletions
|
@ -1,33 +1,24 @@
|
||||||
--- a/net/minecraft/core/component/DataComponentPatch.java
|
--- a/net/minecraft/core/component/DataComponentPatch.java
|
||||||
+++ b/net/minecraft/core/component/DataComponentPatch.java
|
+++ b/net/minecraft/core/component/DataComponentPatch.java
|
||||||
@@ -61,7 +61,7 @@
|
@@ -125,7 +_,13 @@
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- return reference2objectmap;
|
private static <T> void encodeComponent(RegistryFriendlyByteBuf buffer, DataComponentType<T> component, Object value) {
|
||||||
+ return (Reference2ObjectMap) reference2objectmap; // CraftBukkit - decompile error
|
- component.streamCodec().encode(buffer, (T)value);
|
||||||
});
|
|
||||||
public static final StreamCodec<RegistryFriendlyByteBuf, DataComponentPatch> STREAM_CODEC = new StreamCodec<RegistryFriendlyByteBuf, DataComponentPatch>() {
|
|
||||||
public DataComponentPatch decode(RegistryFriendlyByteBuf registryfriendlybytebuf) {
|
|
||||||
@@ -144,7 +144,13 @@
|
|
||||||
}
|
|
||||||
|
|
||||||
private static <T> void encodeComponent(RegistryFriendlyByteBuf buf, DataComponentType<T> type, Object value) {
|
|
||||||
- type.streamCodec().encode(buf, value);
|
|
||||||
+ // Paper start - codec errors of random anonymous classes are useless
|
+ // Paper start - codec errors of random anonymous classes are useless
|
||||||
+ try {
|
+ try {
|
||||||
+ type.streamCodec().encode(buf, (T) value); // CraftBukkit - decompile error
|
+ component.streamCodec().encode(buffer, (T) value); // CraftBukkit - decompile error
|
||||||
+ } catch (final Exception e) {
|
+ } 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
|
+ // Paper end - codec errors of random anonymous classes are useless
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private static final String REMOVED_PREFIX = "!";
|
private static final String REMOVED_PREFIX = "!";
|
||||||
@@ -270,7 +276,43 @@
|
@@ -230,6 +_,42 @@
|
||||||
private final Reference2ObjectMap<DataComponentType<?>, Optional<?>> map = new Reference2ObjectArrayMap();
|
|
||||||
|
|
||||||
Builder() {}
|
Builder() {
|
||||||
|
}
|
||||||
+
|
+
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ public void copy(DataComponentPatch orig) {
|
+ public void copy(DataComponentPatch orig) {
|
||||||
|
@ -45,7 +36,7 @@
|
||||||
+ public boolean isEmpty() {
|
+ public boolean isEmpty() {
|
||||||
+ return this.map.isEmpty();
|
+ return this.map.isEmpty();
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public boolean equals(Object object) {
|
+ public boolean equals(Object object) {
|
||||||
+ if (this == object) {
|
+ if (this == object) {
|
||||||
|
@ -64,7 +55,6 @@
|
||||||
+ return this.map.hashCode();
|
+ return this.map.hashCode();
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
+
|
|
||||||
public <T> DataComponentPatch.Builder set(DataComponentType<T> type, T value) {
|
public <T> DataComponentPatch.Builder set(DataComponentType<T> component, T value) {
|
||||||
this.map.put(type, Optional.of(value));
|
this.map.put(component, Optional.of(value));
|
||||||
return this;
|
|
|
@ -1,6 +1,6 @@
|
||||||
--- a/net/minecraft/core/component/DataComponents.java
|
--- a/net/minecraft/core/component/DataComponents.java
|
||||||
+++ b/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)
|
"map_post_processing", builder -> builder.networkSynchronized(MapPostProcessing.STREAM_CODEC)
|
||||||
);
|
);
|
||||||
public static final DataComponentType<ChargedProjectiles> CHARGED_PROJECTILES = register(
|
public static final DataComponentType<ChargedProjectiles> CHARGED_PROJECTILES = register(
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
);
|
);
|
||||||
public static final DataComponentType<PotionContents> POTION_CONTENTS = register(
|
public static final DataComponentType<PotionContents> POTION_CONTENTS = register(
|
||||||
"potion_contents", builder -> builder.persistent(PotionContents.CODEC).networkSynchronized(PotionContents.STREAM_CODEC).cacheEncoding()
|
"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()
|
"pot_decorations", builder -> builder.persistent(PotDecorations.CODEC).networkSynchronized(PotDecorations.STREAM_CODEC).cacheEncoding()
|
||||||
);
|
);
|
||||||
public static final DataComponentType<ItemContainerContents> CONTAINER = register(
|
public static final DataComponentType<ItemContainerContents> CONTAINER = register(
|
Loading…
Reference in a new issue