cn.nukkit.block.BlockHayBale Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of powernukkit Show documentation
Show all versions of powernukkit Show documentation
A Minecraft Bedrock Edition server software implementation made in Java from scratch which supports all new features.
package cn.nukkit.block;
import cn.nukkit.Player;
import cn.nukkit.item.Item;
import cn.nukkit.item.ItemTool;
import cn.nukkit.math.BlockFace;
import cn.nukkit.utils.BlockColor;
import cn.nukkit.utils.Faceable;
import javax.annotation.Nonnull;
/**
* @author xtypr
* @since 2015/11/24
*/
public class BlockHayBale extends BlockSolidMeta implements Faceable {
public BlockHayBale() {
this(0);
}
public BlockHayBale(int meta) {
super(meta);
}
@Override
public int getId() {
return HAY_BALE;
}
@Override
public String getName() {
return "Hay Bale";
}
@Override
public double getHardness() {
return 0.5;
}
@Override
public double getResistance() {
return 2.5;
}
@Override
public int getToolType() {
return ItemTool.TYPE_HOE;
}
@Override
public int getBurnChance() {
return 60;
}
@Override
public int getBurnAbility() {
return 20;
}
@Override
public boolean place(@Nonnull Item item, @Nonnull Block block, @Nonnull Block target, @Nonnull BlockFace face, double fx, double fy, double fz, Player player) {
int[] faces = new int[]{
0,
0,
0b1000,
0b1000,
0b0100,
0b0100,
};
this.setDamage((this.getDamage() & 0x03) | faces[face.getIndex()]);
this.getLevel().setBlock(block, this, true, true);
return true;
}
@Override
public BlockColor getColor() {
return BlockColor.YELLOW_BLOCK_COLOR;
}
@Override
public BlockFace getBlockFace() {
return BlockFace.fromHorizontalIndex(this.getDamage() & 0x07);
}
}