added some datagen

This commit is contained in:
Adrien1106 2024-02-13 16:54:48 +01:00
parent f0d72ff8c8
commit a788176ffc
22 changed files with 122 additions and 476 deletions

1
.gitignore vendored
View File

@ -33,3 +33,4 @@ local.properties
*-autosave.kra *-autosave.kra
*.kra~ *.kra~
/gradle/ /gradle/
/src/generated/

View File

@ -1,6 +1,8 @@
package fr.adrien1106.reframedtemplates.block; package fr.adrien1106.reframedtemplates.block;
import fr.adrien1106.reframedtemplates.generator.MultipartBlockStateProvider;
import net.minecraft.block.*; import net.minecraft.block.*;
import net.minecraft.data.client.MultipartBlockStateSupplier;
import net.minecraft.item.ItemPlacementContext; import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager; import net.minecraft.state.StateManager;
import net.minecraft.state.property.Properties; import net.minecraft.state.property.Properties;
@ -11,7 +13,7 @@ import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
import org.jetbrains.annotations.Nullable; 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 DOWN = VoxelShapes.cuboid(0f, 0f, 0f, 1f, 0.5f, 1f);
private static final VoxelShape UP = VoxelShapes.cuboid(0f, 0.5f, 0f, 1f, 1f, 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; case WEST -> WEST;
}; };
} }
@Override
public MultipartBlockStateSupplier getMultipart() {
return null;
}
} }

View File

@ -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))));
}
}

View File

@ -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 <T extends Comparable<T>> When when(Property<T> property_1, T value_1) {
return When.create().set(property_1, value_1);
}
public static <T extends Comparable<T>, U extends Comparable<U>> When when(Property<T> property_1, T value_1, Property<U> property_2, U value_2) {
return When.allOf(when(property_1, value_1), when(property_2, value_2));
}
public static <T extends Comparable<T>, U extends Comparable<U>, V extends Comparable<V>> When when(Property<T> property_1, T value_1, Property<U> property_2, U value_2, Property<V> property_3, V value_3) {
return When.allOf(when(property_1, value_1), when(property_2, value_2), when(property_3, value_3));
}
}

View File

@ -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<Block> 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);
}
}

View File

@ -0,0 +1,7 @@
package fr.adrien1106.reframedtemplates.generator;
import net.minecraft.data.client.MultipartBlockStateSupplier;
public interface MultipartBlockStateProvider {
MultipartBlockStateSupplier getMultipart();
}

View File

@ -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
}
}
}

View File

@ -1,19 +0,0 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "reframedtemplates:button"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -1,19 +0,0 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "reframedtemplates:carpet"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -1,19 +0,0 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "reframedtemplates:cube"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -1,19 +0,0 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "reframedtemplates:fence"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -1,19 +0,0 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "reframedtemplates:fence_gate"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -1,19 +0,0 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "reframedtemplates:iron_trapdoor"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -1,19 +0,0 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "reframedtemplates:lever"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -1,19 +0,0 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "reframedtemplates:pane"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -1,19 +0,0 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "reframedtemplates:post"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -1,19 +0,0 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "reframedtemplates:pressure_plate"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -1,19 +0,0 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "reframedtemplates:slab"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -1,19 +0,0 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "reframedtemplates:stairs"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -1,19 +0,0 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "reframedtemplates:trapdoor"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -1,19 +0,0 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "reframedtemplates:wall"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -12,6 +12,9 @@
"icon": "assets/framed-templates-icon.png", "icon": "assets/framed-templates-icon.png",
"environment": "*", "environment": "*",
"entrypoints": { "entrypoints": {
"fabric-datagen": [
"fr.adrien1106.reframedtemplates.generator.Generator"
],
"main": [ "main": [
"fr.adrien1106.reframedtemplates.Templates" "fr.adrien1106.reframedtemplates.Templates"
], ],