cn.nukkit.block.BlockPurpur Maven / Gradle / Ivy
package cn.nukkit.block;
import cn.nukkit.Player;
import cn.nukkit.api.PowerNukkitOnly;
import cn.nukkit.api.Since;
import cn.nukkit.blockproperty.BlockProperties;
import cn.nukkit.item.Item;
import cn.nukkit.item.ItemBlock;
import cn.nukkit.item.ItemTool;
import cn.nukkit.math.BlockFace;
import org.jetbrains.annotations.NotNull;
public class BlockPurpur extends BlockSolidMeta {
@PowerNukkitOnly
@Since("1.5.0.0-PN")
public static final BlockProperties PROPERTIES = BlockQuartz.PROPERTIES;
public static final int PURPUR_NORMAL = 0;
public static final int PURPUR_PILLAR = 2;
public BlockPurpur() {
this(0);
}
public BlockPurpur(int meta) {
super(meta);
}
@Override
public String getName() {
String[] names = new String[]{
"Purpur Block",
"",
"Purpur Pillar",
""
};
return names[this.getDamage() & 0x03];
}
@Override
public int getId() {
return PURPUR_BLOCK;
}
@Since("1.4.0.0-PN")
@PowerNukkitOnly
@NotNull
@Override
public BlockProperties getProperties() {
return PROPERTIES;
}
@Override
public double getHardness() {
return 1.5;
}
@Override
public double getResistance() {
return 30;
}
@Override
public int getToolType() {
return ItemTool.TYPE_PICKAXE;
}
@Override
public boolean place(@NotNull Item item, @NotNull Block block, @NotNull Block target, @NotNull BlockFace face, double fx, double fy, double fz, Player player) {
if (this.getDamage() != PURPUR_NORMAL) {
short[] faces = new short[]{
0,
0,
0b1000,
0b1000,
0b0100,
0b0100
};
this.setDamage(((this.getDamage() & 0x03) | faces[face.getIndex()]));
}
this.getLevel().setBlock(block, this, true, true);
return true;
}
@Since("1.4.0.0-PN")
@PowerNukkitOnly
@Override
public int getToolTier() {
return ItemTool.TIER_WOODEN;
}
@Override
public Item toItem() {
return new ItemBlock(Block.get(BlockID.PURPUR_BLOCK), this.getDamage() & 0x03, 1);
}
}