From f7bc64123028cd4357713241bad0faf9f419fc2a Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Mon, 14 Jun 2021 02:06:46 -0700 Subject: [PATCH 1/2] Add missing getLevel implementation to Hopper Minecart, add mapping to fix reobf --- .../additional-spigot-member-mappings.csrg | 5 +++++ patches/server/0349-Optimize-Hoppers.patch | 22 +++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/build-data/additional-spigot-member-mappings.csrg b/build-data/additional-spigot-member-mappings.csrg index 962d83c9a2..33f15ea1ca 100644 --- a/build-data/additional-spigot-member-mappings.csrg +++ b/build-data/additional-spigot-member-mappings.csrg @@ -20,3 +20,8 @@ net/minecraft/world/entity/npc/EntityVillagerAbstract fD ()Lnet/minecraft/world/ # BehaviorWorkComposter -> BehaviorWork net/minecraft/world/entity/ai/behavior/BehaviorWorkComposter a (Lnet/minecraft/server/level/WorldServer;Lnet/minecraft/world/entity/npc/EntityVillager;)V doWork + +# We add getLevel to the Hopper interface (implemented by Hoppers and Hopper Minecarts), but this also exists on BlockEntity, +# which Hoppers also extend. We need to map the method we add to the Hopper interface to the same name used for the method on BlockEntity +# to avoid remap causing issues +net/minecraft/world/level/block/entity/IHopper getWorld ()Lnet/minecraft/world/level/World; getLevel diff --git a/patches/server/0349-Optimize-Hoppers.patch b/patches/server/0349-Optimize-Hoppers.patch index d68d9a0355..1ec55ab1c3 100644 --- a/patches/server/0349-Optimize-Hoppers.patch +++ b/patches/server/0349-Optimize-Hoppers.patch @@ -43,6 +43,24 @@ index f00839eab02277bf10b742c88fadc4aa9e89e7e0..312be2221e1acc44aaf6936533b0eb96 this.profiler.push(() -> { return worldserver + " " + worldserver.dimension().location(); +diff --git a/src/main/java/net/minecraft/world/entity/vehicle/MinecartHopper.java b/src/main/java/net/minecraft/world/entity/vehicle/MinecartHopper.java +index 449d2e7b18608ca36282f1a29e69457fc525307e..c738cb0433ea4a86d82372bf66e29c01f991d2c6 100644 +--- a/src/main/java/net/minecraft/world/entity/vehicle/MinecartHopper.java ++++ b/src/main/java/net/minecraft/world/entity/vehicle/MinecartHopper.java +@@ -68,6 +68,13 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper + this.enabled = enabled; + } + ++ // Paper start - add back getLevel ++ @Override ++ public net.minecraft.world.level.Level getLevel() { ++ return this.level; ++ } ++ // Paper end ++ + @Override + public double getLevelX() { + return this.getX(); diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java index dd4deb08eb3ed15a156269a11d3d43abfd61fe5b..10f55ba189d12c46e0ef38b0b96a29894b4fba93 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java @@ -84,14 +102,14 @@ index 8a079ee3ed243fd19b1dd7eed2de1dd33785faa1..c3a07ccccd5cc38552363c82398f432c } diff --git a/src/main/java/net/minecraft/world/level/block/entity/Hopper.java b/src/main/java/net/minecraft/world/level/block/entity/Hopper.java -index a05acf709735b40ca86f978508c63a86065fd405..c1754df6a60ff93d75a28145b9dc4e9174241a21 100644 +index a05acf709735b40ca86f978508c63a86065fd405..71dd26ca6626631b94d53818cd06b93f61485369 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/Hopper.java +++ b/src/main/java/net/minecraft/world/level/block/entity/Hopper.java @@ -14,6 +14,10 @@ public interface Hopper extends Container { return SUCK; } -+ net.minecraft.world.level.Level getLevel(); ++ net.minecraft.world.level.Level getLevel(); // Paper + + default net.minecraft.core.BlockPos getBlockPosition() { return new net.minecraft.core.BlockPos(getLevelX(), getLevelY(), getLevelZ()); } // Paper + From eddf0f40dc9022cf233295eba7fe7132a61b8141 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Mon, 14 Jun 2021 02:15:37 -0700 Subject: [PATCH 2/2] decomp fixes --- ...0466-Support-old-UUID-format-for-NBT.patch | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/patches/server/0466-Support-old-UUID-format-for-NBT.patch b/patches/server/0466-Support-old-UUID-format-for-NBT.patch index 0418f312a1..9fd9265bf0 100644 --- a/patches/server/0466-Support-old-UUID-format-for-NBT.patch +++ b/patches/server/0466-Support-old-UUID-format-for-NBT.patch @@ -46,7 +46,7 @@ index 1aa3af8c7714b2c850fb4264c863db8e639e6284..2a805d6bbeede50898d36258976ff25e return tag != null && tag.getType() == IntArrayTag.TYPE && ((IntArrayTag)tag).getAsIntArray().length == 4; } diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java -index 57c9575a9714acb95d9dced672955a96d71dfd1e..dc136cd4d5d4ba1e0e53a7187b3a2e836e185c19 100644 +index 57c9575a9714acb95d9dced672955a96d71dfd1e..06fe97e05608fc21f90c9884d745d910beb6883d 100644 --- a/src/main/java/net/minecraft/nbt/NbtUtils.java +++ b/src/main/java/net/minecraft/nbt/NbtUtils.java @@ -40,14 +40,14 @@ import org.apache.logging.log4j.LogManager; @@ -78,3 +78,23 @@ index 57c9575a9714acb95d9dced672955a96d71dfd1e..dc136cd4d5d4ba1e0e53a7187b3a2e83 if (compound.hasUUID("Id")) { uUID = compound.getUUID("Id"); } +@@ -495,7 +500,7 @@ public final class NbtUtils { + } + + public static CompoundTag update(DataFixer fixer, DataFixTypes fixTypes, CompoundTag compound, int oldVersion, int targetVersion) { +- return fixer.update(fixTypes.getType(), new Dynamic<>(NbtOps.INSTANCE, compound), oldVersion, targetVersion).getValue(); ++ return (CompoundTag) fixer.update(fixTypes.getType(), new com.mojang.serialization.Dynamic<>(NbtOps.INSTANCE, compound), oldVersion, targetVersion).getValue(); // Paper - decompile fix + } + + public static Component toPrettyComponent(Tag element) { +@@ -620,8 +625,8 @@ public final class NbtUtils { + CompoundTag compoundTag2 = new CompoundTag(); + if (i + 2 <= string.length()) { + String string3 = string.substring(i + 1, string.indexOf(125, i)); +- COMMA_SPLITTER.split(string3).forEach((string2) -> { +- List list = COLON_SPLITTER.splitToList(string2); ++ COMMA_SPLITTER.split(string3).forEach(it -> { // Paper - decompile fix ++ List list = COLON_SPLITTER.splitToList(it); // Paper - decompile fix + if (list.size() == 2) { + compoundTag2.putString(list.get(0), list.get(1)); + } else {