Skip to content

Commit

Permalink
1. New Datagen System using DataSettings
Browse files Browse the repository at this point in the history
2. Homes* -> SoH*
3. Recipe Fixes
rotgruengelb committed Jul 3, 2024
1 parent 59df8eb commit 6f52613
Showing 29 changed files with 823 additions and 434 deletions.
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -11,9 +11,8 @@ base {
}

repositories {
maven {
url "https://maven.rotgruengelb.net/releases"
}
maven { url "https://maven.rotgruengelb.net/releases" }
maven { url "https://maven.terraformersmc.com/" }
mavenCentral()
}

@@ -28,6 +27,8 @@ dependencies {

modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation(annotationProcessor("net.rotgruengelb:nixienaut:${project.nixienaut_version}"))

modRuntimeOnly "dev.emi:emi-fabric:1.1.8+1.20.4"
}

processResources {
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package net.rotgruengelb.sweetofhomes;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry;
import net.minecraft.client.render.RenderLayer;
import net.rotgruengelb.sweetofhomes.block.SHomesBlocksCollections;
import net.rotgruengelb.sweetofhomes.client.render.entity.ChairEntityRenderer;
import net.rotgruengelb.sweetofhomes.entity.HomesEntities;
import net.rotgruengelb.sweetofhomes.client.render.RenderLayerHandler;
import net.rotgruengelb.sweetofhomes.client.render.entity.SeatEntityRenderer;
import net.rotgruengelb.sweetofhomes.entity.SoHEntities;

public class SweetOfHomesClient implements ClientModInitializer {
@Override
public void onInitializeClient() {

SHomesBlocksCollections.CHAIR_BOCKS.forEach((block) -> BlockRenderLayerMap.INSTANCE.putBlock(block, RenderLayer.getCutout()));
EntityRendererRegistry.register(HomesEntities.CHAIR_ENTITY, ChairEntityRenderer::new); }
EntityRendererRegistry.register(SoHEntities.CHAIR_ENTITY, SeatEntityRenderer::new);
RenderLayerHandler.handelRenderLayers();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package net.rotgruengelb.sweetofhomes.client.render;

import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.minecraft.client.render.RenderLayer;
import net.rotgruengelb.sweetofhomes.datagen.SoHDataGenerator;
import net.rotgruengelb.sweetofhomes.datagen.settings.BlockDataSettings;
import net.rotgruengelb.sweetofhomes.datagen.settings.DataSettings;

public class RenderLayerHandler {

public static void handelRenderLayers() {
for (DataSettings<?> dataSettings : SoHDataGenerator.dataSettings) {
if (dataSettings instanceof BlockDataSettings<?> blockDataSettings) {
switch (blockDataSettings.getRenderLayer()) {
case CUTOUT ->
BlockRenderLayerMap.INSTANCE.putBlock(blockDataSettings.getBlock(), RenderLayer.getCutout());
case TRANSLUCENT ->
BlockRenderLayerMap.INSTANCE.putBlock(blockDataSettings.getBlock(), RenderLayer.getTranslucent());
}
}
}
}
}
23 changes: 15 additions & 8 deletions src/main/java/net/rotgruengelb/sweetofhomes/SweetOfHomes.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package net.rotgruengelb.sweetofhomes;

import net.fabricmc.api.ModInitializer;
import net.rotgruengelb.sweetofhomes.block.HomesBlocks;
import net.rotgruengelb.sweetofhomes.entity.HomesEntities;
import net.rotgruengelb.sweetofhomes.item.HomesItems;
import net.rotgruengelb.sweetofhomes.world.HomesGameRules;
import net.minecraft.util.Identifier;
import net.rotgruengelb.sweetofhomes.block.SoHBlocks;
import net.rotgruengelb.sweetofhomes.entity.SoHEntities;
import net.rotgruengelb.sweetofhomes.item.SoHItems;
import net.rotgruengelb.sweetofhomes.registry.tag.SoHTags;
import net.rotgruengelb.sweetofhomes.world.SoHGameRules;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@@ -15,9 +17,14 @@ public class SweetOfHomes implements ModInitializer {

@Override
public void onInitialize() {
HomesBlocks.registerModBlocks();
HomesItems.registerModItems();
HomesGameRules.registerModGameRules();
HomesEntities.registerModEntities();
SoHBlocks.registerModBlocks();
SoHItems.registerModItems();
SoHGameRules.registerModGameRules();
SoHEntities.registerModEntities();
SoHTags.registerModTags();
}

public static Identifier id(String path) {
return new Identifier(MOD_ID, path);
}
}
134 changes: 0 additions & 134 deletions src/main/java/net/rotgruengelb/sweetofhomes/block/HomesBlocks.java

This file was deleted.

This file was deleted.

185 changes: 185 additions & 0 deletions src/main/java/net/rotgruengelb/sweetofhomes/block/SoHBlocks.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
package net.rotgruengelb.sweetofhomes.block;

import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.*;
import net.minecraft.data.client.TexturedModel;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroups;
import net.minecraft.item.Items;
import net.minecraft.recipe.book.RecipeCategory;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.registry.tag.ItemTags;
import net.minecraft.util.Identifier;
import net.rotgruengelb.sweetofhomes.SweetOfHomes;
import net.rotgruengelb.sweetofhomes.datagen.settings.BlockDataSettings;
import net.rotgruengelb.sweetofhomes.item.SoHItems;
import net.rotgruengelb.sweetofhomes.registry.tag.SoHItemTags;

import static net.minecraft.block.Blocks.*;
import static net.rotgruengelb.sweetofhomes.SweetOfHomes.id;
import static net.rotgruengelb.sweetofhomes.datagen.SoHDataGenerator.dataSettings;
import static net.rotgruengelb.sweetofhomes.util.Util.shouldMarkAsNonFlammable;

@SuppressWarnings("unused")
public class SoHBlocks {
public static final Block AMETHYST_BRICKS = amethystBricks("amethyst_bricks", new Block(copyOf(AMETHYST_BLOCK)));
public static final Block CALCITE_BRICKS = calciteBricks("calcite_bricks", new Block(copyOf(CALCITE)));
public static final Block PAPER_WALL = paperWall("paper_wall", new Block(copyOf(BAMBOO_PLANKS)));

public static final Block COPPER_BLITZ = copperBlitz("copper_blitz", new OxidizableBlock(Oxidizable.OxidationLevel.UNAFFECTED, copyOf(COPPER_BLOCK)), Items.COPPER_BLOCK);
public static final Block EXPOSED_COPPER_BLITZ = copperBlitz("exposed_copper_blitz", new OxidizableBlock(Oxidizable.OxidationLevel.EXPOSED, copyOf(COPPER_BLOCK)), Items.EXPOSED_COPPER);
public static final Block WEATHERED_COPPER_BLITZ = copperBlitz("weathered_copper_blitz", new OxidizableBlock(Oxidizable.OxidationLevel.WEATHERED, copyOf(COPPER_BLOCK)), Items.WEATHERED_COPPER);
public static final Block OXIDIZED_COPPER_BLITZ = copperBlitz("oxidized_copper_blitz", new OxidizableBlock(Oxidizable.OxidationLevel.OXIDIZED, copyOf(COPPER_BLOCK)), Items.OXIDIZED_COPPER);
public static final Block WAXED_COPPER_BLITZ = copperBlitz("waxed_copper_blitz", new Block(copyOf(COPPER_BLOCK)), Items.WAXED_COPPER_BLOCK);
public static final Block WAXED_EXPOSED_COPPER_BLITZ = copperBlitz("waxed_exposed_copper_blitz", new Block(copyOf(COPPER_BLOCK)), Items.WAXED_EXPOSED_COPPER);
public static final Block WAXED_WEATHERED_COPPER_BLITZ = copperBlitz("waxed_weathered_copper_blitz", new Block(copyOf(COPPER_BLOCK)), Items.WAXED_WEATHERED_COPPER);
public static final Block WAXED_OXIDIZED_COPPER_BLITZ = copperBlitz("waxed_oxidized_copper_blitz", new Block(copyOf(COPPER_BLOCK)), Items.WAXED_OXIDIZED_COPPER);

public static final Block COPPER_PANELS = copperPanels("copper_panels", new OxidizableBlock(Oxidizable.OxidationLevel.UNAFFECTED, copyOf(COPPER_BLOCK)), Items.CUT_COPPER_SLAB, Items.COPPER_BLOCK);
public static final Block EXPOSED_COPPER_PANELS = copperPanels("exposed_copper_panels", new OxidizableBlock(Oxidizable.OxidationLevel.EXPOSED, copyOf(COPPER_BLOCK)), Items.EXPOSED_CUT_COPPER_SLAB, Items.EXPOSED_COPPER);
public static final Block WEATHERED_COPPER_PANELS = copperPanels("weathered_copper_panels", new OxidizableBlock(Oxidizable.OxidationLevel.WEATHERED, copyOf(COPPER_BLOCK)), Items.WEATHERED_CUT_COPPER_SLAB, Items.WEATHERED_COPPER);
public static final Block OXIDIZED_COPPER_PANELS = copperPanels("oxidized_copper_panels", new OxidizableBlock(Oxidizable.OxidationLevel.OXIDIZED, copyOf(COPPER_BLOCK)), Items.OXIDIZED_CUT_COPPER_SLAB, Items.OXIDIZED_COPPER);
public static final Block WAXED_COPPER_PANELS = copperPanels("waxed_copper_panels", new Block(copyOf(COPPER_BLOCK)), Items.WAXED_CUT_COPPER_SLAB, Items.WAXED_COPPER_BLOCK);
public static final Block WAXED_EXPOSED_COPPER_PANELS = copperPanels("waxed_exposed_copper_panels", new Block(copyOf(COPPER_BLOCK)), Items.WAXED_EXPOSED_CUT_COPPER_SLAB, Items.WAXED_EXPOSED_COPPER);
public static final Block WAXED_WEATHERED_COPPER_PANELS = copperPanels("waxed_weathered_copper_panels", new Block(copyOf(COPPER_BLOCK)), Items.WAXED_WEATHERED_CUT_COPPER_SLAB, Items.WAXED_WEATHERED_COPPER);
public static final Block WAXED_OXIDIZED_COPPER_PANELS = copperPanels("waxed_oxidized_copper_panels", new Block(copyOf(COPPER_BLOCK)), Items.WAXED_OXIDIZED_CUT_COPPER_SLAB, Items.WAXED_OXIDIZED_COPPER);

public static final Block COPPER_PILLAR = copperPillar("copper_pillar", new OxidizablePillarBlock(Oxidizable.OxidationLevel.UNAFFECTED, copyOf(COPPER_BLOCK)), Items.COPPER_BLOCK);
public static final Block EXPOSED_COPPER_PILLAR = copperPillar("exposed_copper_pillar", new OxidizablePillarBlock(Oxidizable.OxidationLevel.EXPOSED, copyOf(COPPER_BLOCK)), Items.EXPOSED_COPPER);
public static final Block WEATHERED_COPPER_PILLAR = copperPillar("weathered_copper_pillar", new OxidizablePillarBlock(Oxidizable.OxidationLevel.WEATHERED, copyOf(COPPER_BLOCK)), Items.WEATHERED_COPPER);
public static final Block OXIDIZED_COPPER_PILLAR = copperPillar("oxidized_copper_pillar", new OxidizablePillarBlock(Oxidizable.OxidationLevel.OXIDIZED, copyOf(COPPER_BLOCK)), Items.OXIDIZED_COPPER);
public static final Block WAXED_COPPER_PILLAR = copperPillar("waxed_copper_pillar", new PillarBlock(copyOf(COPPER_BLOCK)), Items.WAXED_COPPER_BLOCK);
public static final Block WAXED_EXPOSED_COPPER_PILLAR = copperPillar("waxed_exposed_copper_pillar", new PillarBlock(copyOf(COPPER_BLOCK)), Items.WAXED_EXPOSED_COPPER);
public static final Block WAXED_WEATHERED_COPPER_PILLAR = copperPillar("waxed_weathered_copper_pillar", new PillarBlock(copyOf(COPPER_BLOCK)), Items.WAXED_WEATHERED_COPPER);
public static final Block WAXED_OXIDIZED_COPPER_PILLAR = copperPillar("waxed_oxidized_copper_pillar", new PillarBlock(copyOf(COPPER_BLOCK)), Items.WAXED_OXIDIZED_COPPER);

public static final Block ACACIA_PILLAR = woodPillar("acacia_pillar", new PillarBlock(copyOf(ACACIA_PLANKS)), Items.ACACIA_PLANKS);
public static final Block BIRCH_PILLAR = woodPillar("birch_pillar", new PillarBlock(copyOf(BIRCH_PLANKS)), Items.BIRCH_PLANKS);
public static final Block CRIMSON_PILLAR = woodPillar("crimson_pillar", new PillarBlock(copyOf(CRIMSON_PLANKS)), Items.CRIMSON_PLANKS);
public static final Block DARK_OAK_PILLAR = woodPillar("dark_oak_pillar", new PillarBlock(copyOf(DARK_OAK_PLANKS)), Items.DARK_OAK_PLANKS);
public static final Block JUNGLE_PILLAR = woodPillar("jungle_pillar", new PillarBlock(copyOf(JUNGLE_PLANKS)), Items.JUNGLE_PLANKS);
public static final Block OAK_PILLAR = woodPillar("oak_pillar", new PillarBlock(copyOf(OAK_PLANKS)), Items.OAK_PLANKS);
public static final Block SPRUCE_PILLAR = woodPillar("spruce_pillar", new PillarBlock(copyOf(SPRUCE_PLANKS)), Items.SPRUCE_PLANKS);
public static final Block WARPED_PILLAR = woodPillar("warped_pillar", new PillarBlock(copyOf(WARPED_PLANKS)), Items.WARPED_PLANKS);
public static final Block CHERRY_PILLAR = woodPillar("cherry_pillar", new PillarBlock(copyOf(CHERRY_PLANKS)), Items.CHERRY_PLANKS);
public static final Block MANGROVE_PILLAR = woodPillar("mangrove_pillar", new PillarBlock(copyOf(MANGROVE_PLANKS)), Items.MANGROVE_PLANKS);
public static final Block BAMBOO_PILLAR = woodPillar("bamboo_pillar", new PillarBlock(copyOf(BAMBOO_PLANKS)), Items.BAMBOO_PLANKS);

public static final Block ACACIA_CHAIR = chair("acacia_chair", new ChairBlock(chairSettings(ACACIA_PLANKS)));
public static final Block BIRCH_CHAIR = chair("birch_chair", new ChairBlock(chairSettings(BIRCH_PLANKS)));
public static final Block CRIMSON_CHAIR = chair("crimson_chair", new ChairBlock(chairSettings(CRIMSON_PLANKS)));
public static final Block DARK_OAK_CHAIR = chair("dark_oak_chair", new ChairBlock(chairSettings(DARK_OAK_PLANKS)));
public static final Block JUNGLE_CHAIR = chair("jungle_chair", new ChairBlock(chairSettings(JUNGLE_PLANKS)));
public static final Block OAK_CHAIR = chair("oak_chair", new ChairBlock(chairSettings(OAK_PLANKS)));
public static final Block SPRUCE_CHAIR = chair("spruce_chair", new ChairBlock(chairSettings(SPRUCE_PLANKS)));
public static final Block WARPED_CHAIR = chair("warped_chair", new ChairBlock(chairSettings(WARPED_PLANKS)));
public static final Block CHERRY_CHAIR = chair("cherry_chair", new ChairBlock(chairSettings(CHERRY_PLANKS)));
public static final Block MANGROVE_CHAIR = chair("mangrove_chair", new ChairBlock(chairSettings(MANGROVE_PLANKS)));
public static final Block BAMBOO_CHAIR = chair("bamboo_chair", new ChairBlock(chairSettings(BAMBOO_PLANKS)));

private static Block block(String name, Block block, boolean withItem) {
if (withItem) {
registerBlockItem(name, new BlockItem(block, new FabricItemSettings()));
}
return Registry.register(Registries.BLOCK, new Identifier(SweetOfHomes.MOD_ID, name), block);
}

private static Block block(String name, Block block) {
block = block(name, block, true);
return dataSettings(new BlockDataSettings<>(id(name), block));
}

private static Block copperBlitz(String name, Block block, Item base) {
block = block(name, block, true);
return dataSettings(new BlockDataSettings<>(id(name), block).itemTags()
.blockTags(BlockTags.NEEDS_STONE_TOOL, BlockTags.PICKAXE_MINEABLE)
.recipe2x2ABBA(RecipeCategory.BUILDING_BLOCKS, SoHItems.COPPER_NUGGET, base, 2)
.recipeStonecutting(RecipeCategory.BUILDING_BLOCKS, base, 4)
.copperHelper());
}

private static Block chair(String name, Block block) {
block = block(name, block, true);
return dataSettings(new BlockDataSettings<>(id(name), block).blockTags(BlockTags.AXE_MINEABLE)
.itemTags(SoHItemTags.CHAIRS)
.itemTagsIf(shouldMarkAsNonFlammable(name), ItemTags.NON_FLAMMABLE_WOOD)
.blockModelChair()
.renderLayer(BlockDataSettings.RenderLayerEnum.CUTOUT));
}

private static FabricBlockSettings chairSettings(Block block) {
return copyOf(block).nonOpaque()
.allowsSpawning(Blocks::never)
.solidBlock(Blocks::never)
.suffocates(Blocks::never)
.blockVision(Blocks::never);
}

private static FabricBlockSettings copyOf(Block block) {
return FabricBlockSettings.copyOf(block);
}

private static Block copperPillar(String name, Block block, Item base) {
block = block(name, block, true);
return dataSettings(new BlockDataSettings<>(id(name), block).blockTags(BlockTags.NEEDS_STONE_TOOL, BlockTags.PICKAXE_MINEABLE)
.blockModelAxisRotated(TexturedModel.CUBE_ALL)
.recipe3x3Pillar(RecipeCategory.BUILDING_BLOCKS, base, SoHItems.COPPER_NUGGET, 4)
.copperHelper());
}

private static Block woodPillar(String name, Block block, Item base) {
block = block(name, block, true);
return dataSettings(new BlockDataSettings<>(id(name), block).blockTags(BlockTags.AXE_MINEABLE)
.itemTags(SoHItemTags.WOODEN_PILLARS)
.itemTagsIf(shouldMarkAsNonFlammable(name), ItemTags.NON_FLAMMABLE_WOOD)
.blockModelAxisRotated(TexturedModel.CUBE_ALL)
.recipe3x3Pillar(RecipeCategory.BUILDING_BLOCKS, base, Items.STICK, 4));
}

private static Block copperPanels(String name, Block block, Item base, Item cuttingBase) {
block = block(name, block, true);
return dataSettings(new BlockDataSettings<>(id(name), block).blockTags(BlockTags.NEEDS_STONE_TOOL, BlockTags.PICKAXE_MINEABLE)
.recipe2x2Compacting(RecipeCategory.BUILDING_BLOCKS, base, 2)
.recipeStonecutting(RecipeCategory.BUILDING_BLOCKS, cuttingBase, 4)
.copperHelper());
}

private static Block amethystBricks(String name, Block block) {
block = block(name, block, true);
return dataSettings(new BlockDataSettings<>(id(name), block).blockTags(BlockTags.CRYSTAL_SOUND_BLOCKS, BlockTags.VIBRATION_RESONATORS)
.recipe2x2ABBA(RecipeCategory.BUILDING_BLOCKS, Items.AMETHYST_SHARD, Items.AMETHYST_BLOCK, 2));
}

private static Block calciteBricks(String name, Block block) {
block = block(name, block, true);
return dataSettings(new BlockDataSettings<>(id(name), block).blockTags(BlockTags.PICKAXE_MINEABLE)
.recipe2x2Compacting(RecipeCategory.BUILDING_BLOCKS, Items.CALCITE, 4)
.recipeStonecutting(RecipeCategory.BUILDING_BLOCKS, Items.CALCITE, 4));
}

private static Block paperWall(String name, Block block) {
block = block(name, block, true);
return dataSettings(new BlockDataSettings<>(id(name), block).blockTags(BlockTags.AXE_MINEABLE)
.recipe2x2ABBA(RecipeCategory.BUILDING_BLOCKS, Items.STICK, Items.PAPER, 4));
}

private static void registerBlockItem(String name, BlockItem blockItem) {
BlockItem item = Registry.register(Registries.ITEM, new Identifier(SweetOfHomes.MOD_ID, name), blockItem);
ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS)
.register(content -> content.add(item));
}

public static void registerModBlocks() {
SweetOfHomes.LOGGER.debug("Registering SoHBlocks for " + SweetOfHomes.MOD_ID);
}

private static Block dataSettings(BlockDataSettings<?> blockDataSettings) {
dataSettings.add(blockDataSettings);
return blockDataSettings.getBlock();
}
}
Original file line number Diff line number Diff line change
@@ -2,35 +2,28 @@

import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import net.minecraft.block.Block;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.tag.BlockTags;
import net.rotgruengelb.sweetofhomes.block.HomesBlocks;
import net.rotgruengelb.sweetofhomes.block.SHomesBlocksCollections;
import net.rotgruengelb.sweetofhomes.util.tag.HomesTags;
import net.rotgruengelb.sweetofhomes.datagen.settings.BlockDataSettings;
import net.rotgruengelb.sweetofhomes.datagen.settings.DataSettings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.CompletableFuture;

public class ModBlockTagProvider extends FabricTagProvider.BlockTagProvider {
public ModBlockTagProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
super(output, registriesFuture);
}
public static final Logger LOGGER = LoggerFactory.getLogger("sweetofhomes/ModBlockTagProvider");

public ModBlockTagProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) { super(output, registriesFuture); }

@Override
protected void configure(RegistryWrapper.WrapperLookup arg) {
FabricTagBuilder pickaxe_mineable = getOrCreateTagBuilder(BlockTags.PICKAXE_MINEABLE).add(HomesBlocks.AMETHYST_BRICKS)
.add(HomesBlocks.CALCITE_BRICKS);

FabricTagBuilder needs_stone_tool = getOrCreateTagBuilder(BlockTags.NEEDS_STONE_TOOL);

SHomesBlocksCollections.COPPER_BLOCKS.forEach(block -> {
pickaxe_mineable.add(block);
needs_stone_tool.add(block);
});
SHomesBlocksCollections.WOOD_BLOCKS.forEach(block -> getOrCreateTagBuilder(BlockTags.AXE_MINEABLE).add(block));
SHomesBlocksCollections.WOODEN_PILLAR_BLOCKS.forEach(block -> getOrCreateTagBuilder(HomesTags.BLOCKS.WOODEN_PILLARS).add(block));
getOrCreateTagBuilder(BlockTags.AXE_MINEABLE).add(HomesBlocks.PAPER_WALL);
getOrCreateTagBuilder(BlockTags.VIBRATION_RESONATORS).add(HomesBlocks.AMETHYST_BRICKS);
getOrCreateTagBuilder(BlockTags.CRYSTAL_SOUND_BLOCKS).add(HomesBlocks.AMETHYST_BRICKS);

for (DataSettings<?> dataSettings : SoHDataGenerator.dataSettings) {
if (dataSettings instanceof BlockDataSettings<?> blockDataSettings) {
Block block = blockDataSettings.getBlock();
blockDataSettings.getBlockTags()
.forEach(tag -> getOrCreateTagBuilder(tag).add(block));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -2,27 +2,29 @@

import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import net.fabricmc.fabric.api.tag.convention.v1.ConventionalItemTags;
import net.minecraft.item.Item;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.tag.ItemTags;
import net.rotgruengelb.sweetofhomes.block.HomesBlocks;
import net.rotgruengelb.sweetofhomes.block.SHomesBlocksCollections;
import net.rotgruengelb.sweetofhomes.item.HomesItems;
import net.rotgruengelb.sweetofhomes.util.tag.HomesTags;
import net.rotgruengelb.sweetofhomes.datagen.settings.DataSettings;
import net.rotgruengelb.sweetofhomes.datagen.settings.ItemDataSettings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.CompletableFuture;

public class ModItemTagProvider extends FabricTagProvider.ItemTagProvider {
public static final Logger LOGGER = LoggerFactory.getLogger("sweetofhomes/ModItemTagProvider");

public ModItemTagProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> completableFuture) {
super(output, completableFuture);
}
public ModItemTagProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> completableFuture) { super(output, completableFuture); }

@Override
protected void configure(RegistryWrapper.WrapperLookup arg) {
SHomesBlocksCollections.WOODEN_PILLAR_BLOCKS.forEach(block -> getOrCreateTagBuilder(HomesTags.ITEMS.WOODEN_PILLARS).add(block.asItem()));
getOrCreateTagBuilder(ItemTags.NON_FLAMMABLE_WOOD).add(HomesBlocks.WARPED_PILLAR.asItem())
.add(HomesBlocks.CRIMSON_PILLAR.asItem());
getOrCreateTagBuilder(ConventionalItemTags.NUGGETS).add(HomesItems.COPPER_NUGGET);
for (DataSettings<?> dataSettings : SoHDataGenerator.dataSettings) {
if (dataSettings instanceof ItemDataSettings<?> itemDataSettings) {
Item item = itemDataSettings.getItem();
if (item == null) { continue; }
itemDataSettings.getItemTags()
.forEach(tag -> getOrCreateTagBuilder(tag).add(item));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -2,43 +2,20 @@

import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricLanguageProvider;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.registry.Registries;
import net.rotgruengelb.sweetofhomes.block.SHomesBlocksCollections;
import net.rotgruengelb.sweetofhomes.item.HomesItems;
import net.rotgruengelb.sweetofhomes.datagen.settings.DataSettings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ModLanguageProvider extends FabricLanguageProvider {
protected ModLanguageProvider(FabricDataOutput dataOutput) {
super(dataOutput);
}

public static String convertSnakeCaseToTitleCase(String snakeCaseText) {
String[] words = snakeCaseText.split("_");

StringBuilder titleCaseText = new StringBuilder();
public static final Logger LOGGER = LoggerFactory.getLogger("sweetofhomes/ModLanguageProvider");

for (String word : words) {
if (!word.isEmpty()) {
titleCaseText.append(Character.toUpperCase(word.charAt(0)))
.append(word.substring(1)
.toLowerCase())
.append(" ");
}
}
return titleCaseText.toString()
.trim();
}
protected ModLanguageProvider(FabricDataOutput dataOutput) { super(dataOutput); }

@Override
public void generateTranslations(TranslationBuilder translationBuilder) {
for (Block block : SHomesBlocksCollections.BLOCKS) {
translationBuilder.add(block, convertSnakeCaseToTitleCase(Registries.BLOCK.getId(block)
.getPath()));
}
for (Item item : HomesItems.ALL.ITEMS) {
translationBuilder.add(item, convertSnakeCaseToTitleCase(Registries.ITEM.getId(item)
.getPath()));
for (DataSettings<?> dataSettings : SoHDataGenerator.dataSettings) {
if (!dataSettings.shouldTranslate()) { continue; }
translationBuilder.add(dataSettings.getTranslationKey(), dataSettings.getTranslation());
}
}
}
Original file line number Diff line number Diff line change
@@ -2,18 +2,22 @@

import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootTableProvider;
import net.minecraft.block.Block;
import net.rotgruengelb.sweetofhomes.block.SHomesBlocksCollections;
import net.rotgruengelb.sweetofhomes.datagen.settings.BlockDataSettings;
import net.rotgruengelb.sweetofhomes.datagen.settings.DataSettings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ModLootTableProvider extends FabricBlockLootTableProvider {
protected ModLootTableProvider(FabricDataOutput dataOutput) {
super(dataOutput);
}
public static final Logger LOGGER = LoggerFactory.getLogger("sweetofhomes/ModLootTableProvider");

protected ModLootTableProvider(FabricDataOutput dataOutput) { super(dataOutput); }

@Override
public void generate() {
for (Block block : SHomesBlocksCollections.BLOCKS) {
addDrop(block);
for (DataSettings<?> dataSettings : SoHDataGenerator.dataSettings) {
if (dataSettings instanceof BlockDataSettings<?> blockDataSettings) {
addDrop(blockDataSettings.getBlock());
}
}
}
}
Original file line number Diff line number Diff line change
@@ -5,20 +5,21 @@
import net.minecraft.block.Block;
import net.minecraft.data.client.*;
import net.minecraft.util.Identifier;
import net.rotgruengelb.sweetofhomes.block.ChairBlock;
import net.rotgruengelb.sweetofhomes.block.HomesBlocks;
import net.rotgruengelb.sweetofhomes.block.SHomesBlocksCollections;
import net.rotgruengelb.sweetofhomes.item.HomesItems;
import net.rotgruengelb.sweetofhomes.datagen.settings.BlockDataSettings;
import net.rotgruengelb.sweetofhomes.datagen.settings.DataSettings;
import net.rotgruengelb.sweetofhomes.datagen.settings.ItemDataSettings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Optional;

public class ModModelProvider extends FabricModelProvider {
public static final Logger LOGGER = LoggerFactory.getLogger("sweetofhomes/ModLootTableProvider");

public static final TexturedModel.Factory CUBE_ALL_NO_WAXED = TexturedModel.makeFactory(ModModelProvider::allRemoveWaxed, Models.CUBE_ALL);
public static final TexturedModel.Factory TEMPLATE_CHAIR = TexturedModel.makeFactory(TextureMap::texture, MODELS.TEMPLATE_CHAIR);

public ModModelProvider(FabricDataOutput output) {
super(output);
}
public ModModelProvider(FabricDataOutput output) { super(output); }

public static TextureMap allRemoveWaxed(Block block) {
Identifier identifier = TextureMap.getId(block);
@@ -29,39 +30,29 @@ public static TextureMap allRemoveWaxed(Block block) {

@Override
public void generateBlockStateModels(BlockStateModelGenerator gen) {
gen.registerSimpleCubeAll(HomesBlocks.AMETHYST_BRICKS);
gen.registerSimpleCubeAll(HomesBlocks.CALCITE_BRICKS);
gen.registerSimpleCubeAll(HomesBlocks.PAPER_WALL);
for (int i = 0; i < SHomesBlocksCollections.MODEL_GEN.WAXED_COPPER_BLOCKS_SIMPLE_MODEL.size(); i++) {
gen.registerSimpleCubeAll(SHomesBlocksCollections.MODEL_GEN.UNWAXED_COPPER_BLOCKS_SIMPLE_MODEL.get(i));
gen.registerParented(SHomesBlocksCollections.MODEL_GEN.UNWAXED_COPPER_BLOCKS_SIMPLE_MODEL.get(i), SHomesBlocksCollections.MODEL_GEN.WAXED_COPPER_BLOCKS_SIMPLE_MODEL.get(i));
for (DataSettings<?> dataSettings : SoHDataGenerator.dataSettings) {
if (dataSettings instanceof BlockDataSettings<?> blockDataSettings) {
blockDataSettings.getBlockModel().accept(gen);
}
}
for (int i = 0; i < SHomesBlocksCollections.MODEL_GEN.WAXED_COPPER_BLOCKS_PILLAR_MODEL.size(); i++) {
gen.registerAxisRotated(SHomesBlocksCollections.MODEL_GEN.UNWAXED_COPPER_BLOCKS_PILLAR_MODEL.get(i), TexturedModel.CUBE_ALL);
gen.registerAxisRotated(SHomesBlocksCollections.MODEL_GEN.WAXED_COPPER_BLOCKS_PILLAR_MODEL.get(i), CUBE_ALL_NO_WAXED);
}
SHomesBlocksCollections.CHAIR_BOCKS.forEach(block -> registerChair(block, gen));
SHomesBlocksCollections.MODEL_GEN.WOOD_BLOCKS_PILLAR_MODEL.forEach(block -> gen.registerAxisRotated(block, TexturedModel.CUBE_ALL));

}

@Override
public void generateItemModels(ItemModelGenerator gen) {
gen.register(HomesItems.COPPER_NUGGET, Models.GENERATED);
gen.register(HomesItems.COPPER_WRENCH, Models.HANDHELD);
}

public final void registerChair(ChairBlock chair, BlockStateModelGenerator generator) {
Identifier identifier = TEMPLATE_CHAIR.upload(chair, generator.modelCollector);
generator.blockStateCollector.accept(BlockStateModelGenerator.createSingletonBlockState(chair, identifier)
.coordinate(BlockStateModelGenerator.createNorthDefaultHorizontalRotationStates()));
for (DataSettings<?> dataSettings : SoHDataGenerator.dataSettings) {
if (dataSettings instanceof BlockDataSettings<?>) { continue; }
if (dataSettings instanceof ItemDataSettings<?> itemDataSettings) {
itemDataSettings.getItemModel().accept(gen);
}
}
}

private static class MODELS {
public static final Model TEMPLATE_CHAIR = block("template_chair", TextureKey.TEXTURE);

private static Model block(String parent, TextureKey... requiredTextureKeys) {
return new Model(Optional.of(new Identifier("sweetofhomes", "block/" + parent)), Optional.empty(), requiredTextureKeys);
return new Model(Optional.of(new Identifier("sweetofhomes", "block/" + parent)),
Optional.empty(), requiredTextureKeys);
}
}
}
Original file line number Diff line number Diff line change
@@ -5,20 +5,18 @@
import net.minecraft.data.server.recipe.RecipeExporter;
import net.minecraft.data.server.recipe.RecipeProvider;
import net.minecraft.data.server.recipe.ShapedRecipeJsonBuilder;
import net.minecraft.data.server.recipe.ShapelessRecipeJsonBuilder;
import net.minecraft.item.ItemConvertible;
import net.minecraft.item.Items;
import net.minecraft.recipe.book.RecipeCategory;
import net.rotgruengelb.sweetofhomes.block.HomesBlocks;
import net.rotgruengelb.sweetofhomes.block.SHomesBlocksCollections;
import net.rotgruengelb.sweetofhomes.item.HomesItems;
import net.rotgruengelb.sweetofhomes.datagen.settings.ItemDataSettings;

public class ModRecipeProvider extends FabricRecipeProvider {
public ModRecipeProvider(FabricDataOutput output) {
super(output);
}
public ModRecipeProvider(FabricDataOutput output) { super(output); }

public static void offer2x2ABBARecipe(RecipeExporter exporter, RecipeCategory category, ItemConvertible output, ItemConvertible inputA, ItemConvertible inputB, int count) {
ShapedRecipeJsonBuilder.create(category, output, count)
.group(getItemPath(output))
.input('A', inputA)
.input('B', inputB)
.pattern("AB")
@@ -30,6 +28,7 @@ public static void offer2x2ABBARecipe(RecipeExporter exporter, RecipeCategory ca

public static void offer3x3PillarRecipe(RecipeExporter exporter, RecipeCategory category, ItemConvertible output, ItemConvertible inputCore, ItemConvertible inputSide, int count) {
ShapedRecipeJsonBuilder.create(category, output, count)
.group(getItemPath(output))
.input('S', inputSide)
.input('C', inputCore)
.pattern("SCS")
@@ -42,37 +41,31 @@ public static void offer3x3PillarRecipe(RecipeExporter exporter, RecipeCategory

public static void offer2x2CompactingRecipe(RecipeExporter exporter, RecipeCategory category, ItemConvertible output, ItemConvertible input, int count) {
ShapedRecipeJsonBuilder.create(category, output, count)
.group(getItemPath(output))
.input('#', input)
.pattern("##")
.pattern("##")
.criterion(RecipeProvider.hasItem(input), RecipeProvider.conditionsFromItem(input))
.offerTo(exporter);
}

public static void offerWaxingRecipe(RecipeExporter exporter, RecipeCategory category, ItemConvertible waxed, ItemConvertible unwaxed) {
ShapelessRecipeJsonBuilder.create(category, waxed, 1)
.group(getItemPath(waxed))
.input(unwaxed)
.input(Items.HONEYCOMB)
.criterion(hasItem(unwaxed), conditionsFromItem(unwaxed))
.offerTo(exporter, convertBetween(waxed, Items.HONEYCOMB));
}

@Override
public void generate(RecipeExporter exporter) {

SHomesBlocksCollections.CRAFTING_GEN.COPPER_BLITZ_CRAFTING.forEach((block, base) -> {
offer2x2ABBARecipe(exporter, RecipeCategory.BUILDING_BLOCKS, block, HomesItems.COPPER_NUGGET, base, 2);
offerStonecuttingRecipe(exporter, RecipeCategory.BUILDING_BLOCKS, block, base, 4);
});

SHomesBlocksCollections.CRAFTING_GEN.COPPER_PANELS_CRAFTING.forEach((block, basePair) -> {
offer2x2CompactingRecipe(exporter, RecipeCategory.BUILDING_BLOCKS, block, basePair.getLeft(), 2);
offerStonecuttingRecipe(exporter, RecipeCategory.BUILDING_BLOCKS, block, basePair.getRight(), 4);
SoHDataGenerator.dataSettings.forEach(settings -> {
if (settings instanceof ItemDataSettings<?> itemDataSettings) {
itemDataSettings.getRecipes()
.forEach(recipe -> recipe.accept(exporter));
}
});

SHomesBlocksCollections.CRAFTING_GEN.COPPER_PILLAR_CRAFTING.forEach((block, core) -> {
offer3x3PillarRecipe(exporter, RecipeCategory.BUILDING_BLOCKS, block, core, HomesItems.COPPER_NUGGET, 4);
offerStonecuttingRecipe(exporter, RecipeCategory.BUILDING_BLOCKS, block, core, 4);
});

SHomesBlocksCollections.CRAFTING_GEN.WOOD_PILLAR_CRAFTING.forEach((block, base) -> offer3x3PillarRecipe(exporter, RecipeCategory.BUILDING_BLOCKS, block, base, Items.STICK, 4));

offer2x2ABBARecipe(exporter, RecipeCategory.BUILDING_BLOCKS, HomesBlocks.AMETHYST_BRICKS, Items.AMETHYST_SHARD, Items.AMETHYST_BLOCK, 2);
offer2x2ABBARecipe(exporter, RecipeCategory.BUILDING_BLOCKS, HomesBlocks.PAPER_WALL, Items.STICK, Items.PAPER, 4);
offer2x2CompactingRecipe(exporter, RecipeCategory.BUILDING_BLOCKS, HomesBlocks.CALCITE_BRICKS, Items.CALCITE, 4);
offerStonecuttingRecipe(exporter, RecipeCategory.BUILDING_BLOCKS, HomesBlocks.CALCITE_BRICKS, Items.CALCITE, 4);
offerReversibleCompactingRecipes(exporter, RecipeCategory.MISC, HomesItems.COPPER_NUGGET, RecipeCategory.MISC, Items.COPPER_INGOT);
}
}
Original file line number Diff line number Diff line change
@@ -2,8 +2,15 @@

import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
import net.rotgruengelb.sweetofhomes.datagen.settings.DataSettings;

import java.util.ArrayList;
import java.util.List;

public class SoHDataGenerator implements DataGeneratorEntrypoint {

public static List<DataSettings<?>> dataSettings = new ArrayList<>();

public class SweetOfHomesDataGenerator implements DataGeneratorEntrypoint {
@Override
public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
FabricDataGenerator.Pack pack = fabricDataGenerator.createPack();
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
package net.rotgruengelb.sweetofhomes.datagen.settings;

import net.minecraft.block.Block;
import net.minecraft.data.client.*;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.util.Identifier;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;

import static net.rotgruengelb.sweetofhomes.datagen.ModModelProvider.TEMPLATE_CHAIR;

@SuppressWarnings("unchecked")
public class BlockDataSettings<T extends BlockDataSettings<?>> extends ItemDataSettings<T> {

protected final Block block;
protected final List<TagKey<Block>> blockTags = new ArrayList<>();
protected Consumer<BlockStateModelGenerator> blockModel = null;
protected RenderLayerEnum renderLayer = RenderLayerEnum.SOLID;

public BlockDataSettings(Identifier id0, Block block0) {
super(id0, block0.asItem());
block = block0;
}

@SafeVarargs
public final T blockTags(TagKey<Block>... tags) {
blockTags.addAll(List.of(tags));
return (T) this;
}

public Block getBlock() {
return block;
}

public T renderLayer(RenderLayerEnum renderLayer) {
this.renderLayer = renderLayer;
return (T) this;
}

public RenderLayerEnum getRenderLayer() {
return renderLayer;
}

public List<TagKey<Block>> getBlockTags() {
return blockTags;
}

public Consumer<BlockStateModelGenerator> getBlockModel() {
if (blockModel == null) {
return generator -> generator.registerSimpleCubeAll(block);
}
return blockModel;
}

public T blockModel(Consumer<BlockStateModelGenerator> modelGeneratorConsumer) {
blockModel = modelGeneratorConsumer;
return (T) this;
}

public T blockModelAxisRotated(TexturedModel.Factory modelFactory) {
blockModel = generator -> generator.registerAxisRotated(block, modelFactory);
return (T) this;
}

public T blockModelParented(Block parent) {
blockModel = generator -> generator.registerParented(block, parent);
return (T) this;
}

public T blockModelChair() {
blockModel = generator -> {
Identifier identifier = TEMPLATE_CHAIR.upload(block, generator.modelCollector);
generator.blockStateCollector.accept(BlockStateModelGenerator.createSingletonBlockState(block, identifier)
.coordinate(BlockStateModelGenerator.createNorthDefaultHorizontalRotationStates()));
};
return (T) this;
}

public T blockModelParented(Identifier parent) {
blockModel = generator -> {
generator.blockStateCollector.accept(VariantsBlockStateSupplier.create(block, BlockStateVariant.create()
.put(VariantSettings.MODEL, parent)));
generator.registerParentedItemModel(block, parent);
};
return (T) this;
}

public T blockModelParentedForWaxed() {
if (id.getPath()
.contains("waxed_")) {
return blockModelParented(new Identifier(id.getNamespace(), id.getPath()
.replace("waxed_", "block/")));
}

return (T) this;
}

@Override
public String getTranslationKey() {
return block.getTranslationKey();
}

public T copperHelper() {
blockModelParentedForWaxed();
return recipeWaxing();
}

@Override
public T itemModel(Model model) {
throw new UnsupportedOperationException("BlockDataSettings cannot have an item model");
}

@Override
public Consumer<ItemModelGenerator> getItemModel() {
throw new UnsupportedOperationException("BlockDataSettings cannot have an item model");
}

public enum RenderLayerEnum {
SOLID,
CUTOUT,
TRANSLUCENT
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package net.rotgruengelb.sweetofhomes.datagen.settings;

import net.minecraft.util.Identifier;
import net.rotgruengelb.sweetofhomes.util.Util;

@SuppressWarnings("unchecked")
public class DataSettings<S extends DataSettings<?>> {

protected final Identifier id;
protected String translation = null;
protected String translationKey = null;
protected boolean shouldTranslate = true;

public DataSettings(Identifier id0) {
id = id0;
}

public S translation(String translation0) {
translation = translation0;
return (S) this;
}

public S translationKey(String translationKey0) {
translationKey = translationKey0;
return (S) this;
}

public S shouldTranslate(boolean shouldTranslate0) {
shouldTranslate = shouldTranslate0;
return (S) this;
}

public boolean shouldTranslate() {
return shouldTranslate;
}

public String getTranslation() {
if (translation == null) {
return Util.convertSnakeCaseToTitleCase(id.getPath());
}
return translation;
}

public String getTranslationKey() {
if (translationKey == null) {
return id.toTranslationKey();
}
return translationKey;
}

public Identifier getId() {
return id;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package net.rotgruengelb.sweetofhomes.datagen.settings;

import net.minecraft.data.client.ItemModelGenerator;
import net.minecraft.data.client.Model;
import net.minecraft.data.client.Models;
import net.minecraft.data.server.recipe.RecipeExporter;
import net.minecraft.data.server.recipe.RecipeProvider;
import net.minecraft.item.Item;
import net.minecraft.recipe.book.RecipeCategory;
import net.minecraft.registry.Registries;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.util.Identifier;
import net.rotgruengelb.sweetofhomes.datagen.ModRecipeProvider;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;

@SuppressWarnings("unchecked")
public class ItemDataSettings<T extends ItemDataSettings<?>> extends DataSettings<T> {

protected final Item item;
protected final List<TagKey<Item>> itemTags = new ArrayList<>();
protected final List<Consumer<RecipeExporter>> recipes = new ArrayList<>();
protected Consumer<ItemModelGenerator> itemModel = null;

public ItemDataSettings(Identifier id0) {
super(id0);
item = null;
}

public ItemDataSettings(Identifier id0, Item item0) {
super(id0);
item = item0;
}

public Item getItem() {
return item;
}

public List<TagKey<Item>> getItemTags() {
return itemTags;
}

public List<Consumer<RecipeExporter>> getRecipes() {
return recipes;
}

public Consumer<ItemModelGenerator> getItemModel() {
if (itemModel == null) {
return generator -> generator.register(item, Models.GENERATED);
}
return itemModel;
}

public T itemModel(Model model) {
itemModel = generator -> generator.register(item, model);
return (T) this;
}

@Override
public String getTranslationKey() {
if (item == null) {
return id.toTranslationKey();
}
return item.getTranslationKey();
}

@SafeVarargs
public final T itemTags(TagKey<Item>... tags) {
itemTags.addAll(List.of(tags));
return (T) this;
}

@SafeVarargs
public final T itemTagsIf(boolean b, TagKey<Item>... tags) {
if (!b) { return (T) this; }
itemTags.addAll(List.of(tags));
return (T) this;
}

public T recipe2x2ABBA(RecipeCategory category, Item inputA, Item inputB, int count) {
recipes.add(exporter -> ModRecipeProvider.offer2x2ABBARecipe(exporter, category, item, inputA, inputB, count));
return (T) this;
}

public T recipeWaxing() {
if (id.getPath()
.contains("waxed_")) {
recipes.add(exporter -> ModRecipeProvider.offerWaxingRecipe(exporter, RecipeCategory.BUILDING_BLOCKS, item, Registries.ITEM.get(new Identifier(id.getNamespace(), id.getPath()
.replace("waxed_", "")))));
}
return (T) this;
}

public T recipe3x3Pillar(RecipeCategory category, Item inputCore, Item inputSide, int count) {
recipes.add(exporter -> ModRecipeProvider.offer3x3PillarRecipe(exporter, category, item, inputCore, inputSide, count));
return (T) this;
}

public T recipe2x2Compacting(RecipeCategory category, Item input, int count) {
recipes.add(exporter -> ModRecipeProvider.offer2x2CompactingRecipe(exporter, category, item, input, count));
return (T) this;
}

public T recipeReversibleCompacting(RecipeCategory categoryBoth, Item conpactItem) {
recipes.add(exporter -> RecipeProvider.offerReversibleCompactingRecipes(exporter, categoryBoth, item, categoryBoth, conpactItem));
return (T) this;
}

public T recipeReversibleCompacting(RecipeCategory reverseCategory, Item conpactItem, RecipeCategory compactingCategory) {
recipes.add(exporter -> RecipeProvider.offerReversibleCompactingRecipes(exporter, reverseCategory, item, compactingCategory, conpactItem));
return (T) this;
}

public T recipeStonecutting(RecipeCategory category, Item base, int count) {
recipes.add(exporter -> RecipeProvider.offerStonecuttingRecipe(exporter, category, item, base, count));
return (T) this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package net.rotgruengelb.sweetofhomes.datagen.settings;

import net.minecraft.util.Identifier;

public class TagDataSettings<S extends TagDataSettings<?>> extends DataSettings<S> {

public final String tagType;

public TagDataSettings(Identifier id0, String tagType0) {
super(id0);
tagType = tagType0;
}

public TagDataSettings(Identifier id0) {
super(id0);
tagType = "block";
}

@Override
public String getTranslationKey() {
return String.format("tag.%s.%s.%s", tagType, id.getNamespace(), id.getPath()
.replace('/', '.'));
}
}
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.rotgruengelb.sweetofhomes.world.HomesGameRules;
import net.rotgruengelb.sweetofhomes.world.SoHGameRules;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;
@@ -42,7 +42,7 @@ private static <T> T cycle(Iterable<T> elements, @Nullable T current, boolean in
private static void sendMessage(PlayerEntity player, Text message) {
if (player.getWorld()
.getGameRules()
.getBoolean(HomesGameRules.SHOW_COPPER_WRENCH_MESSAGES)) {
.getBoolean(SoHGameRules.SHOW_COPPER_WRENCH_MESSAGES)) {
((ServerPlayerEntity) player).sendMessageToClient(message, true);
}
}
52 changes: 0 additions & 52 deletions src/main/java/net/rotgruengelb/sweetofhomes/item/HomesItems.java

This file was deleted.

46 changes: 46 additions & 0 deletions src/main/java/net/rotgruengelb/sweetofhomes/item/SoHItems.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package net.rotgruengelb.sweetofhomes.item;

import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.tag.convention.v1.ConventionalItemTags;
import net.minecraft.data.client.Model;
import net.minecraft.data.client.Models;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.recipe.book.RecipeCategory;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.util.Identifier;
import net.rotgruengelb.sweetofhomes.SweetOfHomes;
import net.rotgruengelb.sweetofhomes.datagen.settings.ItemDataSettings;

import static net.rotgruengelb.sweetofhomes.SweetOfHomes.id;
import static net.rotgruengelb.sweetofhomes.datagen.SoHDataGenerator.dataSettings;

public class SoHItems {

public static final Item COPPER_WRENCH = item("copper_wrench", new CopperWrenchItem(new FabricItemSettings().maxCount(1)), Models.HANDHELD);
public static final Item COPPER_NUGGET = copperNugget("copper_nugget", new Item(new FabricItemSettings()), ConventionalItemTags.NUGGETS);

@SafeVarargs
private static Item item(String name, Item item, Model model, TagKey<Item>... tags) {
item = Registry.register(Registries.ITEM, new Identifier(SweetOfHomes.MOD_ID, name), item);
return dataSettings(new ItemDataSettings<>(id(name), item).itemTags(tags).itemModel(model));
}

@SafeVarargs
private static Item copperNugget(String name, Item item, TagKey<Item>... tags) {
item = Registry.register(Registries.ITEM, new Identifier(SweetOfHomes.MOD_ID, name), item);
return dataSettings(new ItemDataSettings<>(id(name), item).itemTags(tags)
.recipeReversibleCompacting(RecipeCategory.MISC, Items.COPPER_INGOT));
}

public static void registerModItems() {
SweetOfHomes.LOGGER.debug("Registering SoHItems for " + SweetOfHomes.MOD_ID);
}

private static Item dataSettings(ItemDataSettings<?> blockDataSettings) {
dataSettings.add(blockDataSettings);
return blockDataSettings.getItem();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package net.rotgruengelb.sweetofhomes.registry.tag;

import net.minecraft.block.Block;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.util.Identifier;
import net.rotgruengelb.sweetofhomes.SweetOfHomes;
import net.rotgruengelb.sweetofhomes.datagen.SoHDataGenerator;
import net.rotgruengelb.sweetofhomes.datagen.settings.TagDataSettings;

public class SoHBlockTags {
public static final TagKey<Block> ABOVE_BYPASSES_SEAT_CHECK = createTagKey(RegistryKeys.BLOCK, "above_bypasses_seat_check");

private static <Y> TagKey<Y> createTagKey(RegistryKey<? extends Registry<Y>> registryKey, String path) {
Identifier id = new Identifier(SweetOfHomes.MOD_ID, path);
TagKey<Y> tagKey = TagKey.of(registryKey, id);

SoHDataGenerator.dataSettings.add(new TagDataSettings<>(id, "block"));
return tagKey;
}

public static void registerModBlockTags() {
SweetOfHomes.LOGGER.debug("Registering SoHBlockTags for " + SweetOfHomes.MOD_ID);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package net.rotgruengelb.sweetofhomes.registry.tag;

import net.minecraft.item.Item;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.util.Identifier;
import net.rotgruengelb.sweetofhomes.SweetOfHomes;
import net.rotgruengelb.sweetofhomes.datagen.SoHDataGenerator;
import net.rotgruengelb.sweetofhomes.datagen.settings.TagDataSettings;

public class SoHItemTags {
public static final TagKey<Item> WOODEN_PILLARS = createTagKey("wooden_pillars");
public static final TagKey<Item> CHAIRS = createTagKey("chairs");

private static TagKey<Item> createTagKey(String path) {
Identifier id = new Identifier(SweetOfHomes.MOD_ID, path);
TagKey<Item> tagKey = TagKey.of(RegistryKeys.ITEM, id);

SoHDataGenerator.dataSettings.add(new TagDataSettings<>(id, "item"));
return tagKey;
}

public static void registerModItemTags() {
SweetOfHomes.LOGGER.debug("Registering SoHItemTags for " + SweetOfHomes.MOD_ID);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package net.rotgruengelb.sweetofhomes.registry.tag;

import net.minecraft.entity.EntityType;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.util.Identifier;
import net.rotgruengelb.sweetofhomes.SweetOfHomes;
import net.rotgruengelb.sweetofhomes.datagen.SoHDataGenerator;
import net.rotgruengelb.sweetofhomes.datagen.settings.TagDataSettings;

import java.util.Objects;

public class SoHTags {

private static <Y> TagKey<Y> createTagKey(RegistryKey<? extends Registry<Y>> registryKey, String path, String tagType) {
Identifier id = new Identifier(SweetOfHomes.MOD_ID, path);
TagKey<Y> tagKey = TagKey.of(registryKey, id);

SoHDataGenerator.dataSettings.add(new TagDataSettings<>(id, tagType).shouldTranslate(!Objects.equals(tagType, "entity")));
return tagKey;
}

public static void registerModTags() {
SweetOfHomes.LOGGER.debug("Registering SoHTags for " + SweetOfHomes.MOD_ID);
ENTITIES.registerModEntityTags();
SoHBlockTags.registerModBlockTags();
SoHItemTags.registerModItemTags();
}

public static class ENTITIES {
public static final TagKey<EntityType<?>> CAN_SIT_IN_SEATS = createTagKey(RegistryKeys.ENTITY_TYPE, "can_sit_in_seats", "entity");

public static void registerModEntityTags() {
SweetOfHomes.LOGGER.debug("Registering SoHTags.ENTITIES for " + SweetOfHomes.MOD_ID);
}
}
}
25 changes: 25 additions & 0 deletions src/main/java/net/rotgruengelb/sweetofhomes/util/Util.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package net.rotgruengelb.sweetofhomes.util;

public class Util {

public static String convertSnakeCaseToTitleCase(String snakeCaseText) {
String[] words = snakeCaseText.split("_");

StringBuilder titleCaseText = new StringBuilder();

for (String word : words) {
if (!word.isEmpty()) {
titleCaseText.append(Character.toUpperCase(word.charAt(0)))
.append(word.substring(1)
.toLowerCase())
.append(" ");
}
}
return titleCaseText.toString()
.trim();
}

public static boolean shouldMarkAsNonFlammable(String string) {
return string.contains("crimson") || string.contains("warped");
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -5,11 +5,11 @@
import net.minecraft.world.GameRules;
import net.rotgruengelb.sweetofhomes.SweetOfHomes;

public class HomesGameRules {
public class SoHGameRules {

public static final GameRules.Key<GameRules.BooleanRule> SHOW_COPPER_WRENCH_MESSAGES = GameRuleRegistry.register(SweetOfHomes.MOD_ID + ".showCopperWrenchMessages", GameRules.Category.PLAYER, GameRuleFactory.createBooleanRule(false));

public static void registerModGameRules() {
SweetOfHomes.LOGGER.debug("Registering HomesGameRules for " + SweetOfHomes.MOD_ID);
SweetOfHomes.LOGGER.debug("Registering SoHGameRules for " + SweetOfHomes.MOD_ID);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"credit": "Made with Blockbench",
"render_type": "minecraft:cutout",
"texture_size": [64, 64],
"textures": {
"particle": "#texture"
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@
"net.rotgruengelb.sweetofhomes.SweetOfHomesClient"
],
"fabric-datagen": [
"net.rotgruengelb.sweetofhomes.datagen.SweetOfHomesDataGenerator"
"net.rotgruengelb.sweetofhomes.datagen.SoHDataGenerator"
]
},
"mixins": [

0 comments on commit 6f52613

Please sign in to comment.