cn.nukkit.block.BlockBeacon Maven / Gradle / Ivy
package cn.nukkit.block;
import cn.nukkit.Player;
import cn.nukkit.api.PowerNukkitDifference;
import cn.nukkit.api.PowerNukkitOnly;
import cn.nukkit.api.Since;
import cn.nukkit.blockentity.BlockEntity;
import cn.nukkit.blockentity.BlockEntityBeacon;
import cn.nukkit.inventory.BeaconInventory;
import cn.nukkit.item.Item;
import cn.nukkit.item.ItemTool;
import cn.nukkit.math.BlockFace;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
/**
* @author Angelic47 (Nukkit Project)
*/
@PowerNukkitDifference(since = "1.4.0.0-PN", info = "Implements BlockEntityHolder only in PowerNukkit")
public class BlockBeacon extends BlockTransparent implements BlockEntityHolder {
public BlockBeacon() {
// Does nothing
}
@Override
public int getId() {
return BEACON;
}
@Since("1.4.0.0-PN")
@PowerNukkitOnly
@NotNull
@Override
public Class extends BlockEntityBeacon> getBlockEntityClass() {
return BlockEntityBeacon.class;
}
@PowerNukkitOnly
@Since("1.4.0.0-PN")
@NotNull
@Override
public String getBlockEntityType() {
return BlockEntity.BEACON;
}
@Override
public double getHardness() {
return 3;
}
@Since("1.4.0.0-PN")
@PowerNukkitOnly
@NotNull
@Override
public double calculateBreakTime(@NotNull Item item) {
return calculateBreakTime(item, null);
}
@Since("1.4.0.0-PN")
@PowerNukkitOnly
@NotNull
@Override
public double calculateBreakTime(@NotNull Item item, @org.jetbrains.annotations.Nullable Player player) {
return 4.5;
}
@Override
public double getResistance() {
return 15;
}
@Override
public int getLightLevel() {
return 15;
}
@Override
public int getToolType() {
return ItemTool.TYPE_PICKAXE;
}
@Override
public String getName() {
return "Beacon";
}
@Override
public boolean canBeActivated() {
return true;
}
@PowerNukkitOnly
@Override
public int getWaterloggingLevel() {
return 1;
}
@Override
public boolean onActivate(@NotNull Item item, @Nullable Player player) {
if (player == null) {
return false;
}
getOrCreateBlockEntity();
player.addWindow(new BeaconInventory(player.getUIInventory(), this), Player.BEACON_WINDOW_ID);
return true;
}
@Override
public boolean place(@NotNull Item item, @NotNull Block block, @NotNull Block target, @NotNull BlockFace face, double fx, double fy, double fz, @Nullable Player player) {
return BlockEntityHolder.setBlockAndCreateEntity(this) != null;
}
@Override
public boolean canBePushed() {
return false;
}
@Override
@PowerNukkitOnly
public boolean canBePulled() {
return false;
}
}