cn.nukkit.block.BlockOreDiamond 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.ItemDiamond;
import cn.nukkit.item.ItemTool;
import cn.nukkit.item.enchantment.Enchantment;
import cn.nukkit.math.NukkitRandom;
import java.util.concurrent.ThreadLocalRandom;
/**
* @author MagicDroidX (Nukkit Project)
*/
public class BlockOreDiamond extends BlockSolid {
public BlockOreDiamond() {
}
@Override
public int getId() {
return DIAMOND_ORE;
}
@Override
public double getHardness() {
return 3;
}
@Override
public double getResistance() {
return 15;
}
@Override
public int getToolType() {
return ItemTool.TYPE_PICKAXE;
}
@Override
public int getToolTier() {
return ItemTool.TIER_IRON;
}
@Override
public String getName() {
return "Diamond Ore";
}
@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 ItemDiamond(0, count)
};
} else {
return Item.EMPTY_ARRAY;
}
}
@Override
public int getDropExp() {
return new NukkitRandom().nextRange(3, 7);
}
@Override
public boolean canHarvestWithHand() {
return false;
}
@Override
public boolean canSilkTouch() {
return true;
}
}