mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-22 22:45:31 +01:00
Improve Minecart#getMinecartMaterial (#11544)
Removes the hardcoded lookup in favour of calling the AbstractVehicle getItemDrop method.
This commit is contained in:
parent
94ea770212
commit
2e6eafb7e8
2 changed files with 16 additions and 17 deletions
|
@ -6,6 +6,16 @@ Subject: [PATCH] API to get Material from Boats and Minecarts
|
||||||
== AT ==
|
== AT ==
|
||||||
public net.minecraft.world.entity.vehicle.AbstractBoat getDropItem()Lnet/minecraft/world/item/Item;
|
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 fb9f0a62201dfeccd0eec9bb399f9edc6a01f1f0..d01a588aea379c962dd63f1428f92cf2442f4d45 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||||
|
@@ -717,4 +717,5 @@ 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
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java
|
||||||
index c101d01b55472efc9fc2829b8c17db5377ed57ff..5d51a49228eaee94f91cd04843e27c7918ca8796 100644
|
index c101d01b55472efc9fc2829b8c17db5377ed57ff..5d51a49228eaee94f91cd04843e27c7918ca8796 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftBoat.java
|
||||||
|
@ -25,7 +35,7 @@ index c101d01b55472efc9fc2829b8c17db5377ed57ff..5d51a49228eaee94f91cd04843e27c79
|
||||||
public Status getStatus() {
|
public Status getStatus() {
|
||||||
return CraftBoat.boatStatusFromNms(this.getHandle().status);
|
return CraftBoat.boatStatusFromNms(this.getHandle().status);
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java
|
||||||
index c4db7c00c66e064993b8b2158f226d063eea798c..8192ccb01ed4efe9e987cab94952c172ed876581 100644
|
index c4db7c00c66e064993b8b2158f226d063eea798c..e02ecbdc158311bdc7e4d13307de6e2a2cf54235 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java
|
||||||
@@ -4,6 +4,7 @@ import net.minecraft.server.level.ServerLevel;
|
@@ -4,6 +4,7 @@ import net.minecraft.server.level.ServerLevel;
|
||||||
|
@ -36,25 +46,14 @@ index c4db7c00c66e064993b8b2158f226d063eea798c..8192ccb01ed4efe9e987cab94952c172
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||||
@@ -69,6 +70,24 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart {
|
@@ -69,6 +70,13 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart {
|
||||||
this.getHandle().setDerailedVelocityMod(derailed);
|
this.getHandle().setDerailedVelocityMod(derailed);
|
||||||
}
|
}
|
||||||
|
|
||||||
+ // Paper start
|
+ // Paper start
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public Material getMinecartMaterial() {
|
+ public Material getMinecartMaterial() {
|
||||||
+ return CraftMagicNumbers.getMaterial(minecartEntityTypeToMaterial(this.getHandle().getType()));
|
+ return CraftMagicNumbers.getMaterial(this.getHandle().publicGetDropItem());
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ 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());
|
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
+
|
+
|
||||||
|
|
|
@ -110,7 +110,7 @@ index d555fd0b200c012f30ed0c0ec09a37b25a737b76..7a6d51020d9c6be33b4c34c0d6085595
|
||||||
this.discard(null); // CraftBukkit - add Bukkit remove cause
|
this.discard(null); // CraftBukkit - add Bukkit remove cause
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
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 1fdf2179eb768575fa49c019fb6d81f466892f98..ce91809d66007def728a127a0a9d33f6235cc94d 100644
|
index f88c1becd08e7b10f228624160b85f89a379fbeb..cdc8606ffe5c75ee19d92e9f86f26b2a502d765e 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||||
@@ -93,6 +93,7 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
@@ -93,6 +93,7 @@ public abstract class AbstractMinecart extends VehicleEntity {
|
||||||
|
@ -221,10 +221,10 @@ index 1ceaa081231a617bd87331b308c24d9c7a8dcf2b..2fd4a3068d86a37cc18c9203448823c5
|
||||||
+ // Paper end - friction API
|
+ // Paper end - friction API
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java
|
||||||
index 8192ccb01ed4efe9e987cab94952c172ed876581..5791f9936532899b337b149a109781fba0819657 100644
|
index e02ecbdc158311bdc7e4d13307de6e2a2cf54235..b42bce0c4f4b3aac2729cfdad392d863245ed693 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java
|
||||||
@@ -138,4 +138,18 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart {
|
@@ -127,4 +127,18 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart {
|
||||||
public int getDisplayBlockOffset() {
|
public int getDisplayBlockOffset() {
|
||||||
return this.getHandle().getDisplayOffset();
|
return this.getHandle().getDisplayOffset();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue