Private
Public Access
1
0

Data gen, block state, model, and textures.

This commit is contained in:
2026-06-09 22:37:00 +01:00
parent d7faca2535
commit c98979a871
15 changed files with 502 additions and 1 deletions

View File

@ -0,0 +1,160 @@
{
"multipart": [
{
"apply": {
"model": "wildflowers_backport:block/wildflowers_1"
},
"when": {
"facing": "north",
"flower_amount": "1|2|3|4"
}
},
{
"apply": {
"model": "wildflowers_backport:block/wildflowers_1",
"y": 90
},
"when": {
"facing": "east",
"flower_amount": "1|2|3|4"
}
},
{
"apply": {
"model": "wildflowers_backport:block/wildflowers_1",
"y": 180
},
"when": {
"facing": "south",
"flower_amount": "1|2|3|4"
}
},
{
"apply": {
"model": "wildflowers_backport:block/wildflowers_1",
"y": 270
},
"when": {
"facing": "west",
"flower_amount": "1|2|3|4"
}
},
{
"apply": {
"model": "wildflowers_backport:block/wildflowers_2"
},
"when": {
"facing": "north",
"flower_amount": "2|3|4"
}
},
{
"apply": {
"model": "wildflowers_backport:block/wildflowers_2",
"y": 90
},
"when": {
"facing": "east",
"flower_amount": "2|3|4"
}
},
{
"apply": {
"model": "wildflowers_backport:block/wildflowers_2",
"y": 180
},
"when": {
"facing": "south",
"flower_amount": "2|3|4"
}
},
{
"apply": {
"model": "wildflowers_backport:block/wildflowers_2",
"y": 270
},
"when": {
"facing": "west",
"flower_amount": "2|3|4"
}
},
{
"apply": {
"model": "wildflowers_backport:block/wildflowers_3"
},
"when": {
"facing": "north",
"flower_amount": "3|4"
}
},
{
"apply": {
"model": "wildflowers_backport:block/wildflowers_3",
"y": 90
},
"when": {
"facing": "east",
"flower_amount": "3|4"
}
},
{
"apply": {
"model": "wildflowers_backport:block/wildflowers_3",
"y": 180
},
"when": {
"facing": "south",
"flower_amount": "3|4"
}
},
{
"apply": {
"model": "wildflowers_backport:block/wildflowers_3",
"y": 270
},
"when": {
"facing": "west",
"flower_amount": "3|4"
}
},
{
"apply": {
"model": "wildflowers_backport:block/wildflowers_4"
},
"when": {
"facing": "north",
"flower_amount": "4"
}
},
{
"apply": {
"model": "wildflowers_backport:block/wildflowers_4",
"y": 90
},
"when": {
"facing": "east",
"flower_amount": "4"
}
},
{
"apply": {
"model": "wildflowers_backport:block/wildflowers_4",
"y": 180
},
"when": {
"facing": "south",
"flower_amount": "4"
}
},
{
"apply": {
"model": "wildflowers_backport:block/wildflowers_4",
"y": 270
},
"when": {
"facing": "west",
"flower_amount": "4"
}
}
]
}

View File

@ -0,0 +1,7 @@
{
"parent": "wildflowers_backport:block/flowerbed_1",
"textures": {
"flowerbed": "wildflowers_backport:block/wildflowers",
"stem": "wildflowers_backport:block/wildflowers_stem"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "wildflowers_backport:block/flowerbed_2",
"textures": {
"flowerbed": "wildflowers_backport:block/wildflowers",
"stem": "wildflowers_backport:block/wildflowers_stem"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "wildflowers_backport:block/flowerbed_3",
"textures": {
"flowerbed": "wildflowers_backport:block/wildflowers",
"stem": "wildflowers_backport:block/wildflowers_stem"
}
}

View File

@ -0,0 +1,7 @@
{
"parent": "wildflowers_backport:block/flowerbed_4",
"textures": {
"flowerbed": "wildflowers_backport:block/wildflowers",
"stem": "wildflowers_backport:block/wildflowers_stem"
}
}

View File

@ -11,7 +11,7 @@ import org.slf4j.Logger;
@Mod(WildflowersBackport.MOD_ID) @Mod(WildflowersBackport.MOD_ID)
public class WildflowersBackport { public class WildflowersBackport {
public static final String MOD_ID = "wildflowers_backport"; public static final String MOD_ID = "wildflowers_backport";
private static final Logger LOGGER = LogUtils.getLogger(); public static final Logger LOGGER = LogUtils.getLogger();
private static FMLJavaModLoadingContext fmlJavaModLoadingContext; private static FMLJavaModLoadingContext fmlJavaModLoadingContext;
private static IProxy proxy; private static IProxy proxy;

View File

@ -0,0 +1,24 @@
package dev.micle.wildflowers_backport.data;
import dev.micle.wildflowers_backport.WildflowersBackport;
import dev.micle.wildflowers_backport.data.client.ModBlockStateProvider;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.DataGenerator;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.data.event.GatherDataEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import java.util.concurrent.CompletableFuture;
@Mod.EventBusSubscriber(modid = WildflowersBackport.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class DataGenerators {
@SubscribeEvent
public static void gatherData(GatherDataEvent event) {
DataGenerator generator = event.getGenerator();
ExistingFileHelper existingFileHelper = event.getExistingFileHelper();
CompletableFuture<HolderLookup.Provider> lookupProvider = event.getLookupProvider();
generator.addProvider(event.includeClient(), new ModBlockStateProvider(generator, existingFileHelper));
}
}

View File

@ -0,0 +1,53 @@
package dev.micle.wildflowers_backport.data.client;
import dev.micle.wildflowers_backport.WildflowersBackport;
import dev.micle.wildflowers_backport.block.FlowerBedBlock;
import dev.micle.wildflowers_backport.block.ModBlocks;
import dev.micle.wildflowers_backport.util.DirectionUtils;
import net.minecraft.core.Direction;
import net.minecraft.data.DataGenerator;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.client.model.generators.BlockStateProvider;
import net.minecraftforge.client.model.generators.MultiPartBlockStateBuilder;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.registries.RegistryObject;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class ModBlockStateProvider extends BlockStateProvider {
public ModBlockStateProvider(DataGenerator generator, ExistingFileHelper existingFileHelper) {
super(generator.getPackOutput(), WildflowersBackport.MOD_ID, existingFileHelper);
}
@Override
protected void registerStatesAndModels() {
flowerBedBlock(ModBlocks.WILDFLOWERS);
}
private void flowerBedBlock(RegistryObject<Block> block) {
String name = Objects.requireNonNull(block.getId()).getPath();
MultiPartBlockStateBuilder builder = getMultipartBuilder(block.get());
List<Integer> amounts = new ArrayList<>(List.of(1, 2, 3, 4));
for (int i = 1; i < 5; i++) {
for (Direction direction : Direction.Plane.HORIZONTAL) {
int yRot = DirectionUtils.getYRotation(direction);
builder.part()
.modelFile(models().withExistingParent(name + "_" + i, ResourceLocation.fromNamespaceAndPath(WildflowersBackport.MOD_ID, "block/flowerbed_" + i))
.texture("flowerbed", "block/" + name)
.texture("stem", "block/" + name + "_stem")
)
.rotationY(yRot)
.addModel()
.condition(FlowerBedBlock.FACING, direction)
.condition(FlowerBedBlock.AMOUNT, amounts.toArray(new Integer[0]))
.end();
}
amounts.remove(0);
}
}
}

View File

@ -0,0 +1,14 @@
package dev.micle.wildflowers_backport.util;
import net.minecraft.core.Direction;
public class DirectionUtils {
public static int getYRotation(Direction direction) {
return switch (direction) {
case EAST -> 90;
case SOUTH -> 180;
case WEST -> 270;
default -> 0;
};
}
}

View File

@ -0,0 +1,70 @@
{
"ambientocclusion": false,
"textures": {
"particle": "#flowerbed"
},
"elements": [
{
"from": [0, 2.99, 0],
"to": [8, 2.99, 8],
"faces": {
"up": {"uv": [0, 0, 8, 8], "texture": "#flowerbed"},
"down": {"uv": [0, 8, 8, 0], "texture": "#flowerbed"}
}
},
{
"from": [4.25, 0, -2.6],
"to": [4.25, 2.99, -1.6],
"rotation": {"angle": -45, "axis": "y", "origin": [0, 0, 0]},
"faces": {
"east": {"uv": [0, 4, 1, 7], "texture": "#stem", "tintindex": 1},
"west": {"uv": [0, 4, 1, 7], "texture": "#stem", "tintindex": 1}
}
},
{
"from": [3.75, 0, -2.1],
"to": [4.75, 2.99, -2.1],
"rotation": {"angle": -45, "axis": "y", "origin": [0, 0, 0]},
"faces": {
"north": {"uv": [0, 4, 1, 7], "texture": "#stem", "tintindex": 1},
"south": {"uv": [0, 4, 1, 7], "texture": "#stem", "tintindex": 1}
}
},
{
"from": [4.9, 0, 2.3],
"to": [4.9, 2.99, 3.3],
"rotation": {"angle": -45, "axis": "y", "origin": [0, 0, 0]},
"faces": {
"east": {"uv": [0, 4, 1, 7], "texture": "#stem", "tintindex": 1},
"west": {"uv": [0, 4, 1, 7], "texture": "#stem", "tintindex": 1}
}
},
{
"from": [4.4, 0, 2.8],
"to": [5.4, 2.99, 2.8],
"rotation": {"angle": -45, "axis": "y", "origin": [0, 0, 0]},
"faces": {
"north": {"uv": [0, 4, 1, 7], "texture": "#stem", "tintindex": 1},
"south": {"uv": [0, 4, 1, 7], "texture": "#stem", "tintindex": 1}
}
},
{
"from": [9.15, 0, -0.45],
"to": [9.15, 2.99, 0.55],
"rotation": {"angle": -45, "axis": "y", "origin": [0, 0, 0]},
"faces": {
"east": {"uv": [0, 4, 1, 7], "texture": "#stem", "tintindex": 1},
"west": {"uv": [0, 4, 1, 7], "texture": "#stem", "tintindex": 1}
}
},
{
"from": [8.65, 0, 0.05],
"to": [9.65, 2.99, 0.05],
"rotation": {"angle": -45, "axis": "y", "origin": [0, 0, 0]},
"faces": {
"north": {"uv": [0, 4, 1, 7], "texture": "#stem", "tintindex": 1},
"south": {"uv": [0, 4, 1, 7], "texture": "#stem", "tintindex": 1}
}
}
]
}

View File

@ -0,0 +1,42 @@
{
"ambientocclusion": false,
"textures": {
"particle": "#flowerbed"
},
"elements": [
{
"from": [0, 1, 8],
"to": [8, 1, 16],
"faces": {
"up": {"uv": [0, 8, 8, 16], "texture": "#flowerbed"},
"down": {"uv": [0, 16, 8, 8], "texture": "#flowerbed"}
}
},
{
"from": [0, 1, 8],
"to": [8, 1, 16],
"faces": {
"up": {"uv": [0, 8, 8, 16], "texture": "#flowerbed"},
"down": {"uv": [0, 16, 8, 8], "texture": "#flowerbed"}
}
},
{
"from": [10.15, 0, 5.25],
"to": [11.15, 1, 5.25],
"rotation": {"angle": -45, "axis": "y", "origin": [0, 0, 1]},
"faces": {
"north": {"uv": [0, 6, 1, 7], "texture": "#stem", "tintindex": 1},
"south": {"uv": [0, 6, 1, 7], "texture": "#stem", "tintindex": 1}
}
},
{
"from": [10.65, 0, 4.75],
"to": [10.65, 1, 5.75],
"rotation": {"angle": -45, "axis": "y", "origin": [0, 0, 1]},
"faces": {
"east": {"uv": [0, 6, 1, 7], "texture": "#stem", "tintindex": 1},
"west": {"uv": [0, 6, 1, 7], "texture": "#stem", "tintindex": 1}
}
}
]
}

View File

@ -0,0 +1,70 @@
{
"ambientocclusion": false,
"textures": {
"particle": "#flowerbed"
},
"elements": [
{
"from": [8, 2, 8],
"to": [16, 2, 16],
"faces": {
"up": {"uv": [8, 8, 16, 16], "texture": "#flowerbed"},
"down": {"uv": [8, 16, 16, 8], "texture": "#flowerbed"}
}
},
{
"from": [17.65, 0, 1.9],
"to": [18.65, 2, 1.9],
"rotation": {"angle": -45, "axis": "y", "origin": [0.5, 0, 0.5]},
"faces": {
"north": {"uv": [0, 5, 1, 7], "texture": "#stem", "tintindex": 1},
"south": {"uv": [0, 5, 1, 7], "texture": "#stem", "tintindex": 1}
}
},
{
"from": [18.15, 0, 1.4],
"to": [18.15, 2, 2.4],
"rotation": {"angle": -45, "axis": "y", "origin": [0.5, 0, 0.5]},
"faces": {
"east": {"uv": [0, 5, 1, 7], "texture": "#stem", "tintindex": 1},
"west": {"uv": [0, 5, 1, 7], "texture": "#stem", "tintindex": 1}
}
},
{
"from": [17.65, 0, -3.35],
"to": [17.65, 2, -2.35],
"rotation": {"angle": -45, "axis": "y", "origin": [0, 0, 0]},
"faces": {
"east": {"uv": [0, 5, 1, 7], "texture": "#stem", "tintindex": 1},
"west": {"uv": [0, 5, 1, 7], "texture": "#stem", "tintindex": 1}
}
},
{
"from": [17.15, 0, -2.85],
"to": [18.15, 2, -2.85],
"rotation": {"angle": -45, "axis": "y", "origin": [0, 0, 0]},
"faces": {
"north": {"uv": [0, 5, 1, 7], "texture": "#stem", "tintindex": 1},
"south": {"uv": [0, 5, 1, 7], "texture": "#stem", "tintindex": 1}
}
},
{
"from": [13.4, 0, -0.5],
"to": [13.4, 2, 0.5],
"rotation": {"angle": -45, "axis": "y", "origin": [0, 0, 0]},
"faces": {
"east": {"uv": [0, 5, 1, 7], "texture": "#stem", "tintindex": 1},
"west": {"uv": [0, 5, 1, 7], "texture": "#stem", "tintindex": 1}
}
},
{
"from": [12.9, 0, 0],
"to": [13.9, 2, 0],
"rotation": {"angle": -45, "axis": "y", "origin": [0, 0, 0]},
"faces": {
"north": {"uv": [0, 5, 1, 7], "texture": "#stem", "tintindex": 1},
"south": {"uv": [0, 5, 1, 7], "texture": "#stem", "tintindex": 1}
}
}
]
}

View File

@ -0,0 +1,34 @@
{
"ambientocclusion": false,
"textures": {
"particle": "#flowerbed"
},
"elements": [
{
"from": [8, 2, 0],
"to": [16, 2, 8],
"faces": {
"up": {"uv": [8, 0, 16, 8], "texture": "#flowerbed"},
"down": {"uv": [8, 8, 16, 0], "texture": "#flowerbed"}
}
},
{
"from": [12.4, 0, -7.7],
"to": [12.4, 2, -6.7],
"rotation": {"angle": -45, "axis": "y", "origin": [-1, 0, -3]},
"faces": {
"east": {"uv": [0, 5, 1, 7], "texture": "#stem", "tintindex": 1},
"west": {"uv": [0, 5, 1, 7], "texture": "#stem", "tintindex": 1}
}
},
{
"from": [11.9, 0, -7.2],
"to": [12.9, 2, -7.2],
"rotation": {"angle": -45, "axis": "y", "origin": [-1, 0, -3]},
"faces": {
"north": {"uv": [0, 5, 1, 7], "texture": "#stem", "tintindex": 1},
"south": {"uv": [0, 5, 1, 7], "texture": "#stem", "tintindex": 1}
}
}
]
}

Binary file not shown.

Binary file not shown.