|
1 | 1 | package gay.pridecraft.joy.data; |
2 | 2 |
|
3 | 3 | import gay.pridecraft.joy.JoyUtil; |
| 4 | +import gay.pridecraft.joy.block.BlahajBlocks; |
| 5 | +import gay.pridecraft.joy.block.CuddlyBlock; |
4 | 6 | import gay.pridecraft.joy.registry.JoyBlocks; |
5 | 7 | import gay.pridecraft.joy.registry.JoyItems; |
6 | 8 | import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; |
|
20 | 22 | import net.minecraft.data.client.TextureMap; |
21 | 23 | import net.minecraft.data.client.VariantSettings; |
22 | 24 | import net.minecraft.data.client.When; |
| 25 | +import net.minecraft.registry.Registries; |
23 | 26 | import net.minecraft.util.Identifier; |
| 27 | +import net.minecraft.util.math.Direction; |
24 | 28 |
|
| 29 | +import java.util.List; |
25 | 30 | import java.util.Optional; |
26 | 31 |
|
27 | 32 | public class JoyModelProvider extends FabricModelProvider { |
@@ -55,6 +60,44 @@ public void generateBlockStateModels(BlockStateModelGenerator gen) { |
55 | 60 | gen.registerFlowerPotPlant(JoyBlocks.BLUE_ALLIUM, JoyBlocks.POTTED_BLUE_ALLIUM, BlockStateModelGenerator.TintType.NOT_TINTED); |
56 | 61 | gen.registerFlowerPotPlant(JoyBlocks.WHITE_ALLIUM, JoyBlocks.POTTED_WHITE_ALLIUM, BlockStateModelGenerator.TintType.NOT_TINTED); |
57 | 62 | gen.registerFlowerPotPlant(JoyBlocks.TRANS_ALLIUM, JoyBlocks.POTTED_TRANS_ALLIUM, BlockStateModelGenerator.TintType.NOT_TINTED); |
| 63 | + |
| 64 | + registerProxy(gen, |
| 65 | + BlahajBlocks.BLAHAJ_BLOCK, |
| 66 | + BlahajBlocks.BLAVINGAD_BLOCK, |
| 67 | + BlahajBlocks.BREAD_BLOCK, |
| 68 | + BlahajBlocks.BROWN_BEAR_BLOCK |
| 69 | + ); |
| 70 | + for (final var block : List.of( |
| 71 | + BlahajBlocks.BLAHAJ_BLOCK, |
| 72 | + BlahajBlocks.BLAVINGAD_BLOCK, |
| 73 | + BlahajBlocks.BREAD_BLOCK, |
| 74 | + BlahajBlocks.BROWN_BEAR_BLOCK)) { |
| 75 | + gen.blockStateCollector.accept(cuddlyBlockState(block, ModelIds.getBlockModelId(block), false)); |
| 76 | + } |
| 77 | + registerShark(gen, BlahajBlocks.GRAY_SHARK_BLOCK, false); |
| 78 | + BlahajBlocks.PRIDE_BLOCKS.forEach(shark -> registerShark(gen, shark, true)); |
| 79 | + } |
| 80 | + |
| 81 | + private static void registerShark(BlockStateModelGenerator gen, Block shark, boolean pride) { |
| 82 | + final var model = block("blue_shark", TextureKey.TEXTURE); |
| 83 | + final var id = ModelIds.getBlockModelId(shark); |
| 84 | + model.upload( |
| 85 | + id, |
| 86 | + pride ? |
| 87 | + TextureMap.texture(Registries.BLOCK.getId(shark) |
| 88 | + .withPath(str -> "block/pride_sharks/" + str.substring(0, str.lastIndexOf('_')))) : |
| 89 | + TextureMap.texture(shark), |
| 90 | + gen.modelCollector |
| 91 | + ); |
| 92 | + |
| 93 | + gen.registerParentedItemModel(shark, id); |
| 94 | + gen.blockStateCollector.accept(cuddlyBlockState(shark, id, false)); |
| 95 | + } |
| 96 | + |
| 97 | + private static void registerProxy(BlockStateModelGenerator gen, Block... toProxy) { |
| 98 | + for (final var proxied : toProxy) { |
| 99 | + gen.registerParentedItemModel(proxied, ModelIds.getBlockModelId(proxied)); |
| 100 | + } |
58 | 101 | } |
59 | 102 |
|
60 | 103 | private static void registerBed(BlockStateModelGenerator gen, Block block) { |
@@ -102,6 +145,31 @@ private static BlockStateSupplier cakeBlockState(Block block, Identifier base) { |
102 | 145 | return supplier; |
103 | 146 | } |
104 | 147 |
|
| 148 | + private static BlockStateSupplier cuddlyBlockState(Block block, Identifier model, boolean wall) { |
| 149 | + return MultipartBlockStateSupplier.create(block) |
| 150 | + .with(When.create().set(CuddlyBlock.FACING, Direction.NORTH), |
| 151 | + rotateVariant(model, VariantSettings.Rotation.R0, wall)) |
| 152 | + |
| 153 | + .with(When.create().set(CuddlyBlock.FACING, Direction.EAST), |
| 154 | + rotateVariant(model, VariantSettings.Rotation.R90, wall)) |
| 155 | + |
| 156 | + .with(When.create().set(CuddlyBlock.FACING, Direction.SOUTH), |
| 157 | + rotateVariant(model, VariantSettings.Rotation.R180, wall)) |
| 158 | + |
| 159 | + .with(When.create().set(CuddlyBlock.FACING, Direction.WEST), |
| 160 | + rotateVariant(model, VariantSettings.Rotation.R270, wall)); |
| 161 | + } |
| 162 | + |
| 163 | + private static BlockStateVariant rotateVariant(Identifier model, VariantSettings.Rotation Y, boolean wall) { |
| 164 | + final var var = BlockStateVariant.create() |
| 165 | + .put(VariantSettings.MODEL, model) |
| 166 | + .put(VariantSettings.Y, Y); |
| 167 | + if (wall) { |
| 168 | + var.put(VariantSettings.X, VariantSettings.Rotation.R90); |
| 169 | + } |
| 170 | + return var; |
| 171 | + } |
| 172 | + |
105 | 173 | private static BlockStateVariant model(Identifier model) { |
106 | 174 | return BlockStateVariant.create() |
107 | 175 | .put(VariantSettings.MODEL, model); |
|
0 commit comments