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 0426ddb commit 1d64e14
Show file tree
Hide file tree
Showing 21 changed files with 236 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
FabricDataGenerator.Pack pack = fabricDataGenerator.createPack();
pack.addProvider(ModBlockTagProvider::new);
pack.addProvider(ModItemTagProvider::new);
pack.addProvider(ModEntityTypeTagProvider::new);
pack.addProvider(ModBlockLootTableProvider::new);
pack.addProvider(ModModelProvider::new);
pack.addProvider(ModRecipeProvider::new);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package net.blay09.mods.cookingforblockheads.fabric.datagen;

import net.blay09.mods.cookingforblockheads.tag.ModEntityTypeTags;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.entity.EntityType;

import java.util.concurrent.CompletableFuture;

public class ModEntityTypeTagProvider extends FabricTagProvider<EntityType<?>> {
public ModEntityTypeTagProvider(FabricDataOutput output, CompletableFuture<HolderLookup.Provider> registriesFuture) {
super(output, Registries.ENTITY_TYPE, registriesFuture);
}

@Override
protected void addTags(HolderLookup.Provider arg) {
getOrCreateTagBuilder(ModEntityTypeTags.COW).add(EntityType.COW);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.level.block.Block;
import org.jetbrains.annotations.NotNull;

import java.util.Optional;

Expand Down Expand Up @@ -68,21 +69,12 @@ 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 = 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"));
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"));
textureMapping.putForced(TextureSlot.create("ovenbottom"), new ResourceLocation("cookingforblockheads", "block/" + colorName + "_oven_bottom"));
textureMapping.putForced(TextureSlot.create("backsplash"), new ResourceLocation("cookingforblockheads", "block/" + colorName + "_oven_side"));
final var textureMapping = getOvenTextures(oven);
ovenTemplate.create(modelLocation, textureMapping, itemModelGenerator.output);
}
}

private void createOvenBlock(BlockModelGenerators blockStateModelGenerator, Block block) {
private void createOvenBlock(BlockModelGenerators blockStateModelGenerator, OvenBlock block) {
final var dispatch = PropertyDispatch.properties(OvenBlock.ACTIVE, OvenBlock.POWERED);
for (var active = 0; active <= 1; active++) {
for (var powered = 0; powered <= 1; powered++) {
Expand All @@ -102,6 +94,25 @@ private void createOvenBlock(BlockModelGenerators blockStateModelGenerator, Bloc
.with(dispatch);
blockStateModelGenerator.blockStateOutput.accept(generator);
blockStateModelGenerator.skipAutoItemBlock(block);

final var ovenTemplate = new ModelTemplate(Optional.of(new ResourceLocation("cookingforblockheads", "block/dyed_oven")), Optional.empty());
final var textureMapping = getOvenTextures(block);
ovenTemplate.create(block, textureMapping, blockStateModelGenerator.modelOutput);
}

@NotNull
private static TextureMapping getOvenTextures(OvenBlock oven) {
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"));
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"));
textureMapping.putForced(TextureSlot.create("ovenbottom"), new ResourceLocation("cookingforblockheads", "block/" + colorName + "_oven_bottom"));
textureMapping.putForced(TextureSlot.create("backsplash"), new ResourceLocation("cookingforblockheads", "block/" + colorName + "_oven_side"));
return textureMapping;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"parent": "cookingforblockheads:block/dyed_oven",
"textures": {
"backsplash": "cookingforblockheads:block/black_oven_side",
"ovenbottom": "cookingforblockheads:block/black_oven_bottom",
"ovenfront": "cookingforblockheads:block/black_oven_front",
"ovenfront_active": "cookingforblockheads:block/black_oven_front_active",
"oventop": "cookingforblockheads:block/black_oven_top",
"particle": "cookingforblockheads:block/black_oven_side",
"texture": "cookingforblockheads:block/black_oven_side"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"parent": "cookingforblockheads:block/dyed_oven",
"textures": {
"backsplash": "cookingforblockheads:block/blue_oven_side",
"ovenbottom": "cookingforblockheads:block/blue_oven_bottom",
"ovenfront": "cookingforblockheads:block/blue_oven_front",
"ovenfront_active": "cookingforblockheads:block/blue_oven_front_active",
"oventop": "cookingforblockheads:block/blue_oven_top",
"particle": "cookingforblockheads:block/blue_oven_side",
"texture": "cookingforblockheads:block/blue_oven_side"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"parent": "cookingforblockheads:block/dyed_oven",
"textures": {
"backsplash": "cookingforblockheads:block/brown_oven_side",
"ovenbottom": "cookingforblockheads:block/brown_oven_bottom",
"ovenfront": "cookingforblockheads:block/brown_oven_front",
"ovenfront_active": "cookingforblockheads:block/brown_oven_front_active",
"oventop": "cookingforblockheads:block/brown_oven_top",
"particle": "cookingforblockheads:block/brown_oven_side",
"texture": "cookingforblockheads:block/brown_oven_side"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"parent": "cookingforblockheads:block/dyed_oven",
"textures": {
"backsplash": "cookingforblockheads:block/cyan_oven_side",
"ovenbottom": "cookingforblockheads:block/cyan_oven_bottom",
"ovenfront": "cookingforblockheads:block/cyan_oven_front",
"ovenfront_active": "cookingforblockheads:block/cyan_oven_front_active",
"oventop": "cookingforblockheads:block/cyan_oven_top",
"particle": "cookingforblockheads:block/cyan_oven_side",
"texture": "cookingforblockheads:block/cyan_oven_side"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"parent": "cookingforblockheads:block/dyed_oven",
"textures": {
"backsplash": "cookingforblockheads:block/gray_oven_side",
"ovenbottom": "cookingforblockheads:block/gray_oven_bottom",
"ovenfront": "cookingforblockheads:block/gray_oven_front",
"ovenfront_active": "cookingforblockheads:block/gray_oven_front_active",
"oventop": "cookingforblockheads:block/gray_oven_top",
"particle": "cookingforblockheads:block/gray_oven_side",
"texture": "cookingforblockheads:block/gray_oven_side"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"parent": "cookingforblockheads:block/dyed_oven",
"textures": {
"backsplash": "cookingforblockheads:block/green_oven_side",
"ovenbottom": "cookingforblockheads:block/green_oven_bottom",
"ovenfront": "cookingforblockheads:block/green_oven_front",
"ovenfront_active": "cookingforblockheads:block/green_oven_front_active",
"oventop": "cookingforblockheads:block/green_oven_top",
"particle": "cookingforblockheads:block/green_oven_side",
"texture": "cookingforblockheads:block/green_oven_side"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"parent": "cookingforblockheads:block/dyed_oven",
"textures": {
"backsplash": "cookingforblockheads:block/light_blue_oven_side",
"ovenbottom": "cookingforblockheads:block/light_blue_oven_bottom",
"ovenfront": "cookingforblockheads:block/light_blue_oven_front",
"ovenfront_active": "cookingforblockheads:block/light_blue_oven_front_active",
"oventop": "cookingforblockheads:block/light_blue_oven_top",
"particle": "cookingforblockheads:block/light_blue_oven_side",
"texture": "cookingforblockheads:block/light_blue_oven_side"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"parent": "cookingforblockheads:block/dyed_oven",
"textures": {
"backsplash": "cookingforblockheads:block/light_gray_oven_side",
"ovenbottom": "cookingforblockheads:block/light_gray_oven_bottom",
"ovenfront": "cookingforblockheads:block/light_gray_oven_front",
"ovenfront_active": "cookingforblockheads:block/light_gray_oven_front_active",
"oventop": "cookingforblockheads:block/light_gray_oven_top",
"particle": "cookingforblockheads:block/light_gray_oven_side",
"texture": "cookingforblockheads:block/light_gray_oven_side"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"parent": "cookingforblockheads:block/dyed_oven",
"textures": {
"backsplash": "cookingforblockheads:block/lime_oven_side",
"ovenbottom": "cookingforblockheads:block/lime_oven_bottom",
"ovenfront": "cookingforblockheads:block/lime_oven_front",
"ovenfront_active": "cookingforblockheads:block/lime_oven_front_active",
"oventop": "cookingforblockheads:block/lime_oven_top",
"particle": "cookingforblockheads:block/lime_oven_side",
"texture": "cookingforblockheads:block/lime_oven_side"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"parent": "cookingforblockheads:block/dyed_oven",
"textures": {
"backsplash": "cookingforblockheads:block/magenta_oven_side",
"ovenbottom": "cookingforblockheads:block/magenta_oven_bottom",
"ovenfront": "cookingforblockheads:block/magenta_oven_front",
"ovenfront_active": "cookingforblockheads:block/magenta_oven_front_active",
"oventop": "cookingforblockheads:block/magenta_oven_top",
"particle": "cookingforblockheads:block/magenta_oven_side",
"texture": "cookingforblockheads:block/magenta_oven_side"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"parent": "cookingforblockheads:block/dyed_oven",
"textures": {
"backsplash": "cookingforblockheads:block/orange_oven_side",
"ovenbottom": "cookingforblockheads:block/orange_oven_bottom",
"ovenfront": "cookingforblockheads:block/orange_oven_front",
"ovenfront_active": "cookingforblockheads:block/orange_oven_front_active",
"oventop": "cookingforblockheads:block/orange_oven_top",
"particle": "cookingforblockheads:block/orange_oven_side",
"texture": "cookingforblockheads:block/orange_oven_side"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"parent": "cookingforblockheads:block/dyed_oven",
"textures": {
"backsplash": "cookingforblockheads:block/white_oven_side",
"ovenbottom": "cookingforblockheads:block/white_oven_bottom",
"ovenfront": "cookingforblockheads:block/white_oven_front",
"ovenfront_active": "cookingforblockheads:block/white_oven_front_active",
"oventop": "cookingforblockheads:block/white_oven_top",
"particle": "cookingforblockheads:block/white_oven_side",
"texture": "cookingforblockheads:block/white_oven_side"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"parent": "cookingforblockheads:block/dyed_oven",
"textures": {
"backsplash": "cookingforblockheads:block/pink_oven_side",
"ovenbottom": "cookingforblockheads:block/pink_oven_bottom",
"ovenfront": "cookingforblockheads:block/pink_oven_front",
"ovenfront_active": "cookingforblockheads:block/pink_oven_front_active",
"oventop": "cookingforblockheads:block/pink_oven_top",
"particle": "cookingforblockheads:block/pink_oven_side",
"texture": "cookingforblockheads:block/pink_oven_side"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"parent": "cookingforblockheads:block/dyed_oven",
"textures": {
"backsplash": "cookingforblockheads:block/purple_oven_side",
"ovenbottom": "cookingforblockheads:block/purple_oven_bottom",
"ovenfront": "cookingforblockheads:block/purple_oven_front",
"ovenfront_active": "cookingforblockheads:block/purple_oven_front_active",
"oventop": "cookingforblockheads:block/purple_oven_top",
"particle": "cookingforblockheads:block/purple_oven_side",
"texture": "cookingforblockheads:block/purple_oven_side"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"parent": "cookingforblockheads:block/dyed_oven",
"textures": {
"backsplash": "cookingforblockheads:block/red_oven_side",
"ovenbottom": "cookingforblockheads:block/red_oven_bottom",
"ovenfront": "cookingforblockheads:block/red_oven_front",
"ovenfront_active": "cookingforblockheads:block/red_oven_front_active",
"oventop": "cookingforblockheads:block/red_oven_top",
"particle": "cookingforblockheads:block/red_oven_side",
"texture": "cookingforblockheads:block/red_oven_side"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"parent": "cookingforblockheads:block/dyed_oven",
"textures": {
"backsplash": "cookingforblockheads:block/yellow_oven_side",
"ovenbottom": "cookingforblockheads:block/yellow_oven_bottom",
"ovenfront": "cookingforblockheads:block/yellow_oven_front",
"ovenfront_active": "cookingforblockheads:block/yellow_oven_front_active",
"oventop": "cookingforblockheads:block/yellow_oven_top",
"particle": "cookingforblockheads:block/yellow_oven_side",
"texture": "cookingforblockheads:block/yellow_oven_side"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.block.Block;

public class ModEntityTypeTags {
public static final TagKey<EntityType<?>> COW = TagKey.create(Registries.ENTITY_TYPE, new ResourceLocation(CookingForBlockheads.MOD_ID, "cows"));
Expand Down

0 comments on commit 1d64e14

Please sign in to comment.