Skip to content

Commit

Permalink
Make furnace glow while working
Browse files Browse the repository at this point in the history
  • Loading branch information
Rearth committed Jan 1, 2025
1 parent 863b22a commit 12db4eb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<Block, BlockState> builder) {
super.appendProperties(builder);
builder.add(Properties.LIT);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/rearth/oritech/init/BlockContent.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 12db4eb

Please sign in to comment.