Skip to content

Commit

Permalink
feat: make flesh block texture less repetitive (uses placeholder text…
Browse files Browse the repository at this point in the history
…ures)
  • Loading branch information
Elenterius committed Jul 18, 2023
1 parent 870a033 commit 20fb879
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public ModBlockStateProvider(DataGenerator generator, ExistingFileHelper fileHel

@Override
protected void registerStatesAndModels() {
simpleBlockWithItem(ModBlocks.FLESH.get());
final int fleshVariants = 5;
simpleVariantBlockWithItem(ModBlocks.FLESH.get(), fleshVariants);
directionalSlabBlockWithItem(ModBlocks.FLESH_SLAB.get(), ModBlocks.FLESH.get());
stairsBlock(ModBlocks.FLESH_STAIRS.get(), blockTexture(ModBlocks.FLESH.get()));
simpleBlockItem(ModBlocks.FLESH_STAIRS.get());
Expand Down Expand Up @@ -181,6 +182,24 @@ public void simpleBlockWithItem(Block block) {
simpleBlockItem(block, model);
}

public void simpleVariantBlockWithItem(Block block, int variants) {
String path = path(block);
ResourceLocation blockTexture = blockTexture(block);

ModelFile mainModel = models().cubeAll(path, blockTexture);
simpleBlockItem(block, mainModel);

ConfiguredModel.Builder<?> builder = ConfiguredModel.builder().modelFile(mainModel).weight(2); //make main model more frequent than the variants

for (int i = 1; i < variants; i++) {
String suffix = "_" + i;
BlockModelBuilder modelVariant = models().cubeAll(path + suffix, extend(blockTexture, suffix));
builder = builder.nextModel().modelFile(modelVariant).weight(1);
}

getVariantBuilder(block).partialState().setModels(builder.build());
}

public void existingBlock(Block block) {
existingBlock(block, blockModel(block));
}
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 20fb879

Please sign in to comment.