Skip to content

Commit

Permalink
wip: dyeable ovens
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Feb 16, 2024
1 parent e237554 commit 8c7f729
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,17 @@ public void generateItemModels(ItemModelGenerators itemModelGenerator) {
final var ovenTemplate = new ModelTemplate(Optional.of(new ResourceLocation("cookingforblockheads", "item/dyed_oven")), Optional.empty());
for (final var oven : ModBlocks.ovens) {
final var modelLocation = ModelLocationUtils.getModelLocation(oven.asItem());
final var textureMapping = getOvenTextures(oven);
final var textureMapping = getOvenTextures(oven, false);
ovenTemplate.create(modelLocation, textureMapping, itemModelGenerator.output);
}
}

private void createOvenBlock(BlockModelGenerators blockStateModelGenerator, OvenBlock block) {
final var ovenTemplate = new ModelTemplate(Optional.of(new ResourceLocation("cookingforblockheads", "block/dyed_oven")), Optional.empty());
final var textureMapping = getOvenTextures(block);
final var textureMapping = getOvenTextures(block, false);
final var ovenModel = ovenTemplate.create(block, textureMapping, blockStateModelGenerator.modelOutput);
final var activeTextureMapping = getOvenTextures(block);
activeTextureMapping.putForced(TextureSlot.create("ovenfront"),
new ResourceLocation("cookingforblockheads", "block/" + block.getColor().getName() + "_oven_front_active"));
final var activeOvenTemplate = new ModelTemplate(Optional.of(new ResourceLocation("cookingforblockheads", "block/dyed_oven")), Optional.empty());
final var activeOvenModel = activeOvenTemplate.createWithSuffix(block, "_active", activeTextureMapping, blockStateModelGenerator.modelOutput);
final var activeTextureMapping = getOvenTextures(block, true);
final var activeOvenModel = ovenTemplate.createWithSuffix(block, "_active", activeTextureMapping, blockStateModelGenerator.modelOutput);
blockStateModelGenerator.blockStateOutput.accept(MultiVariantGenerator.multiVariant(block)
.with(createBooleanModelDispatch(OvenBlock.ACTIVE, ovenModel, activeOvenModel))
.with(createHorizontalFacingDispatch()));
Expand All @@ -98,12 +95,17 @@ private void createOvenBlock(BlockModelGenerators blockStateModelGenerator, Oven
}

@NotNull
private static TextureMapping getOvenTextures(OvenBlock oven) {
private static TextureMapping getOvenTextures(OvenBlock oven, boolean active) {
final var textureMapping = new TextureMapping();
final var colorName = oven.getColor().getName();
textureMapping.putForced(TextureSlot.PARTICLE, new ResourceLocation("cookingforblockheads", "block/" + colorName + "_oven_side"));
textureMapping.putForced(TextureSlot.TEXTURE, new ResourceLocation("cookingforblockheads", "block/" + colorName + "_oven_side"));
textureMapping.putForced(TextureSlot.create("ovenfront"), new ResourceLocation("cookingforblockheads", "block/" + colorName + "_oven_front"));
if (active) {
textureMapping.putForced(TextureSlot.create("ovenfront"),
new ResourceLocation("cookingforblockheads", "block/" + oven.getColor().getName() + "_oven_front_active"));
} else {
textureMapping.putForced(TextureSlot.create("ovenfront"), new ResourceLocation("cookingforblockheads", "block/" + colorName + "_oven_front"));
}
textureMapping.putForced(TextureSlot.create("ovenfront_active"),
new ResourceLocation("cookingforblockheads", "block/" + colorName + "_oven_front_active"));
textureMapping.putForced(TextureSlot.create("oventop"), new ResourceLocation("cookingforblockheads", "block/" + colorName + "_oven_top"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"textures": {
"backsplash": "cookingforblockheads:block/cyan_oven_side",
"ovenbottom": "cookingforblockheads:block/cyan_oven_bottom",
"ovenfront": "cookingforblockheads:block/cyan_oven_front",
"ovenfront": "cookingforblockheads:block/cyan_oven_front_active",
"ovenfront_active": "cookingforblockheads:block/cyan_oven_front_active",
"oventop": "cookingforblockheads:block/cyan_oven_top",
"particle": "cookingforblockheads:block/cyan_oven_side",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"textures": {
"backsplash": "cookingforblockheads:block/cyan_oven_side",
"ovenbottom": "cookingforblockheads:block/cyan_oven_bottom",
"ovenfront": "cookingforblockheads:block/cyan_oven_front",
"ovenfront": "cookingforblockheads:block/cyan_oven_front_active",
"ovenfront_active": "cookingforblockheads:block/cyan_oven_front_active",
"oventop": "cookingforblockheads:block/cyan_oven_top",
"particle": "cookingforblockheads:block/cyan_oven_side",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"textures": {
"backsplash": "cookingforblockheads:block/white_oven_side",
"ovenbottom": "cookingforblockheads:block/white_oven_bottom",
"ovenfront": "cookingforblockheads:block/white_oven_front",
"ovenfront": "cookingforblockheads:block/white_oven_front_active",
"ovenfront_active": "cookingforblockheads:block/white_oven_front_active",
"oventop": "cookingforblockheads:block/white_oven_top",
"particle": "cookingforblockheads:block/white_oven_side",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"textures": {
"backsplash": "cookingforblockheads:block/white_oven_side",
"ovenbottom": "cookingforblockheads:block/white_oven_bottom",
"ovenfront": "cookingforblockheads:block/white_oven_front",
"ovenfront": "cookingforblockheads:block/white_oven_front_active",
"ovenfront_active": "cookingforblockheads:block/white_oven_front_active",
"oventop": "cookingforblockheads:block/white_oven_top",
"particle": "cookingforblockheads:block/white_oven_side",
Expand Down

0 comments on commit 8c7f729

Please sign in to comment.