summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorFearThe1337 <admin@fearthe1337.com>2014-12-10 14:41:54 +0100
committermd_5 <git@md-5.net>2014-12-12 11:01:47 +1100
commitc13e6e69a23279e424a37576d84ff98f3eb67455 (patch)
tree4a5c0d705b7f90d4ffb1965ce22ab35692aa685a /src/main/java
parentfe8d20e376f1f343d9d1c95f02857b8d1641c0a5 (diff)
downloadcraftbukkit-c13e6e69a23279e424a37576d84ff98f3eb67455.tar
craftbukkit-c13e6e69a23279e424a37576d84ff98f3eb67455.tar.gz
craftbukkit-c13e6e69a23279e424a37576d84ff98f3eb67455.tar.lz
craftbukkit-c13e6e69a23279e424a37576d84ff98f3eb67455.tar.xz
craftbukkit-c13e6e69a23279e424a37576d84ff98f3eb67455.zip
Implement displayblocks for minecarts (SPIGOT-14).
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java
index daf6bb42..958ec2fe 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecart.java
@@ -1,9 +1,14 @@
package org.bukkit.craftbukkit.entity;
+import net.minecraft.server.Blocks;
import net.minecraft.server.EntityMinecartAbstract;
+import net.minecraft.server.IBlockData;
+import org.bukkit.Material;
import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
import org.bukkit.entity.Minecart;
+import org.bukkit.material.MaterialData;
import org.bukkit.util.NumberConversions;
import org.bukkit.util.Vector;
@@ -68,4 +73,28 @@ public abstract class CraftMinecart extends CraftVehicle implements Minecart {
public int _INVALID_getDamage() {
return NumberConversions.ceil(getDamage());
}
+
+ public void setDisplayBlock(MaterialData material) {
+ if(material != null) {
+ IBlockData block = CraftMagicNumbers.getBlock(material.getItemTypeId()).fromLegacyData(material.getData());
+ this.getHandle().a(block);
+ } else {
+ // Set block to air (default) and set the flag to not have a display block.
+ this.getHandle().a(Blocks.AIR.getBlockData());
+ this.getHandle().a(false);
+ }
+ }
+
+ public MaterialData getDisplayBlock() {
+ IBlockData blockData = getHandle().t(); // PAIL: Rename
+ return CraftMagicNumbers.getMaterial(blockData.getBlock()).getNewData((byte) blockData.getBlock().toLegacyData(blockData));
+ }
+
+ public void setDisplayBlockOffset(int offset) {
+ getHandle().l(offset); // PAIL: Rename
+ }
+
+ public int getDisplayBlockOffset() {
+ return getHandle().v(); // PAIL: Rename
+ }
}