From c13e6e69a23279e424a37576d84ff98f3eb67455 Mon Sep 17 00:00:00 2001 From: FearThe1337 Date: Wed, 10 Dec 2014 14:41:54 +0100 Subject: Implement displayblocks for minecarts (SPIGOT-14). --- .../bukkit/craftbukkit/entity/CraftMinecart.java | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/main/java') 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 + } } -- cgit v1.2.3