mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-24 03:25:15 +01:00
Implement displayblocks for minecarts (SPIGOT-14).
This commit is contained in:
parent
fe8d20e376
commit
c13e6e69a2
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user