From 89d6bc1a930e9c2622eae0277a6ed95f5d602ef6 Mon Sep 17 00:00:00 2001 From: Abel <56084910+Abelkrijgtalles@users.noreply.github.com> Date: Sat, 9 Nov 2024 23:22:01 +0100 Subject: [PATCH] Improve Minecart#getMinecartMaterial (#11544) Removes the hardcoded lookup in favour of calling the AbstractVehicle getItemDrop method. --- ...et-Material-from-Boats-and-Minecarts.patch | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/patches/server/API-to-get-Material-from-Boats-and-Minecarts.patch b/patches/server/API-to-get-Material-from-Boats-and-Minecarts.patch index 354ebad579..d0b838c8ed 100644 --- a/patches/server/API-to-get-Material-from-Boats-and-Minecarts.patch +++ b/patches/server/API-to-get-Material-from-Boats-and-Minecarts.patch @@ -6,6 +6,16 @@ Subject: [PATCH] API to get Material from Boats and Minecarts == AT == public net.minecraft.world.entity.vehicle.AbstractBoat getDropItem()Lnet/minecraft/world/item/Item; +diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java ++++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java +@@ -0,0 +0,0 @@ public abstract class AbstractMinecart extends VehicleEntity { + this.derailedZ = derailed.getZ(); + } + // CraftBukkit end ++ public net.minecraft.world.item.Item publicGetDropItem() { return getDropItem(); } // Paper - api to get boat and minecart material - expose public drop item + } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java @@ -43,18 +53,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start + @Override + public Material getMinecartMaterial() { -+ return CraftMagicNumbers.getMaterial(minecartEntityTypeToMaterial(this.getHandle().getType())); -+ } -+ -+ static net.minecraft.world.item.Item minecartEntityTypeToMaterial(final net.minecraft.world.entity.EntityType type) { -+ if (type == net.minecraft.world.entity.EntityType.MINECART) return net.minecraft.world.item.Items.MINECART; -+ else if (type == net.minecraft.world.entity.EntityType.CHEST_MINECART) return net.minecraft.world.item.Items.CHEST_MINECART; -+ else if (type == net.minecraft.world.entity.EntityType.FURNACE_MINECART) return net.minecraft.world.item.Items.FURNACE_MINECART; -+ else if (type == net.minecraft.world.entity.EntityType.SPAWNER_MINECART) return net.minecraft.world.item.Items.MINECART; -+ else if (type == net.minecraft.world.entity.EntityType.COMMAND_BLOCK_MINECART) return net.minecraft.world.item.Items.COMMAND_BLOCK_MINECART; -+ else if (type == net.minecraft.world.entity.EntityType.HOPPER_MINECART) return net.minecraft.world.item.Items.HOPPER_MINECART; -+ else if (type == net.minecraft.world.entity.EntityType.TNT_MINECART) return net.minecraft.world.item.Items.TNT_MINECART; -+ else throw new UnsupportedOperationException("Server implementation is missing minecart material binding for entity type " + type.toShortString()); ++ return CraftMagicNumbers.getMaterial(this.getHandle().publicGetDropItem()); + } + // Paper end +