Skip to content

Commit 4e5e5eb

Browse files
committed
Added Fabric model and blockstate datagen for Wooden Mosaics and Terracotta Tiles
1 parent 7befdc6 commit 4e5e5eb

703 files changed

Lines changed: 67 additions & 4905 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/main/java/io/github/mikip98/humilityafm/datagen/ModelGenerator.java

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package io.github.mikip98.humilityafm.datagen;
22

33
import io.github.mikip98.humilityafm.generators.CabinetBlockGenerator;
4+
import io.github.mikip98.humilityafm.helpers.TerracottaTilesHelper;
5+
import io.github.mikip98.humilityafm.helpers.WoodenMosaicHelper;
46
import io.github.mikip98.humilityafm.registries.BlockRegistry;
57
import io.github.mikip98.humilityafm.util.GenerationData;
68
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
@@ -16,6 +18,7 @@
1618
import static io.github.mikip98.humilityafm.HumilityAFM.getId;
1719

1820
public class ModelGenerator extends FabricModelProvider {
21+
// Cabinet Models
1922
protected static final Model CABINET_BLOCK_MODEL = new Model(
2023
Optional.of(getId("block/cabinet_block")),
2124
Optional.empty()
@@ -24,6 +27,11 @@ public class ModelGenerator extends FabricModelProvider {
2427
Optional.of(getId("block/cabinet_block_open")),
2528
Optional.empty()
2629
);
30+
// Checker 2x2 Model
31+
protected static final Model CHECKER_2X2 = new Model(
32+
Optional.of(getId("block/checker_2x2")),
33+
Optional.empty()
34+
);
2735

2836

2937
public ModelGenerator(FabricDataOutput output) {
@@ -33,11 +41,66 @@ public ModelGenerator(FabricDataOutput output) {
3341

3442
@Override
3543
public void generateBlockStateModels(BlockStateModelGenerator blockStateModelGenerator) {
44+
// ............ TEST BLOCKS & BLOCK ITEMS ............
45+
// Cabinet Blocks
3646
blockStateModelGenerator.registerParentedItemModel(BlockRegistry.CABINET_BLOCK, getId("block/cabinet_block"));
3747
blockStateModelGenerator.registerParentedItemModel(BlockRegistry.ILLUMINATED_CABINET_BLOCK, getId("block/cabinet_block"));
3848
blockStateModelGenerator.blockStateCollector.accept(getCabinetBlockstate(BlockRegistry.CABINET_BLOCK, getId("block/cabinet_block"), getId("block/cabinet_block_open")));
3949
blockStateModelGenerator.blockStateCollector.accept(getCabinetBlockstate(BlockRegistry.ILLUMINATED_CABINET_BLOCK, getId("block/cabinet_block"), getId("block/cabinet_block_open")));
50+
// Wooden Mosaic
51+
blockStateModelGenerator.registerParentedItemModel(BlockRegistry.WOODEN_MOSAIC, getId("block/checker_2x2"));
52+
blockStateModelGenerator.blockStateCollector.accept(getDefaultBlockstate(BlockRegistry.WOODEN_MOSAIC, getId("block/checker_2x2")));
53+
54+
// ............ FINAL BLOCKS & BLOCK ITEMS ............
55+
generateCabinetModelsAndBlockStates(blockStateModelGenerator);
56+
generateWoodenMosaicModelsAndBlockStates(blockStateModelGenerator);
57+
generateTerracottaTilesModelsAndBlockStates(blockStateModelGenerator);
58+
}
4059

60+
protected static void generateWoodenMosaicModelsAndBlockStates(BlockStateModelGenerator blockStateModelGenerator) {
61+
int i = 0;
62+
for (String woodType : GenerationData.vanillaWoodTypes) {
63+
for (String woodType2 : GenerationData.vanillaWoodTypes) {
64+
if (woodType.equals(woodType2)) continue;
65+
66+
final Identifier woodenMosaicModelId = CHECKER_2X2.upload(
67+
getId("block/wooden_mosaic/wooden_mosaic_" + woodType + "_" + woodType2),
68+
new TextureMap()
69+
.register(TextureKey.of("1"), new Identifier("block/" + woodType + "_planks"))
70+
.register(TextureKey.of("2"), new Identifier("block/" + woodType2 + "_planks"))
71+
.register(TextureKey.PARTICLE, new Identifier("block/" + woodType + "_planks")),
72+
blockStateModelGenerator.modelCollector
73+
);
74+
blockStateModelGenerator.registerParentedItemModel(WoodenMosaicHelper.woodenMosaicVariants[i], woodenMosaicModelId);
75+
blockStateModelGenerator.blockStateCollector.accept(getDefaultBlockstate(WoodenMosaicHelper.woodenMosaicVariants[i], woodenMosaicModelId));
76+
77+
++i;
78+
}
79+
}
80+
}
81+
protected static void generateTerracottaTilesModelsAndBlockStates(BlockStateModelGenerator blockStateModelGenerator) {
82+
int i = 0;
83+
for (String color : GenerationData.vanillaColorPallet) {
84+
for (String color2 : GenerationData.vanillaColorPallet) {
85+
if (color.equals(color2)) continue;
86+
87+
final Identifier terracottaTileModelId = CHECKER_2X2.upload(
88+
getId("block/terracotta_tiles/terracotta_tiles_" + color + "_" + color2),
89+
new TextureMap()
90+
.register(TextureKey.of("1"), new Identifier("block/" + color + "_terracotta"))
91+
.register(TextureKey.of("2"), new Identifier("block/" + color2 + "_terracotta"))
92+
.register(TextureKey.PARTICLE, new Identifier("block/" + color + "_terracotta")),
93+
blockStateModelGenerator.modelCollector
94+
);
95+
blockStateModelGenerator.registerParentedItemModel(TerracottaTilesHelper.terracottaTilesVariants[i], terracottaTileModelId);
96+
blockStateModelGenerator.blockStateCollector.accept(getDefaultBlockstate(TerracottaTilesHelper.terracottaTilesVariants[i], terracottaTileModelId));
97+
98+
++i;
99+
}
100+
}
101+
}
102+
103+
protected static void generateCabinetModelsAndBlockStates(BlockStateModelGenerator blockStateModelGenerator) {
41104
int i = 0;
42105
for (String woodType : GenerationData.vanillaWoodTypes) {
43106
final Identifier woodTypeCabinetId = CABINET_BLOCK_MODEL.upload(
@@ -86,6 +149,10 @@ public void generateBlockStateModels(BlockStateModelGenerator blockStateModelGen
86149
}
87150

88151

152+
protected static VariantsBlockStateSupplier getDefaultBlockstate(Block block, Identifier modelId) {
153+
return VariantsBlockStateSupplier.create(block, BlockStateVariant.create().put(VariantSettings.MODEL, modelId));
154+
}
155+
89156
protected static MultipartBlockStateSupplier getCabinetBlockstate(Block cabinetBlock, Identifier cabinetModel, Identifier cabinetOpenModel) {
90157
return MultipartBlockStateSupplier
91158
.create(cabinetBlock)

src/main/resources/assets/humility-afm/blockstates/terracotta_tiles_black_blue.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/main/resources/assets/humility-afm/blockstates/terracotta_tiles_black_brown.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/main/resources/assets/humility-afm/blockstates/terracotta_tiles_black_cyan.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/main/resources/assets/humility-afm/blockstates/terracotta_tiles_black_gray.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/main/resources/assets/humility-afm/blockstates/terracotta_tiles_black_green.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/main/resources/assets/humility-afm/blockstates/terracotta_tiles_black_light_blue.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/main/resources/assets/humility-afm/blockstates/terracotta_tiles_black_light_gray.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/main/resources/assets/humility-afm/blockstates/terracotta_tiles_black_lime.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/main/resources/assets/humility-afm/blockstates/terracotta_tiles_black_magenta.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)