added some datagen
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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))));
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package fr.adrien1106.reframedtemplates.generator;
|
||||
|
||||
import net.minecraft.data.client.MultipartBlockStateSupplier;
|
||||
|
||||
public interface MultipartBlockStateProvider {
|
||||
MultipartBlockStateSupplier getMultipart();
|
||||
}
|
||||
Reference in New Issue
Block a user