cn.nukkit.block.BlockNylium 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.level.Level;
import cn.nukkit.level.generator.object.ObjectNyliumVegetation;
import cn.nukkit.level.particle.BoneMealParticle;
import cn.nukkit.math.NukkitRandom;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public abstract class BlockNylium extends BlockSolid {
@Override
public int getToolType() {
return ItemTool.TYPE_PICKAXE;
}
@Override
public int onUpdate(int type) {
if (type == Level.BLOCK_UPDATE_RANDOM && !up().isTransparent()) {
level.setBlock(this, Block.get(NETHERRACK), false);
return type;
}
return 0;
}
@Override
public boolean canBeActivated() {
return true;
}
@Override
public boolean onActivate(@Nonnull Item item, @Nullable Player player) {
Block up = up();
if (item.isNull() || !item.isFertilizer() || up.getId() != AIR) {
return false;
}
if (player != null && !player.isCreative()) {
item.count--;
}
grow();
level.addParticle(new BoneMealParticle(up));
return true;
}
public boolean grow() {
ObjectNyliumVegetation.growVegetation(level, this, new NukkitRandom());
return true;
}
@Override
public double getResistance() {
return 0.4;
}
@Override
public double getHardness() {
return 0.4;
}
@Override
public Item[] getDrops(Item item) {
if (item.isPickaxe() && item.getTier() >= ItemTool.TIER_WOODEN) {
return new Item[]{ Item.get(NETHERRACK) };
}
return Item.EMPTY_ARRAY;
}
@Override
public boolean canSilkTouch() {
return true;
}
@Override
public boolean canHarvestWithHand() {
return false;
}
}