From 5d33005aaf5be89ac313f01f39a0b9f2724c2035 Mon Sep 17 00:00:00 2001 From: Sebastian Hartte Date: Sat, 29 Aug 2020 01:02:32 +0200 Subject: [PATCH] Added back dynamic cable bus lighting. --- .../block/networking/CableBusBlock.java | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/main/java/appeng/block/networking/CableBusBlock.java b/src/main/java/appeng/block/networking/CableBusBlock.java index 13a858345..d0eb4ff26 100644 --- a/src/main/java/appeng/block/networking/CableBusBlock.java +++ b/src/main/java/appeng/block/networking/CableBusBlock.java @@ -41,6 +41,8 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemPlacementContext; import net.minecraft.item.ItemStack; +import net.minecraft.state.StateManager; +import net.minecraft.state.property.IntProperty; import net.minecraft.util.ActionResult; import net.minecraft.util.DyeColor; import net.minecraft.util.Hand; @@ -80,8 +82,12 @@ public class CableBusBlock extends AEBaseTileBlock implemen private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer(); + private static final IntProperty LIGHT_LEVEL = IntProperty.of("light_level", 0, 15); + public CableBusBlock() { - super(defaultProps(AEMaterials.GLASS).nonOpaque().dropsNothing().dynamicBounds()); + super(defaultProps(AEMaterials.GLASS).nonOpaque().dropsNothing().dynamicBounds() + .lightLevel(state -> state.get(LIGHT_LEVEL))); + setDefaultState(getDefaultState().with(LIGHT_LEVEL, 0)); } static { @@ -134,16 +140,13 @@ public class CableBusBlock extends AEBaseTileBlock implemen // OPPOSITE!? } -// FIXME Dynamic light seems unsupported (?) Must maybe use blockstates... :| -// FIXME FABRIC @Override -// FIXME FABRIC public int getLightValue(final BlockState state, final BlockView world, final BlockPos pos) { -// FIXME FABRIC if (state.getBlock() != this) { -// FIXME FABRIC return state.getLuminance(); -// FIXME FABRIC } -// FIXME FABRIC return this.cb(world, pos).getLightValue(); -// FIXME FABRIC } + @Override + protected void appendProperties(StateManager.Builder builder) { + super.appendProperties(builder); + builder.add(LIGHT_LEVEL); + } -// FIXME: Must hook isClimbing ourselves + // FIXME: Must hook isClimbing ourselves // FIXME FABRIC @Override // FIXME FABRIC public boolean isLadder(BlockState state, WorldView world, BlockPos pos, LivingEntity entity) { // FIXME FABRIC return this.cb(world, pos).isLadder(entity); @@ -399,4 +402,13 @@ public class CableBusBlock extends AEBaseTileBlock implemen } } + @Override + protected BlockState updateBlockStateFromTileEntity(BlockState currentState, CableBusBlockEntity te) { + if (currentState.getBlock() != this) { + return currentState; + } + int lightLevel = te.getCableBus().getLightValue(); + return super.updateBlockStateFromTileEntity(currentState, te).with(LIGHT_LEVEL, lightLevel); + } + }