From ce545de57f5a196386d517afcc0d56e8dd8f321e Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 8 Jul 2023 13:07:16 +1000 Subject: [PATCH] SPIGOT-7398: TextDisplay#setInterpolationDuration incorrectly updates the line width --- .../net/minecraft/world/entity/Display.patch | 90 +++++++++++++++++++ .../craftbukkit/entity/CraftTextDisplay.java | 6 +- 2 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 nms-patches/net/minecraft/world/entity/Display.patch diff --git a/nms-patches/net/minecraft/world/entity/Display.patch b/nms-patches/net/minecraft/world/entity/Display.patch new file mode 100644 index 000000000..d0898c25a --- /dev/null +++ b/nms-patches/net/minecraft/world/entity/Display.patch @@ -0,0 +1,90 @@ +--- a/net/minecraft/world/entity/Display.java ++++ b/net/minecraft/world/entity/Display.java +@@ -183,11 +183,11 @@ + + @Override + protected void readAdditionalSaveData(NBTTagCompound nbttagcompound) { +- DataResult dataresult; ++ // DataResult dataresult; // CraftBukkit - decompile error + Logger logger; + + if (nbttagcompound.contains("transformation")) { +- dataresult = Transformation.EXTENDED_CODEC.decode(DynamicOpsNBT.INSTANCE, nbttagcompound.get("transformation")); ++ DataResult> dataresult = Transformation.EXTENDED_CODEC.decode(DynamicOpsNBT.INSTANCE, nbttagcompound.get("transformation")); // CraftBukkit - decompile error + logger = Display.LOGGER; + Objects.requireNonNull(logger); + dataresult.resultOrPartial(SystemUtils.prefix("Display entity", logger::error)).ifPresent((pair) -> { +@@ -208,7 +208,7 @@ + } + + if (nbttagcompound.contains("billboard", 8)) { +- dataresult = Display.BillboardConstraints.CODEC.decode(DynamicOpsNBT.INSTANCE, nbttagcompound.get("billboard")); ++ DataResult> dataresult = Display.BillboardConstraints.CODEC.decode(DynamicOpsNBT.INSTANCE, nbttagcompound.get("billboard")); // CraftBukkit - decompile error + logger = Display.LOGGER; + Objects.requireNonNull(logger); + dataresult.resultOrPartial(SystemUtils.prefix("Display entity", logger::error)).ifPresent((pair) -> { +@@ -241,7 +241,7 @@ + } + + if (nbttagcompound.contains("brightness", 10)) { +- dataresult = Brightness.CODEC.decode(DynamicOpsNBT.INSTANCE, nbttagcompound.get("brightness")); ++ DataResult> dataresult = Brightness.CODEC.decode(DynamicOpsNBT.INSTANCE, nbttagcompound.get("brightness")); // CraftBukkit - decompile error + logger = Display.LOGGER; + Objects.requireNonNull(logger); + dataresult.resultOrPartial(SystemUtils.prefix("Display entity", logger::error)).ifPresent((pair) -> { +@@ -594,8 +594,8 @@ + private static final byte INITIAL_TEXT_OPACITY = -1; + public static final int INITIAL_BACKGROUND = 1073741824; + private static final DataWatcherObject DATA_TEXT_ID = DataWatcher.defineId(Display.TextDisplay.class, DataWatcherRegistry.COMPONENT); +- private static final DataWatcherObject DATA_LINE_WIDTH_ID = DataWatcher.defineId(Display.TextDisplay.class, DataWatcherRegistry.INT); +- private static final DataWatcherObject DATA_BACKGROUND_COLOR_ID = DataWatcher.defineId(Display.TextDisplay.class, DataWatcherRegistry.INT); ++ public static final DataWatcherObject DATA_LINE_WIDTH_ID = DataWatcher.defineId(Display.TextDisplay.class, DataWatcherRegistry.INT); ++ public static final DataWatcherObject DATA_BACKGROUND_COLOR_ID = DataWatcher.defineId(Display.TextDisplay.class, DataWatcherRegistry.INT); + private static final DataWatcherObject DATA_TEXT_OPACITY_ID = DataWatcher.defineId(Display.TextDisplay.class, DataWatcherRegistry.BYTE); + private static final DataWatcherObject DATA_STYLE_FLAGS_ID = DataWatcher.defineId(Display.TextDisplay.class, DataWatcherRegistry.BYTE); + private static final IntSet TEXT_RENDER_STATE_IDS = IntSet.of(new int[]{Display.TextDisplay.DATA_TEXT_ID.getId(), Display.TextDisplay.DATA_LINE_WIDTH_ID.getId(), Display.TextDisplay.DATA_BACKGROUND_COLOR_ID.getId(), Display.TextDisplay.DATA_TEXT_OPACITY_ID.getId(), Display.TextDisplay.DATA_STYLE_FLAGS_ID.getId()}); +@@ -614,7 +614,7 @@ + this.entityData.define(Display.TextDisplay.DATA_TEXT_ID, IChatBaseComponent.empty()); + this.entityData.define(Display.TextDisplay.DATA_LINE_WIDTH_ID, 200); + this.entityData.define(Display.TextDisplay.DATA_BACKGROUND_COLOR_ID, 1073741824); +- this.entityData.define(Display.TextDisplay.DATA_TEXT_OPACITY_ID, -1); ++ this.entityData.define(Display.TextDisplay.DATA_TEXT_OPACITY_ID, (byte) -1); // CraftBukkit - decompile error + this.entityData.define(Display.TextDisplay.DATA_STYLE_FLAGS_ID, (byte) 0); + } + +@@ -639,7 +639,7 @@ + return (Integer) this.entityData.get(Display.TextDisplay.DATA_LINE_WIDTH_ID); + } + +- public void setLineWidth(int i) { ++ private void setLineWidth(int i) { + this.entityData.set(Display.TextDisplay.DATA_LINE_WIDTH_ID, i); + } + +@@ -655,7 +655,7 @@ + return (Integer) this.entityData.get(Display.TextDisplay.DATA_BACKGROUND_COLOR_ID); + } + +- public void setBackgroundColor(int i) { ++ private void setBackgroundColor(int i) { + this.entityData.set(Display.TextDisplay.DATA_BACKGROUND_COLOR_ID, i); + } + +@@ -690,7 +690,7 @@ + + b0 = loadFlag(b0, nbttagcompound, "see_through", (byte) 2); + b0 = loadFlag(b0, nbttagcompound, "default_background", (byte) 4); +- DataResult dataresult = Display.TextDisplay.Align.CODEC.decode(DynamicOpsNBT.INSTANCE, nbttagcompound.get("alignment")); ++ DataResult> dataresult = Display.TextDisplay.Align.CODEC.decode(DynamicOpsNBT.INSTANCE, nbttagcompound.get("alignment")); // CraftBukkit - decompile error + Logger logger = Display.LOGGER; + + Objects.requireNonNull(logger); +@@ -961,7 +961,7 @@ + super.readAdditionalSaveData(nbttagcompound); + this.setItemStack(ItemStack.of(nbttagcompound.getCompound("item"))); + if (nbttagcompound.contains("item_display", 8)) { +- DataResult dataresult = ItemDisplayContext.CODEC.decode(DynamicOpsNBT.INSTANCE, nbttagcompound.get("item_display")); ++ DataResult> dataresult = ItemDisplayContext.CODEC.decode(DynamicOpsNBT.INSTANCE, nbttagcompound.get("item_display")); // CraftBukkit - decompile error + Logger logger = Display.LOGGER; + + Objects.requireNonNull(logger); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTextDisplay.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTextDisplay.java index 1198aff6b..0b1bb724d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTextDisplay.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTextDisplay.java @@ -46,7 +46,7 @@ public class CraftTextDisplay extends CraftDisplay implements TextDisplay { @Override public void setLineWidth(int width) { - getHandle().setLineWidth(width); + getHandle().getEntityData().set(Display.TextDisplay.DATA_LINE_WIDTH_ID, width); } @Override @@ -59,9 +59,9 @@ public class CraftTextDisplay extends CraftDisplay implements TextDisplay { @Override public void setBackgroundColor(Color color) { if (color == null) { - getHandle().setBackgroundColor(-1); + getHandle().getEntityData().set(Display.TextDisplay.DATA_BACKGROUND_COLOR_ID, -1); } else { - getHandle().setBackgroundColor(color.asARGB()); + getHandle().getEntityData().set(Display.TextDisplay.DATA_BACKGROUND_COLOR_ID, color.asARGB()); } }