-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. New Datagen System using DataSettings
2. Homes* -> SoH* 3. Recipe Fixes
1 parent
59df8eb
commit 6f52613
Showing
29 changed files
with
823 additions
and
434 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 6 additions & 8 deletions
14
src/client/java/net/rotgruengelb/sweetofhomes/SweetOfHomesClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/client/java/net/rotgruengelb/sweetofhomes/client/render/RenderLayerHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 0 additions & 134 deletions
134
src/main/java/net/rotgruengelb/sweetofhomes/block/HomesBlocks.java
This file was deleted.
Oops, something went wrong.
75 changes: 0 additions & 75 deletions
75
src/main/java/net/rotgruengelb/sweetofhomes/block/SHomesBlocksCollections.java
This file was deleted.
Oops, something went wrong.
185 changes: 185 additions & 0 deletions
185
src/main/java/net/rotgruengelb/sweetofhomes/block/SoHBlocks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
src/main/java/net/rotgruengelb/sweetofhomes/datagen/settings/BlockDataSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
src/main/java/net/rotgruengelb/sweetofhomes/datagen/settings/DataSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
120 changes: 120 additions & 0 deletions
120
src/main/java/net/rotgruengelb/sweetofhomes/datagen/settings/ItemDataSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/net/rotgruengelb/sweetofhomes/datagen/settings/TagDataSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('/', '.')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 0 additions & 52 deletions
52
src/main/java/net/rotgruengelb/sweetofhomes/item/HomesItems.java
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
src/main/java/net/rotgruengelb/sweetofhomes/item/SoHItems.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/net/rotgruengelb/sweetofhomes/registry/tag/SoHBlockTags.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/net/rotgruengelb/sweetofhomes/registry/tag/SoHItemTags.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/net/rotgruengelb/sweetofhomes/registry/tag/SoHTags.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
25
src/main/java/net/rotgruengelb/sweetofhomes/util/Util.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |
19 changes: 0 additions & 19 deletions
19
src/main/java/net/rotgruengelb/sweetofhomes/util/tag/HomesTags.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/main/resources/assets/sweetofhomes/models/block/template_chair.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters