Added a bunch of the dungeon blocks to the mod.

Mainly only the "Raw" variants right now. No recipes have been added yet.
This commit is contained in:
WayofTime 2020-11-14 16:15:26 -05:00
parent cb2db9bc50
commit ddadbef425
117 changed files with 2547 additions and 4 deletions

View file

@ -1,11 +1,19 @@
package wayoftime.bloodmagic.common.data;
import net.minecraft.block.Block;
import net.minecraft.block.FenceGateBlock;
import net.minecraft.block.RotatedPillarBlock;
import net.minecraft.block.StairsBlock;
import net.minecraft.block.WallBlock;
import net.minecraft.data.DataGenerator;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.generators.BlockModelBuilder;
import net.minecraftforge.client.model.generators.BlockStateProvider;
import net.minecraftforge.client.model.generators.ConfiguredModel;
import net.minecraftforge.client.model.generators.ConfiguredModel.Builder;
import net.minecraftforge.client.model.generators.ModelBuilder.ElementBuilder;
import net.minecraftforge.client.model.generators.ModelBuilder.FaceRotation;
import net.minecraftforge.client.model.generators.ModelFile;
import net.minecraftforge.client.model.generators.MultiPartBlockStateBuilder;
import net.minecraftforge.client.model.generators.MultiPartBlockStateBuilder.PartBuilder;
@ -16,6 +24,7 @@ import wayoftime.bloodmagic.BloodMagic;
import wayoftime.bloodmagic.common.block.BlockAlchemicalReactionChamber;
import wayoftime.bloodmagic.common.block.BlockDemonCrystal;
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
import wayoftime.bloodmagic.common.block.base.BlockPillarCap;
public class GeneratorBlockStates extends BlockStateProvider
{
@ -35,6 +44,11 @@ public class GeneratorBlockStates extends BlockStateProvider
buildCubeAll(block.get());
}
for (RegistryObject<Block> block : BloodMagicBlocks.DUNGEONBLOCKS.getEntries())
{
buildDungeonBlock(block.get());
}
buildCubeAll(BloodMagicBlocks.BLOOD_LIGHT.get());
buildCubeAll(BloodMagicBlocks.BLANK_RITUAL_STONE.get());
buildCubeAll(BloodMagicBlocks.AIR_RITUAL_STONE.get());
@ -51,6 +65,155 @@ public class GeneratorBlockStates extends BlockStateProvider
buildCrystal(BloodMagicBlocks.DESTRUCTIVE_CRYSTAL_BLOCK.get(), "destructivecrystal");
buildCrystal(BloodMagicBlocks.VENGEFUL_CRYSTAL_BLOCK.get(), "vengefulcrystal");
buildCrystal(BloodMagicBlocks.STEADFAST_CRYSTAL_BLOCK.get(), "steadfastcrystal");
buildRandomStone(BloodMagicBlocks.DUNGEON_STONE.get(), BloodMagic.rl("block/dungeon/dungeon_stone"));
stairsBlock((StairsBlock) BloodMagicBlocks.DUNGEON_BRICK_STAIRS.get(), BloodMagic.rl("block/dungeon/dungeon_brick1"));
stairsBlock((StairsBlock) BloodMagicBlocks.DUNGEON_POLISHED_STAIRS.get(), BloodMagic.rl("block/dungeon/dungeon_polished"));
buildPillarCenter(BloodMagicBlocks.DUNGEON_PILLAR_CENTER.get(), BloodMagic.rl("block/dungeon/dungeon_pillar"), BloodMagic.rl("block/dungeon/dungeon_pillarheart"));
buildPillarCenter(BloodMagicBlocks.DUNGEON_PILLAR_SPECIAL.get(), BloodMagic.rl("block/dungeon/dungeon_pillarspecial"), BloodMagic.rl("block/dungeon/dungeon_pillarheart"));
buildWallInventory((WallBlock) BloodMagicBlocks.DUNGEON_BRICK_WALL.get(), BloodMagic.rl("block/dungeon/dungeon_brick1"));
buildWallInventory((WallBlock) BloodMagicBlocks.DUNGEON_POLISHED_WALL.get(), BloodMagic.rl("block/dungeon/dungeon_polished"));
fenceGateBlock((FenceGateBlock) BloodMagicBlocks.DUNGEON_BRICK_GATE.get(), BloodMagic.rl("block/dungeon/dungeon_brick1"));
fenceGateBlock((FenceGateBlock) BloodMagicBlocks.DUNGEON_POLISHED_GATE.get(), BloodMagic.rl("block/dungeon/dungeon_polished"));
buildPillarCap(BloodMagicBlocks.DUNGEON_PILLAR_CAP.get(), BloodMagic.rl("block/dungeon/dungeon_pillarheart"), BloodMagic.rl("block/dungeon/dungeon_pillarbottom"), BloodMagic.rl("block/dungeon/dungeon_pillartop"));
buildAssortedBlock(BloodMagicBlocks.DUNGEON_BRICK_ASSORTED.get(), modLoc("dungeon_brick1"), modLoc("dungeon_brick2"), modLoc("dungeon_brick3"));
}
private void buildAssortedBlock(Block block, ResourceLocation... modelResources)
{
getVariantBuilder(block).forAllStates(state -> {
Builder builder = ConfiguredModel.builder();
for (int i = 0; i < modelResources.length; i++)
{
ResourceLocation location = modelResources[i];
ModelFile file = models().getExistingFile(location);
if (i < modelResources.length - 1)
{
builder = builder.modelFile(file).nextModel();
} else
{
builder = builder.modelFile(file);
}
}
return builder.build();
});
}
private void buildRandomStone(Block block, ResourceLocation texture)
{
String basePath = block.getRegistryName().getPath();
ModelFile modelFile = models().cubeAll(basePath, texture);
ModelFile modelFile_mirrored = models().withExistingParent(basePath + "_mirrored", "cube_mirrored_all").texture("all", texture);
getVariantBuilder(block).forAllStates(state -> ConfiguredModel.builder().modelFile(modelFile).nextModel().modelFile(modelFile_mirrored).nextModel().modelFile(modelFile).rotationY(180).nextModel().modelFile(modelFile_mirrored).rotationY(180).build());
}
private void buildWallInventory(WallBlock block, ResourceLocation texture)
{
String basePath = block.getRegistryName().getPath();
wallBlock(block, texture);
ModelFile file = models().wallInventory(basePath + "_inventory", texture);
file.assertExistence();
}
private void buildDungeonBlock(Block block)
{
String basePath = block.getRegistryName().getPath();
ModelFile modelFile = models().cubeAll(basePath, BloodMagic.rl("block/dungeon/" + basePath));
getVariantBuilder(block).forAllStates(state -> ConfiguredModel.builder().modelFile(modelFile).build());
// ModelFile furnace_off = models().cubeAll(block.getRegistryName().toString(), texture)\
}
private void buildPillarCenter(Block block, ResourceLocation side, ResourceLocation pillarEnd)
{
String basePath = block.getRegistryName().getPath();
ModelFile yModel = models().cubeColumn(basePath, side, pillarEnd);
ElementBuilder xElementBuilder = models().withExistingParent(basePath + "_x", "cube").texture("particle", side).texture("end", pillarEnd).texture("side", side).element();
xElementBuilder.face(Direction.UP).uvs(0, 0, 16, 16).texture("#side").rotation(FaceRotation.COUNTERCLOCKWISE_90).end();
xElementBuilder.face(Direction.DOWN).uvs(0, 0, 16, 16).texture("#side").rotation(FaceRotation.COUNTERCLOCKWISE_90).end();
xElementBuilder.face(Direction.NORTH).uvs(0, 0, 16, 16).texture("#side").rotation(FaceRotation.COUNTERCLOCKWISE_90).end();
xElementBuilder.face(Direction.SOUTH).uvs(0, 0, 16, 16).texture("#side").rotation(FaceRotation.COUNTERCLOCKWISE_90).end();
xElementBuilder.face(Direction.WEST).uvs(16, 0, 0, 16).texture("#end").end();
xElementBuilder.face(Direction.EAST).uvs(16, 0, 0, 16).texture("#end").end();
ModelFile xModel = xElementBuilder.end();
ElementBuilder zElementBuilder = models().withExistingParent(basePath + "_z", "cube").texture("particle", side).texture("end", pillarEnd).texture("side", side).element();
zElementBuilder.face(Direction.UP).uvs(0, 0, 16, 16).texture("#side").end();
zElementBuilder.face(Direction.DOWN).uvs(0, 0, 16, 16).texture("#side").end();
zElementBuilder.face(Direction.NORTH).uvs(0, 0, 16, 16).texture("#end").end();
zElementBuilder.face(Direction.SOUTH).uvs(0, 0, 16, 16).texture("#end").end();
zElementBuilder.face(Direction.WEST).uvs(16, 0, 0, 16).texture("#side").rotation(FaceRotation.COUNTERCLOCKWISE_90).end();
zElementBuilder.face(Direction.EAST).uvs(16, 0, 0, 16).texture("#side").rotation(FaceRotation.COUNTERCLOCKWISE_90).end();
ModelFile zModel = zElementBuilder.end();
VariantBlockStateBuilder builder = getVariantBuilder(block);
builder.partialState().with(RotatedPillarBlock.AXIS, Direction.Axis.X).modelForState().modelFile(xModel).addModel();
builder.partialState().with(RotatedPillarBlock.AXIS, Direction.Axis.Y).modelForState().modelFile(yModel).addModel();
builder.partialState().with(RotatedPillarBlock.AXIS, Direction.Axis.Z).modelForState().modelFile(zModel).addModel();
}
private void buildPillarCap(Block block, ResourceLocation pillarEnd, ResourceLocation sideBottom, ResourceLocation sideTop)
{
String basePath = block.getRegistryName().getPath();
ModelFile upModel = models().cubeBottomTop(basePath, sideTop, pillarEnd, pillarEnd);
ModelFile downModel = models().cubeBottomTop(basePath + "_down", sideBottom, pillarEnd, pillarEnd);
ElementBuilder northElementBuilder = models().withExistingParent(basePath + "_north", "cube").texture("particle", pillarEnd).texture("sideBottom", sideBottom).texture("end", pillarEnd).texture("sideTop", sideTop).element();
northElementBuilder.face(Direction.UP).uvs(0, 0, 16, 16).texture("#sideTop").end();
northElementBuilder.face(Direction.DOWN).uvs(0, 0, 16, 16).texture("#sideBottom").end();
northElementBuilder.face(Direction.NORTH).uvs(0, 0, 16, 16).texture("#end").end();
northElementBuilder.face(Direction.SOUTH).uvs(0, 0, 16, 16).texture("#end").end();
northElementBuilder.face(Direction.WEST).uvs(16, 0, 0, 16).texture("#sideTop").rotation(FaceRotation.COUNTERCLOCKWISE_90).end();
northElementBuilder.face(Direction.EAST).uvs(16, 0, 0, 16).texture("#sideBottom").rotation(FaceRotation.COUNTERCLOCKWISE_90).end();
ModelFile northModel = northElementBuilder.end();
ElementBuilder southElementBuilder = models().withExistingParent(basePath + "_south", "cube").texture("particle", pillarEnd).texture("sideBottom", sideBottom).texture("end", pillarEnd).texture("sideTop", sideTop).element();
southElementBuilder.face(Direction.UP).uvs(0, 0, 16, 16).texture("#sideBottom").end();
southElementBuilder.face(Direction.DOWN).uvs(0, 0, 16, 16).texture("#sideTop").end();
southElementBuilder.face(Direction.NORTH).uvs(0, 0, 16, 16).texture("#end").end();
southElementBuilder.face(Direction.SOUTH).uvs(0, 0, 16, 16).texture("#end").end();
southElementBuilder.face(Direction.WEST).uvs(16, 0, 0, 16).texture("#sideBottom").rotation(FaceRotation.COUNTERCLOCKWISE_90).end();
southElementBuilder.face(Direction.EAST).uvs(16, 0, 0, 16).texture("#sideTop").rotation(FaceRotation.COUNTERCLOCKWISE_90).end();
ModelFile southModel = southElementBuilder.end();
ElementBuilder westElementBuilder = models().withExistingParent(basePath + "_west", "cube").texture("particle", pillarEnd).texture("sideBottom", sideBottom).texture("end", pillarEnd).texture("sideTop", sideTop).element();
westElementBuilder.face(Direction.UP).uvs(0, 0, 16, 16).texture("#sideTop").rotation(FaceRotation.COUNTERCLOCKWISE_90).end();
westElementBuilder.face(Direction.DOWN).uvs(0, 0, 16, 16).texture("#sideTop").rotation(FaceRotation.COUNTERCLOCKWISE_90).end();
westElementBuilder.face(Direction.NORTH).uvs(0, 0, 16, 16).texture("#sideBottom").rotation(FaceRotation.COUNTERCLOCKWISE_90).end();
westElementBuilder.face(Direction.SOUTH).uvs(0, 0, 16, 16).texture("#sideTop").rotation(FaceRotation.COUNTERCLOCKWISE_90).end();
westElementBuilder.face(Direction.WEST).uvs(16, 0, 0, 16).texture("#end").end();
westElementBuilder.face(Direction.EAST).uvs(16, 0, 0, 16).texture("#end").end();
ModelFile westModel = westElementBuilder.end();
ElementBuilder eastElementBuilder = models().withExistingParent(basePath + "_east", "cube").texture("particle", pillarEnd).texture("sideBottom", sideBottom).texture("end", pillarEnd).texture("sideTop", sideTop).element();
eastElementBuilder.face(Direction.UP).uvs(0, 0, 16, 16).texture("#sideBottom").rotation(FaceRotation.COUNTERCLOCKWISE_90).end();
eastElementBuilder.face(Direction.DOWN).uvs(0, 0, 16, 16).texture("#sideBottom").rotation(FaceRotation.COUNTERCLOCKWISE_90).end();
eastElementBuilder.face(Direction.NORTH).uvs(0, 0, 16, 16).texture("#sideTop").rotation(FaceRotation.COUNTERCLOCKWISE_90).end();
eastElementBuilder.face(Direction.SOUTH).uvs(0, 0, 16, 16).texture("#sideBottom").rotation(FaceRotation.COUNTERCLOCKWISE_90).end();
eastElementBuilder.face(Direction.WEST).uvs(16, 0, 0, 16).texture("#end").end();
eastElementBuilder.face(Direction.EAST).uvs(16, 0, 0, 16).texture("#end").end();
ModelFile eastModel = eastElementBuilder.end();
VariantBlockStateBuilder builder = getVariantBuilder(block);
builder.partialState().with(BlockPillarCap.FACING, Direction.UP).modelForState().modelFile(upModel).addModel();
builder.partialState().with(BlockPillarCap.FACING, Direction.DOWN).modelForState().modelFile(downModel).addModel();
builder.partialState().with(BlockPillarCap.FACING, Direction.NORTH).modelForState().modelFile(northModel).addModel();
builder.partialState().with(BlockPillarCap.FACING, Direction.SOUTH).modelForState().modelFile(southModel).addModel();
builder.partialState().with(BlockPillarCap.FACING, Direction.WEST).modelForState().modelFile(westModel).addModel();
builder.partialState().with(BlockPillarCap.FACING, Direction.EAST).modelForState().modelFile(eastModel).addModel();
}
private BlockModelBuilder rotateTextureFace(BlockModelBuilder file, Direction face, FaceRotation rotation, String texture)
{
// BiConsumer<Direction, ModelBuilder<BlockModelBuilder>.ElementBuilder.FaceBuilder> biCon = (fc, rot) -> {
// rot.rotation(rotation).texture(texture);
// };
return file.element().face(face).uvs(16, 0, 0, 16).rotation(rotation).texture("#east").end().end();
// return file.element().faces(biCon).texture("#east").end();
}
private void buildCubeAll(Block block)
@ -58,6 +221,11 @@ public class GeneratorBlockStates extends BlockStateProvider
getVariantBuilder(block).forAllStates(state -> ConfiguredModel.builder().modelFile(cubeAll(block)).build());
}
// private void buildStairs(StairsBlock block, ResourceLocation texture)
// {
// getVariantBuilder(block).forAllStates(state -> ConfiguredModel.builder().modelFile(stairsBlock(block, texture)).build());
// }
private void buildCrystal(Block block, String name)
{
MultiPartBlockStateBuilder builder = getMultipartBuilder(block);