cn.nukkit.block.BlockRedstoneRepeaterPowered 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.ItemRedstoneRepeater;
import cn.nukkit.math.BlockFace;
import javax.annotation.Nonnull;
/**
* @author CreeperFace
* @since 10.4.2017
*/
public class BlockRedstoneRepeaterPowered extends BlockRedstoneDiode {
public BlockRedstoneRepeaterPowered() {
this(0);
}
public BlockRedstoneRepeaterPowered(int meta) {
super(meta);
this.isPowered = true;
}
@Override
public int getId() {
return POWERED_REPEATER;
}
@Override
public String getName() {
return "Powered Repeater";
}
@Override
public BlockFace getFacing() {
return BlockFace.fromHorizontalIndex(getDamage());
}
@Override
protected boolean isAlternateInput(Block block) {
return isDiode(block);
}
@Override
public Item toItem() {
return new ItemRedstoneRepeater();
}
@Override
protected int getDelay() {
return (1 + (getDamage() >> 2)) * 2;
}
@Override
protected Block getPowered() {
return this;
}
@Override
protected Block getUnpowered() {
return Block.get(BlockID.UNPOWERED_REPEATER, this.getDamage());
}
@Override
public int getLightLevel() {
return 7;
}
@Override
public boolean onActivate(@Nonnull Item item, Player player) {
this.setDamage(this.getDamage() + 4);
if (this.getDamage() > 15) this.setDamage(this.getDamage() % 4);
this.level.setBlock(this, this, true, true);
return true;
}
@Override
public boolean isLocked() {
return this.getPowerOnSides() > 0;
}
}