diff --git a/src/main/java/io/github/mikip98/humilityafm/content/blocks/cabinet/CabinetBlock.java b/src/main/java/io/github/mikip98/humilityafm/content/blocks/cabinet/CabinetBlock.java index 1e65008a..67c21ba1 100644 --- a/src/main/java/io/github/mikip98/humilityafm/content/blocks/cabinet/CabinetBlock.java +++ b/src/main/java/io/github/mikip98/humilityafm/content/blocks/cabinet/CabinetBlock.java @@ -182,7 +182,7 @@ public void onStateReplaced(BlockState state, World world, BlockPos pos, BlockSt if (state.getBlock() != newState.getBlock()) { BlockEntity blockEntity = world.getBlockEntity(pos); if (blockEntity instanceof CabinetBlockEntity cabinetEntity) { - // Handle item drops and block entity cleanup here + // Handle item drops and block entity clean-up here DefaultedList inventory = cabinetEntity.getItems(); for (ItemStack stack : inventory) { if (!stack.isEmpty()) { diff --git a/src/main/java/io/github/mikip98/humilityafm/content/blocks/stairs/InnerStairs.java b/src/main/java/io/github/mikip98/humilityafm/content/blocks/stairs/InnerStairs.java index d0f90a8e..9fb79384 100644 --- a/src/main/java/io/github/mikip98/humilityafm/content/blocks/stairs/InnerStairs.java +++ b/src/main/java/io/github/mikip98/humilityafm/content/blocks/stairs/InnerStairs.java @@ -12,28 +12,58 @@ import java.util.Map; public class InnerStairs extends OuterStairs { - protected static final Map bottomVoxelShape = getVoxelShapeMapOfY(0.5f); - protected static final Map topVoxelShape = getVoxelShapeMapOfY(0f); - protected static Map getVoxelShapeMapOfY(double y) { + protected static final VoxelShape voxelShapeBottomNorth; + protected static final VoxelShape voxelShapeBottomSouth; + protected static final VoxelShape voxelShapeBottomEast; + protected static final VoxelShape voxelShapeBottomWest; + + protected static final VoxelShape voxelShapeTopNorth; + protected static final VoxelShape voxelShapeTopSouth; + protected static final VoxelShape voxelShapeTopEast; + protected static final VoxelShape voxelShapeTopWest; + + protected static Map getVoxelShapeMapOfY ( double y){ + VoxelShape base = VoxelShapes.cuboid( + 0f, 0.5f - y, 0f, + 1f, 1f - y, 1f + ); return Map.of( Direction.NORTH, VoxelShapes.union( - VoxelShapes.cuboid(0.5f, y, 0f, 1f, y+0.5f, 1f), - VoxelShapes.cuboid(0f, y, 0.5f, 0.5f, y+0.5f, 1f) + base, + VoxelShapes.cuboid(0.5f, y, 0f, 1f, y + 0.5f, 1f), + VoxelShapes.cuboid(0f, y, 0.5f, 0.5f, y + 0.5f, 1f) ), // original Direction.SOUTH, VoxelShapes.union( - VoxelShapes.cuboid(0f, y, 0f, 0.5f, y+0.5f, 1f), - VoxelShapes.cuboid(0.5f, y, 0f, 1f, y+0.5f, 0.5f) + base, + VoxelShapes.cuboid(0f, y, 0f, 0.5f, y + 0.5f, 1f), + VoxelShapes.cuboid(0.5f, y, 0f, 1f, y + 0.5f, 0.5f) ), // reverse original Direction.EAST, VoxelShapes.union( - VoxelShapes.cuboid(0f, y, 0.5f, 1f, y+0.5f, 1f), - VoxelShapes.cuboid(0f, y, 0f, 0.5f, y+0.5f, 0.5f) + base, + VoxelShapes.cuboid(0f, y, 0.5f, 1f, y + 0.5f, 1f), + VoxelShapes.cuboid(0f, y, 0f, 0.5f, y + 0.5f, 0.5f) ), // swap x <-> z + reverse - Direction.WEST, VoxelShapes.union( - VoxelShapes.cuboid(0f, y, 0f, 1f, y+0.5f, 0.5f), - VoxelShapes.cuboid(0.5f, y, 0.5f, 1f, y+0.5f, 1f) + Direction.WEST, VoxelShapes.union( + base, + VoxelShapes.cuboid(0f, y, 0f, 1f, y + 0.5f, 0.5f), + VoxelShapes.cuboid(0.5f, y, 0.5f, 1f, y + 0.5f, 1f) ) // swap x <-> z ); } + static { + final Map bottomVoxelShape = getVoxelShapeMapOfY(0.5f); + final Map topVoxelShape = getVoxelShapeMapOfY(0f); + + voxelShapeBottomNorth = bottomVoxelShape.get(Direction.NORTH); + voxelShapeBottomSouth = bottomVoxelShape.get(Direction.SOUTH); + voxelShapeBottomEast = bottomVoxelShape.get(Direction.EAST); + voxelShapeBottomWest = bottomVoxelShape.get(Direction.WEST); + + voxelShapeTopNorth = topVoxelShape.get(Direction.NORTH); + voxelShapeTopSouth = topVoxelShape.get(Direction.SOUTH); + voxelShapeTopEast = topVoxelShape.get(Direction.EAST); + voxelShapeTopWest = topVoxelShape.get(Direction.WEST); + } public InnerStairs(Settings settings) { super(settings); @@ -42,8 +72,37 @@ public InnerStairs(Settings settings) { @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { Direction dir = state.get(FACING); - return state.get(Properties.BLOCK_HALF) == BlockHalf.TOP - ? topVoxelShape.get(dir) - : bottomVoxelShape.get(dir); + if (state.get(Properties.BLOCK_HALF) == BlockHalf.BOTTOM) { + switch (dir) { + case NORTH -> { + return voxelShapeBottomNorth; + } + case SOUTH -> { + return voxelShapeBottomSouth; + } + case EAST -> { + return voxelShapeBottomEast; + } + case WEST -> { + return voxelShapeBottomWest; + } + } + } else { + switch (dir) { + case NORTH -> { + return voxelShapeTopNorth; + } + case SOUTH -> { + return voxelShapeTopSouth; + } + case EAST -> { + return voxelShapeTopEast; + } + case WEST -> { + return voxelShapeTopWest; + } + } + } + return VoxelShapes.fullCube(); // Fallback, should not happen } } diff --git a/src/main/java/io/github/mikip98/humilityafm/content/blocks/stairs/OuterStairs.java b/src/main/java/io/github/mikip98/humilityafm/content/blocks/stairs/OuterStairs.java index 291a9e6c..71b88fc4 100644 --- a/src/main/java/io/github/mikip98/humilityafm/content/blocks/stairs/OuterStairs.java +++ b/src/main/java/io/github/mikip98/humilityafm/content/blocks/stairs/OuterStairs.java @@ -18,15 +18,21 @@ import java.util.Map; public class OuterStairs extends HorizontalFacingBlock implements Waterloggable { - protected static final Map bottomVoxelShape = getVoxelShapeMapOfY( - VoxelShapes.cuboid(0f, 0f, 0f, 1f, 0.5f, 1.0f), - 0.5f - ); - protected static final Map topVoxelShape = getVoxelShapeMapOfY( - VoxelShapes.cuboid(0f, 0.5f, 0f, 1f, 1f, 1.0f), - 0f - ); - protected static Map getVoxelShapeMapOfY(VoxelShape base, double y) { + protected static final VoxelShape voxelShapeBottomNorth; + protected static final VoxelShape voxelShapeBottomSouth; + protected static final VoxelShape voxelShapeBottomEast; + protected static final VoxelShape voxelShapeBottomWest; + + protected static final VoxelShape voxelShapeTopNorth; + protected static final VoxelShape voxelShapeTopSouth; + protected static final VoxelShape voxelShapeTopEast; + protected static final VoxelShape voxelShapeTopWest; + + protected static Map getVoxelShapeMapOfY(double y) { + VoxelShape base = VoxelShapes.cuboid( + 0f, 0.5f - y, 0f, + 1f, 1f - y, 1f + ); return Map.of( Direction.NORTH, VoxelShapes.union(base, VoxelShapes.cuboid(0.5f, y, 0.5f, 1.0f, y+0.5f, 1.0f)), // original Direction.SOUTH, VoxelShapes.union(base, VoxelShapes.cuboid(0.0f, y, 0.0f, 0.5f, y+0.5f, 0.5f)), // reverse original @@ -34,6 +40,20 @@ protected static Map getVoxelShapeMapOfY(VoxelShape base, Direction.WEST, VoxelShapes.union(base, VoxelShapes.cuboid(0.5f, y, 0.0f, 1.0f, y+0.5f, 0.5f)) // swap x <-> z ); } + static { + final Map bottomVoxelShape = getVoxelShapeMapOfY(0.5f); + final Map topVoxelShape = getVoxelShapeMapOfY(0f); + + voxelShapeBottomNorth = bottomVoxelShape.get(Direction.NORTH); + voxelShapeBottomSouth = bottomVoxelShape.get(Direction.SOUTH); + voxelShapeBottomEast = bottomVoxelShape.get(Direction.EAST); + voxelShapeBottomWest = bottomVoxelShape.get(Direction.WEST); + + voxelShapeTopNorth = topVoxelShape.get(Direction.NORTH); + voxelShapeTopSouth = topVoxelShape.get(Direction.SOUTH); + voxelShapeTopEast = topVoxelShape.get(Direction.EAST); + voxelShapeTopWest = topVoxelShape.get(Direction.WEST); + } public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED; @@ -77,8 +97,29 @@ public FluidState getFluidState(BlockState state) { @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { Direction dir = state.get(FACING); - return state.get(Properties.BLOCK_HALF) == BlockHalf.TOP - ? topVoxelShape.get(dir) - : bottomVoxelShape.get(dir); + if (state.get(Properties.BLOCK_HALF) == BlockHalf.BOTTOM) { + switch (dir) { + case NORTH: + return voxelShapeBottomNorth; + case SOUTH: + return voxelShapeBottomSouth; + case EAST: + return voxelShapeBottomEast; + case WEST: + return voxelShapeBottomWest; + } + } else { + switch (dir) { + case NORTH: + return voxelShapeTopNorth; + case SOUTH: + return voxelShapeTopSouth; + case EAST: + return voxelShapeTopEast; + case WEST: + return voxelShapeTopWest; + } + } + return VoxelShapes.fullCube(); // Fallback, should not happen } } diff --git a/src/main/java/io/github/mikip98/humilityafm/datagen/BlockTagGenerator.java b/src/main/java/io/github/mikip98/humilityafm/datagen/BlockTagGenerator.java index 3019c88f..0dcfdfea 100644 --- a/src/main/java/io/github/mikip98/humilityafm/datagen/BlockTagGenerator.java +++ b/src/main/java/io/github/mikip98/humilityafm/datagen/BlockTagGenerator.java @@ -2,6 +2,7 @@ import io.github.mikip98.humilityafm.content.ModBlockTags; import io.github.mikip98.humilityafm.generators.CabinetBlockGenerator; +import io.github.mikip98.humilityafm.generators.CandlestickGenerator; import io.github.mikip98.humilityafm.generators.TerracottaTilesGenerator; import io.github.mikip98.humilityafm.generators.WoodenMosaicGenerator; import io.github.mikip98.humilityafm.registries.BlockRegistry; @@ -28,26 +29,26 @@ protected void configure(RegistryWrapper.WrapperLookup arg) { // ------------ Custom Tags ------------ // Cabinet Block Tags getOrCreateTagBuilder(ModBlockTags.CABINET_BLOCKS) - .add(getIds(Arrays.stream(CabinetBlockGenerator.cabinetBlockVariantsNames).map(s -> "cabinet_block_" + s))) + .add(CabinetBlockGenerator.cabinetBlockVariants) .add(BlockRegistry.CABINET_BLOCK); // Manual testing block getOrCreateTagBuilder(ModBlockTags.ILLUMINATED_CABINET_BLOCKS) - .add(getIds(Arrays.stream(CabinetBlockGenerator.cabinetBlockVariantsNames).map(s -> "illuminated_cabinet_block_" + s))) + .add(CabinetBlockGenerator.illuminatedCabinetBlockVariants) .add(BlockRegistry.ILLUMINATED_CABINET_BLOCK); // Manual testing block getOrCreateTagBuilder(ModBlockTags.CABINET_BLOCKS) - .add(getIds(Arrays.stream(CabinetBlockGenerator.cabinetBlockVariantsNames).map(s -> "floor_cabinet_block_" + s))) + .add(CabinetBlockGenerator.floorCabinetBlockVariants) .add(BlockRegistry.FLOOR_CABINET_BLOCK); // Manual testing block getOrCreateTagBuilder(ModBlockTags.ILLUMINATED_CABINET_BLOCKS) - .add(getIds(Arrays.stream(CabinetBlockGenerator.cabinetBlockVariantsNames).map(s -> "floor_illuminated_cabinet_block_" + s))) + .add(CabinetBlockGenerator.floorIlluminatedCabinetBlockVariants) .add(BlockRegistry.FLOOR_ILLUMINATED_CABINET_BLOCK); // Manual testing block // Wooden Mosaic Block Tag getOrCreateTagBuilder(ModBlockTags.WOODEN_MOSAIC_BLOCKS) - .add(getIds(Arrays.stream(WoodenMosaicGenerator.woodenMosaicVariantsNames).map(s -> "wooden_mosaic_" + s))) + .add(WoodenMosaicGenerator.woodenMosaicVariants) .add(BlockRegistry.WOODEN_MOSAIC); // Manual testing block // Terracotta Tiles Block Tag getOrCreateTagBuilder(ModBlockTags.TERRACOTTA_TILES_BLOCKS) - .add(getIds(Arrays.stream(TerracottaTilesGenerator.terracottaTilesVariantsNames).map(s -> "terracotta_tiles_" + s))); + .add(TerracottaTilesGenerator.terracottaTilesVariants); // Inner & Outer Stairs Block Tags String[] woodenVariants = GenerationData.vanillaWoodTypes; @@ -69,19 +70,19 @@ protected void configure(RegistryWrapper.WrapperLookup arg) { // Jack o'Lanterns getOrCreateTagBuilder(ModBlockTags.JACK_O_LANTERNS) - .add(getId("jack_o_lantern_redstone")) - .add(getId("jack_o_lantern_soul")); + .add(BlockRegistry.JACK_O_LANTERN_SOUL) + .add(BlockRegistry.JACK_O_LANTERN_REDSTONE); getOrCreateTagBuilder(ModBlockTags.COLOURED_JACK_O_LANTERNS) - .add(getIds(Arrays.stream(GenerationData.vanillaColorPallet).map(s -> "coloured_weak_jack_o_lantern_" + s + "_weak"))) - .add(getIds(Arrays.stream(GenerationData.vanillaColorPallet).map(s -> "coloured_weak_jack_o_lantern_" + s))) - .add(getIds(Arrays.stream(GenerationData.vanillaColorPallet).map(s -> "coloured_weak_jack_o_lantern_" + s + "_strong"))); + .add(BlockRegistry.COLOURED_WEAK_JACK_O_LANTERNS) + .add(BlockRegistry.COLOURED_WEAK_JACK_O_LANTERNS) + .add(BlockRegistry.COLOURED_STRONG_JACK_O_LANTERNS); // Candlesticks FabricTagProvider.FabricTagBuilder tag = getOrCreateTagBuilder(ModBlockTags.CANDLESTICKS) - .add(getIds(Arrays.stream(GenerationData.vanillaCandlestickMetals).map(s -> "candlestick_" + s))) - .add(getIds(Arrays.stream(GenerationData.vanillaCandlestickMetals).map(s -> "candlestick_wall_" + s))); - GenerationData.vanillaRustableCandlestickMetals.forEach(metals -> tag.add(getIds(Arrays.stream(metals).map(s -> "candlestick_" + s)))); - GenerationData.vanillaRustableCandlestickMetals.forEach(metals -> tag.add(getIds(Arrays.stream(metals).map(s -> "candlestick_wall_" + s)))); + .add(CandlestickGenerator.candlestickClassicStandingVariants) + .add(CandlestickGenerator.candlestickClassicWallVariants); + CandlestickGenerator.candlestickRustableStandingVariants.forEach(tag::add); + CandlestickGenerator.candlestickRustableWallVariants.forEach(tag::add); // ------------ Vanilla Tags ------------ diff --git a/src/main/java/io/github/mikip98/humilityafm/registries/BlockRegistry.java b/src/main/java/io/github/mikip98/humilityafm/registries/BlockRegistry.java index 8e462a2e..667952ed 100644 --- a/src/main/java/io/github/mikip98/humilityafm/registries/BlockRegistry.java +++ b/src/main/java/io/github/mikip98/humilityafm/registries/BlockRegistry.java @@ -148,9 +148,9 @@ public static void register() { putIntoItemGroup(ColouredFeatureSetGenerator.LightStripBlockVariants, ItemGroups.COLORED_BLOCKS); // Register coloured Jack o'Lanterns - COLOURED_WEAK_JACK_O_LANTERNS = Arrays.stream(GenerationData.vanillaColorPallet).map(s -> registerWithItem(new JackOLantern(), "coloured_jack_o_lantern_" + s + "_weak")).toArray(Block[]::new); + COLOURED_WEAK_JACK_O_LANTERNS = Arrays.stream(GenerationData.vanillaColorPallet).map(s -> registerWithItem(new JackOLantern(), "coloured_weak_jack_o_lantern_" + s)).toArray(Block[]::new); COLOURED_JACK_O_LANTERNS = Arrays.stream(GenerationData.vanillaColorPallet).map(s -> registerWithItem(new JackOLantern(), "coloured_jack_o_lantern_" + s)).toArray(Block[]::new); - COLOURED_STRONG_JACK_O_LANTERNS = Arrays.stream(GenerationData.vanillaColorPallet).map(s -> registerWithItem(new JackOLantern(), "coloured_jack_o_lantern_" + s + "_strong")).toArray(Block[]::new); + COLOURED_STRONG_JACK_O_LANTERNS = Arrays.stream(GenerationData.vanillaColorPallet).map(s -> registerWithItem(new JackOLantern(), "coloured_strong_jack_o_lantern_" + s)).toArray(Block[]::new); } diff --git a/src/main/java/io/github/mikip98/humilityafm/registries/ItemRegistry.java b/src/main/java/io/github/mikip98/humilityafm/registries/ItemRegistry.java index 2a3f56aa..0e2f2328 100644 --- a/src/main/java/io/github/mikip98/humilityafm/registries/ItemRegistry.java +++ b/src/main/java/io/github/mikip98/humilityafm/registries/ItemRegistry.java @@ -1,5 +1,6 @@ package io.github.mikip98.humilityafm.registries; +import io.github.mikip98.humilityafm.config.ModConfig; import io.github.mikip98.humilityafm.content.items.DoubleVerticallyAttachableBlockItem; import io.github.mikip98.humilityafm.util.GenerationData; import net.fabricmc.fabric.api.item.v1.FabricItemSettings; @@ -36,11 +37,15 @@ public class ItemRegistry { public static void register() { - putIntoItemGroup(GLOWING_POWDER_VARIANTS, ItemGroups.INGREDIENTS); putIntoItemGroup(CABINET_ITEM_VARIANTS, ItemGroups.COLORED_BLOCKS); putIntoItemGroup(ILLUMINATED_CABINET_ITEM_VARIANTS, ItemGroups.COLORED_BLOCKS); - putIntoItemGroup(CANDLESTICK_ITEM_VARIANTS, ItemGroups.FUNCTIONAL); - RUSTABLE_CANDLESTICK_ITEM_VARIANTS.forEach(s -> putIntoItemGroup(s, ItemGroups.FUNCTIONAL)); + if (ModConfig.enableCandlestickBeta) { + putIntoItemGroup(CANDLESTICK_ITEM_VARIANTS, ItemGroups.FUNCTIONAL); + RUSTABLE_CANDLESTICK_ITEM_VARIANTS.forEach(s -> putIntoItemGroup(s, ItemGroups.FUNCTIONAL)); + } + if (ModConfig.enableColouredFeatureSetBeta) { + putIntoItemGroup(GLOWING_POWDER_VARIANTS, ItemGroups.INGREDIENTS); + } }