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] 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 +