From 776e88241136abb3df30a24bcb4bafbbf3f075f3 Mon Sep 17 00:00:00 2001 From: Robotgiggle <88736742+Robotgiggle@users.noreply.github.com> Date: Wed, 28 Oct 2026 23:37:57 -0400 Subject: [PATCH 01/12] Basic block + blockentity implementation --- .../hexcasting/blockstates/chest_locus.json | 216 ++++++++++++++++++ .../hexcasting/models/item/chest_locus.json | 3 + .../blocks/circles/BlockChestLocus.java | 51 +++++ .../blocks/circles/BlockEntityChestLocus.java | 45 ++++ .../common/lib/HexBlockEntities.java | 6 + .../hexcasting/common/lib/HexBlocks.java | 6 + .../hexcasting/models/block/chest_locus.json | 70 ++++++ .../hexcasting/blockstates/chest_locus.json | 216 ++++++++++++++++++ .../hexcasting/models/item/chest_locus.json | 3 + .../xplat/HexBlockStatesAndModels.java | 4 + 10 files changed, 620 insertions(+) create mode 100644 Common/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json create mode 100644 Common/src/generated/resources/assets/hexcasting/models/item/chest_locus.json create mode 100644 Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java create mode 100644 Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockEntityChestLocus.java create mode 100644 Common/src/main/resources/assets/hexcasting/models/block/chest_locus.json create mode 100644 Neoforge/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json create mode 100644 Neoforge/src/generated/resources/assets/hexcasting/models/item/chest_locus.json diff --git a/Common/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json b/Common/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json new file mode 100644 index 0000000000..96278b6b66 --- /dev/null +++ b/Common/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json @@ -0,0 +1,216 @@ +{ + "variants": { + "energized=false,face=ceiling,facing=east,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 180, + "y": 270 + }, + "energized=false,face=ceiling,facing=east,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 180, + "y": 270 + }, + "energized=false,face=ceiling,facing=north,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 180, + "y": 180 + }, + "energized=false,face=ceiling,facing=north,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 180, + "y": 180 + }, + "energized=false,face=ceiling,facing=south,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 180 + }, + "energized=false,face=ceiling,facing=south,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 180 + }, + "energized=false,face=ceiling,facing=west,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 180, + "y": 90 + }, + "energized=false,face=ceiling,facing=west,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 180, + "y": 90 + }, + "energized=false,face=floor,facing=east,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "y": 90 + }, + "energized=false,face=floor,facing=east,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "y": 90 + }, + "energized=false,face=floor,facing=north,waterlogged=false": { + "model": "hexcasting:block/chest_locus" + }, + "energized=false,face=floor,facing=north,waterlogged=true": { + "model": "hexcasting:block/chest_locus" + }, + "energized=false,face=floor,facing=south,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "y": 180 + }, + "energized=false,face=floor,facing=south,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "y": 180 + }, + "energized=false,face=floor,facing=west,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "y": 270 + }, + "energized=false,face=floor,facing=west,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "y": 270 + }, + "energized=false,face=wall,facing=east,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 90, + "y": 90 + }, + "energized=false,face=wall,facing=east,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 90, + "y": 90 + }, + "energized=false,face=wall,facing=north,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 90 + }, + "energized=false,face=wall,facing=north,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 90 + }, + "energized=false,face=wall,facing=south,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 90, + "y": 180 + }, + "energized=false,face=wall,facing=south,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 90, + "y": 180 + }, + "energized=false,face=wall,facing=west,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 90, + "y": 270 + }, + "energized=false,face=wall,facing=west,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 90, + "y": 270 + }, + "energized=true,face=ceiling,facing=east,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 180, + "y": 270 + }, + "energized=true,face=ceiling,facing=east,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 180, + "y": 270 + }, + "energized=true,face=ceiling,facing=north,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 180, + "y": 180 + }, + "energized=true,face=ceiling,facing=north,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 180, + "y": 180 + }, + "energized=true,face=ceiling,facing=south,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 180 + }, + "energized=true,face=ceiling,facing=south,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 180 + }, + "energized=true,face=ceiling,facing=west,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 180, + "y": 90 + }, + "energized=true,face=ceiling,facing=west,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 180, + "y": 90 + }, + "energized=true,face=floor,facing=east,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "y": 90 + }, + "energized=true,face=floor,facing=east,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "y": 90 + }, + "energized=true,face=floor,facing=north,waterlogged=false": { + "model": "hexcasting:block/chest_locus" + }, + "energized=true,face=floor,facing=north,waterlogged=true": { + "model": "hexcasting:block/chest_locus" + }, + "energized=true,face=floor,facing=south,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "y": 180 + }, + "energized=true,face=floor,facing=south,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "y": 180 + }, + "energized=true,face=floor,facing=west,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "y": 270 + }, + "energized=true,face=floor,facing=west,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "y": 270 + }, + "energized=true,face=wall,facing=east,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 90, + "y": 90 + }, + "energized=true,face=wall,facing=east,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 90, + "y": 90 + }, + "energized=true,face=wall,facing=north,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 90 + }, + "energized=true,face=wall,facing=north,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 90 + }, + "energized=true,face=wall,facing=south,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 90, + "y": 180 + }, + "energized=true,face=wall,facing=south,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 90, + "y": 180 + }, + "energized=true,face=wall,facing=west,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 90, + "y": 270 + }, + "energized=true,face=wall,facing=west,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 90, + "y": 270 + } + } +} \ No newline at end of file diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/chest_locus.json b/Common/src/generated/resources/assets/hexcasting/models/item/chest_locus.json new file mode 100644 index 0000000000..db79c5fdd5 --- /dev/null +++ b/Common/src/generated/resources/assets/hexcasting/models/item/chest_locus.json @@ -0,0 +1,3 @@ +{ + "parent": "hexcasting:block/chest_locus" +} \ No newline at end of file diff --git a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java new file mode 100644 index 0000000000..40ef24ff3b --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java @@ -0,0 +1,51 @@ +package at.petrak.hexcasting.common.blocks.circles; + +import at.petrak.hexcasting.api.casting.eval.env.CircleCastEnv; +import at.petrak.hexcasting.api.casting.eval.vm.CastingImage; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.BlockHitResult; + +public class BlockChestLocus extends BlockSlate { + public BlockChestLocus(Properties properties) { + super(properties); + } + + @Override + public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { + return new BlockEntityChestLocus(blockPos, blockState); + } + + @Override + public ControlFlow acceptControlFlow(CastingImage imageIn, CircleCastEnv env, Direction enterDir, BlockPos pos, + BlockState bs, ServerLevel world) { + + // TODO: make it actually do something! + + var exitDirsSet = this.possibleExitDirections(pos, bs, world); + exitDirsSet.remove(enterDir.getOpposite()); + + var exitDirs = exitDirsSet.stream().map((dir) -> this.exitPositionFromDirection(pos, dir)); + + return new ControlFlow.Continue(imageIn, exitDirs.toList()); + } + + protected InteractionResult useWithoutItem(BlockState blockState, Level level, BlockPos blockPos, Player player, BlockHitResult blockHitResult) { + if (level.isClientSide) { + return InteractionResult.SUCCESS; + } + + BlockEntity blockEntity = level.getBlockEntity(blockPos); + if (blockEntity instanceof BlockEntityChestLocus) { + player.openMenu((BlockEntityChestLocus)blockEntity); + } + + return InteractionResult.CONSUME; + } +} diff --git a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockEntityChestLocus.java b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockEntityChestLocus.java new file mode 100644 index 0000000000..b493e2a080 --- /dev/null +++ b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockEntityChestLocus.java @@ -0,0 +1,45 @@ +package at.petrak.hexcasting.common.blocks.circles; + +import at.petrak.hexcasting.common.lib.HexBlockEntities; +import net.minecraft.core.BlockPos; +import net.minecraft.core.NonNullList; +import net.minecraft.network.chat.Component; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.ChestMenu; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity; +import net.minecraft.world.level.block.state.BlockState; + +public class BlockEntityChestLocus extends RandomizableContainerBlockEntity { + private NonNullList items = NonNullList.withSize(27, ItemStack.EMPTY); + + public BlockEntityChestLocus(BlockPos blockPos, BlockState blockState) { + super(HexBlockEntities.CHEST_LOCUS_TILE.get(), blockPos, blockState); + } + + @Override + public int getContainerSize() { + return 9; + } + + @Override + protected Component getDefaultName() { + return Component.translatable("hexcasting.container.chest_locus"); + } + + @Override + protected NonNullList getItems() { + return this.items; + } + + @Override + protected void setItems(NonNullList nonNullList) { + this.items = nonNullList; + } + + @Override + protected AbstractContainerMenu createMenu(int i, Inventory inventory) { + return ChestMenu.threeRows(i, inventory); + } +} diff --git a/Common/src/main/java/at/petrak/hexcasting/common/lib/HexBlockEntities.java b/Common/src/main/java/at/petrak/hexcasting/common/lib/HexBlockEntities.java index 988af09b34..131f373cde 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/lib/HexBlockEntities.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/lib/HexBlockEntities.java @@ -2,6 +2,7 @@ import at.petrak.hexcasting.common.blocks.BlockQuenchedAllay; import at.petrak.hexcasting.common.blocks.akashic.BlockEntityAkashicBookshelf; +import at.petrak.hexcasting.common.blocks.circles.BlockEntityChestLocus; import at.petrak.hexcasting.common.blocks.circles.BlockEntitySlate; import at.petrak.hexcasting.common.blocks.circles.impetuses.BlockEntityLookingImpetus; import at.petrak.hexcasting.common.blocks.circles.impetuses.BlockEntityRedstoneImpetus; @@ -31,6 +32,11 @@ public static void register() { () -> IXplatAbstractions.INSTANCE.createBlockEntityType(BlockEntityAkashicBookshelf::new, HexBlocks.AKASHIC_BOOKSHELF.get())); + public static final Supplier> CHEST_LOCUS_TILE = REGISTER.register( + "chest_locus", + () -> IXplatAbstractions.INSTANCE.createBlockEntityType(BlockEntityChestLocus::new, + HexBlocks.CHEST_LOCUS.get())); + public static final Supplier> IMPETUS_REDSTONE_TILE = REGISTER.register( "impetus/redstone", () -> IXplatAbstractions.INSTANCE.createBlockEntityType(BlockEntityRedstoneImpetus::new, diff --git a/Common/src/main/java/at/petrak/hexcasting/common/lib/HexBlocks.java b/Common/src/main/java/at/petrak/hexcasting/common/lib/HexBlocks.java index 4f9fd2f54e..afbfbef84d 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/lib/HexBlocks.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/lib/HexBlocks.java @@ -8,6 +8,7 @@ import at.petrak.hexcasting.common.blocks.akashic.BlockAkashicBookshelf; import at.petrak.hexcasting.common.blocks.akashic.BlockAkashicLigature; import at.petrak.hexcasting.common.blocks.akashic.BlockAkashicRecord; +import at.petrak.hexcasting.common.blocks.circles.BlockChestLocus; import at.petrak.hexcasting.common.blocks.circles.BlockEmptyImpetus; import at.petrak.hexcasting.common.blocks.circles.BlockSlate; import at.petrak.hexcasting.common.blocks.circles.directrix.BlockBooleanDirectrix; @@ -150,6 +151,11 @@ private static BlockBehaviour.Properties quenched() { new BlockSlate(slateish() .pushReaction(PushReaction.DESTROY))); + public static final Supplier CHEST_LOCUS = blockItem("chest_locus", () -> + new BlockChestLocus(slateish() + .noOcclusion() + .pushReaction(PushReaction.DESTROY))); + public static final Supplier IMPETUS_EMPTY = blockItem("impetus/empty", () -> new BlockEmptyImpetus(slateish() .pushReaction(PushReaction.BLOCK))); diff --git a/Common/src/main/resources/assets/hexcasting/models/block/chest_locus.json b/Common/src/main/resources/assets/hexcasting/models/block/chest_locus.json new file mode 100644 index 0000000000..50922258bd --- /dev/null +++ b/Common/src/main/resources/assets/hexcasting/models/block/chest_locus.json @@ -0,0 +1,70 @@ +{ + "credit": "Made with Blockbench", + "textures": { + "0": "hexcasting:block/slate", + "particle": "hexcasting:block/slate" + }, + "elements": [ + { + "name": "base", + "from": [0, 0, 0], + "to": [16, 1, 16], + "faces": { + "north": {"uv": [0, 0, 16, 1], "texture": "#0"}, + "east": {"uv": [15, 0, 16, 16], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 15, 16, 16], "texture": "#0"}, + "west": {"uv": [0, 0, 1, 16], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 16, 16], "texture": "#0"}, + "down": {"uv": [0, 0, 16, 16], "texture": "#0"} + } + }, + { + "name": "chest", + "from": [3, 0, 3], + "to": [13, 5, 13], + "faces": { + "north": {"uv": [0, 0, 16, 1], "texture": "#0"}, + "east": {"uv": [15, 0, 16, 16], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 15, 16, 16], "texture": "#0"}, + "west": {"uv": [0, 0, 1, 16], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 16, 16], "texture": "#0"}, + "down": {"uv": [0, 0, 16, 16], "texture": "#0"} + } + } + ], + "display": { + "thirdperson_righthand": { + "translation": [0, 3, 1], + "scale": [0.55, 0.55, 0.55] + }, + "thirdperson_lefthand": { + "translation": [0, 3, 1], + "scale": [0.55, 0.55, 0.55] + }, + "firstperson_righthand": { + "rotation": [0, -90, 25], + "translation": [1.13, 3.2, 1.13], + "scale": [0.68, 0.68, 0.68] + }, + "firstperson_lefthand": { + "rotation": [0, -90, 25], + "translation": [1.13, 3.2, 1.13], + "scale": [0.68, 0.68, 0.68] + }, + "ground": { + "translation": [0, 2, 0], + "scale": [0.5, 0.5, 0.5] + }, + "gui": { + "rotation": [30, 225, 0], + "scale": [0.625, 0.625, 0.625] + }, + "head": { + "rotation": [0, 180, 0], + "translation": [0, 13, 7] + }, + "fixed": { + "rotation": [0, 180, 0] + } + } +} \ No newline at end of file diff --git a/Neoforge/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json b/Neoforge/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json new file mode 100644 index 0000000000..96278b6b66 --- /dev/null +++ b/Neoforge/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json @@ -0,0 +1,216 @@ +{ + "variants": { + "energized=false,face=ceiling,facing=east,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 180, + "y": 270 + }, + "energized=false,face=ceiling,facing=east,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 180, + "y": 270 + }, + "energized=false,face=ceiling,facing=north,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 180, + "y": 180 + }, + "energized=false,face=ceiling,facing=north,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 180, + "y": 180 + }, + "energized=false,face=ceiling,facing=south,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 180 + }, + "energized=false,face=ceiling,facing=south,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 180 + }, + "energized=false,face=ceiling,facing=west,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 180, + "y": 90 + }, + "energized=false,face=ceiling,facing=west,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 180, + "y": 90 + }, + "energized=false,face=floor,facing=east,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "y": 90 + }, + "energized=false,face=floor,facing=east,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "y": 90 + }, + "energized=false,face=floor,facing=north,waterlogged=false": { + "model": "hexcasting:block/chest_locus" + }, + "energized=false,face=floor,facing=north,waterlogged=true": { + "model": "hexcasting:block/chest_locus" + }, + "energized=false,face=floor,facing=south,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "y": 180 + }, + "energized=false,face=floor,facing=south,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "y": 180 + }, + "energized=false,face=floor,facing=west,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "y": 270 + }, + "energized=false,face=floor,facing=west,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "y": 270 + }, + "energized=false,face=wall,facing=east,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 90, + "y": 90 + }, + "energized=false,face=wall,facing=east,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 90, + "y": 90 + }, + "energized=false,face=wall,facing=north,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 90 + }, + "energized=false,face=wall,facing=north,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 90 + }, + "energized=false,face=wall,facing=south,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 90, + "y": 180 + }, + "energized=false,face=wall,facing=south,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 90, + "y": 180 + }, + "energized=false,face=wall,facing=west,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 90, + "y": 270 + }, + "energized=false,face=wall,facing=west,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 90, + "y": 270 + }, + "energized=true,face=ceiling,facing=east,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 180, + "y": 270 + }, + "energized=true,face=ceiling,facing=east,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 180, + "y": 270 + }, + "energized=true,face=ceiling,facing=north,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 180, + "y": 180 + }, + "energized=true,face=ceiling,facing=north,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 180, + "y": 180 + }, + "energized=true,face=ceiling,facing=south,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 180 + }, + "energized=true,face=ceiling,facing=south,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 180 + }, + "energized=true,face=ceiling,facing=west,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 180, + "y": 90 + }, + "energized=true,face=ceiling,facing=west,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 180, + "y": 90 + }, + "energized=true,face=floor,facing=east,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "y": 90 + }, + "energized=true,face=floor,facing=east,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "y": 90 + }, + "energized=true,face=floor,facing=north,waterlogged=false": { + "model": "hexcasting:block/chest_locus" + }, + "energized=true,face=floor,facing=north,waterlogged=true": { + "model": "hexcasting:block/chest_locus" + }, + "energized=true,face=floor,facing=south,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "y": 180 + }, + "energized=true,face=floor,facing=south,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "y": 180 + }, + "energized=true,face=floor,facing=west,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "y": 270 + }, + "energized=true,face=floor,facing=west,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "y": 270 + }, + "energized=true,face=wall,facing=east,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 90, + "y": 90 + }, + "energized=true,face=wall,facing=east,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 90, + "y": 90 + }, + "energized=true,face=wall,facing=north,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 90 + }, + "energized=true,face=wall,facing=north,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 90 + }, + "energized=true,face=wall,facing=south,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 90, + "y": 180 + }, + "energized=true,face=wall,facing=south,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 90, + "y": 180 + }, + "energized=true,face=wall,facing=west,waterlogged=false": { + "model": "hexcasting:block/chest_locus", + "x": 90, + "y": 270 + }, + "energized=true,face=wall,facing=west,waterlogged=true": { + "model": "hexcasting:block/chest_locus", + "x": 90, + "y": 270 + } + } +} \ No newline at end of file diff --git a/Neoforge/src/generated/resources/assets/hexcasting/models/item/chest_locus.json b/Neoforge/src/generated/resources/assets/hexcasting/models/item/chest_locus.json new file mode 100644 index 0000000000..db79c5fdd5 --- /dev/null +++ b/Neoforge/src/generated/resources/assets/hexcasting/models/item/chest_locus.json @@ -0,0 +1,3 @@ +{ + "parent": "hexcasting:block/chest_locus" +} \ No newline at end of file diff --git a/Neoforge/src/main/java/at/petrak/hexcasting/forge/datagen/xplat/HexBlockStatesAndModels.java b/Neoforge/src/main/java/at/petrak/hexcasting/forge/datagen/xplat/HexBlockStatesAndModels.java index d1f11fd7aa..1b68cc5284 100644 --- a/Neoforge/src/main/java/at/petrak/hexcasting/forge/datagen/xplat/HexBlockStatesAndModels.java +++ b/Neoforge/src/main/java/at/petrak/hexcasting/forge/datagen/xplat/HexBlockStatesAndModels.java @@ -52,6 +52,10 @@ protected void registerStatesAndModels() { .build(); }, BlockSlate.WATERLOGGED); + var chestLocusModel = models().getExistingFile(modLoc("chest_locus")); + horizontalFaceBlock(HexBlocks.CHEST_LOCUS.get(), chestLocusModel); + simpleBlockItem(HexBlocks.CHEST_LOCUS.get(), chestLocusModel); + impetus(HexBlocks.IMPETUS_EMPTY.get(), "impetus/empty", "empty", false); impetus(HexBlocks.IMPETUS_RIGHTCLICK.get(), "impetus/rightclick", "rightclick", true); impetus(HexBlocks.IMPETUS_LOOK.get(), "impetus/look", "look", true); From 1dea8947608ed2de00fd7c91f19e4d70bdbabaa9 Mon Sep 17 00:00:00 2001 From: Robotgiggle <88736742+Robotgiggle@users.noreply.github.com> Date: Thu, 29 Oct 2026 01:03:47 -0400 Subject: [PATCH 02/12] Make the inventory save properly --- .../blocks/circles/BlockChestLocus.java | 7 +++++ .../blocks/circles/BlockEntityChestLocus.java | 26 ++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java index 40ef24ff3b..5a7571b747 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java @@ -5,6 +5,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.Containers; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; @@ -48,4 +49,10 @@ protected InteractionResult useWithoutItem(BlockState blockState, Level level, B return InteractionResult.CONSUME; } + + @Override + protected void onRemove(BlockState blockState, Level level, BlockPos blockPos, BlockState blockState2, boolean bl) { + Containers.dropContentsOnDestroy(blockState, blockState2, level, blockPos); + super.onRemove(blockState, level, blockPos, blockState2, bl); + } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockEntityChestLocus.java b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockEntityChestLocus.java index b493e2a080..226982e53c 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockEntityChestLocus.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockEntityChestLocus.java @@ -2,8 +2,11 @@ import at.petrak.hexcasting.common.lib.HexBlockEntities; import net.minecraft.core.BlockPos; +import net.minecraft.core.HolderLookup.Provider; import net.minecraft.core.NonNullList; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; +import net.minecraft.world.ContainerHelper; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.ChestMenu; @@ -20,7 +23,7 @@ public BlockEntityChestLocus(BlockPos blockPos, BlockState blockState) { @Override public int getContainerSize() { - return 9; + return 27; } @Override @@ -29,7 +32,7 @@ protected Component getDefaultName() { } @Override - protected NonNullList getItems() { + public NonNullList getItems() { return this.items; } @@ -40,6 +43,23 @@ protected void setItems(NonNullList nonNullList) { @Override protected AbstractContainerMenu createMenu(int i, Inventory inventory) { - return ChestMenu.threeRows(i, inventory); + return ChestMenu.threeRows(i, inventory, this); + } + + @Override + protected void loadAdditional(CompoundTag compoundTag, Provider provider) { + super.loadAdditional(compoundTag, provider); + this.items = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); + if (!this.tryLoadLootTable(compoundTag)) { + ContainerHelper.loadAllItems(compoundTag, this.items, provider); + } + } + + @Override + protected void saveAdditional(CompoundTag compoundTag, Provider provider) { + super.saveAdditional(compoundTag, provider); + if (!this.trySaveLootTable(compoundTag)) { + ContainerHelper.saveAllItems(compoundTag, this.items, provider); + } } } From 8ad247303a9cb24e636def6ec386e287fdecd788 Mon Sep 17 00:00:00 2001 From: Robotgiggle <88736742+Robotgiggle@users.noreply.github.com> Date: Thu, 29 Oct 2026 01:32:58 -0400 Subject: [PATCH 03/12] CircleCastEnv inventory functionality --- .../casting/circles/CircleExecutionState.java | 12 ++++-- .../api/casting/eval/env/CircleCastEnv.java | 39 ++++++++++++++++--- .../blocks/circles/BlockChestLocus.java | 3 +- 3 files changed, 43 insertions(+), 11 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/circles/CircleExecutionState.java b/Common/src/main/java/at/petrak/hexcasting/api/casting/circles/CircleExecutionState.java index bc34df2ea1..2bfbde63d3 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/casting/circles/CircleExecutionState.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/circles/CircleExecutionState.java @@ -34,6 +34,7 @@ public class CircleExecutionState { TAG_REACHED_POSITIONS = "reached_positions", TAG_CURRENT_POS = "current_pos", TAG_ENTERED_FROM = "entered_from", + TAG_INVENTORY_POS = "inventory_pos", TAG_IMAGE = "image", TAG_CASTER = "caster", TAG_PIGMENT = "pigment", @@ -47,6 +48,7 @@ public class CircleExecutionState { public final HashSet reachedPositions; public BlockPos currentPos; public Direction enteredFrom; + public @Nullable BlockPos inventoryPos; public CastingImage currentImage; public @Nullable UUID caster; public @Nullable FrozenPigment casterPigment; @@ -60,13 +62,14 @@ public class CircleExecutionState { protected CircleExecutionState(BlockPos impetusPos, Direction impetusDir, HashSet reachedPositions, - BlockPos currentPos, Direction enteredFrom, CastingImage currentImage, @Nullable UUID caster, + BlockPos currentPos, Direction enteredFrom, BlockPos inventoryPos, CastingImage currentImage, @Nullable UUID caster, @Nullable FrozenPigment casterPigment, Long reachedSlate, BlockPos greaterCorner, BlockPos lesserCorner) { this.impetusPos = impetusPos; this.impetusDir = impetusDir; this.reachedPositions = reachedPositions; this.currentPos = currentPos; this.enteredFrom = enteredFrom; + this.inventoryPos = inventoryPos; this.currentImage = currentImage; this.caster = caster; this.casterPigment = casterPigment; @@ -170,7 +173,7 @@ protected CircleExecutionState(BlockPos impetusPos, Direction impetusDir, HashSe return new Result.Ok<>( new CircleExecutionState(impetus.getBlockPos(), impetus.getStartDirection(), reachedPositions, impetus.getBlockPos().offset(impetus.getStartDirection().getNormal()), - impetus.getStartDirection(), new CastingImage(), casterUUID, colorizer, 0L, + impetus.getStartDirection(), null, new CastingImage(), casterUUID, colorizer, 0L, positiveBlock, negativeBlock)); } @@ -188,6 +191,8 @@ public CompoundTag save() { out.put(TAG_CURRENT_POS, NbtUtils.writeBlockPos(this.currentPos)); out.putByte(TAG_ENTERED_FROM, (byte) this.enteredFrom.ordinal()); + if (this.inventoryPos != null) + out.put(TAG_INVENTORY_POS, NbtUtils.writeBlockPos(this.inventoryPos)); out.put(TAG_IMAGE, CastingImage.getCODEC().encodeStart(NbtOps.INSTANCE, currentImage).getOrThrow()); if (this.caster != null) @@ -217,6 +222,7 @@ public static CircleExecutionState load(CompoundTag nbt, ServerLevel world) { var currentPos = NbtUtils.readBlockPos(nbt, TAG_CURRENT_POS).orElseThrow(); var enteredFrom = Direction.values()[nbt.getByte(TAG_ENTERED_FROM)]; + var inventoryPos = NbtUtils.readBlockPos(nbt, TAG_INVENTORY_POS).orElse(null); var image = CastingImage.getCODEC().parse(NbtOps.INSTANCE, nbt.getCompound(TAG_IMAGE)).getOrThrow(); var reachedSlate = nbt.getLong(TAG_REACHED_NUMBER); @@ -232,7 +238,7 @@ public static CircleExecutionState load(CompoundTag nbt, ServerLevel world) { pigment = FrozenPigment.CODEC.parse(NbtOps.INSTANCE, nbt.getCompound(TAG_PIGMENT)).getOrThrow(); return new CircleExecutionState(startPos, startDir, reachedPositions, currentPos, - enteredFrom, image, caster, pigment, reachedSlate, positivePos, negativePos); + enteredFrom, inventoryPos, image, caster, pigment, reachedSlate, positivePos, negativePos); } private static Optional readBlockPos(int[] aint) { diff --git a/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/CircleCastEnv.java b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/CircleCastEnv.java index a61a522476..9c35a0e96c 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/CircleCastEnv.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/CircleCastEnv.java @@ -13,6 +13,7 @@ import at.petrak.hexcasting.api.casting.mishaps.MishapDisallowedSpell; import at.petrak.hexcasting.api.mod.HexConfig; import at.petrak.hexcasting.api.pigment.FrozenPigment; +import at.petrak.hexcasting.common.blocks.circles.BlockEntityChestLocus; import at.petrak.hexcasting.common.lib.HexAttributes; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; @@ -163,26 +164,52 @@ public InteractionHand getCastingHand() { } @Override - // TODO: Could do something like get items in inventories adjacent to the circle? public List getUsableStacks(StackDiscoveryMode mode) { - if (this.getCastingEntity() instanceof ServerPlayer caster) + var invPos = this.execState.inventoryPos; + if (invPos != null && world.getBlockEntity(invPos) instanceof BlockEntityChestLocus chestLocus) { + return switch (mode) { + // top row of items is the "hotbar" for use in filtering + case QUERY -> chestLocus.getItems().subList(0,9); + // reverse order so non-hotbar items are prioritized for extraction + case EXTRACTION -> chestLocus.getItems().reversed(); + }; + } else if (this.getCastingEntity() instanceof ServerPlayer caster) { return getUsableStacksForPlayer(mode, null, caster); + } return new ArrayList<>(); } @Override - // TODO: Adjacent inv! public List getPrimaryStacks() { - if (this.getCastingEntity() instanceof ServerPlayer caster) + var invPos = this.execState.inventoryPos; + if (invPos != null && world.getBlockEntity(invPos) instanceof BlockEntityChestLocus chestLocus) { + // slot 0 is treated as the "offhand" + return List.of(new HeldItemInfo(chestLocus.getItem(0), InteractionHand.OFF_HAND)); + } else if (this.getCastingEntity() instanceof ServerPlayer caster) { return getPrimaryStacksForPlayer(InteractionHand.OFF_HAND, caster); + } return List.of(); } @Override - // TODO: Adjacent inv! public boolean replaceItem(Predicate stackOk, ItemStack replaceWith, @Nullable InteractionHand hand) { - if (this.getCastingEntity() instanceof ServerPlayer caster) + var invPos = this.execState.inventoryPos; + if (invPos != null && world.getBlockEntity(invPos) instanceof BlockEntityChestLocus chestLocus) { + if (hand != null && stackOk.test(chestLocus.getItem(0))) { + // slot 0 is treated as the "offhand" + chestLocus.setItem(0, replaceWith); + return true; + } else { + for (int i = 26; i >= 0; i--) { + if (stackOk.test(chestLocus.getItem(i))) { + chestLocus.setItem(0, replaceWith); + return true; + } + } + } + } else if (this.getCastingEntity() instanceof ServerPlayer caster) { return replaceItemForPlayer(stackOk, replaceWith, hand, caster); + } return false; } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java index 5a7571b747..94146726c1 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java @@ -27,11 +27,10 @@ public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) { public ControlFlow acceptControlFlow(CastingImage imageIn, CircleCastEnv env, Direction enterDir, BlockPos pos, BlockState bs, ServerLevel world) { - // TODO: make it actually do something! + env.circleState().inventoryPos = pos; var exitDirsSet = this.possibleExitDirections(pos, bs, world); exitDirsSet.remove(enterDir.getOpposite()); - var exitDirs = exitDirsSet.stream().map((dir) -> this.exitPositionFromDirection(pos, dir)); return new ControlFlow.Continue(imageIn, exitDirs.toList()); From 1c7e4e47279a17d3cb10678a8132b33695ff8eea Mon Sep 17 00:00:00 2001 From: Robotgiggle <88736742+Robotgiggle@users.noreply.github.com> Date: Thu, 29 Oct 2026 04:10:26 -0400 Subject: [PATCH 04/12] Proper model and texture --- .../hexcasting/blockstates/chest_locus.json | 308 +++++++++++++++--- .../blocks/circles/BlockChestLocus.java | 18 + .../hexcasting/models/block/chest_locus.json | 17 +- .../models/block/chest_locus_open.json | 9 + .../block/circle/locus/chest_closed.png | Bin 0 -> 455 bytes .../block/circle/locus/chest_open.png | Bin 0 -> 391 bytes .../block/circle/locus/chest_side.png | Bin 0 -> 439 bytes .../hexcasting/blockstates/chest_locus.json | 308 +++++++++++++++--- .../xplat/HexBlockStatesAndModels.java | 15 +- 9 files changed, 568 insertions(+), 107 deletions(-) create mode 100644 Common/src/main/resources/assets/hexcasting/models/block/chest_locus_open.json create mode 100644 Common/src/main/resources/assets/hexcasting/textures/block/circle/locus/chest_closed.png create mode 100644 Common/src/main/resources/assets/hexcasting/textures/block/circle/locus/chest_open.png create mode 100644 Common/src/main/resources/assets/hexcasting/textures/block/circle/locus/chest_side.png diff --git a/Common/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json b/Common/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json index 96278b6b66..0bab4f51e7 100644 --- a/Common/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json +++ b/Common/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json @@ -1,216 +1,428 @@ { "variants": { - "energized=false,face=ceiling,facing=east,waterlogged=false": { + "energized=false,face=ceiling,facing=east,open=false,waterlogged=false": { "model": "hexcasting:block/chest_locus", "x": 180, "y": 270 }, - "energized=false,face=ceiling,facing=east,waterlogged=true": { + "energized=false,face=ceiling,facing=east,open=false,waterlogged=true": { "model": "hexcasting:block/chest_locus", "x": 180, "y": 270 }, - "energized=false,face=ceiling,facing=north,waterlogged=false": { + "energized=false,face=ceiling,facing=east,open=true,waterlogged=false": { + "model": "hexcasting:block/chest_locus_open", + "x": 180, + "y": 270 + }, + "energized=false,face=ceiling,facing=east,open=true,waterlogged=true": { + "model": "hexcasting:block/chest_locus_open", + "x": 180, + "y": 270 + }, + "energized=false,face=ceiling,facing=north,open=false,waterlogged=false": { "model": "hexcasting:block/chest_locus", "x": 180, "y": 180 }, - "energized=false,face=ceiling,facing=north,waterlogged=true": { + "energized=false,face=ceiling,facing=north,open=false,waterlogged=true": { "model": "hexcasting:block/chest_locus", "x": 180, "y": 180 }, - "energized=false,face=ceiling,facing=south,waterlogged=false": { + "energized=false,face=ceiling,facing=north,open=true,waterlogged=false": { + "model": "hexcasting:block/chest_locus_open", + "x": 180, + "y": 180 + }, + "energized=false,face=ceiling,facing=north,open=true,waterlogged=true": { + "model": "hexcasting:block/chest_locus_open", + "x": 180, + "y": 180 + }, + "energized=false,face=ceiling,facing=south,open=false,waterlogged=false": { "model": "hexcasting:block/chest_locus", "x": 180 }, - "energized=false,face=ceiling,facing=south,waterlogged=true": { + "energized=false,face=ceiling,facing=south,open=false,waterlogged=true": { "model": "hexcasting:block/chest_locus", "x": 180 }, - "energized=false,face=ceiling,facing=west,waterlogged=false": { + "energized=false,face=ceiling,facing=south,open=true,waterlogged=false": { + "model": "hexcasting:block/chest_locus_open", + "x": 180 + }, + "energized=false,face=ceiling,facing=south,open=true,waterlogged=true": { + "model": "hexcasting:block/chest_locus_open", + "x": 180 + }, + "energized=false,face=ceiling,facing=west,open=false,waterlogged=false": { "model": "hexcasting:block/chest_locus", "x": 180, "y": 90 }, - "energized=false,face=ceiling,facing=west,waterlogged=true": { + "energized=false,face=ceiling,facing=west,open=false,waterlogged=true": { "model": "hexcasting:block/chest_locus", "x": 180, "y": 90 }, - "energized=false,face=floor,facing=east,waterlogged=false": { + "energized=false,face=ceiling,facing=west,open=true,waterlogged=false": { + "model": "hexcasting:block/chest_locus_open", + "x": 180, + "y": 90 + }, + "energized=false,face=ceiling,facing=west,open=true,waterlogged=true": { + "model": "hexcasting:block/chest_locus_open", + "x": 180, + "y": 90 + }, + "energized=false,face=floor,facing=east,open=false,waterlogged=false": { "model": "hexcasting:block/chest_locus", "y": 90 }, - "energized=false,face=floor,facing=east,waterlogged=true": { + "energized=false,face=floor,facing=east,open=false,waterlogged=true": { "model": "hexcasting:block/chest_locus", "y": 90 }, - "energized=false,face=floor,facing=north,waterlogged=false": { + "energized=false,face=floor,facing=east,open=true,waterlogged=false": { + "model": "hexcasting:block/chest_locus_open", + "y": 90 + }, + "energized=false,face=floor,facing=east,open=true,waterlogged=true": { + "model": "hexcasting:block/chest_locus_open", + "y": 90 + }, + "energized=false,face=floor,facing=north,open=false,waterlogged=false": { "model": "hexcasting:block/chest_locus" }, - "energized=false,face=floor,facing=north,waterlogged=true": { + "energized=false,face=floor,facing=north,open=false,waterlogged=true": { "model": "hexcasting:block/chest_locus" }, - "energized=false,face=floor,facing=south,waterlogged=false": { + "energized=false,face=floor,facing=north,open=true,waterlogged=false": { + "model": "hexcasting:block/chest_locus_open" + }, + "energized=false,face=floor,facing=north,open=true,waterlogged=true": { + "model": "hexcasting:block/chest_locus_open" + }, + "energized=false,face=floor,facing=south,open=false,waterlogged=false": { "model": "hexcasting:block/chest_locus", "y": 180 }, - "energized=false,face=floor,facing=south,waterlogged=true": { + "energized=false,face=floor,facing=south,open=false,waterlogged=true": { "model": "hexcasting:block/chest_locus", "y": 180 }, - "energized=false,face=floor,facing=west,waterlogged=false": { + "energized=false,face=floor,facing=south,open=true,waterlogged=false": { + "model": "hexcasting:block/chest_locus_open", + "y": 180 + }, + "energized=false,face=floor,facing=south,open=true,waterlogged=true": { + "model": "hexcasting:block/chest_locus_open", + "y": 180 + }, + "energized=false,face=floor,facing=west,open=false,waterlogged=false": { "model": "hexcasting:block/chest_locus", "y": 270 }, - "energized=false,face=floor,facing=west,waterlogged=true": { + "energized=false,face=floor,facing=west,open=false,waterlogged=true": { "model": "hexcasting:block/chest_locus", "y": 270 }, - "energized=false,face=wall,facing=east,waterlogged=false": { + "energized=false,face=floor,facing=west,open=true,waterlogged=false": { + "model": "hexcasting:block/chest_locus_open", + "y": 270 + }, + "energized=false,face=floor,facing=west,open=true,waterlogged=true": { + "model": "hexcasting:block/chest_locus_open", + "y": 270 + }, + "energized=false,face=wall,facing=east,open=false,waterlogged=false": { "model": "hexcasting:block/chest_locus", "x": 90, "y": 90 }, - "energized=false,face=wall,facing=east,waterlogged=true": { + "energized=false,face=wall,facing=east,open=false,waterlogged=true": { "model": "hexcasting:block/chest_locus", "x": 90, "y": 90 }, - "energized=false,face=wall,facing=north,waterlogged=false": { + "energized=false,face=wall,facing=east,open=true,waterlogged=false": { + "model": "hexcasting:block/chest_locus_open", + "x": 90, + "y": 90 + }, + "energized=false,face=wall,facing=east,open=true,waterlogged=true": { + "model": "hexcasting:block/chest_locus_open", + "x": 90, + "y": 90 + }, + "energized=false,face=wall,facing=north,open=false,waterlogged=false": { "model": "hexcasting:block/chest_locus", "x": 90 }, - "energized=false,face=wall,facing=north,waterlogged=true": { + "energized=false,face=wall,facing=north,open=false,waterlogged=true": { "model": "hexcasting:block/chest_locus", "x": 90 }, - "energized=false,face=wall,facing=south,waterlogged=false": { + "energized=false,face=wall,facing=north,open=true,waterlogged=false": { + "model": "hexcasting:block/chest_locus_open", + "x": 90 + }, + "energized=false,face=wall,facing=north,open=true,waterlogged=true": { + "model": "hexcasting:block/chest_locus_open", + "x": 90 + }, + "energized=false,face=wall,facing=south,open=false,waterlogged=false": { "model": "hexcasting:block/chest_locus", "x": 90, "y": 180 }, - "energized=false,face=wall,facing=south,waterlogged=true": { + "energized=false,face=wall,facing=south,open=false,waterlogged=true": { "model": "hexcasting:block/chest_locus", "x": 90, "y": 180 }, - "energized=false,face=wall,facing=west,waterlogged=false": { + "energized=false,face=wall,facing=south,open=true,waterlogged=false": { + "model": "hexcasting:block/chest_locus_open", + "x": 90, + "y": 180 + }, + "energized=false,face=wall,facing=south,open=true,waterlogged=true": { + "model": "hexcasting:block/chest_locus_open", + "x": 90, + "y": 180 + }, + "energized=false,face=wall,facing=west,open=false,waterlogged=false": { "model": "hexcasting:block/chest_locus", "x": 90, "y": 270 }, - "energized=false,face=wall,facing=west,waterlogged=true": { + "energized=false,face=wall,facing=west,open=false,waterlogged=true": { "model": "hexcasting:block/chest_locus", "x": 90, "y": 270 }, - "energized=true,face=ceiling,facing=east,waterlogged=false": { + "energized=false,face=wall,facing=west,open=true,waterlogged=false": { + "model": "hexcasting:block/chest_locus_open", + "x": 90, + "y": 270 + }, + "energized=false,face=wall,facing=west,open=true,waterlogged=true": { + "model": "hexcasting:block/chest_locus_open", + "x": 90, + "y": 270 + }, + "energized=true,face=ceiling,facing=east,open=false,waterlogged=false": { "model": "hexcasting:block/chest_locus", "x": 180, "y": 270 }, - "energized=true,face=ceiling,facing=east,waterlogged=true": { + "energized=true,face=ceiling,facing=east,open=false,waterlogged=true": { "model": "hexcasting:block/chest_locus", "x": 180, "y": 270 }, - "energized=true,face=ceiling,facing=north,waterlogged=false": { + "energized=true,face=ceiling,facing=east,open=true,waterlogged=false": { + "model": "hexcasting:block/chest_locus_open", + "x": 180, + "y": 270 + }, + "energized=true,face=ceiling,facing=east,open=true,waterlogged=true": { + "model": "hexcasting:block/chest_locus_open", + "x": 180, + "y": 270 + }, + "energized=true,face=ceiling,facing=north,open=false,waterlogged=false": { "model": "hexcasting:block/chest_locus", "x": 180, "y": 180 }, - "energized=true,face=ceiling,facing=north,waterlogged=true": { + "energized=true,face=ceiling,facing=north,open=false,waterlogged=true": { "model": "hexcasting:block/chest_locus", "x": 180, "y": 180 }, - "energized=true,face=ceiling,facing=south,waterlogged=false": { + "energized=true,face=ceiling,facing=north,open=true,waterlogged=false": { + "model": "hexcasting:block/chest_locus_open", + "x": 180, + "y": 180 + }, + "energized=true,face=ceiling,facing=north,open=true,waterlogged=true": { + "model": "hexcasting:block/chest_locus_open", + "x": 180, + "y": 180 + }, + "energized=true,face=ceiling,facing=south,open=false,waterlogged=false": { "model": "hexcasting:block/chest_locus", "x": 180 }, - "energized=true,face=ceiling,facing=south,waterlogged=true": { + "energized=true,face=ceiling,facing=south,open=false,waterlogged=true": { "model": "hexcasting:block/chest_locus", "x": 180 }, - "energized=true,face=ceiling,facing=west,waterlogged=false": { + "energized=true,face=ceiling,facing=south,open=true,waterlogged=false": { + "model": "hexcasting:block/chest_locus_open", + "x": 180 + }, + "energized=true,face=ceiling,facing=south,open=true,waterlogged=true": { + "model": "hexcasting:block/chest_locus_open", + "x": 180 + }, + "energized=true,face=ceiling,facing=west,open=false,waterlogged=false": { "model": "hexcasting:block/chest_locus", "x": 180, "y": 90 }, - "energized=true,face=ceiling,facing=west,waterlogged=true": { + "energized=true,face=ceiling,facing=west,open=false,waterlogged=true": { "model": "hexcasting:block/chest_locus", "x": 180, "y": 90 }, - "energized=true,face=floor,facing=east,waterlogged=false": { + "energized=true,face=ceiling,facing=west,open=true,waterlogged=false": { + "model": "hexcasting:block/chest_locus_open", + "x": 180, + "y": 90 + }, + "energized=true,face=ceiling,facing=west,open=true,waterlogged=true": { + "model": "hexcasting:block/chest_locus_open", + "x": 180, + "y": 90 + }, + "energized=true,face=floor,facing=east,open=false,waterlogged=false": { "model": "hexcasting:block/chest_locus", "y": 90 }, - "energized=true,face=floor,facing=east,waterlogged=true": { + "energized=true,face=floor,facing=east,open=false,waterlogged=true": { "model": "hexcasting:block/chest_locus", "y": 90 }, - "energized=true,face=floor,facing=north,waterlogged=false": { + "energized=true,face=floor,facing=east,open=true,waterlogged=false": { + "model": "hexcasting:block/chest_locus_open", + "y": 90 + }, + "energized=true,face=floor,facing=east,open=true,waterlogged=true": { + "model": "hexcasting:block/chest_locus_open", + "y": 90 + }, + "energized=true,face=floor,facing=north,open=false,waterlogged=false": { "model": "hexcasting:block/chest_locus" }, - "energized=true,face=floor,facing=north,waterlogged=true": { + "energized=true,face=floor,facing=north,open=false,waterlogged=true": { "model": "hexcasting:block/chest_locus" }, - "energized=true,face=floor,facing=south,waterlogged=false": { + "energized=true,face=floor,facing=north,open=true,waterlogged=false": { + "model": "hexcasting:block/chest_locus_open" + }, + "energized=true,face=floor,facing=north,open=true,waterlogged=true": { + "model": "hexcasting:block/chest_locus_open" + }, + "energized=true,face=floor,facing=south,open=false,waterlogged=false": { "model": "hexcasting:block/chest_locus", "y": 180 }, - "energized=true,face=floor,facing=south,waterlogged=true": { + "energized=true,face=floor,facing=south,open=false,waterlogged=true": { "model": "hexcasting:block/chest_locus", "y": 180 }, - "energized=true,face=floor,facing=west,waterlogged=false": { + "energized=true,face=floor,facing=south,open=true,waterlogged=false": { + "model": "hexcasting:block/chest_locus_open", + "y": 180 + }, + "energized=true,face=floor,facing=south,open=true,waterlogged=true": { + "model": "hexcasting:block/chest_locus_open", + "y": 180 + }, + "energized=true,face=floor,facing=west,open=false,waterlogged=false": { "model": "hexcasting:block/chest_locus", "y": 270 }, - "energized=true,face=floor,facing=west,waterlogged=true": { + "energized=true,face=floor,facing=west,open=false,waterlogged=true": { "model": "hexcasting:block/chest_locus", "y": 270 }, - "energized=true,face=wall,facing=east,waterlogged=false": { + "energized=true,face=floor,facing=west,open=true,waterlogged=false": { + "model": "hexcasting:block/chest_locus_open", + "y": 270 + }, + "energized=true,face=floor,facing=west,open=true,waterlogged=true": { + "model": "hexcasting:block/chest_locus_open", + "y": 270 + }, + "energized=true,face=wall,facing=east,open=false,waterlogged=false": { "model": "hexcasting:block/chest_locus", "x": 90, "y": 90 }, - "energized=true,face=wall,facing=east,waterlogged=true": { + "energized=true,face=wall,facing=east,open=false,waterlogged=true": { "model": "hexcasting:block/chest_locus", "x": 90, "y": 90 }, - "energized=true,face=wall,facing=north,waterlogged=false": { + "energized=true,face=wall,facing=east,open=true,waterlogged=false": { + "model": "hexcasting:block/chest_locus_open", + "x": 90, + "y": 90 + }, + "energized=true,face=wall,facing=east,open=true,waterlogged=true": { + "model": "hexcasting:block/chest_locus_open", + "x": 90, + "y": 90 + }, + "energized=true,face=wall,facing=north,open=false,waterlogged=false": { "model": "hexcasting:block/chest_locus", "x": 90 }, - "energized=true,face=wall,facing=north,waterlogged=true": { + "energized=true,face=wall,facing=north,open=false,waterlogged=true": { "model": "hexcasting:block/chest_locus", "x": 90 }, - "energized=true,face=wall,facing=south,waterlogged=false": { + "energized=true,face=wall,facing=north,open=true,waterlogged=false": { + "model": "hexcasting:block/chest_locus_open", + "x": 90 + }, + "energized=true,face=wall,facing=north,open=true,waterlogged=true": { + "model": "hexcasting:block/chest_locus_open", + "x": 90 + }, + "energized=true,face=wall,facing=south,open=false,waterlogged=false": { "model": "hexcasting:block/chest_locus", "x": 90, "y": 180 }, - "energized=true,face=wall,facing=south,waterlogged=true": { + "energized=true,face=wall,facing=south,open=false,waterlogged=true": { "model": "hexcasting:block/chest_locus", "x": 90, "y": 180 }, - "energized=true,face=wall,facing=west,waterlogged=false": { + "energized=true,face=wall,facing=south,open=true,waterlogged=false": { + "model": "hexcasting:block/chest_locus_open", + "x": 90, + "y": 180 + }, + "energized=true,face=wall,facing=south,open=true,waterlogged=true": { + "model": "hexcasting:block/chest_locus_open", + "x": 90, + "y": 180 + }, + "energized=true,face=wall,facing=west,open=false,waterlogged=false": { "model": "hexcasting:block/chest_locus", "x": 90, "y": 270 }, - "energized=true,face=wall,facing=west,waterlogged=true": { + "energized=true,face=wall,facing=west,open=false,waterlogged=true": { "model": "hexcasting:block/chest_locus", "x": 90, "y": 270 + }, + "energized=true,face=wall,facing=west,open=true,waterlogged=false": { + "model": "hexcasting:block/chest_locus_open", + "x": 90, + "y": 270 + }, + "energized=true,face=wall,facing=west,open=true,waterlogged=true": { + "model": "hexcasting:block/chest_locus_open", + "x": 90, + "y": 270 } } } \ No newline at end of file diff --git a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java index 94146726c1..304b60f4a5 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java @@ -9,13 +9,25 @@ import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; 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.phys.BlockHitResult; public class BlockChestLocus extends BlockSlate { + public static final BooleanProperty OPEN = BlockStateProperties.OPEN; + public BlockChestLocus(Properties properties) { super(properties); + this.registerDefaultState( + this.stateDefinition.any() + .setValue(OPEN, false) + .setValue(ENERGIZED, false) + .setValue(FACING, Direction.NORTH) + .setValue(WATERLOGGED, false)); } @Override @@ -54,4 +66,10 @@ protected void onRemove(BlockState blockState, Level level, BlockPos blockPos, B Containers.dropContentsOnDestroy(blockState, blockState2, level, blockPos); super.onRemove(blockState, level, blockPos, blockState2, bl); } + + @Override + protected void createBlockStateDefinition(StateDefinition.Builder builder) { + super.createBlockStateDefinition(builder); + builder.add(OPEN); + } } diff --git a/Common/src/main/resources/assets/hexcasting/models/block/chest_locus.json b/Common/src/main/resources/assets/hexcasting/models/block/chest_locus.json index 50922258bd..dbd7dbc073 100644 --- a/Common/src/main/resources/assets/hexcasting/models/block/chest_locus.json +++ b/Common/src/main/resources/assets/hexcasting/models/block/chest_locus.json @@ -2,6 +2,8 @@ "credit": "Made with Blockbench", "textures": { "0": "hexcasting:block/slate", + "1": "hexcasting:block/circle/locus/chest_side", + "2": "hexcasting:block/circle/locus/chest_closed", "particle": "hexcasting:block/slate" }, "elements": [ @@ -20,15 +22,14 @@ }, { "name": "chest", - "from": [3, 0, 3], - "to": [13, 5, 13], + "from": [1, 1, 1], + "to": [15, 9, 15], "faces": { - "north": {"uv": [0, 0, 16, 1], "texture": "#0"}, - "east": {"uv": [15, 0, 16, 16], "rotation": 90, "texture": "#0"}, - "south": {"uv": [0, 15, 16, 16], "texture": "#0"}, - "west": {"uv": [0, 0, 1, 16], "rotation": 270, "texture": "#0"}, - "up": {"uv": [0, 0, 16, 16], "texture": "#0"}, - "down": {"uv": [0, 0, 16, 16], "texture": "#0"} + "north": {"uv": [1, 8, 15, 16], "texture": "#1"}, + "east": {"uv": [1, 8, 15, 16], "texture": "#1"}, + "south": {"uv": [1, 8, 15, 16], "texture": "#1"}, + "west": {"uv": [1, 8, 15, 16], "texture": "#1"}, + "up": {"uv": [1, 1, 15, 15], "texture": "#2"} } } ], diff --git a/Common/src/main/resources/assets/hexcasting/models/block/chest_locus_open.json b/Common/src/main/resources/assets/hexcasting/models/block/chest_locus_open.json new file mode 100644 index 0000000000..1590b51c73 --- /dev/null +++ b/Common/src/main/resources/assets/hexcasting/models/block/chest_locus_open.json @@ -0,0 +1,9 @@ +{ + "parent": "hexcasting:block/chest_locus", + "textures": { + "0": "hexcasting:block/slate", + "1": "hexcasting:block/circle/locus/chest_side", + "2": "hexcasting:block/circle/locus/chest_open", + "particle": "hexcasting:block/slate" + } +} \ No newline at end of file diff --git a/Common/src/main/resources/assets/hexcasting/textures/block/circle/locus/chest_closed.png b/Common/src/main/resources/assets/hexcasting/textures/block/circle/locus/chest_closed.png new file mode 100644 index 0000000000000000000000000000000000000000..3daf0c0a14ddf06e3e3c1a2e3f3fe3d0d074a744 GIT binary patch literal 455 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jPK-BC>eK@{Ea{HEjtmSN z`?>!lvI6-E$sR$z3=CCj3=9n|3=F@3LJcn%7)lKo7+xhXFj&oCU=S~uvn$XBD8ZKG z?e4;m$zaA%BVxi;1{C2e@Q5sCVBi)8VMc~ob0mO*>?NMQuI#V4WI5P5?l^kA0=j_P z)5S5w;`GwV8~qL&2(;~Yn>is(bd`+WKRzyER%+b6Sp`0?RO?S)xSQw$^itTbg<|EV>CBP{>?Vu1$> zOdqe;e0}%Xnw6hb(pPgaI5j*?Iasy*q1jHw?x58XtB#%WylSv}A9E2`7>i!)s$;ix zLX+Rl+`y0;9lUMp_6rTCwr%^Acwgo_N92?;ttDB0v#cHB8?86)H(Oxe|G?}wPf2J5 z!+l*I(`w(E^>$V>YfnZ_DYBo(TV2rEbRqo3=L4n}4>*0^_T2N|??Zissz*+`OkUme uS5ScaV3_EXw_n!m4`8iM;{UVg2jjHE&1t%~J^XeK@{Ea{HEjtmSN z`?>!lvI6-E$sR$z3=CCj3=9n|3=F@3LJcn%7)lKo7+xhXFj&oCU=S~uvn$XBD8ZKG z?e4;m$zaA%BVxi;1{C2e@Q5sCVBi)8VMc~ob0mO*>?NMQuI#V4WI0&0lz1Y}0){nuHrLu>A-o)yfmsupQRtUG#AasQE{g?*O`=ZjzSsor>&Sw|CSZsDcuoNY^< bs8=y0Pjj`9Vm-eF=q(0MS3j3^P6eK@{Ea{HEjtmSN z`?>!lvI6-E$sR$z3=CCj3=9n|3=F@3LJcn%7)lKo7+xhXFj&oCU=S~uvn$XBD8ZKG z?e4mxo%{RV~+J-7e?Q#T{GnbkT)Y z0TB_=+g6Qgp`V={H*mk);?*qvV!L$OzT@B7u0^tYF`PX-`Tg{R4U6v{+uyp8L$=sa zx65L`jdre1e4OnU4qM*`VO)%V19{Fp%3+NBcdl*$qd{d92T(lc*Od;j29whaFYN9M zX#8ha;$-+4QgFJ<;irV>iRFi$UF%|HSleusEVz47asAnkak34$OW*AN_V#6#!<;=# z27fA)znJ7jM!vsrd4I^W)pM2n54`%LtAAW?M$NK2mi^ai openPred = (BlockState state) -> { + if (state.getValue(BlockStateProperties.OPEN)) return chestLocusOpen; + else return chestLocusClosed; + }; + horizontalFaceBlock(HexBlocks.CHEST_LOCUS.get(), openPred); + simpleBlockItem(HexBlocks.CHEST_LOCUS.get(), chestLocusClosed); impetus(HexBlocks.IMPETUS_EMPTY.get(), "impetus/empty", "empty", false); impetus(HexBlocks.IMPETUS_RIGHTCLICK.get(), "impetus/rightclick", "rightclick", true); From dd318f4dcc4807f4a17fe13af892b409d4c0dd82 Mon Sep 17 00:00:00 2001 From: Robotgiggle <88736742+Robotgiggle@users.noreply.github.com> Date: Thu, 29 Oct 2026 14:16:07 -0400 Subject: [PATCH 05/12] Improve datagen, add proper bounding box --- .../hexcasting/blockstates/chest_locus.json | 366 ++---------------- .../blocks/circles/BlockChestLocus.java | 26 ++ .../hexcasting/blockstates/chest_locus.json | 366 ++---------------- .../xplat/HexBlockStatesAndModels.java | 12 +- 4 files changed, 81 insertions(+), 689 deletions(-) diff --git a/Common/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json b/Common/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json index 0bab4f51e7..0eac83693a 100644 --- a/Common/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json +++ b/Common/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json @@ -1,425 +1,107 @@ { "variants": { - "energized=false,face=ceiling,facing=east,open=false,waterlogged=false": { + "face=ceiling,facing=east,open=false": { "model": "hexcasting:block/chest_locus", "x": 180, "y": 270 }, - "energized=false,face=ceiling,facing=east,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 180, - "y": 270 - }, - "energized=false,face=ceiling,facing=east,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 180, - "y": 270 - }, - "energized=false,face=ceiling,facing=east,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 180, - "y": 270 - }, - "energized=false,face=ceiling,facing=north,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "x": 180, - "y": 180 - }, - "energized=false,face=ceiling,facing=north,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 180, - "y": 180 - }, - "energized=false,face=ceiling,facing=north,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 180, - "y": 180 - }, - "energized=false,face=ceiling,facing=north,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 180, - "y": 180 - }, - "energized=false,face=ceiling,facing=south,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "x": 180 - }, - "energized=false,face=ceiling,facing=south,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 180 - }, - "energized=false,face=ceiling,facing=south,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 180 - }, - "energized=false,face=ceiling,facing=south,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 180 - }, - "energized=false,face=ceiling,facing=west,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "x": 180, - "y": 90 - }, - "energized=false,face=ceiling,facing=west,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 180, - "y": 90 - }, - "energized=false,face=ceiling,facing=west,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 180, - "y": 90 - }, - "energized=false,face=ceiling,facing=west,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 180, - "y": 90 - }, - "energized=false,face=floor,facing=east,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "y": 90 - }, - "energized=false,face=floor,facing=east,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "y": 90 - }, - "energized=false,face=floor,facing=east,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "y": 90 - }, - "energized=false,face=floor,facing=east,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "y": 90 - }, - "energized=false,face=floor,facing=north,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus" - }, - "energized=false,face=floor,facing=north,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus" - }, - "energized=false,face=floor,facing=north,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open" - }, - "energized=false,face=floor,facing=north,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open" - }, - "energized=false,face=floor,facing=south,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "y": 180 - }, - "energized=false,face=floor,facing=south,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "y": 180 - }, - "energized=false,face=floor,facing=south,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "y": 180 - }, - "energized=false,face=floor,facing=south,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "y": 180 - }, - "energized=false,face=floor,facing=west,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "y": 270 - }, - "energized=false,face=floor,facing=west,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "y": 270 - }, - "energized=false,face=floor,facing=west,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "y": 270 - }, - "energized=false,face=floor,facing=west,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "y": 270 - }, - "energized=false,face=wall,facing=east,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "x": 90, - "y": 90 - }, - "energized=false,face=wall,facing=east,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 90, - "y": 90 - }, - "energized=false,face=wall,facing=east,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 90, - "y": 90 - }, - "energized=false,face=wall,facing=east,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 90, - "y": 90 - }, - "energized=false,face=wall,facing=north,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "x": 90 - }, - "energized=false,face=wall,facing=north,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 90 - }, - "energized=false,face=wall,facing=north,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 90 - }, - "energized=false,face=wall,facing=north,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 90 - }, - "energized=false,face=wall,facing=south,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "x": 90, - "y": 180 - }, - "energized=false,face=wall,facing=south,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 90, - "y": 180 - }, - "energized=false,face=wall,facing=south,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 90, - "y": 180 - }, - "energized=false,face=wall,facing=south,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 90, - "y": 180 - }, - "energized=false,face=wall,facing=west,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "x": 90, - "y": 270 - }, - "energized=false,face=wall,facing=west,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 90, - "y": 270 - }, - "energized=false,face=wall,facing=west,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 90, - "y": 270 - }, - "energized=false,face=wall,facing=west,open=true,waterlogged=true": { + "face=ceiling,facing=east,open=true": { "model": "hexcasting:block/chest_locus_open", - "x": 90, - "y": 270 - }, - "energized=true,face=ceiling,facing=east,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", "x": 180, "y": 270 }, - "energized=true,face=ceiling,facing=east,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 180, - "y": 270 - }, - "energized=true,face=ceiling,facing=east,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 180, - "y": 270 - }, - "energized=true,face=ceiling,facing=east,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 180, - "y": 270 - }, - "energized=true,face=ceiling,facing=north,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "x": 180, - "y": 180 - }, - "energized=true,face=ceiling,facing=north,open=false,waterlogged=true": { + "face=ceiling,facing=north,open=false": { "model": "hexcasting:block/chest_locus", "x": 180, "y": 180 }, - "energized=true,face=ceiling,facing=north,open=true,waterlogged=false": { + "face=ceiling,facing=north,open=true": { "model": "hexcasting:block/chest_locus_open", "x": 180, "y": 180 }, - "energized=true,face=ceiling,facing=north,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 180, - "y": 180 - }, - "energized=true,face=ceiling,facing=south,open=false,waterlogged=false": { + "face=ceiling,facing=south,open=false": { "model": "hexcasting:block/chest_locus", "x": 180 }, - "energized=true,face=ceiling,facing=south,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 180 - }, - "energized=true,face=ceiling,facing=south,open=true,waterlogged=false": { + "face=ceiling,facing=south,open=true": { "model": "hexcasting:block/chest_locus_open", "x": 180 }, - "energized=true,face=ceiling,facing=south,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 180 - }, - "energized=true,face=ceiling,facing=west,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "x": 180, - "y": 90 - }, - "energized=true,face=ceiling,facing=west,open=false,waterlogged=true": { + "face=ceiling,facing=west,open=false": { "model": "hexcasting:block/chest_locus", "x": 180, "y": 90 }, - "energized=true,face=ceiling,facing=west,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 180, - "y": 90 - }, - "energized=true,face=ceiling,facing=west,open=true,waterlogged=true": { + "face=ceiling,facing=west,open=true": { "model": "hexcasting:block/chest_locus_open", "x": 180, "y": 90 }, - "energized=true,face=floor,facing=east,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "y": 90 - }, - "energized=true,face=floor,facing=east,open=false,waterlogged=true": { + "face=floor,facing=east,open=false": { "model": "hexcasting:block/chest_locus", "y": 90 }, - "energized=true,face=floor,facing=east,open=true,waterlogged=false": { + "face=floor,facing=east,open=true": { "model": "hexcasting:block/chest_locus_open", "y": 90 }, - "energized=true,face=floor,facing=east,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "y": 90 - }, - "energized=true,face=floor,facing=north,open=false,waterlogged=false": { + "face=floor,facing=north,open=false": { "model": "hexcasting:block/chest_locus" }, - "energized=true,face=floor,facing=north,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus" - }, - "energized=true,face=floor,facing=north,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open" - }, - "energized=true,face=floor,facing=north,open=true,waterlogged=true": { + "face=floor,facing=north,open=true": { "model": "hexcasting:block/chest_locus_open" }, - "energized=true,face=floor,facing=south,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "y": 180 - }, - "energized=true,face=floor,facing=south,open=false,waterlogged=true": { + "face=floor,facing=south,open=false": { "model": "hexcasting:block/chest_locus", "y": 180 }, - "energized=true,face=floor,facing=south,open=true,waterlogged=false": { + "face=floor,facing=south,open=true": { "model": "hexcasting:block/chest_locus_open", "y": 180 }, - "energized=true,face=floor,facing=south,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "y": 180 - }, - "energized=true,face=floor,facing=west,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "y": 270 - }, - "energized=true,face=floor,facing=west,open=false,waterlogged=true": { + "face=floor,facing=west,open=false": { "model": "hexcasting:block/chest_locus", "y": 270 }, - "energized=true,face=floor,facing=west,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "y": 270 - }, - "energized=true,face=floor,facing=west,open=true,waterlogged=true": { + "face=floor,facing=west,open=true": { "model": "hexcasting:block/chest_locus_open", "y": 270 }, - "energized=true,face=wall,facing=east,open=false,waterlogged=false": { + "face=wall,facing=east,open=false": { "model": "hexcasting:block/chest_locus", "x": 90, "y": 90 }, - "energized=true,face=wall,facing=east,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 90, - "y": 90 - }, - "energized=true,face=wall,facing=east,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 90, - "y": 90 - }, - "energized=true,face=wall,facing=east,open=true,waterlogged=true": { + "face=wall,facing=east,open=true": { "model": "hexcasting:block/chest_locus_open", "x": 90, "y": 90 }, - "energized=true,face=wall,facing=north,open=false,waterlogged=false": { + "face=wall,facing=north,open=false": { "model": "hexcasting:block/chest_locus", "x": 90 }, - "energized=true,face=wall,facing=north,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 90 - }, - "energized=true,face=wall,facing=north,open=true,waterlogged=false": { + "face=wall,facing=north,open=true": { "model": "hexcasting:block/chest_locus_open", "x": 90 }, - "energized=true,face=wall,facing=north,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 90 - }, - "energized=true,face=wall,facing=south,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "x": 90, - "y": 180 - }, - "energized=true,face=wall,facing=south,open=false,waterlogged=true": { + "face=wall,facing=south,open=false": { "model": "hexcasting:block/chest_locus", "x": 90, "y": 180 }, - "energized=true,face=wall,facing=south,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 90, - "y": 180 - }, - "energized=true,face=wall,facing=south,open=true,waterlogged=true": { + "face=wall,facing=south,open=true": { "model": "hexcasting:block/chest_locus_open", "x": 90, "y": 180 }, - "energized=true,face=wall,facing=west,open=false,waterlogged=false": { + "face=wall,facing=west,open=false": { "model": "hexcasting:block/chest_locus", "x": 90, "y": 270 }, - "energized=true,face=wall,facing=west,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 90, - "y": 270 - }, - "energized=true,face=wall,facing=west,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 90, - "y": 270 - }, - "energized=true,face=wall,facing=west,open=true,waterlogged=true": { + "face=wall,facing=west,open=true": { "model": "hexcasting:block/chest_locus_open", "x": 90, "y": 270 diff --git a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java index 304b60f4a5..f76c5086d7 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java @@ -2,12 +2,14 @@ import at.petrak.hexcasting.api.casting.eval.env.CircleCastEnv; import at.petrak.hexcasting.api.casting.eval.vm.CastingImage; +import at.petrak.hexcasting.common.blocks.circles.BlockSlate.*; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.Containers; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; @@ -16,10 +18,20 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.BooleanProperty; import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; public class BlockChestLocus extends BlockSlate { public static final BooleanProperty OPEN = BlockStateProperties.OPEN; + private static final VoxelShape BOX_FLOOR = Shapes.or(AABB_FLOOR, Block.box(1, 1, 1, 15, 9, 15)); + private static final VoxelShape BOX_CEILING = Shapes.or(AABB_CEILING, Block.box(1, 7, 1, 15, 15, 15)); + private static final VoxelShape BOX_EAST = Shapes.or(AABB_EAST_WALL, Block.box(1, 1, 1, 9, 15, 15)); + private static final VoxelShape BOX_WEST = Shapes.or(AABB_WEST_WALL, Block.box(7, 1, 1, 15, 15, 15)); + private static final VoxelShape BOX_SOUTH = Shapes.or(AABB_SOUTH_WALL, Block.box(1, 1, 1, 15, 15, 9)); + private static final VoxelShape BOX_NORTH = Shapes.or(AABB_NORTH_WALL, Block.box(1, 1, 7, 15, 15, 15)); + public BlockChestLocus(Properties properties) { super(properties); this.registerDefaultState( @@ -67,6 +79,20 @@ protected void onRemove(BlockState blockState, Level level, BlockPos blockPos, B super.onRemove(blockState, level, blockPos, blockState2, bl); } + @Override + public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) { + return switch (pState.getValue(ATTACH_FACE)) { + case FLOOR -> BOX_FLOOR; + case CEILING -> BOX_CEILING; + case WALL -> switch (pState.getValue(FACING)) { + case NORTH -> BOX_NORTH; + case EAST -> BOX_EAST; + case SOUTH -> BOX_SOUTH; + default -> BOX_WEST; + }; + }; + } + @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { super.createBlockStateDefinition(builder); diff --git a/Neoforge/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json b/Neoforge/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json index 0bab4f51e7..0eac83693a 100644 --- a/Neoforge/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json +++ b/Neoforge/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json @@ -1,425 +1,107 @@ { "variants": { - "energized=false,face=ceiling,facing=east,open=false,waterlogged=false": { + "face=ceiling,facing=east,open=false": { "model": "hexcasting:block/chest_locus", "x": 180, "y": 270 }, - "energized=false,face=ceiling,facing=east,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 180, - "y": 270 - }, - "energized=false,face=ceiling,facing=east,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 180, - "y": 270 - }, - "energized=false,face=ceiling,facing=east,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 180, - "y": 270 - }, - "energized=false,face=ceiling,facing=north,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "x": 180, - "y": 180 - }, - "energized=false,face=ceiling,facing=north,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 180, - "y": 180 - }, - "energized=false,face=ceiling,facing=north,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 180, - "y": 180 - }, - "energized=false,face=ceiling,facing=north,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 180, - "y": 180 - }, - "energized=false,face=ceiling,facing=south,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "x": 180 - }, - "energized=false,face=ceiling,facing=south,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 180 - }, - "energized=false,face=ceiling,facing=south,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 180 - }, - "energized=false,face=ceiling,facing=south,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 180 - }, - "energized=false,face=ceiling,facing=west,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "x": 180, - "y": 90 - }, - "energized=false,face=ceiling,facing=west,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 180, - "y": 90 - }, - "energized=false,face=ceiling,facing=west,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 180, - "y": 90 - }, - "energized=false,face=ceiling,facing=west,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 180, - "y": 90 - }, - "energized=false,face=floor,facing=east,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "y": 90 - }, - "energized=false,face=floor,facing=east,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "y": 90 - }, - "energized=false,face=floor,facing=east,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "y": 90 - }, - "energized=false,face=floor,facing=east,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "y": 90 - }, - "energized=false,face=floor,facing=north,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus" - }, - "energized=false,face=floor,facing=north,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus" - }, - "energized=false,face=floor,facing=north,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open" - }, - "energized=false,face=floor,facing=north,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open" - }, - "energized=false,face=floor,facing=south,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "y": 180 - }, - "energized=false,face=floor,facing=south,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "y": 180 - }, - "energized=false,face=floor,facing=south,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "y": 180 - }, - "energized=false,face=floor,facing=south,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "y": 180 - }, - "energized=false,face=floor,facing=west,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "y": 270 - }, - "energized=false,face=floor,facing=west,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "y": 270 - }, - "energized=false,face=floor,facing=west,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "y": 270 - }, - "energized=false,face=floor,facing=west,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "y": 270 - }, - "energized=false,face=wall,facing=east,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "x": 90, - "y": 90 - }, - "energized=false,face=wall,facing=east,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 90, - "y": 90 - }, - "energized=false,face=wall,facing=east,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 90, - "y": 90 - }, - "energized=false,face=wall,facing=east,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 90, - "y": 90 - }, - "energized=false,face=wall,facing=north,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "x": 90 - }, - "energized=false,face=wall,facing=north,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 90 - }, - "energized=false,face=wall,facing=north,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 90 - }, - "energized=false,face=wall,facing=north,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 90 - }, - "energized=false,face=wall,facing=south,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "x": 90, - "y": 180 - }, - "energized=false,face=wall,facing=south,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 90, - "y": 180 - }, - "energized=false,face=wall,facing=south,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 90, - "y": 180 - }, - "energized=false,face=wall,facing=south,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 90, - "y": 180 - }, - "energized=false,face=wall,facing=west,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "x": 90, - "y": 270 - }, - "energized=false,face=wall,facing=west,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 90, - "y": 270 - }, - "energized=false,face=wall,facing=west,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 90, - "y": 270 - }, - "energized=false,face=wall,facing=west,open=true,waterlogged=true": { + "face=ceiling,facing=east,open=true": { "model": "hexcasting:block/chest_locus_open", - "x": 90, - "y": 270 - }, - "energized=true,face=ceiling,facing=east,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", "x": 180, "y": 270 }, - "energized=true,face=ceiling,facing=east,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 180, - "y": 270 - }, - "energized=true,face=ceiling,facing=east,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 180, - "y": 270 - }, - "energized=true,face=ceiling,facing=east,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 180, - "y": 270 - }, - "energized=true,face=ceiling,facing=north,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "x": 180, - "y": 180 - }, - "energized=true,face=ceiling,facing=north,open=false,waterlogged=true": { + "face=ceiling,facing=north,open=false": { "model": "hexcasting:block/chest_locus", "x": 180, "y": 180 }, - "energized=true,face=ceiling,facing=north,open=true,waterlogged=false": { + "face=ceiling,facing=north,open=true": { "model": "hexcasting:block/chest_locus_open", "x": 180, "y": 180 }, - "energized=true,face=ceiling,facing=north,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 180, - "y": 180 - }, - "energized=true,face=ceiling,facing=south,open=false,waterlogged=false": { + "face=ceiling,facing=south,open=false": { "model": "hexcasting:block/chest_locus", "x": 180 }, - "energized=true,face=ceiling,facing=south,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 180 - }, - "energized=true,face=ceiling,facing=south,open=true,waterlogged=false": { + "face=ceiling,facing=south,open=true": { "model": "hexcasting:block/chest_locus_open", "x": 180 }, - "energized=true,face=ceiling,facing=south,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 180 - }, - "energized=true,face=ceiling,facing=west,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "x": 180, - "y": 90 - }, - "energized=true,face=ceiling,facing=west,open=false,waterlogged=true": { + "face=ceiling,facing=west,open=false": { "model": "hexcasting:block/chest_locus", "x": 180, "y": 90 }, - "energized=true,face=ceiling,facing=west,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 180, - "y": 90 - }, - "energized=true,face=ceiling,facing=west,open=true,waterlogged=true": { + "face=ceiling,facing=west,open=true": { "model": "hexcasting:block/chest_locus_open", "x": 180, "y": 90 }, - "energized=true,face=floor,facing=east,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "y": 90 - }, - "energized=true,face=floor,facing=east,open=false,waterlogged=true": { + "face=floor,facing=east,open=false": { "model": "hexcasting:block/chest_locus", "y": 90 }, - "energized=true,face=floor,facing=east,open=true,waterlogged=false": { + "face=floor,facing=east,open=true": { "model": "hexcasting:block/chest_locus_open", "y": 90 }, - "energized=true,face=floor,facing=east,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "y": 90 - }, - "energized=true,face=floor,facing=north,open=false,waterlogged=false": { + "face=floor,facing=north,open=false": { "model": "hexcasting:block/chest_locus" }, - "energized=true,face=floor,facing=north,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus" - }, - "energized=true,face=floor,facing=north,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open" - }, - "energized=true,face=floor,facing=north,open=true,waterlogged=true": { + "face=floor,facing=north,open=true": { "model": "hexcasting:block/chest_locus_open" }, - "energized=true,face=floor,facing=south,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "y": 180 - }, - "energized=true,face=floor,facing=south,open=false,waterlogged=true": { + "face=floor,facing=south,open=false": { "model": "hexcasting:block/chest_locus", "y": 180 }, - "energized=true,face=floor,facing=south,open=true,waterlogged=false": { + "face=floor,facing=south,open=true": { "model": "hexcasting:block/chest_locus_open", "y": 180 }, - "energized=true,face=floor,facing=south,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "y": 180 - }, - "energized=true,face=floor,facing=west,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "y": 270 - }, - "energized=true,face=floor,facing=west,open=false,waterlogged=true": { + "face=floor,facing=west,open=false": { "model": "hexcasting:block/chest_locus", "y": 270 }, - "energized=true,face=floor,facing=west,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "y": 270 - }, - "energized=true,face=floor,facing=west,open=true,waterlogged=true": { + "face=floor,facing=west,open=true": { "model": "hexcasting:block/chest_locus_open", "y": 270 }, - "energized=true,face=wall,facing=east,open=false,waterlogged=false": { + "face=wall,facing=east,open=false": { "model": "hexcasting:block/chest_locus", "x": 90, "y": 90 }, - "energized=true,face=wall,facing=east,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 90, - "y": 90 - }, - "energized=true,face=wall,facing=east,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 90, - "y": 90 - }, - "energized=true,face=wall,facing=east,open=true,waterlogged=true": { + "face=wall,facing=east,open=true": { "model": "hexcasting:block/chest_locus_open", "x": 90, "y": 90 }, - "energized=true,face=wall,facing=north,open=false,waterlogged=false": { + "face=wall,facing=north,open=false": { "model": "hexcasting:block/chest_locus", "x": 90 }, - "energized=true,face=wall,facing=north,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 90 - }, - "energized=true,face=wall,facing=north,open=true,waterlogged=false": { + "face=wall,facing=north,open=true": { "model": "hexcasting:block/chest_locus_open", "x": 90 }, - "energized=true,face=wall,facing=north,open=true,waterlogged=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 90 - }, - "energized=true,face=wall,facing=south,open=false,waterlogged=false": { - "model": "hexcasting:block/chest_locus", - "x": 90, - "y": 180 - }, - "energized=true,face=wall,facing=south,open=false,waterlogged=true": { + "face=wall,facing=south,open=false": { "model": "hexcasting:block/chest_locus", "x": 90, "y": 180 }, - "energized=true,face=wall,facing=south,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 90, - "y": 180 - }, - "energized=true,face=wall,facing=south,open=true,waterlogged=true": { + "face=wall,facing=south,open=true": { "model": "hexcasting:block/chest_locus_open", "x": 90, "y": 180 }, - "energized=true,face=wall,facing=west,open=false,waterlogged=false": { + "face=wall,facing=west,open=false": { "model": "hexcasting:block/chest_locus", "x": 90, "y": 270 }, - "energized=true,face=wall,facing=west,open=false,waterlogged=true": { - "model": "hexcasting:block/chest_locus", - "x": 90, - "y": 270 - }, - "energized=true,face=wall,facing=west,open=true,waterlogged=false": { - "model": "hexcasting:block/chest_locus_open", - "x": 90, - "y": 270 - }, - "energized=true,face=wall,facing=west,open=true,waterlogged=true": { + "face=wall,facing=west,open=true": { "model": "hexcasting:block/chest_locus_open", "x": 90, "y": 270 diff --git a/Neoforge/src/main/java/at/petrak/hexcasting/forge/datagen/xplat/HexBlockStatesAndModels.java b/Neoforge/src/main/java/at/petrak/hexcasting/forge/datagen/xplat/HexBlockStatesAndModels.java index 723dc20586..b715542ce8 100644 --- a/Neoforge/src/main/java/at/petrak/hexcasting/forge/datagen/xplat/HexBlockStatesAndModels.java +++ b/Neoforge/src/main/java/at/petrak/hexcasting/forge/datagen/xplat/HexBlockStatesAndModels.java @@ -3,6 +3,7 @@ import at.petrak.hexcasting.api.HexAPI; import at.petrak.hexcasting.api.block.circle.BlockCircleComponent; import at.petrak.hexcasting.common.blocks.akashic.BlockAkashicBookshelf; +import at.petrak.hexcasting.common.blocks.circles.BlockChestLocus; import at.petrak.hexcasting.common.blocks.circles.BlockSlate; import at.petrak.hexcasting.common.blocks.circles.directrix.BlockBooleanDirectrix; import at.petrak.hexcasting.common.blocks.circles.directrix.BlockRedstoneDirectrix; @@ -13,6 +14,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.AttachFace; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.neoforged.neoforge.client.model.generators.BlockModelBuilder; import net.neoforged.neoforge.client.model.generators.ConfiguredModel; @@ -58,11 +60,11 @@ protected void registerStatesAndModels() { var chestLocusClosed = models().getExistingFile(modLoc("chest_locus")); var chestLocusOpen = models().getExistingFile(modLoc("chest_locus_open")); - Function openPred = (BlockState state) -> { - if (state.getValue(BlockStateProperties.OPEN)) return chestLocusOpen; - else return chestLocusClosed; - }; - horizontalFaceBlock(HexBlocks.CHEST_LOCUS.get(), openPred); + getVariantBuilder(HexBlocks.CHEST_LOCUS.get()).forAllStatesExcept(state -> ConfiguredModel.builder() + .modelFile(state.getValue(BlockStateProperties.OPEN) ? chestLocusOpen : chestLocusClosed) + .rotationX(state.getValue(BlockStateProperties.ATTACH_FACE).ordinal() * 90) + .rotationY((((int) state.getValue(BlockStateProperties.HORIZONTAL_FACING).toYRot() + 180) + (state.getValue(BlockStateProperties.ATTACH_FACE) == AttachFace.CEILING ? 180 : 0)) % 360) + .build(), BlockChestLocus.WATERLOGGED, BlockChestLocus.ENERGIZED); simpleBlockItem(HexBlocks.CHEST_LOCUS.get(), chestLocusClosed); impetus(HexBlocks.IMPETUS_EMPTY.get(), "impetus/empty", "empty", false); From 8df77b81572ae5e9d9e5c4595910763b70ed2690 Mon Sep 17 00:00:00 2001 From: Robotgiggle <88736742+Robotgiggle@users.noreply.github.com> Date: Thu, 29 Oct 2026 16:31:34 -0400 Subject: [PATCH 06/12] Rework block states, make opening/closing work --- .../hexcasting/blockstates/chest_locus.json | 106 +++++------------- .../blocks/circles/BlockChestLocus.java | 70 ++++++++++-- .../blocks/circles/BlockEntityChestLocus.java | 83 ++++++++++++-- .../hexcasting/models/block/chest_locus.json | 2 +- .../block/circle/locus/chest_closed.png | Bin 455 -> 480 bytes .../hexcasting/blockstates/chest_locus.json | 106 +++++------------- .../xplat/HexBlockStatesAndModels.java | 13 ++- 7 files changed, 194 insertions(+), 186 deletions(-) diff --git a/Common/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json b/Common/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json index 0eac83693a..6f4acb0b0e 100644 --- a/Common/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json +++ b/Common/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json @@ -1,110 +1,56 @@ { "variants": { - "face=ceiling,facing=east,open=false": { - "model": "hexcasting:block/chest_locus", - "x": 180, - "y": 270 - }, - "face=ceiling,facing=east,open=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 180, - "y": 270 - }, - "face=ceiling,facing=north,open=false": { - "model": "hexcasting:block/chest_locus", - "x": 180, - "y": 180 - }, - "face=ceiling,facing=north,open=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 180, - "y": 180 - }, - "face=ceiling,facing=south,open=false": { + "facing=down,open=false": { "model": "hexcasting:block/chest_locus", "x": 180 }, - "face=ceiling,facing=south,open=true": { + "facing=down,open=true": { "model": "hexcasting:block/chest_locus_open", "x": 180 }, - "face=ceiling,facing=west,open=false": { - "model": "hexcasting:block/chest_locus", - "x": 180, - "y": 90 - }, - "face=ceiling,facing=west,open=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 180, - "y": 90 - }, - "face=floor,facing=east,open=false": { - "model": "hexcasting:block/chest_locus", - "y": 90 - }, - "face=floor,facing=east,open=true": { - "model": "hexcasting:block/chest_locus_open", - "y": 90 - }, - "face=floor,facing=north,open=false": { - "model": "hexcasting:block/chest_locus" - }, - "face=floor,facing=north,open=true": { - "model": "hexcasting:block/chest_locus_open" - }, - "face=floor,facing=south,open=false": { - "model": "hexcasting:block/chest_locus", - "y": 180 - }, - "face=floor,facing=south,open=true": { - "model": "hexcasting:block/chest_locus_open", - "y": 180 - }, - "face=floor,facing=west,open=false": { + "facing=east,open=false": { "model": "hexcasting:block/chest_locus", + "x": 270, "y": 270 }, - "face=floor,facing=west,open=true": { + "facing=east,open=true": { "model": "hexcasting:block/chest_locus_open", + "x": 270, "y": 270 }, - "face=wall,facing=east,open=false": { + "facing=north,open=false": { "model": "hexcasting:block/chest_locus", - "x": 90, - "y": 90 + "x": 270, + "y": 180 }, - "face=wall,facing=east,open=true": { + "facing=north,open=true": { "model": "hexcasting:block/chest_locus_open", - "x": 90, - "y": 90 + "x": 270, + "y": 180 }, - "face=wall,facing=north,open=false": { + "facing=south,open=false": { "model": "hexcasting:block/chest_locus", - "x": 90 + "x": 270 }, - "face=wall,facing=north,open=true": { + "facing=south,open=true": { "model": "hexcasting:block/chest_locus_open", - "x": 90 + "x": 270 }, - "face=wall,facing=south,open=false": { - "model": "hexcasting:block/chest_locus", - "x": 90, - "y": 180 + "facing=up,open=false": { + "model": "hexcasting:block/chest_locus" }, - "face=wall,facing=south,open=true": { - "model": "hexcasting:block/chest_locus_open", - "x": 90, - "y": 180 + "facing=up,open=true": { + "model": "hexcasting:block/chest_locus_open" }, - "face=wall,facing=west,open=false": { + "facing=west,open=false": { "model": "hexcasting:block/chest_locus", - "x": 90, - "y": 270 + "x": 270, + "y": 90 }, - "face=wall,facing=west,open=true": { + "facing=west,open=true": { "model": "hexcasting:block/chest_locus_open", - "x": 90, - "y": 270 + "x": 270, + "y": 90 } } } \ No newline at end of file diff --git a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java index f76c5086d7..6d949fda82 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java @@ -1,28 +1,42 @@ package at.petrak.hexcasting.common.blocks.circles; +import at.petrak.hexcasting.api.block.circle.BlockCircleComponent; import at.petrak.hexcasting.api.casting.eval.env.CircleCastEnv; import at.petrak.hexcasting.api.casting.eval.vm.CastingImage; -import at.petrak.hexcasting.common.blocks.circles.BlockSlate.*; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; +import net.minecraft.tags.FluidTags; +import net.minecraft.util.RandomSource; import net.minecraft.world.Containers; 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.block.Block; +import net.minecraft.world.level.block.EntityBlock; +import net.minecraft.world.level.block.SimpleWaterloggedBlock; import net.minecraft.world.level.block.entity.BlockEntity; 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.DirectionProperty; +import net.minecraft.world.level.material.FluidState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.Nullable; -public class BlockChestLocus extends BlockSlate { +import java.util.EnumSet; + +import static at.petrak.hexcasting.common.blocks.circles.BlockSlate.*; + +public class BlockChestLocus extends BlockCircleComponent implements EntityBlock, SimpleWaterloggedBlock { + public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; + public static final DirectionProperty FACING = BlockStateProperties.FACING; public static final BooleanProperty OPEN = BlockStateProperties.OPEN; private static final VoxelShape BOX_FLOOR = Shapes.or(AABB_FLOOR, Block.box(1, 1, 1, 15, 9, 15)); @@ -60,6 +74,30 @@ public ControlFlow acceptControlFlow(CastingImage imageIn, CircleCastEnv env, Di return new ControlFlow.Continue(imageIn, exitDirs.toList()); } + @Override + public Direction normalDir(BlockPos pos, BlockState bs, Level world, int recursionLeft) { + return bs.getValue(FACING); + } + + @Override + public float particleHeight(BlockPos pos, BlockState bs, Level world) { + return 0.5f - 7f / 16f; + } + + @Override + public boolean canEnterFromDirection(Direction enterDir, BlockPos pos, BlockState bs, ServerLevel world) { + var thisNormal = this.normalDir(pos, bs, world); + return enterDir != thisNormal.getOpposite(); + } + + @Override + public EnumSet possibleExitDirections(BlockPos pos, BlockState bs, Level world) { + var allDirs = EnumSet.allOf(Direction.class); + var normal = this.normalDir(pos, bs, world); + allDirs.remove(normal); + return allDirs; + } + protected InteractionResult useWithoutItem(BlockState blockState, Level level, BlockPos blockPos, Player player, BlockHitResult blockHitResult) { if (level.isClientSide) { return InteractionResult.SUCCESS; @@ -79,23 +117,37 @@ protected void onRemove(BlockState blockState, Level level, BlockPos blockPos, B super.onRemove(blockState, level, blockPos, blockState2, bl); } + protected void tick(BlockState blockState, ServerLevel serverLevel, BlockPos blockPos, RandomSource randomSource) { + BlockEntity blockEntity = serverLevel.getBlockEntity(blockPos); + if (blockEntity instanceof BlockEntityChestLocus) { + ((BlockEntityChestLocus)blockEntity).recheckOpen(); + } + } + @Override public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) { - return switch (pState.getValue(ATTACH_FACE)) { - case FLOOR -> BOX_FLOOR; - case CEILING -> BOX_CEILING; - case WALL -> switch (pState.getValue(FACING)) { + return switch (pState.getValue(FACING)) { + case UP -> BOX_FLOOR; + case DOWN -> BOX_CEILING; case NORTH -> BOX_NORTH; case EAST -> BOX_EAST; case SOUTH -> BOX_SOUTH; - default -> BOX_WEST; - }; + case WEST -> BOX_WEST; }; } + @Override + @Nullable + public BlockState getStateForPlacement(BlockPlaceContext pContext) { + FluidState fluidState = pContext.getLevel().getFluidState(pContext.getClickedPos()); + return this.defaultBlockState() + .setValue(FACING, pContext.getNearestLookingDirection().getOpposite()) + .setValue(WATERLOGGED, fluidState.is(FluidTags.WATER) && fluidState.getAmount() == 8); + } + @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { super.createBlockStateDefinition(builder); - builder.add(OPEN); + builder.add(WATERLOGGED, FACING, OPEN); } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockEntityChestLocus.java b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockEntityChestLocus.java index 226982e53c..551718472c 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockEntityChestLocus.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockEntityChestLocus.java @@ -1,26 +1,74 @@ package at.petrak.hexcasting.common.blocks.circles; import at.petrak.hexcasting.common.lib.HexBlockEntities; +import at.petrak.hexcasting.common.lib.HexBlocks; import net.minecraft.core.BlockPos; import net.minecraft.core.HolderLookup.Provider; import net.minecraft.core.NonNullList; +import net.minecraft.core.Vec3i; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.Container; import net.minecraft.world.ContainerHelper; import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.inventory.ChestMenu; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.ContainerOpenersCounter; import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity; import net.minecraft.world.level.block.state.BlockState; public class BlockEntityChestLocus extends RandomizableContainerBlockEntity { private NonNullList items = NonNullList.withSize(27, ItemStack.EMPTY); + private final ContainerOpenersCounter openersCounter = new ContainerOpenersCounter() { + @Override + protected void onOpen(Level level, BlockPos blockPos, BlockState blockState) { + BlockEntityChestLocus.this.playSound(blockState, SoundEvents.BAMBOO_WOOD_TRAPDOOR_OPEN); + BlockEntityChestLocus.this.updateBlockState(blockState, true); + } + @Override + protected void onClose(Level level, BlockPos blockPos, BlockState blockState) { + BlockEntityChestLocus.this.playSound(blockState, SoundEvents.BAMBOO_WOOD_TRAPDOOR_CLOSE); + BlockEntityChestLocus.this.updateBlockState(blockState, false); + } + @Override + protected void openerCountChanged(Level level, BlockPos blockPos, BlockState blockState, int i, int j) {} + @Override + protected boolean isOwnContainer(Player player) { + if (player.containerMenu instanceof ChestMenu) { + Container container = ((ChestMenu)player.containerMenu).getContainer(); + return container == BlockEntityChestLocus.this; + } + return false; + } + }; public BlockEntityChestLocus(BlockPos blockPos, BlockState blockState) { super(HexBlockEntities.CHEST_LOCUS_TILE.get(), blockPos, blockState); } + @Override + protected void loadAdditional(CompoundTag compoundTag, Provider provider) { + super.loadAdditional(compoundTag, provider); + this.items = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); + if (!this.tryLoadLootTable(compoundTag)) { + ContainerHelper.loadAllItems(compoundTag, this.items, provider); + } + } + + @Override + protected void saveAdditional(CompoundTag compoundTag, Provider provider) { + super.saveAdditional(compoundTag, provider); + if (!this.trySaveLootTable(compoundTag)) { + ContainerHelper.saveAllItems(compoundTag, this.items, provider); + } + } + @Override public int getContainerSize() { return 27; @@ -46,20 +94,33 @@ protected AbstractContainerMenu createMenu(int i, Inventory inventory) { return ChestMenu.threeRows(i, inventory, this); } - @Override - protected void loadAdditional(CompoundTag compoundTag, Provider provider) { - super.loadAdditional(compoundTag, provider); - this.items = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); - if (!this.tryLoadLootTable(compoundTag)) { - ContainerHelper.loadAllItems(compoundTag, this.items, provider); + public void startOpen(Player player) { + if (!this.remove && !player.isSpectator()) { + this.openersCounter.incrementOpeners(player, this.getLevel(), this.getBlockPos(), this.getBlockState()); } } - @Override - protected void saveAdditional(CompoundTag compoundTag, Provider provider) { - super.saveAdditional(compoundTag, provider); - if (!this.trySaveLootTable(compoundTag)) { - ContainerHelper.saveAllItems(compoundTag, this.items, provider); + public void stopOpen(Player player) { + if (!this.remove && !player.isSpectator()) { + this.openersCounter.decrementOpeners(player, this.getLevel(), this.getBlockPos(), this.getBlockState()); + } + } + + public void recheckOpen() { + if (!this.remove) { + this.openersCounter.recheckOpeners(this.getLevel(), this.getBlockPos(), this.getBlockState()); } } + + void updateBlockState(BlockState blockState, boolean bl) { + this.level.setBlock(this.getBlockPos(), blockState.setValue(BlockChestLocus.OPEN, bl), 3); + } + + void playSound(BlockState blockState, SoundEvent soundEvent) { + Vec3i vec3i = (HexBlocks.CHEST_LOCUS.get().normalDir(null, blockState, null)).getNormal(); + double d = this.worldPosition.getX() + 0.5 + vec3i.getX() / 2.0; + double e = this.worldPosition.getY() + 0.5 + vec3i.getY() / 2.0; + double f = this.worldPosition.getZ() + 0.5 + vec3i.getZ() / 2.0; + this.level.playSound(null, d, e, f, soundEvent, SoundSource.BLOCKS, 0.8F, this.level.random.nextFloat() * 0.1F + 0.9F); + } } diff --git a/Common/src/main/resources/assets/hexcasting/models/block/chest_locus.json b/Common/src/main/resources/assets/hexcasting/models/block/chest_locus.json index dbd7dbc073..a0fd84de07 100644 --- a/Common/src/main/resources/assets/hexcasting/models/block/chest_locus.json +++ b/Common/src/main/resources/assets/hexcasting/models/block/chest_locus.json @@ -8,7 +8,7 @@ }, "elements": [ { - "name": "base", + "name": "slate", "from": [0, 0, 0], "to": [16, 1, 16], "faces": { diff --git a/Common/src/main/resources/assets/hexcasting/textures/block/circle/locus/chest_closed.png b/Common/src/main/resources/assets/hexcasting/textures/block/circle/locus/chest_closed.png index 3daf0c0a14ddf06e3e3c1a2e3f3fe3d0d074a744..ad99d3bc7aeb281b197559a8a369703526f302a6 100644 GIT binary patch delta 332 zcmV-S0ki(c1K9smFVBuPX;R5;6}lD%ufP!z>~hD>QwSkXomPQwjK1PNsJ=(EEn#_dFR~w;6n5O?r!gY zwq?nDJUiL^Rh9reW)GM`uzXqcbbxJH;(mKPy}zFI>eLEY$$t<49bi75v3PstX5ir% zcGcJyg6Q+3k;`O`e{~H6ge-Ri3UQGV7bzoa*ceiSaghS-33kxh^16lr9K&X04G;2K zeK~44lR4`os+!hGL?-i260L1P#fj@z`HAZ{YDWqF1Fh{}#kPfdtq#4*f@9c?MJhY$ z5+|<^7b%&{4@IQb&v;b9u@lx+DRM=otG_)R1Py5l?Ob0701|EUM_>xUN`}ORch=?; eZG*Wdx){IlS$1>!A%~&>0000Hq)%3rR#lR5;6}ld(?2Fc5~nMwy&s2oj-)rQN!r z4oG;qY&VrHRG=->)qz8sq-Xfs|o-@fPdv=!FsphHn|~-Qma_1 z#>z?6FuT43atc-iE?ug|+bmUM?U}FuWm{9WwYSiK%C@%hVc#702w9YNDx_*onma&W zfjhCkHlRO`;5PdVbX8aY-z^L^drf?=K029w$yt ConfiguredModel.builder() - .modelFile(state.getValue(BlockStateProperties.OPEN) ? chestLocusOpen : chestLocusClosed) - .rotationX(state.getValue(BlockStateProperties.ATTACH_FACE).ordinal() * 90) - .rotationY((((int) state.getValue(BlockStateProperties.HORIZONTAL_FACING).toYRot() + 180) + (state.getValue(BlockStateProperties.ATTACH_FACE) == AttachFace.CEILING ? 180 : 0)) % 360) - .build(), BlockChestLocus.WATERLOGGED, BlockChestLocus.ENERGIZED); + getVariantBuilder(HexBlocks.CHEST_LOCUS.get()).forAllStatesExcept(state -> { + Direction dir = state.getValue(BlockStateProperties.FACING); + return ConfiguredModel.builder() + .modelFile(state.getValue(BlockStateProperties.OPEN) ? chestLocusOpen : chestLocusClosed) + .rotationX(dir == Direction.DOWN ? 180 : dir.getAxis().isHorizontal() ? 270 : 0) + .rotationY(dir.getAxis().isVertical() ? 0 : ((int) dir.toYRot()) % 360) + .build(); + }, BlockChestLocus.WATERLOGGED, BlockChestLocus.ENERGIZED); simpleBlockItem(HexBlocks.CHEST_LOCUS.get(), chestLocusClosed); impetus(HexBlocks.IMPETUS_EMPTY.get(), "impetus/empty", "empty", false); From 322443b0e75806ee1835b8ab4c52c5d3608a0603 Mon Sep 17 00:00:00 2001 From: Robotgiggle <88736742+Robotgiggle@users.noreply.github.com> Date: Thu, 29 Oct 2026 22:36:27 -0400 Subject: [PATCH 07/12] Match ID structure for other circle components, add recipe and loot table --- .../{chest_locus.json => locus/chest.json} | 0 .../{chest_locus.json => locus/chest.json} | 0 .../recipes/redstone/locus/chest.json | 35 ++++++++++++++++ .../loot_table/blocks/locus/chest.json | 15 +++++++ .../data/hexcasting/recipe/locus/chest.json | 24 +++++++++++ .../blocks/circles/BlockChestLocus.java | 40 +++++++++++++++++-- .../hexcasting/common/lib/HexBlocks.java | 6 +-- .../hexcasting/datagen/HexLootTables.java | 2 +- .../datagen/recipe/HexplatRecipes.java | 9 +++++ .../hexcasting/lang/en_us.flatten.json5 | 6 +++ .../hexcasting/models/block/chest_locus.json | 38 +----------------- .../recipes/redstone/locus/chest.json | 35 ++++++++++++++++ .../loot_table/blocks/locus/chest.json | 15 +++++++ .../data/hexcasting/recipe/locus/chest.json | 24 +++++++++++ .../{chest_locus.json => locus/chest.json} | 0 .../{chest_locus.json => locus/chest.json} | 0 .../recipes/redstone/locus/chest.json | 35 ++++++++++++++++ .../loot_table/blocks/locus/chest.json | 15 +++++++ .../data/hexcasting/recipe/locus/chest.json | 24 +++++++++++ .../xplat/HexBlockStatesAndModels.java | 3 +- 20 files changed, 281 insertions(+), 45 deletions(-) rename Common/src/generated/resources/assets/hexcasting/blockstates/{chest_locus.json => locus/chest.json} (100%) rename Common/src/generated/resources/assets/hexcasting/models/item/{chest_locus.json => locus/chest.json} (100%) create mode 100644 Common/src/generated/resources/data/hexcasting/advancement/recipes/redstone/locus/chest.json create mode 100644 Common/src/generated/resources/data/hexcasting/loot_table/blocks/locus/chest.json create mode 100644 Common/src/generated/resources/data/hexcasting/recipe/locus/chest.json create mode 100644 Fabric/src/generated/resources/data/hexcasting/advancement/recipes/redstone/locus/chest.json create mode 100644 Fabric/src/generated/resources/data/hexcasting/loot_table/blocks/locus/chest.json create mode 100644 Fabric/src/generated/resources/data/hexcasting/recipe/locus/chest.json rename Neoforge/src/generated/resources/assets/hexcasting/blockstates/{chest_locus.json => locus/chest.json} (100%) rename Neoforge/src/generated/resources/assets/hexcasting/models/item/{chest_locus.json => locus/chest.json} (100%) create mode 100644 Neoforge/src/generated/resources/data/hexcasting/advancement/recipes/redstone/locus/chest.json create mode 100644 Neoforge/src/generated/resources/data/hexcasting/loot_table/blocks/locus/chest.json create mode 100644 Neoforge/src/generated/resources/data/hexcasting/recipe/locus/chest.json diff --git a/Common/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json b/Common/src/generated/resources/assets/hexcasting/blockstates/locus/chest.json similarity index 100% rename from Common/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json rename to Common/src/generated/resources/assets/hexcasting/blockstates/locus/chest.json diff --git a/Common/src/generated/resources/assets/hexcasting/models/item/chest_locus.json b/Common/src/generated/resources/assets/hexcasting/models/item/locus/chest.json similarity index 100% rename from Common/src/generated/resources/assets/hexcasting/models/item/chest_locus.json rename to Common/src/generated/resources/assets/hexcasting/models/item/locus/chest.json diff --git a/Common/src/generated/resources/data/hexcasting/advancement/recipes/redstone/locus/chest.json b/Common/src/generated/resources/data/hexcasting/advancement/recipes/redstone/locus/chest.json new file mode 100644 index 0000000000..f22eb01746 --- /dev/null +++ b/Common/src/generated/resources/data/hexcasting/advancement/recipes/redstone/locus/chest.json @@ -0,0 +1,35 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "enlightenment": { + "conditions": { + "health_used": { + "min": 0.8 + }, + "media_generated": {}, + "mojang_i_am_begging_and_crying_please_add_an_entity_health_criterion": { + "max": 1.0, + "min": 2.2250738585072014E-308 + } + }, + "trigger": "hexcasting:overcast" + }, + "has_the_recipe": { + "conditions": { + "recipe": "hexcasting:locus/chest" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "enlightenment" + ] + ], + "rewards": { + "recipes": [ + "hexcasting:locus/chest" + ] + } +} \ No newline at end of file diff --git a/Common/src/generated/resources/data/hexcasting/loot_table/blocks/locus/chest.json b/Common/src/generated/resources/data/hexcasting/loot_table/blocks/locus/chest.json new file mode 100644 index 0000000000..b3fdb297e3 --- /dev/null +++ b/Common/src/generated/resources/data/hexcasting/loot_table/blocks/locus/chest.json @@ -0,0 +1,15 @@ +{ + "pools": [ + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:item", + "name": "hexcasting:locus/chest" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "hexcasting:blocks/locus/chest" +} \ No newline at end of file diff --git a/Common/src/generated/resources/data/hexcasting/recipe/locus/chest.json b/Common/src/generated/resources/data/hexcasting/recipe/locus/chest.json new file mode 100644 index 0000000000..ca31765021 --- /dev/null +++ b/Common/src/generated/resources/data/hexcasting/recipe/locus/chest.json @@ -0,0 +1,24 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "redstone", + "key": { + "C": { + "item": "minecraft:chest" + }, + "E": { + "item": "hexcasting:edified_planks" + }, + "S": { + "item": "hexcasting:slate" + } + }, + "pattern": [ + " E ", + "ECE", + " S " + ], + "result": { + "count": 1, + "id": "hexcasting:locus/chest" + } +} \ No newline at end of file diff --git a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java index 6d949fda82..2c9885f53b 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java @@ -14,16 +14,21 @@ 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.LevelReader; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.EntityBlock; import net.minecraft.world.level.block.SimpleWaterloggedBlock; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.AttachFace; 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.DirectionProperty; import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.level.material.Fluids; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; @@ -136,13 +141,42 @@ public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, }; } + @Override + public BlockState updateShape(BlockState pState, Direction pFacing, BlockState pFacingState, LevelAccessor pLevel, + BlockPos pCurrentPos, BlockPos pFacingPos) { + if (pState.getValue(WATERLOGGED)) { + pLevel.scheduleTick(pCurrentPos, Fluids.WATER, Fluids.WATER.getTickDelay(pLevel)); + } + + return (pFacing.getOpposite() == pState.getValue(FACING) && !pState.canSurvive(pLevel, pCurrentPos)) ? + pState.getFluidState().createLegacyBlock() + : super.updateShape(pState, pFacing, pFacingState, pLevel, pCurrentPos, pFacingPos); + } + @Override @Nullable public BlockState getStateForPlacement(BlockPlaceContext pContext) { FluidState fluidState = pContext.getLevel().getFluidState(pContext.getClickedPos()); - return this.defaultBlockState() - .setValue(FACING, pContext.getNearestLookingDirection().getOpposite()) - .setValue(WATERLOGGED, fluidState.is(FluidTags.WATER) && fluidState.getAmount() == 8); + for (Direction direction : pContext.getNearestLookingDirections()) { + var state = this.defaultBlockState() + .setValue(FACING, direction.getOpposite()) + .setValue(WATERLOGGED, fluidState.is(FluidTags.WATER) && fluidState.getAmount() == 8); + if (state.canSurvive(pContext.getLevel(), pContext.getClickedPos())) { + return state; + } + } + return null; + } + + @Override + protected boolean canSurvive(BlockState blockState, LevelReader levelReader, BlockPos blockPos) { + Direction direction = blockState.getValue(FACING); + return this.canAttachTo(levelReader, blockPos.relative(direction.getOpposite()), direction); + } + + private boolean canAttachTo(BlockGetter blockGetter, BlockPos blockPos, Direction direction) { + BlockState blockState = blockGetter.getBlockState(blockPos); + return blockState.isFaceSturdy(blockGetter, blockPos, direction); } @Override diff --git a/Common/src/main/java/at/petrak/hexcasting/common/lib/HexBlocks.java b/Common/src/main/java/at/petrak/hexcasting/common/lib/HexBlocks.java index afbfbef84d..2320538a1c 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/lib/HexBlocks.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/lib/HexBlocks.java @@ -151,10 +151,8 @@ private static BlockBehaviour.Properties quenched() { new BlockSlate(slateish() .pushReaction(PushReaction.DESTROY))); - public static final Supplier CHEST_LOCUS = blockItem("chest_locus", () -> - new BlockChestLocus(slateish() - .noOcclusion() - .pushReaction(PushReaction.DESTROY))); + public static final Supplier CHEST_LOCUS = blockItem("locus/chest", () -> + new BlockChestLocus(slateish())); public static final Supplier IMPETUS_EMPTY = blockItem("impetus/empty", () -> new BlockEmptyImpetus(slateish() diff --git a/Common/src/main/java/at/petrak/hexcasting/datagen/HexLootTables.java b/Common/src/main/java/at/petrak/hexcasting/datagen/HexLootTables.java index 713b16d052..f732ec6cab 100644 --- a/Common/src/main/java/at/petrak/hexcasting/datagen/HexLootTables.java +++ b/Common/src/main/java/at/petrak/hexcasting/datagen/HexLootTables.java @@ -45,7 +45,7 @@ public HexLootTables(HolderLookup.Provider registries) { @Override protected void makeLootTables(Map blockTables, Map, LootTable.Builder> lootTables) { - dropSelf(blockTables, HexBlocks.IMPETUS_EMPTY.get(), + dropSelf(blockTables, HexBlocks.CHEST_LOCUS.get(), HexBlocks.IMPETUS_EMPTY.get(), HexBlocks.IMPETUS_RIGHTCLICK.get(), HexBlocks.IMPETUS_LOOK.get(), HexBlocks.IMPETUS_REDSTONE.get(), HexBlocks.EMPTY_DIRECTRIX.get(), HexBlocks.DIRECTRIX_REDSTONE.get(), HexBlocks.DIRECTRIX_BOOLEAN.get(), HexBlocks.AKASHIC_RECORD.get(), HexBlocks.AKASHIC_BOOKSHELF.get(), HexBlocks.AKASHIC_LIGATURE.get(), diff --git a/Common/src/main/java/at/petrak/hexcasting/datagen/recipe/HexplatRecipes.java b/Common/src/main/java/at/petrak/hexcasting/datagen/recipe/HexplatRecipes.java index 4f817a0293..02964d379e 100644 --- a/Common/src/main/java/at/petrak/hexcasting/datagen/recipe/HexplatRecipes.java +++ b/Common/src/main/java/at/petrak/hexcasting/datagen/recipe/HexplatRecipes.java @@ -416,6 +416,15 @@ public void buildRecipes(RecipeOutput recipes) { .pattern("SSC") .unlockedBy("enlightenment", new Criterion<>(HexAdvancementTriggers.OVERCAST_TRIGGER.get(), enlightenment)).save(recipes); + ShapedRecipeBuilder.shaped(RecipeCategory.REDSTONE, HexBlocks.CHEST_LOCUS.get()) + .define('E', HexBlocks.EDIFIED_PLANKS.get()) + .define('C', Blocks.CHEST) + .define('S', HexItems.SLATE.get()) + .pattern(" E ") + .pattern("ECE") + .pattern(" S ") + .unlockedBy("enlightenment", new Criterion<>(HexAdvancementTriggers.OVERCAST_TRIGGER.get(), enlightenment)).save(recipes); + ShapedRecipeBuilder.shaped(RecipeCategory.REDSTONE, HexBlocks.AKASHIC_BOOKSHELF.get()) .define('L', HexTags.Items.EDIFIED_LOGS) .define('P', HexTags.Items.EDIFIED_PLANKS) diff --git a/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 b/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 index ee3691bbf1..df279b4191 100644 --- a/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 +++ b/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 @@ -138,6 +138,10 @@ look: "Fletcher Impetus", redstone: "Cleric Impetus", }, + + locus: { + chest: "Storage Locus", + }, akashic_: { record: "Akashic Record", @@ -551,6 +555,8 @@ hexcasting: { "pattern.unknown": "Unknown pattern resource location %s", + + "container.chest_locus": "Storage Locus", debug: { media_withdrawn: "%s - Media withdrawn: %s", diff --git a/Common/src/main/resources/assets/hexcasting/models/block/chest_locus.json b/Common/src/main/resources/assets/hexcasting/models/block/chest_locus.json index a0fd84de07..c891a431e6 100644 --- a/Common/src/main/resources/assets/hexcasting/models/block/chest_locus.json +++ b/Common/src/main/resources/assets/hexcasting/models/block/chest_locus.json @@ -1,5 +1,6 @@ { "credit": "Made with Blockbench", + "parent": "block/block", "textures": { "0": "hexcasting:block/slate", "1": "hexcasting:block/circle/locus/chest_side", @@ -32,40 +33,5 @@ "up": {"uv": [1, 1, 15, 15], "texture": "#2"} } } - ], - "display": { - "thirdperson_righthand": { - "translation": [0, 3, 1], - "scale": [0.55, 0.55, 0.55] - }, - "thirdperson_lefthand": { - "translation": [0, 3, 1], - "scale": [0.55, 0.55, 0.55] - }, - "firstperson_righthand": { - "rotation": [0, -90, 25], - "translation": [1.13, 3.2, 1.13], - "scale": [0.68, 0.68, 0.68] - }, - "firstperson_lefthand": { - "rotation": [0, -90, 25], - "translation": [1.13, 3.2, 1.13], - "scale": [0.68, 0.68, 0.68] - }, - "ground": { - "translation": [0, 2, 0], - "scale": [0.5, 0.5, 0.5] - }, - "gui": { - "rotation": [30, 225, 0], - "scale": [0.625, 0.625, 0.625] - }, - "head": { - "rotation": [0, 180, 0], - "translation": [0, 13, 7] - }, - "fixed": { - "rotation": [0, 180, 0] - } - } + ] } \ No newline at end of file diff --git a/Fabric/src/generated/resources/data/hexcasting/advancement/recipes/redstone/locus/chest.json b/Fabric/src/generated/resources/data/hexcasting/advancement/recipes/redstone/locus/chest.json new file mode 100644 index 0000000000..f22eb01746 --- /dev/null +++ b/Fabric/src/generated/resources/data/hexcasting/advancement/recipes/redstone/locus/chest.json @@ -0,0 +1,35 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "enlightenment": { + "conditions": { + "health_used": { + "min": 0.8 + }, + "media_generated": {}, + "mojang_i_am_begging_and_crying_please_add_an_entity_health_criterion": { + "max": 1.0, + "min": 2.2250738585072014E-308 + } + }, + "trigger": "hexcasting:overcast" + }, + "has_the_recipe": { + "conditions": { + "recipe": "hexcasting:locus/chest" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "enlightenment" + ] + ], + "rewards": { + "recipes": [ + "hexcasting:locus/chest" + ] + } +} \ No newline at end of file diff --git a/Fabric/src/generated/resources/data/hexcasting/loot_table/blocks/locus/chest.json b/Fabric/src/generated/resources/data/hexcasting/loot_table/blocks/locus/chest.json new file mode 100644 index 0000000000..b3fdb297e3 --- /dev/null +++ b/Fabric/src/generated/resources/data/hexcasting/loot_table/blocks/locus/chest.json @@ -0,0 +1,15 @@ +{ + "pools": [ + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:item", + "name": "hexcasting:locus/chest" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "hexcasting:blocks/locus/chest" +} \ No newline at end of file diff --git a/Fabric/src/generated/resources/data/hexcasting/recipe/locus/chest.json b/Fabric/src/generated/resources/data/hexcasting/recipe/locus/chest.json new file mode 100644 index 0000000000..ca31765021 --- /dev/null +++ b/Fabric/src/generated/resources/data/hexcasting/recipe/locus/chest.json @@ -0,0 +1,24 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "redstone", + "key": { + "C": { + "item": "minecraft:chest" + }, + "E": { + "item": "hexcasting:edified_planks" + }, + "S": { + "item": "hexcasting:slate" + } + }, + "pattern": [ + " E ", + "ECE", + " S " + ], + "result": { + "count": 1, + "id": "hexcasting:locus/chest" + } +} \ No newline at end of file diff --git a/Neoforge/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json b/Neoforge/src/generated/resources/assets/hexcasting/blockstates/locus/chest.json similarity index 100% rename from Neoforge/src/generated/resources/assets/hexcasting/blockstates/chest_locus.json rename to Neoforge/src/generated/resources/assets/hexcasting/blockstates/locus/chest.json diff --git a/Neoforge/src/generated/resources/assets/hexcasting/models/item/chest_locus.json b/Neoforge/src/generated/resources/assets/hexcasting/models/item/locus/chest.json similarity index 100% rename from Neoforge/src/generated/resources/assets/hexcasting/models/item/chest_locus.json rename to Neoforge/src/generated/resources/assets/hexcasting/models/item/locus/chest.json diff --git a/Neoforge/src/generated/resources/data/hexcasting/advancement/recipes/redstone/locus/chest.json b/Neoforge/src/generated/resources/data/hexcasting/advancement/recipes/redstone/locus/chest.json new file mode 100644 index 0000000000..f22eb01746 --- /dev/null +++ b/Neoforge/src/generated/resources/data/hexcasting/advancement/recipes/redstone/locus/chest.json @@ -0,0 +1,35 @@ +{ + "parent": "minecraft:recipes/root", + "criteria": { + "enlightenment": { + "conditions": { + "health_used": { + "min": 0.8 + }, + "media_generated": {}, + "mojang_i_am_begging_and_crying_please_add_an_entity_health_criterion": { + "max": 1.0, + "min": 2.2250738585072014E-308 + } + }, + "trigger": "hexcasting:overcast" + }, + "has_the_recipe": { + "conditions": { + "recipe": "hexcasting:locus/chest" + }, + "trigger": "minecraft:recipe_unlocked" + } + }, + "requirements": [ + [ + "has_the_recipe", + "enlightenment" + ] + ], + "rewards": { + "recipes": [ + "hexcasting:locus/chest" + ] + } +} \ No newline at end of file diff --git a/Neoforge/src/generated/resources/data/hexcasting/loot_table/blocks/locus/chest.json b/Neoforge/src/generated/resources/data/hexcasting/loot_table/blocks/locus/chest.json new file mode 100644 index 0000000000..b3fdb297e3 --- /dev/null +++ b/Neoforge/src/generated/resources/data/hexcasting/loot_table/blocks/locus/chest.json @@ -0,0 +1,15 @@ +{ + "pools": [ + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:item", + "name": "hexcasting:locus/chest" + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "hexcasting:blocks/locus/chest" +} \ No newline at end of file diff --git a/Neoforge/src/generated/resources/data/hexcasting/recipe/locus/chest.json b/Neoforge/src/generated/resources/data/hexcasting/recipe/locus/chest.json new file mode 100644 index 0000000000..ca31765021 --- /dev/null +++ b/Neoforge/src/generated/resources/data/hexcasting/recipe/locus/chest.json @@ -0,0 +1,24 @@ +{ + "type": "minecraft:crafting_shaped", + "category": "redstone", + "key": { + "C": { + "item": "minecraft:chest" + }, + "E": { + "item": "hexcasting:edified_planks" + }, + "S": { + "item": "hexcasting:slate" + } + }, + "pattern": [ + " E ", + "ECE", + " S " + ], + "result": { + "count": 1, + "id": "hexcasting:locus/chest" + } +} \ No newline at end of file diff --git a/Neoforge/src/main/java/at/petrak/hexcasting/forge/datagen/xplat/HexBlockStatesAndModels.java b/Neoforge/src/main/java/at/petrak/hexcasting/forge/datagen/xplat/HexBlockStatesAndModels.java index b57354dd4e..0f857c2fcc 100644 --- a/Neoforge/src/main/java/at/petrak/hexcasting/forge/datagen/xplat/HexBlockStatesAndModels.java +++ b/Neoforge/src/main/java/at/petrak/hexcasting/forge/datagen/xplat/HexBlockStatesAndModels.java @@ -68,7 +68,8 @@ protected void registerStatesAndModels() { .rotationY(dir.getAxis().isVertical() ? 0 : ((int) dir.toYRot()) % 360) .build(); }, BlockChestLocus.WATERLOGGED, BlockChestLocus.ENERGIZED); - simpleBlockItem(HexBlocks.CHEST_LOCUS.get(), chestLocusClosed); + // simpleItemModel doesn't like slashes in the path, so we do it manually + itemModels().getBuilder("item/locus/chest").parent(chestLocusClosed); impetus(HexBlocks.IMPETUS_EMPTY.get(), "impetus/empty", "empty", false); impetus(HexBlocks.IMPETUS_RIGHTCLICK.get(), "impetus/rightclick", "rightclick", true); From 7955cf950dced49954d00382d70f78441ee0089f Mon Sep 17 00:00:00 2001 From: Robotgiggle <88736742+Robotgiggle@users.noreply.github.com> Date: Fri, 30 Oct 2026 01:49:48 -0400 Subject: [PATCH 08/12] Add book entry and comparator output --- .../blocks/circles/BlockChestLocus.java | 6 +++++ .../hexcasting/lang/en_us.flatten.json5 | 7 ++++++ .../en_us/entries/greatwork/akashiclib.json | 2 +- .../en_us/entries/greatwork/chest_locus.json | 23 +++++++++++++++++++ .../entries/greatwork/fanciful_staves.json | 2 +- .../entries/greatwork/quenching_allays.json | 2 +- 6 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 Common/src/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/greatwork/chest_locus.json diff --git a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java index 2c9885f53b..b5a6635641 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockChestLocus.java @@ -11,6 +11,7 @@ import net.minecraft.world.Containers; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; @@ -129,6 +130,11 @@ protected void tick(BlockState blockState, ServerLevel serverLevel, BlockPos blo } } + @Override + public int getAnalogOutputSignal(BlockState pState, Level pLevel, BlockPos pPos) { + return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(pLevel.getBlockEntity(pPos)); + } + @Override public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) { return switch (pState.getValue(FACING)) { diff --git a/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 b/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 index df279b4191..c3e8a6f00e 100644 --- a/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 +++ b/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 @@ -1322,6 +1322,7 @@ spellcircles: "Spell Circles", impetus: "Impeti", directrix: "Directrices", + chest_locus: "Storage Locus", akashiclib: "Akashic Libraries", quenching_allays: "Quenching Allays", fanciful_staves: "Fanciful Staves", @@ -1767,6 +1768,12 @@ directrix_redstone: "A $(l:greatwork/directrix)$(item)Mason Directrix/$ switches output side based on a redstone signal. Without a signal, the exit is the _media-color side; with a signal, the exit is the redstone-color side.", directrix_boolean: "A $(l:greatwork/directrix)$(item)Shepherd Directrix/$ switches output side based on a boolean popped from the stack. A $(thing)True/$ makes the wave exit from the back, a $(thing)False/$ from the front. Failing to provide a boolean at all will cause a mishap." }, + + chest_locus: { + "1": "Even when cast from a spell circle, certain spells rely on the presence of items in my inventory or offhand. The $(l:greatwork/impetus)$(item)Impetus/$ is still tied to me, its mind echoing mine, reaching out to me--$(br2)--no. I must focus. The $(l:greatwork/chest_locus)$(item)Storage Locus/$ is the solution. A simple box of $(l:items/edified)$(item)edified wood/$ and all the problems are gone.", + "2": "The locus works like a chest, but it can be built directly into a spell circle. Once the _media wave passes over it, any subsequent spells cast by the circle will reach for its inventory rather than mine.$(br2)Activating a second $(l:greatwork/chest_locus)$(item)Storage Locus/$ within the same circle will cause spells to look there instead - only one can be active at a time. A cleverly built circle might be able to take advantage of this to swap between multiple \"hands\".", + "crafting.desc": "The upper row of slots in the inventory of the locus acts as the hotbar, for the purposes of $(l:patterns/spells/itempicking)item selection/$. The leftmost slot in that row acts as the offhand.", + }, akashiclib: { "1": "I KNOW SO MUCH it is ONLY RIGHT to have a place to store it all. Information can be stored in books but it is oh so so so so $(italic)slow/$ to write by hand and read by eye. I demand BETTER. And so I shall MAKE better.$(br2)... I am getting worse ... do not know if I have time to write everything bursting through my head before expiring.", diff --git a/Common/src/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/greatwork/akashiclib.json b/Common/src/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/greatwork/akashiclib.json index ad63b36001..453beda304 100644 --- a/Common/src/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/greatwork/akashiclib.json +++ b/Common/src/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/greatwork/akashiclib.json @@ -4,7 +4,7 @@ "icon": "hexcasting:akashic_record", "advancement": "hexcasting:enlightenment", "entry_color": "54398a", - "sortnum": 4, + "sortnum": 5, "pages": [ { "type": "patchouli:text", diff --git a/Common/src/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/greatwork/chest_locus.json b/Common/src/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/greatwork/chest_locus.json new file mode 100644 index 0000000000..466683e660 --- /dev/null +++ b/Common/src/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/greatwork/chest_locus.json @@ -0,0 +1,23 @@ +{ + "name": "hexcasting.entry.chest_locus", + "category": "hexcasting:greatwork", + "icon": "hexcasting:locus/chest", + "advancement": "hexcasting:enlightenment", + "entry_color": "54398a", + "sortnum": 4, + "pages": [ + { + "type": "patchouli:text", + "text": "hexcasting.page.chest_locus.1" + }, + { + "type": "patchouli:text", + "text": "hexcasting.page.chest_locus.2" + }, + { + "type": "patchouli:crafting", + "recipe": "hexcasting:locus/chest", + "text": "hexcasting.page.chest_locus.crafting.desc" + } + ] +} \ No newline at end of file diff --git a/Common/src/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/greatwork/fanciful_staves.json b/Common/src/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/greatwork/fanciful_staves.json index f62fbc0013..b1c04421b4 100644 --- a/Common/src/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/greatwork/fanciful_staves.json +++ b/Common/src/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/greatwork/fanciful_staves.json @@ -2,7 +2,7 @@ "name": "hexcasting.entry.fanciful_staves", "category": "hexcasting:greatwork", "icon": "hexcasting:staff/mindsplice", - "sortnum": 6, + "sortnum": 7, "advancement": "hexcasting:enlightenment", "entry_color": "54398a", "pages": [ diff --git a/Common/src/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/greatwork/quenching_allays.json b/Common/src/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/greatwork/quenching_allays.json index f11537b77d..7f58d95817 100644 --- a/Common/src/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/greatwork/quenching_allays.json +++ b/Common/src/main/resources/assets/hexcasting/patchouli_books/thehexbook/en_us/entries/greatwork/quenching_allays.json @@ -4,7 +4,7 @@ "icon": "hexcasting:quenched_allay", "advancement": "hexcasting:enlightenment", "entry_color": "54398a", - "sortnum": 5, + "sortnum": 6, "pages": [ { "type": "patchouli:text", From 94146fc3802d9986aad1e5dc1c0501f36d74358b Mon Sep 17 00:00:00 2001 From: Robotgiggle <88736742+Robotgiggle@users.noreply.github.com> Date: Fri, 30 Oct 2026 02:25:30 -0400 Subject: [PATCH 09/12] Fix backward item model --- .../hexcasting/models/block/chest_locus.json | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Common/src/main/resources/assets/hexcasting/models/block/chest_locus.json b/Common/src/main/resources/assets/hexcasting/models/block/chest_locus.json index c891a431e6..b06839f0d9 100644 --- a/Common/src/main/resources/assets/hexcasting/models/block/chest_locus.json +++ b/Common/src/main/resources/assets/hexcasting/models/block/chest_locus.json @@ -33,5 +33,27 @@ "up": {"uv": [1, 1, 15, 15], "texture": "#2"} } } - ] + ], + "display": { + "gui": { + "rotation": [ 30, 45, 0 ], + "translation": [ 0, 0, 0], + "scale":[ 0.625, 0.625, 0.625 ] + }, + "thirdperson_righthand": { + "rotation": [ 75, 225, 0 ], + "translation": [ 0, 2.5, 0], + "scale": [ 0.375, 0.375, 0.375 ] + }, + "firstperson_righthand": { + "rotation": [ 0, 315, 0 ], + "translation": [ 0, 0, 0 ], + "scale": [ 0.40, 0.40, 0.40 ] + }, + "firstperson_lefthand": { + "rotation": [ 0, 315, 0 ], + "translation": [ 0, 0, 0 ], + "scale": [ 0.40, 0.40, 0.40 ] + } + } } \ No newline at end of file From 610e14cd4d8b8ce6faf33501e082a4e363cda008 Mon Sep 17 00:00:00 2001 From: Robotgiggle <88736742+Robotgiggle@users.noreply.github.com> Date: Fri, 30 Oct 2026 20:36:20 -0400 Subject: [PATCH 10/12] Rewrite book entry page 1 --- .../main/resources/assets/hexcasting/lang/en_us.flatten.json5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 b/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 index 9da86232bb..4c13a90103 100644 --- a/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 +++ b/Common/src/main/resources/assets/hexcasting/lang/en_us.flatten.json5 @@ -1770,7 +1770,7 @@ }, chest_locus: { - "1": "Even when cast from a spell circle, certain spells rely on the presence of items in my inventory or offhand. The $(l:greatwork/impetus)$(item)Impetus/$ is still tied to me, its mind echoing mine, reaching out to me--$(br2)--no. I must focus. The $(l:greatwork/chest_locus)$(item)Storage Locus/$ is the solution. A simple box of $(l:items/edified)$(item)edified wood/$ and all the problems are gone.", + "1": "Even when cast from a spell circle, certain spells rely on the presence of items in my inventory or offhand. Such a limitation is clearly not befitting of my grand design!$(br2)Consequently, I have developed a solution. By affixing an $(l:items/edified)$(item)edified/$ box to a $(l:items/slate)$(item)slate/$, I can create a surrogate inventory for the spell circle in which I install it. I call this device a $(l:greatwork/chest_locus)$(item)Storage Locus/$.", "2": "The locus works like a chest, but it can be built directly into a spell circle. Once the _media wave passes over it, any subsequent spells cast by the circle will reach for its inventory rather than mine.$(br2)Activating a second $(l:greatwork/chest_locus)$(item)Storage Locus/$ within the same circle will cause spells to look there instead - only one can be active at a time. A cleverly built circle might be able to take advantage of this to swap between multiple \"hands\".", "crafting.desc": "The upper row of slots in the inventory of the locus acts as the hotbar, for the purposes of $(l:patterns/spells/itempicking)item selection/$. The leftmost slot in that row acts as the offhand.", }, From 46769d5355da22373037912c480193169534e8f1 Mon Sep 17 00:00:00 2001 From: Robotgiggle <88736742+Robotgiggle@users.noreply.github.com> Date: Mon, 2 Nov 2026 00:48:49 -0500 Subject: [PATCH 11/12] Update changelog (and fix that duped bit) --- CHANGELOG.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c6847ca84..b3233336b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ### Added - Updated to Minecraft 1.21.1 ([#985](https://github.com/FallingColors/HexMod/pull/985)) @SuperKnux @slava110 +- Added the Storage Locus, a spell circle component that lets a circle stop depending on its caster's inventory ([#1364](https://github.com/FallingColors/HexMod/pull/1364)) @Robotgiggle - Added Simulate, which causes the next pattern drawn to be simulated (to check for mishaps) rather than executed ([#1194](https://github.com/FallingColors/HexMod/pull/1194)) @Robotgiggle - Added Coalescing Distillation, which performs the null-coalescing operation ([#1196](https://github.com/FallingColors/HexMod/pull/1196)) @Robotgiggle - Added the `hex_unbreakable` tag for blocks that should be immune to Break Block regardless of the configured mining tier ([#1186](https://github.com/FallingColors/HexMod/pull/1186)) @Robotgiggle @slava110 @@ -25,9 +26,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). - Iotas included via the above process are now popped from the original stack - Entity iotas no longer become Null if the referenced entity ceases to exist or becomes unloaded ([#1299](https://github.com/FallingColors/HexMod/pull/1299)) @Robotgiggle - Augur's Purification now returns false for nonexistent or unloaded entity iotas ([#1299](https://github.com/FallingColors/HexMod/pull/1299)) @Robotgiggle - -### Changed - - The media cost of Impulse now scales linearly rather than quadratically ([#1145](https://github.com/FallingColors/HexMod/pull/1145)) @Robotgiggle - Erase Item is now free for most items ([#1359](https://github.com/FallingColors/HexMod/pull/1359)) @beholderface From d8cc3dca4b23da1c32be52e30ce4098aee923ee5 Mon Sep 17 00:00:00 2001 From: Robotgiggle <88736742+Robotgiggle@users.noreply.github.com> Date: Mon, 2 Nov 2026 22:52:07 -0500 Subject: [PATCH 12/12] Streamline the block entity boilerplate a little --- .../blocks/circles/BlockEntityChestLocus.java | 37 ++++++------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockEntityChestLocus.java b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockEntityChestLocus.java index 551718472c..f45d402529 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockEntityChestLocus.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/blocks/circles/BlockEntityChestLocus.java @@ -1,17 +1,13 @@ package at.petrak.hexcasting.common.blocks.circles; import at.petrak.hexcasting.common.lib.HexBlockEntities; -import at.petrak.hexcasting.common.lib.HexBlocks; import net.minecraft.core.BlockPos; import net.minecraft.core.HolderLookup.Provider; import net.minecraft.core.NonNullList; -import net.minecraft.core.Vec3i; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; -import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; -import net.minecraft.world.Container; import net.minecraft.world.ContainerHelper; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; @@ -28,21 +24,22 @@ public class BlockEntityChestLocus extends RandomizableContainerBlockEntity { private final ContainerOpenersCounter openersCounter = new ContainerOpenersCounter() { @Override protected void onOpen(Level level, BlockPos blockPos, BlockState blockState) { - BlockEntityChestLocus.this.playSound(blockState, SoundEvents.BAMBOO_WOOD_TRAPDOOR_OPEN); - BlockEntityChestLocus.this.updateBlockState(blockState, true); + level.playSound(null, blockPos, SoundEvents.BAMBOO_WOOD_TRAPDOOR_OPEN, SoundSource.BLOCKS, + 0.8F, level.random.nextFloat() * 0.1F + 0.9F); + level.setBlock(blockPos, blockState.setValue(BlockChestLocus.OPEN, true), 3); } @Override protected void onClose(Level level, BlockPos blockPos, BlockState blockState) { - BlockEntityChestLocus.this.playSound(blockState, SoundEvents.BAMBOO_WOOD_TRAPDOOR_CLOSE); - BlockEntityChestLocus.this.updateBlockState(blockState, false); + level.playSound(null, blockPos, SoundEvents.BAMBOO_WOOD_TRAPDOOR_CLOSE, SoundSource.BLOCKS, + 0.8F, level.random.nextFloat() * 0.1F + 0.9F); + level.setBlock(blockPos, blockState.setValue(BlockChestLocus.OPEN, false), 3); } @Override protected void openerCountChanged(Level level, BlockPos blockPos, BlockState blockState, int i, int j) {} @Override protected boolean isOwnContainer(Player player) { - if (player.containerMenu instanceof ChestMenu) { - Container container = ((ChestMenu)player.containerMenu).getContainer(); - return container == BlockEntityChestLocus.this; + if (player.containerMenu instanceof ChestMenu chestMenu) { + return chestMenu.getContainer() == BlockEntityChestLocus.this; } return false; } @@ -85,8 +82,8 @@ public NonNullList getItems() { } @Override - protected void setItems(NonNullList nonNullList) { - this.items = nonNullList; + protected void setItems(NonNullList itemList) { + this.items = itemList; } @Override @@ -94,12 +91,14 @@ protected AbstractContainerMenu createMenu(int i, Inventory inventory) { return ChestMenu.threeRows(i, inventory, this); } + @Override public void startOpen(Player player) { if (!this.remove && !player.isSpectator()) { this.openersCounter.incrementOpeners(player, this.getLevel(), this.getBlockPos(), this.getBlockState()); } } + @Override public void stopOpen(Player player) { if (!this.remove && !player.isSpectator()) { this.openersCounter.decrementOpeners(player, this.getLevel(), this.getBlockPos(), this.getBlockState()); @@ -111,16 +110,4 @@ public void recheckOpen() { this.openersCounter.recheckOpeners(this.getLevel(), this.getBlockPos(), this.getBlockState()); } } - - void updateBlockState(BlockState blockState, boolean bl) { - this.level.setBlock(this.getBlockPos(), blockState.setValue(BlockChestLocus.OPEN, bl), 3); - } - - void playSound(BlockState blockState, SoundEvent soundEvent) { - Vec3i vec3i = (HexBlocks.CHEST_LOCUS.get().normalDir(null, blockState, null)).getNormal(); - double d = this.worldPosition.getX() + 0.5 + vec3i.getX() / 2.0; - double e = this.worldPosition.getY() + 0.5 + vec3i.getY() / 2.0; - double f = this.worldPosition.getZ() + 0.5 + vec3i.getZ() / 2.0; - this.level.playSound(null, d, e, f, soundEvent, SoundSource.BLOCKS, 0.8F, this.level.random.nextFloat() * 0.1F + 0.9F); - } }