cn.nukkit.block.BlockCarpet 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.PowerNukkitOnly;
import cn.nukkit.api.Since;
import cn.nukkit.item.Item;
import cn.nukkit.level.Level;
import cn.nukkit.math.AxisAlignedBB;
import cn.nukkit.math.BlockFace;
import cn.nukkit.utils.BlockColor;
import cn.nukkit.utils.DyeColor;
import javax.annotation.Nonnull;
/**
* @author xtypr
* @since 2015/11/24
*/
public class BlockCarpet extends BlockFlowable {
public BlockCarpet() {
this(0);
}
public BlockCarpet(int meta) {
super(meta);
}
public BlockCarpet(DyeColor dyeColor) {
this(dyeColor.getWoolData());
}
@Override
public int getId() {
return CARPET;
}
@Override
public double getHardness() {
return 0.1;
}
@Override
public double getResistance() {
return 0.5;
}
@Override
public boolean isSolid() {
return true;
}
@Since("1.3.0.0-PN")
@PowerNukkitOnly
@Override
public boolean isSolid(BlockFace side) {
return false;
}
@Override
public String getName() {
return DyeColor.getByWoolData(getDamage()) + " Carpet";
}
@Override
public boolean canPassThrough() {
return false;
}
@PowerNukkitOnly
@Override
public int getWaterloggingLevel() {
return 1;
}
@Override
protected AxisAlignedBB recalculateBoundingBox() {
return this;
}
@Override
public double getMaxY() {
return this.y + 0.0625;
}
@Override
public boolean place(@Nonnull Item item, @Nonnull Block block, @Nonnull Block target, @Nonnull BlockFace face, double fx, double fy, double fz, Player player) {
Block down = this.down();
if (down.getId() != Item.AIR) {
this.getLevel().setBlock(block, this, true, true);
return true;
}
return false;
}
@Override
public int onUpdate(int type) {
if (type == Level.BLOCK_UPDATE_NORMAL) {
if (this.down().getId() == Item.AIR) {
this.getLevel().useBreakOn(this);
return Level.BLOCK_UPDATE_NORMAL;
}
}
return 0;
}
@Override
public BlockColor getColor() {
return DyeColor.getByWoolData(getDamage()).getColor();
}
public DyeColor getDyeColor() {
return DyeColor.getByWoolData(getDamage());
}
}