diff --git a/.gitignore b/.gitignore index 1aeaf57..39db14c 100755 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ local.properties *-autosave.kra *.kra~ /gradle/ +/src/generated/ diff --git a/src/main/java/fr/adrien1106/reframedtemplates/block/TemplateSlabBlock.java b/src/main/java/fr/adrien1106/reframedtemplates/block/TemplateSlabBlock.java index 44860ba..e7bd7fc 100644 --- a/src/main/java/fr/adrien1106/reframedtemplates/block/TemplateSlabBlock.java +++ b/src/main/java/fr/adrien1106/reframedtemplates/block/TemplateSlabBlock.java @@ -1,6 +1,8 @@ package fr.adrien1106.reframedtemplates.block; +import fr.adrien1106.reframedtemplates.generator.MultipartBlockStateProvider; import net.minecraft.block.*; +import net.minecraft.data.client.MultipartBlockStateSupplier; import net.minecraft.item.ItemPlacementContext; import net.minecraft.state.StateManager; import net.minecraft.state.property.Properties; @@ -11,7 +13,7 @@ import net.minecraft.util.shape.VoxelShapes; import net.minecraft.world.BlockView; import org.jetbrains.annotations.Nullable; -public class TemplateSlabBlock extends WaterloggableTemplateBlock implements BlockEntityProvider, Waterloggable { +public class TemplateSlabBlock extends WaterloggableTemplateBlock implements MultipartBlockStateProvider { private static final VoxelShape DOWN = VoxelShapes.cuboid(0f, 0f, 0f, 1f, 0.5f, 1f); private static final VoxelShape UP = VoxelShapes.cuboid(0f, 0.5f, 0f, 1f, 1f, 1f); @@ -47,4 +49,9 @@ public class TemplateSlabBlock extends WaterloggableTemplateBlock implements Blo case WEST -> WEST; }; } + + @Override + public MultipartBlockStateSupplier getMultipart() { + return null; + } } diff --git a/src/main/java/fr/adrien1106/reframedtemplates/generator/GBlockLoot.java b/src/main/java/fr/adrien1106/reframedtemplates/generator/GBlockLoot.java new file mode 100644 index 0000000..258ad83 --- /dev/null +++ b/src/main/java/fr/adrien1106/reframedtemplates/generator/GBlockLoot.java @@ -0,0 +1,17 @@ +package fr.adrien1106.reframedtemplates.generator; + +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootTableProvider; +import net.minecraft.registry.Registries; + +public class GBlockLoot extends FabricBlockLootTableProvider { + + protected GBlockLoot(FabricDataOutput data_output) { + super(data_output); + } + + @Override + public void generate() { + Generator.BLOCKS.forEach(block -> addDrop(block, Registries.ITEM.get(Registries.BLOCK.getId(block)))); + } +} diff --git a/src/main/java/fr/adrien1106/reframedtemplates/generator/GBlockstate.java b/src/main/java/fr/adrien1106/reframedtemplates/generator/GBlockstate.java new file mode 100644 index 0000000..1bab3f4 --- /dev/null +++ b/src/main/java/fr/adrien1106/reframedtemplates/generator/GBlockstate.java @@ -0,0 +1,63 @@ +package fr.adrien1106.reframedtemplates.generator; + +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricModelProvider; +import net.minecraft.block.CandleBlock; +import net.minecraft.block.DoorBlock; +import net.minecraft.block.LeverBlock; +import net.minecraft.block.PaneBlock; +import net.minecraft.data.client.*; +import net.minecraft.registry.Registries; +import net.minecraft.state.property.Property; +import net.minecraft.util.Identifier; + +import java.util.Iterator; +import java.util.Objects; +import java.util.stream.Stream; + +public class GBlockstate extends FabricModelProvider { + + public GBlockstate(FabricDataOutput output) { + super(output); + } + + @Override + public void generateBlockStateModels(BlockStateModelGenerator model_generator) { // TODO Find out smth for items + Generator.BLOCKS + .forEach(block -> { + Identifier block_id = Registries.BLOCK.getId(block); + model_generator.excludeFromSimpleItemModelGeneration(block); +// model_generator.registerParentedItemModel( +// block.asItem(), +// block_id.withSuffixedPath("_special") +// ); + }); + Generator.BLOCKS.stream() + .map(block -> block instanceof MultipartBlockStateProvider multipart_block ? multipart_block.getMultipart(): null) + .filter(Objects::nonNull) + .forEach(model_generator.blockStateCollector); + } + + @Override + public void generateItemModels(ItemModelGenerator itemModelGenerator) {} + + public static BlockStateVariant variant(Identifier model, boolean uv_lock, VariantSettings.Rotation x, VariantSettings.Rotation y) { + BlockStateVariant variant = BlockStateVariant.create().put(VariantSettings.MODEL, model); + if (uv_lock) variant.put(VariantSettings.UVLOCK, uv_lock); + if (!x.equals(VariantSettings.Rotation.R0)) variant.put(VariantSettings.X, x); + if (!y.equals(VariantSettings.Rotation.R0)) variant.put(VariantSettings.Y, y); + return variant; + } + + public static > When when(Property property_1, T value_1) { + return When.create().set(property_1, value_1); + } + + public static , U extends Comparable> When when(Property property_1, T value_1, Property property_2, U value_2) { + return When.allOf(when(property_1, value_1), when(property_2, value_2)); + } + + public static , U extends Comparable, V extends Comparable> When when(Property property_1, T value_1, Property property_2, U value_2, Property property_3, V value_3) { + return When.allOf(when(property_1, value_1), when(property_2, value_2), when(property_3, value_3)); + } +} \ No newline at end of file diff --git a/src/main/java/fr/adrien1106/reframedtemplates/generator/Generator.java b/src/main/java/fr/adrien1106/reframedtemplates/generator/Generator.java new file mode 100644 index 0000000..c89c5ba --- /dev/null +++ b/src/main/java/fr/adrien1106/reframedtemplates/generator/Generator.java @@ -0,0 +1,23 @@ +package fr.adrien1106.reframedtemplates.generator; + +import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint; +import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; +import net.minecraft.block.Block; + +import java.util.List; + +import static fr.adrien1106.reframedtemplates.Templates.*; + +public class Generator implements DataGeneratorEntrypoint { + + /** + * missing DOOR, IRON_DOOR, CANDLE + */ + public static List BLOCKS = List.of(CUBE, STAIRS, SLAB, POST, FENCE, FENCE_GATE, TRAPDOOR, IRON_TRAPDOOR, PRESSURE_PLATE, BUTTON, LEVER, WALL, CARPET, PANE); + @Override + public void onInitializeDataGenerator(FabricDataGenerator data_generator) { + FabricDataGenerator.Pack myPack = data_generator.createPack(); + myPack.addProvider(GBlockLoot::new); + myPack.addProvider(GBlockstate::new); + } +} diff --git a/src/main/java/fr/adrien1106/reframedtemplates/generator/MultipartBlockStateProvider.java b/src/main/java/fr/adrien1106/reframedtemplates/generator/MultipartBlockStateProvider.java new file mode 100644 index 0000000..c347e57 --- /dev/null +++ b/src/main/java/fr/adrien1106/reframedtemplates/generator/MultipartBlockStateProvider.java @@ -0,0 +1,7 @@ +package fr.adrien1106.reframedtemplates.generator; + +import net.minecraft.data.client.MultipartBlockStateSupplier; + +public interface MultipartBlockStateProvider { + MultipartBlockStateSupplier getMultipart(); +} diff --git a/src/main/resources/assets/reframedtemplates/blockstates/stairs.json b/src/main/resources/assets/reframedtemplates/blockstates/stairs.json deleted file mode 100644 index bc3a5d0..0000000 --- a/src/main/resources/assets/reframedtemplates/blockstates/stairs.json +++ /dev/null @@ -1,209 +0,0 @@ -{ - "variants": { - "facing=east,half=bottom,shape=inner_left": { - "model": "reframedtemplates:inner_stairs_special", - "uvlock": true, - "y": 270 - }, - "facing=east,half=bottom,shape=inner_right": { - "model": "reframedtemplates:inner_stairs_special" - }, - "facing=east,half=bottom,shape=outer_left": { - "model": "reframedtemplates:outer_stairs_special", - "uvlock": true, - "y": 270 - }, - "facing=east,half=bottom,shape=outer_right": { - "model": "reframedtemplates:outer_stairs_special" - }, - "facing=east,half=bottom,shape=straight": { - "model": "reframedtemplates:stairs_special" - }, - "facing=east,half=top,shape=inner_left": { - "model": "reframedtemplates:inner_stairs_special", - "uvlock": true, - "x": 180 - }, - "facing=east,half=top,shape=inner_right": { - "model": "reframedtemplates:inner_stairs_special", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=east,half=top,shape=outer_left": { - "model": "reframedtemplates:outer_stairs_special", - "uvlock": true, - "x": 180 - }, - "facing=east,half=top,shape=outer_right": { - "model": "reframedtemplates:outer_stairs_special", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=east,half=top,shape=straight": { - "model": "reframedtemplates:stairs_special", - "uvlock": true, - "x": 180 - }, - "facing=north,half=bottom,shape=inner_left": { - "model": "reframedtemplates:inner_stairs_special", - "uvlock": true, - "y": 180 - }, - "facing=north,half=bottom,shape=inner_right": { - "model": "reframedtemplates:inner_stairs_special", - "uvlock": true, - "y": 270 - }, - "facing=north,half=bottom,shape=outer_left": { - "model": "reframedtemplates:outer_stairs_special", - "uvlock": true, - "y": 180 - }, - "facing=north,half=bottom,shape=outer_right": { - "model": "reframedtemplates:outer_stairs_special", - "uvlock": true, - "y": 270 - }, - "facing=north,half=bottom,shape=straight": { - "model": "reframedtemplates:stairs_special", - "uvlock": true, - "y": 270 - }, - "facing=north,half=top,shape=inner_left": { - "model": "reframedtemplates:inner_stairs_special", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=north,half=top,shape=inner_right": { - "model": "reframedtemplates:inner_stairs_special", - "uvlock": true, - "x": 180 - }, - "facing=north,half=top,shape=outer_left": { - "model": "reframedtemplates:outer_stairs_special", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=north,half=top,shape=outer_right": { - "model": "reframedtemplates:outer_stairs_special", - "uvlock": true, - "x": 180 - }, - "facing=north,half=top,shape=straight": { - "model": "reframedtemplates:stairs_special", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=south,half=bottom,shape=inner_left": { - "model": "reframedtemplates:inner_stairs_special" - }, - "facing=south,half=bottom,shape=inner_right": { - "model": "reframedtemplates:inner_stairs_special", - "uvlock": true, - "y": 90 - }, - "facing=south,half=bottom,shape=outer_left": { - "model": "reframedtemplates:outer_stairs_special" - }, - "facing=south,half=bottom,shape=outer_right": { - "model": "reframedtemplates:outer_stairs_special", - "uvlock": true, - "y": 90 - }, - "facing=south,half=bottom,shape=straight": { - "model": "reframedtemplates:stairs_special", - "uvlock": true, - "y": 90 - }, - "facing=south,half=top,shape=inner_left": { - "model": "reframedtemplates:inner_stairs_special", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=south,half=top,shape=inner_right": { - "model": "reframedtemplates:inner_stairs_special", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=south,half=top,shape=outer_left": { - "model": "reframedtemplates:outer_stairs_special", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=south,half=top,shape=outer_right": { - "model": "reframedtemplates:outer_stairs_special", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=south,half=top,shape=straight": { - "model": "reframedtemplates:stairs_special", - "uvlock": true, - "x": 180, - "y": 90 - }, - "facing=west,half=bottom,shape=inner_left": { - "model": "reframedtemplates:inner_stairs_special", - "uvlock": true, - "y": 90 - }, - "facing=west,half=bottom,shape=inner_right": { - "model": "reframedtemplates:inner_stairs_special", - "uvlock": true, - "y": 180 - }, - "facing=west,half=bottom,shape=outer_left": { - "model": "reframedtemplates:outer_stairs_special", - "uvlock": true, - "y": 90 - }, - "facing=west,half=bottom,shape=outer_right": { - "model": "reframedtemplates:outer_stairs_special", - "uvlock": true, - "y": 180 - }, - "facing=west,half=bottom,shape=straight": { - "model": "reframedtemplates:stairs_special", - "uvlock": true, - "y": 180 - }, - "facing=west,half=top,shape=inner_left": { - "model": "reframedtemplates:inner_stairs_special", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=west,half=top,shape=inner_right": { - "model": "reframedtemplates:inner_stairs_special", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=west,half=top,shape=outer_left": { - "model": "reframedtemplates:outer_stairs_special", - "uvlock": true, - "x": 180, - "y": 180 - }, - "facing=west,half=top,shape=outer_right": { - "model": "reframedtemplates:outer_stairs_special", - "uvlock": true, - "x": 180, - "y": 270 - }, - "facing=west,half=top,shape=straight": { - "model": "reframedtemplates:stairs_special", - "uvlock": true, - "x": 180, - "y": 180 - } - } -} \ No newline at end of file diff --git a/src/main/resources/data/reframedtemplates/loot_tables/blocks/button.json b/src/main/resources/data/reframedtemplates/loot_tables/blocks/button.json deleted file mode 100644 index f9bf564..0000000 --- a/src/main/resources/data/reframedtemplates/loot_tables/blocks/button.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "rolls": 1, - "entries": [ - { - "type": "minecraft:item", - "name": "reframedtemplates:button" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ] - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/reframedtemplates/loot_tables/blocks/carpet.json b/src/main/resources/data/reframedtemplates/loot_tables/blocks/carpet.json deleted file mode 100644 index 1611a2a..0000000 --- a/src/main/resources/data/reframedtemplates/loot_tables/blocks/carpet.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "rolls": 1, - "entries": [ - { - "type": "minecraft:item", - "name": "reframedtemplates:carpet" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ] - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/reframedtemplates/loot_tables/blocks/cube.json b/src/main/resources/data/reframedtemplates/loot_tables/blocks/cube.json deleted file mode 100644 index dee242b..0000000 --- a/src/main/resources/data/reframedtemplates/loot_tables/blocks/cube.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "rolls": 1, - "entries": [ - { - "type": "minecraft:item", - "name": "reframedtemplates:cube" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ] - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/reframedtemplates/loot_tables/blocks/fence.json b/src/main/resources/data/reframedtemplates/loot_tables/blocks/fence.json deleted file mode 100644 index 93a5455..0000000 --- a/src/main/resources/data/reframedtemplates/loot_tables/blocks/fence.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "rolls": 1, - "entries": [ - { - "type": "minecraft:item", - "name": "reframedtemplates:fence" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ] - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/reframedtemplates/loot_tables/blocks/fence_gate.json b/src/main/resources/data/reframedtemplates/loot_tables/blocks/fence_gate.json deleted file mode 100644 index 7ceaab1..0000000 --- a/src/main/resources/data/reframedtemplates/loot_tables/blocks/fence_gate.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "rolls": 1, - "entries": [ - { - "type": "minecraft:item", - "name": "reframedtemplates:fence_gate" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ] - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/reframedtemplates/loot_tables/blocks/iron_trapdoor.json b/src/main/resources/data/reframedtemplates/loot_tables/blocks/iron_trapdoor.json deleted file mode 100644 index 365f465..0000000 --- a/src/main/resources/data/reframedtemplates/loot_tables/blocks/iron_trapdoor.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "rolls": 1, - "entries": [ - { - "type": "minecraft:item", - "name": "reframedtemplates:iron_trapdoor" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ] - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/reframedtemplates/loot_tables/blocks/lever.json b/src/main/resources/data/reframedtemplates/loot_tables/blocks/lever.json deleted file mode 100644 index 128ddc6..0000000 --- a/src/main/resources/data/reframedtemplates/loot_tables/blocks/lever.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "rolls": 1, - "entries": [ - { - "type": "minecraft:item", - "name": "reframedtemplates:lever" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ] - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/reframedtemplates/loot_tables/blocks/pane.json b/src/main/resources/data/reframedtemplates/loot_tables/blocks/pane.json deleted file mode 100644 index a13a8d8..0000000 --- a/src/main/resources/data/reframedtemplates/loot_tables/blocks/pane.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "rolls": 1, - "entries": [ - { - "type": "minecraft:item", - "name": "reframedtemplates:pane" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ] - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/reframedtemplates/loot_tables/blocks/post.json b/src/main/resources/data/reframedtemplates/loot_tables/blocks/post.json deleted file mode 100644 index 09944dc..0000000 --- a/src/main/resources/data/reframedtemplates/loot_tables/blocks/post.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "rolls": 1, - "entries": [ - { - "type": "minecraft:item", - "name": "reframedtemplates:post" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ] - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/reframedtemplates/loot_tables/blocks/pressure_plate.json b/src/main/resources/data/reframedtemplates/loot_tables/blocks/pressure_plate.json deleted file mode 100644 index b043c27..0000000 --- a/src/main/resources/data/reframedtemplates/loot_tables/blocks/pressure_plate.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "rolls": 1, - "entries": [ - { - "type": "minecraft:item", - "name": "reframedtemplates:pressure_plate" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ] - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/reframedtemplates/loot_tables/blocks/slab.json b/src/main/resources/data/reframedtemplates/loot_tables/blocks/slab.json deleted file mode 100644 index ea48143..0000000 --- a/src/main/resources/data/reframedtemplates/loot_tables/blocks/slab.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "rolls": 1, - "entries": [ - { - "type": "minecraft:item", - "name": "reframedtemplates:slab" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ] - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/reframedtemplates/loot_tables/blocks/stairs.json b/src/main/resources/data/reframedtemplates/loot_tables/blocks/stairs.json deleted file mode 100644 index 17a6af0..0000000 --- a/src/main/resources/data/reframedtemplates/loot_tables/blocks/stairs.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "rolls": 1, - "entries": [ - { - "type": "minecraft:item", - "name": "reframedtemplates:stairs" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ] - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/reframedtemplates/loot_tables/blocks/trapdoor.json b/src/main/resources/data/reframedtemplates/loot_tables/blocks/trapdoor.json deleted file mode 100644 index bd30565..0000000 --- a/src/main/resources/data/reframedtemplates/loot_tables/blocks/trapdoor.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "rolls": 1, - "entries": [ - { - "type": "minecraft:item", - "name": "reframedtemplates:trapdoor" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ] - } - ] -} \ No newline at end of file diff --git a/src/main/resources/data/reframedtemplates/loot_tables/blocks/wall.json b/src/main/resources/data/reframedtemplates/loot_tables/blocks/wall.json deleted file mode 100644 index 23cf712..0000000 --- a/src/main/resources/data/reframedtemplates/loot_tables/blocks/wall.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "rolls": 1, - "entries": [ - { - "type": "minecraft:item", - "name": "reframedtemplates:wall" - } - ], - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ] - } - ] -} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 77dc5c8..3926f82 100755 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -12,6 +12,9 @@ "icon": "assets/framed-templates-icon.png", "environment": "*", "entrypoints": { + "fabric-datagen": [ + "fr.adrien1106.reframedtemplates.generator.Generator" + ], "main": [ "fr.adrien1106.reframedtemplates.Templates" ],