diff --git a/src/main/java/techreborn/blockentity/lighting/LampBlockEntity.java b/src/main/java/techreborn/blockentity/lighting/LampBlockEntity.java index b5aaadfb9..2f8651d12 100644 --- a/src/main/java/techreborn/blockentity/lighting/LampBlockEntity.java +++ b/src/main/java/techreborn/blockentity/lighting/LampBlockEntity.java @@ -31,7 +31,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.math.Direction; import reborncore.api.IToolDrop; import reborncore.common.powerSystem.PowerAcceptorBlockEntity; -import techreborn.blocks.lighting.BlockLamp; +import techreborn.blocks.lighting.LampBlock; import techreborn.init.TRBlockEntities; public class LampBlockEntity extends PowerAcceptorBlockEntity @@ -52,14 +52,14 @@ public class LampBlockEntity extends PowerAcceptorBlockEntity } BlockState state = world.getBlockState(pos); Block b = state.getBlock(); - if (b instanceof BlockLamp) { - double cost = getEuPerTick(((BlockLamp) b).getCost()); + if (b instanceof LampBlock) { + double cost = getEuPerTick(((LampBlock) b).getCost()); if (getEnergy() > cost) { useEnergy(getEuPerTick(cost)); - if (!BlockLamp.isActive(state)) - BlockLamp.setActive(true, world, pos); - } else if (BlockLamp.isActive(state)) { - BlockLamp.setActive(false, world, pos); + if (!LampBlock.isActive(state)) + LampBlock.setActive(true, world, pos); + } else if (LampBlock.isActive(state)) { + LampBlock.setActive(false, world, pos); } } } @@ -75,7 +75,7 @@ public class LampBlockEntity extends PowerAcceptorBlockEntity // Blame tooltip for this return true; } - Direction me = BlockLamp.getFacing(world.getBlockState(pos)).getOpposite(); + Direction me = LampBlock.getFacing(world.getBlockState(pos)).getOpposite(); return direction == me; } diff --git a/src/main/java/techreborn/blockentity/machine/tier1/GreenhouseControllerBlockEntity.java b/src/main/java/techreborn/blockentity/machine/tier1/GreenhouseControllerBlockEntity.java index 12a517d18..ab3ff95e8 100644 --- a/src/main/java/techreborn/blockentity/machine/tier1/GreenhouseControllerBlockEntity.java +++ b/src/main/java/techreborn/blockentity/machine/tier1/GreenhouseControllerBlockEntity.java @@ -41,7 +41,7 @@ import reborncore.common.blockentity.MultiblockWriter; import reborncore.common.powerSystem.PowerAcceptorBlockEntity; import reborncore.common.util.ItemUtils; import reborncore.common.util.RebornInventory; -import techreborn.blocks.lighting.BlockLamp; +import techreborn.blocks.lighting.LampBlock; import techreborn.blocks.misc.BlockRubberLog; import techreborn.config.TechRebornConfig; import techreborn.init.TRBlockEntities; @@ -240,7 +240,7 @@ public class GreenhouseControllerBlockEntity extends PowerAcceptorBlockEntity for (int i = 0; i < 3; i++) { for (int j = -1; j < 2; j++) { - writer.add(i * 3 + 2, 3, j * 3, (world, pos) -> BlockLamp.isActive(world.getBlockState(pos)), lamp); + writer.add(i * 3 + 2, 3, j * 3, (world, pos) -> LampBlock.isActive(world.getBlockState(pos)), lamp); } } diff --git a/src/main/java/techreborn/blocks/lighting/BlockLamp.java b/src/main/java/techreborn/blocks/lighting/LampBlock.java similarity index 92% rename from src/main/java/techreborn/blocks/lighting/BlockLamp.java rename to src/main/java/techreborn/blocks/lighting/LampBlock.java index b4b27d98d..1aa4bf426 100644 --- a/src/main/java/techreborn/blocks/lighting/BlockLamp.java +++ b/src/main/java/techreborn/blocks/lighting/LampBlock.java @@ -50,7 +50,9 @@ import techreborn.blockentity.lighting.LampBlockEntity; import org.jetbrains.annotations.Nullable; -public class BlockLamp extends BaseBlockEntityProvider { +import java.util.function.ToIntFunction; + +public class LampBlock extends BaseBlockEntityProvider { public static DirectionProperty FACING = Properties.FACING; public static BooleanProperty ACTIVE; @@ -59,14 +61,18 @@ public class BlockLamp extends BaseBlockEntityProvider { private final int cost; private static final int brightness = 15; - public BlockLamp(int cost, double depth, double width) { - super(FabricBlockSettings.of(Material.REDSTONE_LAMP).strength(2f, 2f).lightLevel(brightness)); + public LampBlock(int cost, double depth, double width) { + super(FabricBlockSettings.of(Material.REDSTONE_LAMP).strength(2f, 2f).lightLevel(createLightLevelFromBlockState())); this.shape = genCuboidShapes(depth, width); this.cost = cost; this.setDefaultState(this.getStateManager().getDefaultState().with(FACING, Direction.NORTH).with(ACTIVE, false)); BlockWrenchEventHandler.wrenableBlocks.add(this); } + private static ToIntFunction createLightLevelFromBlockState() { + return (blockState) -> isActive(blockState) ? brightness : 0; + } + private VoxelShape[] genCuboidShapes(double depth, double width) { double culling = (16.0D - width) / 2; return new VoxelShape[]{ @@ -79,11 +85,6 @@ public class BlockLamp extends BaseBlockEntityProvider { }; } - @Override - public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPos, ShapeContext shapeContext) { - return shape[blockState.get(FACING).ordinal()]; - } - public static boolean isActive(BlockState state) { return state.contains(ACTIVE) && state.get(ACTIVE); } @@ -131,11 +132,19 @@ public class BlockLamp extends BaseBlockEntityProvider { return null; } + @SuppressWarnings("deprecation") + @Override + public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPos, ShapeContext shapeContext) { + return shape[blockState.get(FACING).ordinal()]; + } + + @SuppressWarnings("deprecation") @Override public BlockRenderType getRenderType(BlockState state) { return BlockRenderType.MODEL; } + @SuppressWarnings("deprecation") @Override public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) { ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND); diff --git a/src/main/java/techreborn/init/TRContent.java b/src/main/java/techreborn/init/TRContent.java index 098d7fb03..cb91b00c4 100644 --- a/src/main/java/techreborn/init/TRContent.java +++ b/src/main/java/techreborn/init/TRContent.java @@ -60,7 +60,7 @@ import techreborn.blocks.generator.BlockFusionCoil; import techreborn.blocks.generator.BlockFusionControlComputer; import techreborn.blocks.generator.BlockSolarPanel; import techreborn.blocks.generator.GenericGeneratorBlock; -import techreborn.blocks.lighting.BlockLamp; +import techreborn.blocks.lighting.LampBlock; import techreborn.blocks.machine.tier0.IronAlloyFurnaceBlock; import techreborn.blocks.machine.tier0.IronFurnaceBlock; import techreborn.blocks.machine.tier1.PlayerDetectorBlock; @@ -558,8 +558,8 @@ public class TRContent { ALARM(new BlockAlarm()), CHUNK_LOADER(new GenericMachineBlock(GuiType.CHUNK_LOADER, ChunkLoaderBlockEntity::new)), - LAMP_INCANDESCENT(new BlockLamp(4, 10, 8)), - LAMP_LED(new BlockLamp(1, 1, 12)), + LAMP_INCANDESCENT(new LampBlock(4, 10, 8)), + LAMP_LED(new LampBlock(1, 1, 12)), PLAYER_DETECTOR(new PlayerDetectorBlock()); public final String name;