cn.nukkit.block.BlockConcretePowder 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.api.PowerNukkitDifference;
import cn.nukkit.item.Item;
import cn.nukkit.item.ItemTool;
import cn.nukkit.level.Level;
import cn.nukkit.math.BlockFace;
import javax.annotation.Nonnull;
/**
* @author CreeperFace
* @since 2.6.2017
*/
@PowerNukkitDifference(info = "Extends BlockFallableMeta instead of BlockFallable")
public class BlockConcretePowder extends BlockFallableMeta {
public BlockConcretePowder() {
// Does nothing
}
public BlockConcretePowder(int meta) {
super(meta);
}
@Override
public int getId() {
return CONCRETE_POWDER;
}
@Override
public String getName() {
return "Concrete Powder";
}
@Override
public double getResistance() {
return 2.5;
}
@Override
public double getHardness() {
return 0.5;
}
@Override
public int getToolType() {
return ItemTool.TYPE_SHOVEL;
}
@Override
public int onUpdate(int type) {
if (type == Level.BLOCK_UPDATE_NORMAL) {
super.onUpdate(Level.BLOCK_UPDATE_NORMAL);
for (int side = 1; side <= 5; side++) {
Block block = this.getSide(BlockFace.fromIndex(side));
if (block.getId() == Block.WATER || block.getId() == Block.STILL_WATER || block.getId() == Block.LAVA || block.getId() == Block.STILL_LAVA) {
this.level.setBlock(this, Block.get(Block.CONCRETE, getDamage()), true, true);
}
}
return Level.BLOCK_UPDATE_NORMAL;
}
return 0;
}
@Override
public boolean place(@Nonnull Item item, @Nonnull Block b, @Nonnull Block target, @Nonnull BlockFace face, double fx, double fy, double fz, Player player) {
boolean concrete = false;
for (int side = 1; side <= 5; side++) {
Block block = this.getSide(BlockFace.fromIndex(side));
if (block.getId() == Block.WATER || block.getId() == Block.STILL_WATER || block.getId() == Block.LAVA || block.getId() == Block.STILL_LAVA) {
concrete = true;
break;
}
}
if (concrete) {
this.level.setBlock(this, Block.get(Block.CONCRETE, this.getDamage()), true, true);
} else {
this.level.setBlock(this, this, true, true);
}
return true;
}
}