From d996316c90c380c3d15646bb56f969546dda3b00 Mon Sep 17 00:00:00 2001 From: crispytwig <48872606+crispytwig@users.noreply.github.com> Date: Tue, 17 Dec 2024 10:13:52 -0600 Subject: [PATCH] Gift Box advancement + Wreath tweaks --- .../common/block/WreathBlock.java | 13 ++++++++ .../event/WreathInteractions.java | 3 ++ .../seasons_greetings/registry/SGBlocks.java | 5 ++- .../recipes/misc/white_gift_box.json | 32 +++++++++++++++++++ 4 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/data/seasonsgreetings/advancement/recipes/misc/white_gift_box.json diff --git a/src/main/java/com/starfish_studios/seasons_greetings/common/block/WreathBlock.java b/src/main/java/com/starfish_studios/seasons_greetings/common/block/WreathBlock.java index d89a60d..c02bd8f 100644 --- a/src/main/java/com/starfish_studios/seasons_greetings/common/block/WreathBlock.java +++ b/src/main/java/com/starfish_studios/seasons_greetings/common/block/WreathBlock.java @@ -18,6 +18,8 @@ import net.minecraft.world.phys.shapes.VoxelShape; import org.jetbrains.annotations.NotNull; +import java.util.function.ToIntFunction; + public class WreathBlock extends Block { public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; public static final EnumProperty GARLAND = EnumProperty.create("garland", WreathGarland.class); @@ -38,6 +40,17 @@ public WreathBlock(Properties properties) { .setValue(BELL, false)); } + public static ToIntFunction litBlockEmission(int lightValue) { + return (blockState) -> blockState.getValue(GARLAND) == WreathGarland.RED_LIGHTS || + blockState.getValue(GARLAND) == WreathGarland.ORANGE_LIGHTS || + blockState.getValue(GARLAND) == WreathGarland.YELLOW_LIGHTS || + blockState.getValue(GARLAND) == WreathGarland.GREEN_LIGHTS || + blockState.getValue(GARLAND) == WreathGarland.BLUE_LIGHTS || + blockState.getValue(GARLAND) == WreathGarland.PURPLE_LIGHTS || + blockState.getValue(GARLAND) == WreathGarland.WHITE_LIGHTS || + blockState.getValue(GARLAND) == WreathGarland.MULTICOLOR_LIGHTS ? lightValue : 0; + } + @Override protected void createBlockStateDefinition(StateDefinition.Builder stateDefinition) { stateDefinition.add(FACING, GARLAND, BOW, BELL); diff --git a/src/main/java/com/starfish_studios/seasons_greetings/event/WreathInteractions.java b/src/main/java/com/starfish_studios/seasons_greetings/event/WreathInteractions.java index 36e09ec..14772d4 100644 --- a/src/main/java/com/starfish_studios/seasons_greetings/event/WreathInteractions.java +++ b/src/main/java/com/starfish_studios/seasons_greetings/event/WreathInteractions.java @@ -68,6 +68,9 @@ public InteractionResult interact(Player player, Level level, InteractionHand ha level.setBlockAndUpdate(pos, newState); playSound(level, pos, SoundEvents.AZALEA_PLACE, player); consumeItemIfNotCreative(player, itemStack); + if (newState.getValue(WreathBlock.GARLAND) != WreathBlock.WreathGarland.EMPTY) { + playSound(level, pos, SoundEvents.AZALEA_PLACE, player); + } return InteractionResult.SUCCESS; } diff --git a/src/main/java/com/starfish_studios/seasons_greetings/registry/SGBlocks.java b/src/main/java/com/starfish_studios/seasons_greetings/registry/SGBlocks.java index 72b06cf..5403242 100644 --- a/src/main/java/com/starfish_studios/seasons_greetings/registry/SGBlocks.java +++ b/src/main/java/com/starfish_studios/seasons_greetings/registry/SGBlocks.java @@ -19,7 +19,7 @@ public class SGBlocks { public static final Block HOT_COCOA_CAULDRON = registerBlock("hot_cocoa_cauldron", new HotCocoaCauldronBlock(Block.Properties.ofFullCopy(Blocks.CAULDRON), null)); public static final Block EGGNOG_CAULDRON = registerBlock("eggnog_cauldron", new EggnogCauldronBlock(Block.Properties.ofFullCopy(Blocks.CAULDRON), null)); - public static final Block WREATH = registerBlock("wreath", new WreathBlock(Block.Properties.of().instabreak().noCollission().noOcclusion().sound(SoundType.AZALEA_LEAVES))); + public static final Block WREATH = registerBlock("wreath", new WreathBlock(Block.Properties.of().instabreak().noCollission().noOcclusion().sound(SoundType.AZALEA_LEAVES).lightLevel(WreathBlock.litBlockEmission(10)))); public static final BlockBehaviour.Properties lightProperties = Block.Properties.of().sound(SoundType.STONE).instabreak().noCollission().noOcclusion().emissiveRendering((state, world, pos) -> true).lightLevel(WrappedBlock.emission(10)); public static final Block WHITE_LIGHTS = registerBlock("white_lights", new WrappedBlock(lightProperties)); @@ -48,8 +48,7 @@ public class SGBlocks { .strength(1.5F, 3.0F) .dynamicShape() .offsetType(BlockBehaviour.OffsetType.XZ) - .pushReaction(PushReaction.DESTROY) - .isRedstoneConductor(Blocks::never))); + .pushReaction(PushReaction.DESTROY))); // region Gingerbread House Blocks diff --git a/src/main/resources/data/seasonsgreetings/advancement/recipes/misc/white_gift_box.json b/src/main/resources/data/seasonsgreetings/advancement/recipes/misc/white_gift_box.json new file mode 100644 index 0000000..13ce2ab --- /dev/null +++ b/src/main/resources/data/seasonsgreetings/advancement/recipes/misc/white_gift_box.json @@ -0,0 +1,32 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_item": { + "conditions": { + "items": [ + { + "items": "#minecraft:logs" + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_recipe": { + "conditions": { + "recipe": "seasonsgreetings:white_gift_box" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_recipe", + "has_item" + ] + ], + "rewards": { + "recipes": [ + "seasonsgreetings:white_gift_box" + ] + } +} \ No newline at end of file