From 0a32234e30ee33aaf1e35ce538e917cc98eb5464 Mon Sep 17 00:00:00 2001 From: Kli Kli Date: Wed, 24 Jan 2024 07:41:29 +0100 Subject: [PATCH] fix: spirit campfire provides light even when off Closes #1040 --- .../occultism/registry/OccultismBlocks.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/klikli_dev/occultism/registry/OccultismBlocks.java b/src/main/java/com/klikli_dev/occultism/registry/OccultismBlocks.java index d335b1f92..32a2de839 100644 --- a/src/main/java/com/klikli_dev/occultism/registry/OccultismBlocks.java +++ b/src/main/java/com/klikli_dev/occultism/registry/OccultismBlocks.java @@ -45,6 +45,7 @@ import net.minecraft.world.level.block.*; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.material.MapColor; import net.minecraft.world.level.material.PushReaction; import net.minecraft.world.phys.AABB; @@ -55,6 +56,7 @@ import java.util.HashMap; import java.util.Map; import java.util.function.Supplier; +import java.util.function.ToIntFunction; public class OccultismBlocks { @@ -254,7 +256,8 @@ public void tick(BlockState pState, ServerLevel pLevel, BlockPos pPos, RandomSou public static final RegistryObject SPIRIT_CAMPFIRE = register("spirit_campfire", () -> new CampfireBlock(false, 2, BlockBehaviour.Properties.of() .mapColor(MapColor.PODZOL) - .strength(2.0F).sound(SoundType.WOOD).lightLevel((state) -> 10).noOcclusion())); + .strength(2.0F).sound(SoundType.WOOD).lightLevel( + litBlockEmission(10)).noOcclusion())); public static final RegistryObject SPIRIT_TORCH = register("spirit_torch", () -> new SpiritTorchBlock(BlockBehaviour.Properties.of() @@ -286,6 +289,13 @@ public static RegistryObject register(final String name, fi return object; } + private static ToIntFunction litBlockEmission(int pLightValue) { + return (p_50763_) -> { + return p_50763_.getValue(BlockStateProperties.LIT) ? pLightValue : 0; + }; + } + + public enum LootTableType { EMPTY, DROP_SELF,