Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 12:30:06 +01:00
Implement displayblocks for minecarts (SPIGOT-14).
Dieser Commit ist enthalten in:
Ursprung
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
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren