From d38930d51ee57ccbd17b6f30a063782c1d2e3f83 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/Optimize-Hoppers.patch         | 20 ++++++++++++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)

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/Optimize-Hoppers.patch b/patches/server/Optimize-Hoppers.patch
index 48bbc09754..641aeeb368 100644
--- a/patches/server/Optimize-Hoppers.patch
+++ b/patches/server/Optimize-Hoppers.patch
@@ -43,6 +43,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
  
              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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
+--- a/src/main/java/net/minecraft/world/entity/vehicle/MinecartHopper.java
++++ b/src/main/java/net/minecraft/world/entity/vehicle/MinecartHopper.java
+@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
 --- a/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -91,7 +109,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
          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
 +