From eb624e856ddb8120d1611e1c1e71f126500b9634 Mon Sep 17 00:00:00 2001 From: ZestyBlaze <68081568+ZestyBlaze@users.noreply.github.com> Date: Mon, 9 Sep 2024 21:44:46 +0100 Subject: [PATCH] Add `hangingSignBlock` method to `BlockStateProvider` (#1528) --- .../client/model/generators/BlockStateProvider.java | 12 ++++++++++++ .../models/block/acacia_hanging_sign.json | 5 +++++ .../minecraft/blockstates/acacia_hanging_sign.json | 7 +++++++ .../blockstates/acacia_wall_hanging_sign.json | 7 +++++++ .../neoforge/oldtest/DataGeneratorTest.java | 3 +++ 5 files changed, 34 insertions(+) create mode 100644 tests/src/generated/resources/assets/data_gen_test/models/block/acacia_hanging_sign.json create mode 100644 tests/src/generated/resources/assets/minecraft/blockstates/acacia_hanging_sign.json create mode 100644 tests/src/generated/resources/assets/minecraft/blockstates/acacia_wall_hanging_sign.json diff --git a/src/main/java/net/neoforged/neoforge/client/model/generators/BlockStateProvider.java b/src/main/java/net/neoforged/neoforge/client/model/generators/BlockStateProvider.java index dc0c4782f3..72745b01ba 100644 --- a/src/main/java/net/neoforged/neoforge/client/model/generators/BlockStateProvider.java +++ b/src/main/java/net/neoforged/neoforge/client/model/generators/BlockStateProvider.java @@ -29,6 +29,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.ButtonBlock; +import net.minecraft.world.level.block.CeilingHangingSignBlock; import net.minecraft.world.level.block.CrossCollisionBlock; import net.minecraft.world.level.block.DoorBlock; import net.minecraft.world.level.block.FenceBlock; @@ -42,6 +43,7 @@ import net.minecraft.world.level.block.StandingSignBlock; import net.minecraft.world.level.block.TrapDoorBlock; import net.minecraft.world.level.block.WallBlock; +import net.minecraft.world.level.block.WallHangingSignBlock; import net.minecraft.world.level.block.WallSignBlock; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.AttachFace; @@ -481,6 +483,16 @@ public void signBlock(StandingSignBlock signBlock, WallSignBlock wallSignBlock, simpleBlock(wallSignBlock, sign); } + public void hangingSignBlock(CeilingHangingSignBlock hangingSignBlock, WallHangingSignBlock wallHangingSignBlock, ResourceLocation texture) { + ModelFile hangingSign = models().sign(name(hangingSignBlock), texture); + hangingSignBlock(hangingSignBlock, wallHangingSignBlock, hangingSign); + } + + public void hangingSignBlock(CeilingHangingSignBlock hangingSignBlock, WallHangingSignBlock wallHangingSignBlock, ModelFile hangingSign) { + simpleBlock(hangingSignBlock, hangingSign); + simpleBlock(wallHangingSignBlock, hangingSign); + } + public void fourWayBlock(CrossCollisionBlock block, ModelFile post, ModelFile side) { MultiPartBlockStateBuilder builder = getMultipartBuilder(block) .part().modelFile(post).addModel().end(); diff --git a/tests/src/generated/resources/assets/data_gen_test/models/block/acacia_hanging_sign.json b/tests/src/generated/resources/assets/data_gen_test/models/block/acacia_hanging_sign.json new file mode 100644 index 0000000000..9d088d1113 --- /dev/null +++ b/tests/src/generated/resources/assets/data_gen_test/models/block/acacia_hanging_sign.json @@ -0,0 +1,5 @@ +{ + "textures": { + "particle": "minecraft:block/stripped_acacia_log" + } +} \ No newline at end of file diff --git a/tests/src/generated/resources/assets/minecraft/blockstates/acacia_hanging_sign.json b/tests/src/generated/resources/assets/minecraft/blockstates/acacia_hanging_sign.json new file mode 100644 index 0000000000..21adab31a7 --- /dev/null +++ b/tests/src/generated/resources/assets/minecraft/blockstates/acacia_hanging_sign.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "data_gen_test:block/acacia_hanging_sign" + } + } +} \ No newline at end of file diff --git a/tests/src/generated/resources/assets/minecraft/blockstates/acacia_wall_hanging_sign.json b/tests/src/generated/resources/assets/minecraft/blockstates/acacia_wall_hanging_sign.json new file mode 100644 index 0000000000..21adab31a7 --- /dev/null +++ b/tests/src/generated/resources/assets/minecraft/blockstates/acacia_wall_hanging_sign.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "data_gen_test:block/acacia_hanging_sign" + } + } +} \ No newline at end of file diff --git a/tests/src/main/java/net/neoforged/neoforge/oldtest/DataGeneratorTest.java b/tests/src/main/java/net/neoforged/neoforge/oldtest/DataGeneratorTest.java index f92fb5b82d..104839af33 100644 --- a/tests/src/main/java/net/neoforged/neoforge/oldtest/DataGeneratorTest.java +++ b/tests/src/main/java/net/neoforged/neoforge/oldtest/DataGeneratorTest.java @@ -86,6 +86,7 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.ButtonBlock; +import net.minecraft.world.level.block.CeilingHangingSignBlock; import net.minecraft.world.level.block.DoorBlock; import net.minecraft.world.level.block.FenceGateBlock; import net.minecraft.world.level.block.FurnaceBlock; @@ -96,6 +97,7 @@ import net.minecraft.world.level.block.StairBlock; import net.minecraft.world.level.block.StandingSignBlock; import net.minecraft.world.level.block.TrapDoorBlock; +import net.minecraft.world.level.block.WallHangingSignBlock; import net.minecraft.world.level.block.WallSignBlock; import net.minecraft.world.level.dimension.BuiltinDimensionTypes; import net.minecraft.world.level.dimension.DimensionType; @@ -742,6 +744,7 @@ protected void registerStatesAndModels() { pressurePlateBlock((PressurePlateBlock) Blocks.ACACIA_PRESSURE_PLATE, blockTexture(Blocks.ACACIA_PLANKS)); signBlock((StandingSignBlock) Blocks.ACACIA_SIGN, (WallSignBlock) Blocks.ACACIA_WALL_SIGN, blockTexture(Blocks.ACACIA_PLANKS)); + hangingSignBlock((CeilingHangingSignBlock) Blocks.ACACIA_HANGING_SIGN, (WallHangingSignBlock) Blocks.ACACIA_WALL_HANGING_SIGN, blockTexture(Blocks.STRIPPED_ACACIA_LOG)); simpleBlock(Blocks.TORCH, models().torch("torch", mcLoc("block/torch"))); horizontalBlock(Blocks.WALL_TORCH, models().torchWall("wall_torch", mcLoc("block/torch")), 90);