From b5573b9884b799c5e2d407b20b8c8100d6eda555 Mon Sep 17 00:00:00 2001 From: Joshua Gallas <32830098+CiviledCode@users.noreply.github.com> Date: Fri, 17 Apr 2020 06:59:04 -0700 Subject: [PATCH] [2.0] Add DaylightDetector block entity (#1337) (#1345) * Add DaylightDetector block entity * Removed saveAdditionalData() Co-authored-by: CiviledCode --- .../impl/DaylightDetectorBlockEntity.java | 23 +++++++++++++++++++ .../nukkit/registry/BlockEntityRegistry.java | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 src/main/java/cn/nukkit/blockentity/impl/DaylightDetectorBlockEntity.java diff --git a/src/main/java/cn/nukkit/blockentity/impl/DaylightDetectorBlockEntity.java b/src/main/java/cn/nukkit/blockentity/impl/DaylightDetectorBlockEntity.java new file mode 100644 index 00000000000..8267d6470a6 --- /dev/null +++ b/src/main/java/cn/nukkit/blockentity/impl/DaylightDetectorBlockEntity.java @@ -0,0 +1,23 @@ +package cn.nukkit.blockentity.impl; + +import cn.nukkit.block.BlockIds; +import cn.nukkit.blockentity.BlockEntityType; +import cn.nukkit.blockentity.DaylightDetector; +import cn.nukkit.level.chunk.Chunk; +import cn.nukkit.utils.Identifier; +import com.nukkitx.math.vector.Vector3i; + +public class DaylightDetectorBlockEntity extends BaseBlockEntity implements DaylightDetector { + + + public DaylightDetectorBlockEntity(BlockEntityType type, Chunk chunk, Vector3i position) { + super(type, chunk, position); + } + + @Override + public boolean isValid() { + Identifier blockId = getBlock().getId(); + return blockId == BlockIds.DAYLIGHT_DETECTOR || blockId == BlockIds.DAYLIGHT_DETECTOR_INVERTED; + } + +} diff --git a/src/main/java/cn/nukkit/registry/BlockEntityRegistry.java b/src/main/java/cn/nukkit/registry/BlockEntityRegistry.java index 2ba78255615..945f50febd3 100644 --- a/src/main/java/cn/nukkit/registry/BlockEntityRegistry.java +++ b/src/main/java/cn/nukkit/registry/BlockEntityRegistry.java @@ -137,7 +137,7 @@ private void registerVanillaEntities() { registerVanilla(SKULL, SkullBlockEntity::new, "Skull"); registerVanilla(FLOWER_POT, FlowerPotBlockEntity::new, "FlowerPot"); registerVanilla(BREWING_STAND, BrewingStandBlockEntity::new, "BrewingStand"); - //registerVanilla(DAYLIGHT_DETECTOR, DaylightDetectorBlockEntity::new, "DaylightDetector"); + registerVanilla(DAYLIGHT_DETECTOR, DaylightDetectorBlockEntity::new, "DaylightDetector"); registerVanilla(NOTEBLOCK, MusicBlockEntity::new, "Music"); registerVanilla(ITEM_FRAME, ItemFrameBlockEntity::new, "ItemFrame"); registerVanilla(CAULDRON, CauldronBlockEntity::new, "Cauldron");