Add new datagenned resources
This commit is contained in:
parent
9e61a85498
commit
f63f250e3b
309 changed files with 16088 additions and 300 deletions
|
@ -1,22 +1,23 @@
|
|||
package dev.zontreck.otemod.data;
|
||||
|
||||
import dev.zontreck.otemod.OTEMod;
|
||||
import dev.zontreck.otemod.blocks.*;
|
||||
import dev.zontreck.otemod.items.DeprecatedModItems;
|
||||
import dev.zontreck.otemod.blocks.ModBlocks;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.properties.*;
|
||||
import net.minecraftforge.client.model.generators.BlockStateProvider;
|
||||
import net.minecraftforge.client.model.generators.ConfiguredModel;
|
||||
import net.minecraftforge.client.model.generators.ModelFile;
|
||||
import net.minecraftforge.client.model.generators.VariantBlockStateBuilder;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class ModBlockStatesProvider extends BlockStateProvider
|
||||
{
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class ModBlockStatesProvider extends BlockStateProvider {
|
||||
public ModBlockStatesProvider(PackOutput output, ExistingFileHelper existingFileHelper) {
|
||||
super(output, OTEMod.MOD_ID, existingFileHelper);
|
||||
}
|
||||
|
@ -74,45 +75,226 @@ public class ModBlockStatesProvider extends BlockStateProvider
|
|||
stairBlock(ModBlocks.DIRTY_GREEN_POOL_TILE_STAIRS, ModBlocks.DIRTY_GREEN_POOL_TILE);
|
||||
slabBlock(ModBlocks.DIRTY_GREEN_POOL_TILE_SLAB, ModBlocks.DIRTY_GREEN_POOL_TILE);
|
||||
|
||||
ResourceLocation[] clinkerBlock = new ResourceLocation[]{
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_texture0"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_texture1"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_texture2"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_texture3"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_texture4"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_texture5"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_texture6"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_texture7")
|
||||
};
|
||||
ResourceLocation[] clinkerStainedBlock = new ResourceLocation[]{
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_stained_texture0"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_stained_texture1"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_stained_texture2"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_stained_texture3"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_stained_texture4"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_stained_texture5"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_stained_texture6"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_stained_texture7")
|
||||
};
|
||||
|
||||
ResourceLocation[] slagBricks = new ResourceLocation[]{
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/slag_brick/slag_brick_texture0"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/slag_brick/slag_brick_texture1"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/slag_brick/slag_brick_texture2"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/slag_brick/slag_brick_texture3"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/slag_brick/slag_brick_texture4"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/slag_brick/slag_brick_texture5"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/slag_brick/slag_brick_texture6"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/slag_brick/slag_brick_texture7")
|
||||
};
|
||||
|
||||
variantCubeBlock(ModBlocks.CLINKER_BRICK_BLOCK, clinkerBlock);
|
||||
customSlabBlock(ModBlocks.CLINKER_BRICK_SLAB, clinkerBlock);
|
||||
customStairBlock(ModBlocks.CLINKER_BRICK_STAIRS, clinkerBlock);
|
||||
variantCubeBlock(ModBlocks.CLINKER_BRICK_STAINED_BLOCK, clinkerStainedBlock);
|
||||
customSlabBlock(ModBlocks.CLINKER_BRICK_STAINED_SLAB, clinkerStainedBlock);
|
||||
customStairBlock(ModBlocks.CLINKER_BRICK_STAINED_STAIRS, clinkerStainedBlock);
|
||||
|
||||
wallBlock(ModBlocks.CLINKER_BRICK_WALL, new ResourceLocation(OTEMod.MOD_ID, "block/engineersdecor/clinker_brick/clinker_brick_wall0"));
|
||||
|
||||
variantCubeBlock(ModBlocks.SLAG_BRICK_BLOCK, slagBricks);
|
||||
customSlabBlock(ModBlocks.SLAG_BRICK_SLAB, slagBricks);
|
||||
customStairBlock(ModBlocks.SLAG_BRICK_STAIRS, slagBricks);
|
||||
wallBlock(ModBlocks.SLAG_BRICK_WALL, new ResourceLocation(OTEMod.MOD_ID, "block/engineersdecor/slag_brick/slag_brick_wall0"));
|
||||
}
|
||||
|
||||
private void blockWithItem(RegistryObject<Block> blockRegistryObject)
|
||||
private void wallBlock(RegistryObject<Block> blk, ResourceLocation texture)
|
||||
{
|
||||
wallBlock((WallBlock) blk.get(), texture);
|
||||
|
||||
simpleBlockItem(blk.get(), models().withExistingParent(name(blk.get()), blk.getId()));
|
||||
}
|
||||
|
||||
private void blockWithItem(RegistryObject<Block> blockRegistryObject) {
|
||||
simpleBlockWithItem(blockRegistryObject.get(), cubeAll(blockRegistryObject.get()));
|
||||
}
|
||||
private void blockWithItem(RegistryObject<Block> blockRegistryObject, ModelFile model)
|
||||
{
|
||||
|
||||
private void blockWithItem(RegistryObject<Block> blockRegistryObject, ModelFile model) {
|
||||
simpleBlockWithItem(blockRegistryObject.get(), model);
|
||||
}
|
||||
|
||||
private void stairBlock(RegistryObject<Block> blk, RegistryObject<Block> texture)
|
||||
{
|
||||
private void stairBlock(RegistryObject<Block> blk, RegistryObject<Block> texture) {
|
||||
stairsBlock((StairBlock) blk.get(), blockTexture(texture.get()));
|
||||
simpleBlockItem(blk.get(), stairsModel(blk.get(), texture.get()));
|
||||
}
|
||||
private void carpetBlock(RegistryObject<Block> blk, RegistryObject<Block> texture)
|
||||
{
|
||||
|
||||
private void carpetBlock(RegistryObject<Block> blk, RegistryObject<Block> texture) {
|
||||
simpleBlockWithItem(blk.get(), carpetModel(blk.get(), texture.get()));
|
||||
}
|
||||
|
||||
private String name(Block block) {
|
||||
return this.key(block).getPath();
|
||||
}
|
||||
|
||||
private ResourceLocation key(Block block) {
|
||||
return ForgeRegistries.BLOCKS.getKey(block);
|
||||
}
|
||||
|
||||
public ModelFile stairsModel(Block block, Block texture) {
|
||||
return this.models().stairs(name(block), blockTexture(texture), blockTexture(texture), blockTexture(texture));
|
||||
}
|
||||
|
||||
public ModelFile carpetModel(Block block, Block texture) {
|
||||
return this.models().carpet(name(block), blockTexture(texture));
|
||||
}
|
||||
|
||||
public ModelFile slabModel(Block block, Block texture) {
|
||||
return this.models().slab(name(block), blockTexture(texture), blockTexture(texture), blockTexture(texture));
|
||||
}
|
||||
private void slabBlock(RegistryObject<Block> blk, RegistryObject<Block> texture)
|
||||
{
|
||||
|
||||
private void slabBlock(RegistryObject<Block> blk, RegistryObject<Block> texture) {
|
||||
slabBlock((SlabBlock) blk.get(), blockTexture(texture.get()), blockTexture(texture.get()));
|
||||
simpleBlockItem(blk.get(), slabModel(blk.get(), texture.get()));
|
||||
}
|
||||
|
||||
private void customSlabBlock(RegistryObject<Block> blockId, ResourceLocation... variations) {
|
||||
VariantBlockStateBuilder builder = getVariantBuilder(blockId.get());
|
||||
|
||||
|
||||
AtomicReference<ModelFile> model0 = new AtomicReference<>();
|
||||
|
||||
builder.forAllStates((state)->{
|
||||
ConfiguredModel[] models = new ConfiguredModel[variations.length];
|
||||
|
||||
|
||||
String appendName = "";
|
||||
SlabType type = state.getValue(SlabBlock.TYPE);
|
||||
|
||||
if(type == SlabType.BOTTOM)
|
||||
appendName = "_bottom";
|
||||
else if(type == SlabType.TOP)
|
||||
appendName = "_top";
|
||||
else if(type == SlabType.DOUBLE)
|
||||
appendName = "_double";
|
||||
|
||||
for (int i = 0; i < variations.length; i++) {
|
||||
ResourceLocation texture = variations[i];
|
||||
ResourceLocation rss = new ResourceLocation(texture.getNamespace(), "block/" + texture.getPath());
|
||||
ModelFile model = null;
|
||||
if(type == SlabType.TOP)
|
||||
model = models().slabTop(name(blockId.get()) + "_model" + i + appendName, rss, rss, rss);
|
||||
else if(type == SlabType.BOTTOM)
|
||||
model = models().slab(name(blockId.get()) + "_model" + i + appendName, rss, rss, rss);
|
||||
else if(type == SlabType.DOUBLE)
|
||||
model = models().cubeAll(name(blockId.get()) + "_model" + i + appendName, rss);
|
||||
|
||||
|
||||
ConfiguredModel[] cfgModel = ConfiguredModel.builder().modelFile(model).build();
|
||||
|
||||
if(i==0 && model0.get()==null && type == SlabType.BOTTOM) model0.set(model);
|
||||
|
||||
models[i] = cfgModel[0];
|
||||
//builder.partialState().addModels(cfgModel);
|
||||
}
|
||||
return models;
|
||||
});
|
||||
|
||||
|
||||
simpleBlockItem(blockId.get(), model0.get());
|
||||
}
|
||||
|
||||
private void customStairBlock(RegistryObject<Block> blockId, ResourceLocation... variations) {
|
||||
VariantBlockStateBuilder builder = getVariantBuilder(blockId.get());
|
||||
ResourceLocation blockDefault = blockTexture(blockId.get());
|
||||
|
||||
|
||||
AtomicReference<ModelFile> model0 = new AtomicReference<>();
|
||||
|
||||
builder.forAllStates((state)->{
|
||||
ConfiguredModel[] models = new ConfiguredModel[variations.length];
|
||||
Direction facing = (Direction)state.getValue(StairBlock.FACING);
|
||||
Half half = (Half)state.getValue(StairBlock.HALF);
|
||||
StairsShape shape = (StairsShape)state.getValue(StairBlock.SHAPE);
|
||||
int yRot = (int)facing.getClockWise().toYRot();
|
||||
if (shape == StairsShape.INNER_LEFT || shape == StairsShape.OUTER_LEFT) {
|
||||
yRot += 270;
|
||||
}
|
||||
|
||||
if (shape != StairsShape.STRAIGHT && half == Half.TOP) {
|
||||
yRot += 90;
|
||||
}
|
||||
|
||||
yRot %= 360;
|
||||
boolean uvlock = yRot != 0 || half == Half.TOP;
|
||||
|
||||
String modelName = (shape == StairsShape.STRAIGHT) ? "" : (shape != StairsShape.INNER_LEFT && shape != StairsShape.INNER_RIGHT) ? "_outer":"_inner";
|
||||
boolean straight = (shape == StairsShape.STRAIGHT);
|
||||
boolean inner = (shape == StairsShape.INNER_LEFT || shape == StairsShape.INNER_RIGHT);
|
||||
|
||||
|
||||
for (int i = 0; i < variations.length; i++) {
|
||||
ResourceLocation texture = variations[i];
|
||||
ResourceLocation rss = new ResourceLocation(texture.getNamespace(), "block/" + texture.getPath());
|
||||
ModelFile cubeModel = null;
|
||||
if(straight)
|
||||
cubeModel = models().stairs(
|
||||
blockId.getId().getPath() + "_model"+i + modelName, // Model name
|
||||
rss, rss, rss // Texture location
|
||||
);
|
||||
|
||||
if(inner)
|
||||
cubeModel = models().stairsInner(blockId.getId().getPath()+"_model"+i + modelName, rss, rss, rss);
|
||||
else if(!inner && !straight)
|
||||
cubeModel = models().stairsOuter(blockId.getId().getPath() + "_model"+i+modelName, rss, rss, rss);
|
||||
|
||||
ConfiguredModel[] cfgModel = ConfiguredModel.builder().modelFile(cubeModel).rotationX(half == Half.BOTTOM ? 0 : 180).rotationY(yRot).uvLock(uvlock).build();
|
||||
|
||||
if(i==0 && model0.get()==null) model0.set(cubeModel);
|
||||
|
||||
models[i] = cfgModel[0];
|
||||
//builder.partialState().addModels(cfgModel);
|
||||
}
|
||||
|
||||
return models;
|
||||
});
|
||||
|
||||
|
||||
simpleBlockItem(blockId.get(), model0.get());
|
||||
}
|
||||
|
||||
public void variantCubeBlock(RegistryObject<Block> blockId, ResourceLocation... variations) {
|
||||
VariantBlockStateBuilder builder = getVariantBuilder(blockId.get());
|
||||
ResourceLocation blockDefault = blockTexture(blockId.get());
|
||||
|
||||
ModelFile model0 = null;
|
||||
for (int i = 0; i < variations.length; i++) {
|
||||
ResourceLocation texture = variations[i];
|
||||
ResourceLocation rss = new ResourceLocation(texture.getNamespace(), "block/" + texture.getPath());
|
||||
ModelFile cubeModel = models().cubeAll(
|
||||
blockId.getId().getPath() + "_model"+i, // Model name
|
||||
rss // Texture location
|
||||
);
|
||||
var cfgModel = ConfiguredModel.builder().modelFile(cubeModel).build();
|
||||
if(i==0)model0 = cubeModel;
|
||||
builder.partialState().addModels(cfgModel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
simpleBlockItem(blockId.get(), model0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,6 +61,11 @@ public class ModItemModelsProvider extends ItemModelProvider
|
|||
item(ModItems.LIME_BRICK);
|
||||
item(ModItems.GREEN_BRICK);
|
||||
|
||||
/*
|
||||
Engineer's Decor Items
|
||||
*/
|
||||
item(ModItems.METAL_BAR);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -107,6 +107,26 @@ public class ModBlockLootTablesProvider extends BlockLootSubProvider
|
|||
dropSelf(ModBlocks.DIRTY_GREEN_POOL_TILE_SLAB.get());
|
||||
dropSelf(ModBlocks.DIRTY_GREEN_POOL_TILE_STAIRS.get());
|
||||
dropSelf(ModBlocks.FILTHY_GREEN_POOL_LIGHT.get());
|
||||
dropSelf(ModBlocks.UNCRAFTER.get());
|
||||
|
||||
/*
|
||||
Engineer's Decor Blocks
|
||||
*/
|
||||
dropSelf(ModBlocks.CLINKER_BRICK_BLOCK.get());
|
||||
dropSelf(ModBlocks.CLINKER_BRICK_RECESSED.get());
|
||||
dropSelf(ModBlocks.CLINKER_BRICK_VERTICALLY_SLIT.get());
|
||||
dropSelf(ModBlocks.CLINKER_BRICK_SLAB.get());
|
||||
dropSelf(ModBlocks.CLINKER_BRICK_STAIRS.get());
|
||||
dropSelf(ModBlocks.CLINKER_BRICK_STAINED_BLOCK.get());
|
||||
dropSelf(ModBlocks.CLINKER_BRICK_STAINED_SLAB.get());
|
||||
dropSelf(ModBlocks.CLINKER_BRICK_STAINED_STAIRS.get());
|
||||
dropSelf(ModBlocks.CLINKER_BRICK_SASTOR_CORNER_BLOCK.get());
|
||||
dropSelf(ModBlocks.CLINKER_BRICK_WALL.get());
|
||||
|
||||
dropSelf(ModBlocks.SLAG_BRICK_BLOCK.get());
|
||||
dropSelf(ModBlocks.SLAG_BRICK_SLAB.get());
|
||||
dropSelf(ModBlocks.SLAG_BRICK_WALL.get());
|
||||
dropSelf(ModBlocks.SLAG_BRICK_STAIRS.get());
|
||||
|
||||
|
||||
|
||||
|
|
Reference in a new issue