From 12db4eb99f97cfcfffae5f1efcab421919fe7d7e Mon Sep 17 00:00:00 2001 From: rearth Date: Wed, 1 Jan 2025 22:15:21 +0100 Subject: [PATCH] Make furnace glow while working --- .../blocks/processing/PoweredFurnaceBlock.java | 11 +++++++++++ .../processing/PoweredFurnaceBlockEntity.java | 14 ++++++++++++++ .../java/rearth/oritech/init/BlockContent.java | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/rearth/oritech/block/blocks/processing/PoweredFurnaceBlock.java b/common/src/main/java/rearth/oritech/block/blocks/processing/PoweredFurnaceBlock.java index 50fc533c6..451fd8a01 100644 --- a/common/src/main/java/rearth/oritech/block/blocks/processing/PoweredFurnaceBlock.java +++ b/common/src/main/java/rearth/oritech/block/blocks/processing/PoweredFurnaceBlock.java @@ -1,7 +1,11 @@ package rearth.oritech.block.blocks.processing; +import net.minecraft.block.Block; import net.minecraft.block.BlockEntityProvider; +import net.minecraft.block.BlockState; import net.minecraft.block.entity.BlockEntity; +import net.minecraft.state.StateManager; +import net.minecraft.state.property.Properties; import org.jetbrains.annotations.NotNull; import rearth.oritech.block.base.block.MultiblockMachine; import rearth.oritech.block.entity.processing.PoweredFurnaceBlockEntity; @@ -10,6 +14,13 @@ public class PoweredFurnaceBlock extends MultiblockMachine implements BlockEntit public PoweredFurnaceBlock(Settings settings) { super(settings); + setDefaultState(getDefaultState().with(Properties.LIT, false)); + } + + @Override + protected void appendProperties(StateManager.Builder builder) { + super.appendProperties(builder); + builder.add(Properties.LIT); } @Override diff --git a/common/src/main/java/rearth/oritech/block/entity/processing/PoweredFurnaceBlockEntity.java b/common/src/main/java/rearth/oritech/block/entity/processing/PoweredFurnaceBlockEntity.java index 7034158f8..18ed23c9f 100644 --- a/common/src/main/java/rearth/oritech/block/entity/processing/PoweredFurnaceBlockEntity.java +++ b/common/src/main/java/rearth/oritech/block/entity/processing/PoweredFurnaceBlockEntity.java @@ -5,6 +5,7 @@ import net.minecraft.recipe.SmeltingRecipe; import net.minecraft.recipe.input.SingleStackRecipeInput; import net.minecraft.screen.ScreenHandlerType; +import net.minecraft.state.property.Properties; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3i; @@ -81,11 +82,24 @@ public void tick(World world, BlockPos pos, BlockState state, MachineBlockEntity if (progress > 0) resetProgress(); } + if (world.getTime() % 18 == 0) + updateFurnaceState(state); + if (networkDirty) { updateNetwork(); } } + private void updateFurnaceState(BlockState state) { + var wasLit = state.get(Properties.LIT); + var isLit = isActivelyWorking(); + + if (wasLit != isLit) { + world.setBlockState(pos, state.with(Properties.LIT, isLit)); + } + + } + private void craftFurnaceItem(SmeltingRecipe activeRecipe) { var result = activeRecipe.getResult(world.getRegistryManager()); var outSlot = inventory.heldStacks.get(1); diff --git a/common/src/main/java/rearth/oritech/init/BlockContent.java b/common/src/main/java/rearth/oritech/init/BlockContent.java index b0e4f9698..12a917923 100644 --- a/common/src/main/java/rearth/oritech/init/BlockContent.java +++ b/common/src/main/java/rearth/oritech/init/BlockContent.java @@ -123,7 +123,7 @@ public class BlockContent implements ArchitecturyBlockRegistryContainer { @UseGeoBlockItem(scale = 0.7f) public static final Block BIG_SOLAR_PANEL_BLOCK = new BigSolarPanelBlock(AbstractBlock.Settings.copy(Blocks.IRON_BLOCK).nonOpaque(), Oritech.CONFIG.generators.solarGeneratorData.energyPerTick()); @UseGeoBlockItem(scale = 0.7f) - public static final Block POWERED_FURNACE_BLOCK = new PoweredFurnaceBlock(AbstractBlock.Settings.copy(Blocks.IRON_BLOCK).nonOpaque()); + public static final Block POWERED_FURNACE_BLOCK = new PoweredFurnaceBlock(AbstractBlock.Settings.copy(Blocks.IRON_BLOCK).nonOpaque().luminance(Blocks.createLightLevelFromLitBlockState(15))); @UseGeoBlockItem(scale = 0.5f) public static final Block LASER_ARM_BLOCK = new LaserArmBlock(AbstractBlock.Settings.copy(Blocks.IRON_BLOCK).nonOpaque()); @UseGeoBlockItem(scale = 0.25f)