cn.nukkit.block.BlockOreCoal 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.item.Item;
import cn.nukkit.item.ItemCoal;
import cn.nukkit.item.ItemTool;
import cn.nukkit.item.enchantment.Enchantment;
import cn.nukkit.math.NukkitRandom;
import cn.nukkit.utils.BlockColor;
import java.util.concurrent.ThreadLocalRandom;
/**
* @author MagicDroidX (Nukkit Project)
*/
public class BlockOreCoal extends BlockSolid {
public BlockOreCoal() {
}
@Override
public int getId() {
return COAL_ORE;
}
@Override
public double getHardness() {
return 3;
}
@Override
public double getResistance() {
return 15;
}
@Override
public int getToolType() {
return ItemTool.TYPE_PICKAXE;
}
@Override
public String getName() {
return "Coal Ore";
}
@Override
public int getToolTier() {
return ItemTool.TIER_WOODEN;
}
@Override
public Item[] getDrops(Item item) {
if (item.isPickaxe() && item.getTier() >= getToolTier()) {
int count = 1;
Enchantment fortune = item.getEnchantment(Enchantment.ID_FORTUNE_DIGGING);
if (fortune != null && fortune.getLevel() >= 1) {
int i = ThreadLocalRandom.current().nextInt(fortune.getLevel() + 2) - 1;
if (i < 0) {
i = 0;
}
count = i + 1;
}
return new Item[]{
new ItemCoal(0, count)
};
} else {
return Item.EMPTY_ARRAY;
}
}
@Override
public int getDropExp() {
return new NukkitRandom().nextRange(0, 2);
}
@Override
public boolean canHarvestWithHand() {
return false;
}
@Override
public boolean canSilkTouch() {
return true;
}
@Override
public BlockColor getColor() {
return BlockColor.BLACK_BLOCK_COLOR;
}
}