From df0b43041a53d1c3146203c536aa8273d19db1b2 Mon Sep 17 00:00:00 2001 From: crispytwig <48872606+crispytwig@users.noreply.github.com> Date: Wed, 28 Feb 2024 17:39:34 -0600 Subject: [PATCH] [~] Stone Fence shapes, moulding recipes/advancements --- gradle.properties | 2 +- .../foundation/block/StoneFenceBlock.java | 84 ++++++++++++++++--- .../foundation/registry/FoundationBlocks.java | 1 + .../recipes/blackstone_moulding.json | 34 ++++++++ .../recipes/deepslate_moulding.json | 34 ++++++++ .../recipes/nether_bricks_moulding.json | 34 ++++++++ .../advancements/recipes/quartz_moulding.json | 34 ++++++++ .../recipes/red_sandstone_moulding.json | 34 ++++++++ .../recipes/sandstone_moulding.json | 34 ++++++++ .../foundation/loot_tables/blocks/urn.json | 20 ----- .../recipes/blackstone_moulding.json | 18 ++++ .../recipes/deepslate_moulding.json | 18 ++++ .../recipes/nether_brick_moulding.json | 18 ++++ .../foundation/recipes/quartz_moulding.json | 18 ++++ .../recipes/red_sandstone_moulding.json | 18 ++++ .../recipes/sandstone_moulding.json | 18 ++++ .../foundation/recipes/stone_moulding.json | 18 ++++ 17 files changed, 404 insertions(+), 33 deletions(-) create mode 100644 src/main/resources/data/foundation/advancements/recipes/blackstone_moulding.json create mode 100644 src/main/resources/data/foundation/advancements/recipes/deepslate_moulding.json create mode 100644 src/main/resources/data/foundation/advancements/recipes/nether_bricks_moulding.json create mode 100644 src/main/resources/data/foundation/advancements/recipes/quartz_moulding.json create mode 100644 src/main/resources/data/foundation/advancements/recipes/red_sandstone_moulding.json create mode 100644 src/main/resources/data/foundation/advancements/recipes/sandstone_moulding.json delete mode 100644 src/main/resources/data/foundation/loot_tables/blocks/urn.json create mode 100644 src/main/resources/data/foundation/recipes/blackstone_moulding.json create mode 100644 src/main/resources/data/foundation/recipes/deepslate_moulding.json create mode 100644 src/main/resources/data/foundation/recipes/nether_brick_moulding.json create mode 100644 src/main/resources/data/foundation/recipes/quartz_moulding.json create mode 100644 src/main/resources/data/foundation/recipes/red_sandstone_moulding.json create mode 100644 src/main/resources/data/foundation/recipes/sandstone_moulding.json create mode 100644 src/main/resources/data/foundation/recipes/stone_moulding.json diff --git a/gradle.properties b/gradle.properties index 09a1c295..ffdfe8fd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ loader_version=0.14.24 mod_menu_version=7.2.2 # Mod Properties -mod_version=0.5b-fabric +mod_version=0.6b-fabric maven_group=com.starfish_studios archives_base_name=foundation diff --git a/src/main/java/com/starfish_studios/foundation/block/StoneFenceBlock.java b/src/main/java/com/starfish_studios/foundation/block/StoneFenceBlock.java index 36611d76..21bf7221 100644 --- a/src/main/java/com/starfish_studios/foundation/block/StoneFenceBlock.java +++ b/src/main/java/com/starfish_studios/foundation/block/StoneFenceBlock.java @@ -1,37 +1,47 @@ package com.starfish_studios.foundation.block; import com.starfish_studios.foundation.registry.FoundationTags; +import net.minecraft.Util; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; import net.minecraft.tags.BlockTags; import net.minecraft.util.RandomSource; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.*; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.BooleanProperty; -import net.minecraft.world.level.block.state.properties.Property; -import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.Fluids; -import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.level.pathfinder.PathComputationType; import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; -import java.util.Random; +import java.util.Map; -public class StoneFenceBlock extends FenceBlock { - private final VoxelShape[] occlusionByIndex; +public class StoneFenceBlock extends Block implements SimpleWaterloggedBlock { + public static final BooleanProperty NORTH = BlockStateProperties.NORTH; + public static final BooleanProperty EAST = BlockStateProperties.EAST; + public static final BooleanProperty SOUTH = BlockStateProperties.SOUTH; + public static final BooleanProperty WEST = BlockStateProperties.WEST; + public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; + protected static final Map PROPERTY_BY_DIRECTION = + PipeBlock.PROPERTY_BY_DIRECTION.entrySet().stream().filter((entry) -> entry.getKey().getAxis().isHorizontal()).collect(Util.toMap()); public static final BooleanProperty SIDE_FILL = BooleanProperty.create("side_fill"); public static final BooleanProperty PILLAR = BooleanProperty.create("pillar"); + + public VoxelShape PILLAR_AABB = Block.box(4.0D, 0.0D, 4.0D, 12.0D, 16.0D, 12.0D); + public VoxelShape NORTH_AABB = Block.box(4.0D, 0.0D, 0.0D, 12.0D, 16.0D, 4.0D); + public VoxelShape EAST_AABB = Block.box(12.0D, 0.0D, 4.0D, 16.0D, 16.0D, 12.0D); + public VoxelShape SOUTH_AABB = Block.box(4.0D, 0.0D, 12.0D, 12.0D, 16.0D, 16.0D); + public VoxelShape WEST_AABB = Block.box(0.0D, 0.0D, 4.0D, 4.0D, 16.0D, 12.0D); + public StoneFenceBlock(Properties properties) { super(properties); this.registerDefaultState((this.stateDefinition.any() @@ -40,7 +50,15 @@ public StoneFenceBlock(Properties properties) { .setValue(WATERLOGGED, false) .setValue(SIDE_FILL, false) .setValue(PILLAR, true)); - this.occlusionByIndex = this.makeShapes(2.0F, 1.0F, 16.0F, 6.0F, 15.0F); + } + + public VoxelShape getShape(BlockState state, BlockGetter blockGetter, BlockPos blockPos, CollisionContext collisionContext) { + VoxelShape shape = PILLAR_AABB; + if (state.getValue(NORTH)) shape = Shapes.or(shape, NORTH_AABB); + if (state.getValue(EAST)) shape = Shapes.or(shape, EAST_AABB); + if (state.getValue(SOUTH)) shape = Shapes.or(shape, SOUTH_AABB); + if (state.getValue(WEST)) shape = Shapes.or(shape, WEST_AABB); + return shape; } public void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { @@ -49,7 +67,14 @@ public void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource } } - @Override + public VoxelShape getVisualShape(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, CollisionContext collisionContext) { + return this.getShape(blockState, blockGetter, blockPos, collisionContext); + } + + public boolean isPathfindable(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, PathComputationType pathComputationType) { + return false; + } + public boolean connectsTo(BlockState blockState, boolean bl, Direction direction) { Block block = blockState.getBlock(); boolean bl2 = this.isSameFence(blockState); @@ -97,6 +122,41 @@ public BlockState updateShape(BlockState blockState, Direction direction, BlockS : super.updateShape(blockState, direction, blockState2, levelAccessor, blockPos, blockPos2); } + public BlockState rotate(BlockState blockState, Rotation rotation) { + return switch (rotation) { + case CLOCKWISE_180 -> + blockState + .setValue(NORTH, blockState.getValue(SOUTH)) + .setValue(EAST, blockState.getValue(WEST)) + .setValue(SOUTH, blockState.getValue(NORTH)) + .setValue(WEST, blockState.getValue(EAST)); + case COUNTERCLOCKWISE_90 -> + blockState + .setValue(NORTH, blockState.getValue(EAST)) + .setValue(EAST, blockState.getValue(SOUTH)) + .setValue(SOUTH, blockState.getValue(WEST)) + .setValue(WEST, blockState.getValue(NORTH)); + case CLOCKWISE_90 -> + blockState + .setValue(NORTH, blockState.getValue(WEST)) + .setValue(EAST, blockState.getValue(NORTH)) + .setValue(SOUTH, blockState.getValue(EAST)) + .setValue(WEST, blockState.getValue(SOUTH)); + default -> blockState; + }; + } + + public BlockState mirror(BlockState blockState, Mirror mirror) { + switch (mirror) { + case LEFT_RIGHT: + return blockState.setValue(NORTH, blockState.getValue(SOUTH)).setValue(SOUTH, blockState.getValue(NORTH)); + case FRONT_BACK: + return blockState.setValue(EAST, blockState.getValue(WEST)).setValue(WEST, blockState.getValue(EAST)); + default: + return super.mirror(blockState, mirror); + } + } + @Override protected void createBlockStateDefinition(StateDefinition.Builder stateDefinition) { diff --git a/src/main/java/com/starfish_studios/foundation/registry/FoundationBlocks.java b/src/main/java/com/starfish_studios/foundation/registry/FoundationBlocks.java index 598d6ee3..3e3eb67b 100644 --- a/src/main/java/com/starfish_studios/foundation/registry/FoundationBlocks.java +++ b/src/main/java/com/starfish_studios/foundation/registry/FoundationBlocks.java @@ -28,6 +28,7 @@ public class FoundationBlocks { + public static final Block STONE_URN = register("stone_urn", new UrnBlock(FabricBlockSettings.copy((Blocks.STONE)).noOcclusion().pushReaction(PushReaction.DESTROY))); public static final Block BLACKSTONE_URN = register("blackstone_urn", new UrnBlock(FabricBlockSettings.copy((Blocks.BLACKSTONE)).noOcclusion().pushReaction(PushReaction.DESTROY))); public static final Block DEEPSLATE_URN = register("deepslate_urn", new UrnBlock(FabricBlockSettings.copy((Blocks.DEEPSLATE_BRICKS)).noOcclusion().pushReaction(PushReaction.DESTROY))); public static final Block NETHER_BRICK_URN = register("nether_brick_urn", new UrnBlock(FabricBlockSettings.copy((Blocks.NETHER_BRICKS)).noOcclusion().pushReaction(PushReaction.DESTROY))); diff --git a/src/main/resources/data/foundation/advancements/recipes/blackstone_moulding.json b/src/main/resources/data/foundation/advancements/recipes/blackstone_moulding.json new file mode 100644 index 00000000..df5db4f3 --- /dev/null +++ b/src/main/resources/data/foundation/advancements/recipes/blackstone_moulding.json @@ -0,0 +1,34 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_block": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:blackstone" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "foundation:blackstone_moulding" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_block", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "foundation:blackstone_moulding" + ] + } +} diff --git a/src/main/resources/data/foundation/advancements/recipes/deepslate_moulding.json b/src/main/resources/data/foundation/advancements/recipes/deepslate_moulding.json new file mode 100644 index 00000000..e5b5ff8e --- /dev/null +++ b/src/main/resources/data/foundation/advancements/recipes/deepslate_moulding.json @@ -0,0 +1,34 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_block": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:deepslate" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "foundation:deepslate_moulding" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_block", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "foundation:deepslate_moulding" + ] + } +} diff --git a/src/main/resources/data/foundation/advancements/recipes/nether_bricks_moulding.json b/src/main/resources/data/foundation/advancements/recipes/nether_bricks_moulding.json new file mode 100644 index 00000000..fbad80ca --- /dev/null +++ b/src/main/resources/data/foundation/advancements/recipes/nether_bricks_moulding.json @@ -0,0 +1,34 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_block": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:nether_bricks" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "foundation:nether_brick_moulding" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_block", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "foundation:nether_brick_moulding" + ] + } +} diff --git a/src/main/resources/data/foundation/advancements/recipes/quartz_moulding.json b/src/main/resources/data/foundation/advancements/recipes/quartz_moulding.json new file mode 100644 index 00000000..f29e1e91 --- /dev/null +++ b/src/main/resources/data/foundation/advancements/recipes/quartz_moulding.json @@ -0,0 +1,34 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_block": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:quartz_block" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "foundation:quartz_moulding" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_block", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "foundation:quartz_moulding" + ] + } +} diff --git a/src/main/resources/data/foundation/advancements/recipes/red_sandstone_moulding.json b/src/main/resources/data/foundation/advancements/recipes/red_sandstone_moulding.json new file mode 100644 index 00000000..52865f14 --- /dev/null +++ b/src/main/resources/data/foundation/advancements/recipes/red_sandstone_moulding.json @@ -0,0 +1,34 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_block": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:red_sandstone" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "foundation:red_sandstone_moulding" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_block", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "foundation:red_sandstone_moulding" + ] + } +} diff --git a/src/main/resources/data/foundation/advancements/recipes/sandstone_moulding.json b/src/main/resources/data/foundation/advancements/recipes/sandstone_moulding.json new file mode 100644 index 00000000..8820794f --- /dev/null +++ b/src/main/resources/data/foundation/advancements/recipes/sandstone_moulding.json @@ -0,0 +1,34 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "has_block": { + "conditions": { + "items": [ + { + "items": [ + "minecraft:sandstone" + ] + } + ] + }, + "trigger": "minecraft:inventory_changed" + }, + "has_the_recipe": { + "conditions": { + "recipe": "foundation:sandstone_moulding" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_block", + "has_the_recipe" + ] + ], + "rewards": { + "recipes": [ + "foundation:sandstone_moulding" + ] + } +} diff --git a/src/main/resources/data/foundation/loot_tables/blocks/urn.json b/src/main/resources/data/foundation/loot_tables/blocks/urn.json deleted file mode 100644 index be122893..00000000 --- a/src/main/resources/data/foundation/loot_tables/blocks/urn.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "bonus_rolls": 0.0, - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ], - "entries": [ - { - "type": "minecraft:item", - "name": "foundation:urn" - } - ], - "rolls": 1.0 - } - ] -} diff --git a/src/main/resources/data/foundation/recipes/blackstone_moulding.json b/src/main/resources/data/foundation/recipes/blackstone_moulding.json new file mode 100644 index 00000000..97ab8b6e --- /dev/null +++ b/src/main/resources/data/foundation/recipes/blackstone_moulding.json @@ -0,0 +1,18 @@ +{ + "group": "foundation/mouldings", + "type": "minecraft:crafting_shaped", + "pattern": [ + "# ", + "###", + "###" + ], + "key": { + "#": { + "item": "minecraft:blackstone" + } + }, + "result": { + "item": "foundation:blackstone_moulding", + "count": 8 + } +} diff --git a/src/main/resources/data/foundation/recipes/deepslate_moulding.json b/src/main/resources/data/foundation/recipes/deepslate_moulding.json new file mode 100644 index 00000000..e6f8c45f --- /dev/null +++ b/src/main/resources/data/foundation/recipes/deepslate_moulding.json @@ -0,0 +1,18 @@ +{ + "group": "foundation/mouldings", + "type": "minecraft:crafting_shaped", + "pattern": [ + "# ", + "###", + "###" + ], + "key": { + "#": { + "item": "minecraft:deepslate" + } + }, + "result": { + "item": "foundation:deepslate_moulding", + "count": 8 + } +} diff --git a/src/main/resources/data/foundation/recipes/nether_brick_moulding.json b/src/main/resources/data/foundation/recipes/nether_brick_moulding.json new file mode 100644 index 00000000..4fc67675 --- /dev/null +++ b/src/main/resources/data/foundation/recipes/nether_brick_moulding.json @@ -0,0 +1,18 @@ +{ + "group": "foundation/mouldings", + "type": "minecraft:crafting_shaped", + "pattern": [ + "# ", + "###", + "###" + ], + "key": { + "#": { + "item": "minecraft:nether_bricks" + } + }, + "result": { + "item": "foundation:nether_brick_moulding", + "count": 8 + } +} diff --git a/src/main/resources/data/foundation/recipes/quartz_moulding.json b/src/main/resources/data/foundation/recipes/quartz_moulding.json new file mode 100644 index 00000000..22de0dac --- /dev/null +++ b/src/main/resources/data/foundation/recipes/quartz_moulding.json @@ -0,0 +1,18 @@ +{ + "group": "foundation/mouldings", + "type": "minecraft:crafting_shaped", + "pattern": [ + "# ", + "###", + "###" + ], + "key": { + "#": { + "item": "minecraft:quartz_block" + } + }, + "result": { + "item": "foundation:quartz_moulding", + "count": 8 + } +} diff --git a/src/main/resources/data/foundation/recipes/red_sandstone_moulding.json b/src/main/resources/data/foundation/recipes/red_sandstone_moulding.json new file mode 100644 index 00000000..4f2e5cae --- /dev/null +++ b/src/main/resources/data/foundation/recipes/red_sandstone_moulding.json @@ -0,0 +1,18 @@ +{ + "group": "foundation/mouldings", + "type": "minecraft:crafting_shaped", + "pattern": [ + "# ", + "###", + "###" + ], + "key": { + "#": { + "item": "minecraft:red_sandstone" + } + }, + "result": { + "item": "foundation:red_sandstone_moulding", + "count": 8 + } +} diff --git a/src/main/resources/data/foundation/recipes/sandstone_moulding.json b/src/main/resources/data/foundation/recipes/sandstone_moulding.json new file mode 100644 index 00000000..eb3565fb --- /dev/null +++ b/src/main/resources/data/foundation/recipes/sandstone_moulding.json @@ -0,0 +1,18 @@ +{ + "group": "foundation/mouldings", + "type": "minecraft:crafting_shaped", + "pattern": [ + "# ", + "###", + "###" + ], + "key": { + "#": { + "item": "minecraft:sandstone" + } + }, + "result": { + "item": "foundation:sandstone_moulding", + "count": 8 + } +} diff --git a/src/main/resources/data/foundation/recipes/stone_moulding.json b/src/main/resources/data/foundation/recipes/stone_moulding.json new file mode 100644 index 00000000..c00a670c --- /dev/null +++ b/src/main/resources/data/foundation/recipes/stone_moulding.json @@ -0,0 +1,18 @@ +{ + "group": "foundation/mouldings", + "type": "minecraft:crafting_shaped", + "pattern": [ + "# ", + "###", + "###" + ], + "key": { + "#": { + "item": "minecraft:stone_bricks" + } + }, + "result": { + "item": "foundation:stone_moulding", + "count": 8 + } +} \ No newline at end of file