Skip to content

Commit

Permalink
Gift Box advancement + Wreath tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
crispytwig committed Dec 17, 2024
1 parent 4fa6df2 commit 7377ba3
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<WreathGarland> GARLAND = EnumProperty.create("garland", WreathGarland.class);
Expand All @@ -38,6 +40,17 @@ public WreathBlock(Properties properties) {
.setValue(BELL, false));
}

public static ToIntFunction<BlockState> 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<Block, BlockState> stateDefinition) {
stateDefinition.add(FACING, GARLAND, BOW, BELL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
import com.starfish_studios.seasons_greetings.registry.SGItems;
import net.minecraft.Util;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.core.particles.DustParticleOptions;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
Expand Down Expand Up @@ -64,8 +66,10 @@ public void onBlockInteract(RightClickBlock event) {
if (InteractionMaps.GARLAND_MAP.containsKey(item) && blockState.getValue(WreathBlock.GARLAND) == WreathBlock.WreathGarland.EMPTY) {
BlockState newState = InteractionMaps.getBlockstateForGarland(item, blockState);
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);
}
event.setCancellationResult(InteractionResult.SUCCESS);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class SGBlocks {
public static final DeferredBlock<Block> HOT_COCOA_CAULDRON = BLOCKS.register("hot_cocoa_cauldron", () -> new HotCocoaCauldronBlock(Block.Properties.ofFullCopy(Blocks.CAULDRON), null));
public static final DeferredBlock<Block> EGGNOG_CAULDRON = BLOCKS.register("eggnog_cauldron", () -> new EggnogCauldronBlock(Block.Properties.ofFullCopy(Blocks.CAULDRON), null));

public static final DeferredBlock<Block> WREATH = BLOCKS.register("wreath", () -> new WreathBlock(Block.Properties.of().instabreak().noCollission().noOcclusion().sound(SoundType.AZALEA_LEAVES)));
public static final DeferredBlock<Block> WREATH = BLOCKS.register("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 DeferredBlock<Block> WHITE_LIGHTS = BLOCKS.register("white_lights", () -> new WrappedBlock(lightProperties));
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
]
}
}

0 comments on commit 7377ba3

Please sign in to comment.