From 9299e754c0501be60c2f1f4dee8aaeb8d838ec70 Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Fri, 3 Jul 2020 11:51:28 -0500 Subject: [PATCH] Generate more stuff --- .../botania/blockstates/fel_pumpkin.json | 19 --- .../botania/models/block/ender_eye_block.json | 4 +- .../models/block/ender_eye_block_powered.json | 4 +- .../botania/models/block/fel_pumpkin.json | 8 ++ .../botania/models/block/mana_detector.json | 4 +- .../models/block/mana_detector_powered.json | 6 + .../botania/models/block/petal_block.json | 2 +- .../botania/data/BlockstateProvider.java | 114 ++++++++++-------- .../botania/models/block/fel_pumpkin.json | 8 -- .../models/block/mana_detector_powered.json | 6 - ...ctivated.png => mana_detector_powered.png} | Bin 11 files changed, 85 insertions(+), 90 deletions(-) delete mode 100644 src/generated/resources/assets/botania/blockstates/fel_pumpkin.json rename src/{main => generated}/resources/assets/botania/models/block/ender_eye_block.json (60%) rename src/{main => generated}/resources/assets/botania/models/block/ender_eye_block_powered.json (63%) create mode 100644 src/generated/resources/assets/botania/models/block/fel_pumpkin.json rename src/{main => generated}/resources/assets/botania/models/block/mana_detector.json (60%) create mode 100644 src/generated/resources/assets/botania/models/block/mana_detector_powered.json rename src/{main => generated}/resources/assets/botania/models/block/petal_block.json (98%) delete mode 100644 src/main/resources/assets/botania/models/block/fel_pumpkin.json delete mode 100644 src/main/resources/assets/botania/models/block/mana_detector_powered.json rename src/main/resources/assets/botania/textures/block/{mana_detector_activated.png => mana_detector_powered.png} (100%) diff --git a/src/generated/resources/assets/botania/blockstates/fel_pumpkin.json b/src/generated/resources/assets/botania/blockstates/fel_pumpkin.json deleted file mode 100644 index da9415ad3..000000000 --- a/src/generated/resources/assets/botania/blockstates/fel_pumpkin.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "variants": { - "facing=north": { - "model": "botania:block/fel_pumpkin" - }, - "facing=south": { - "model": "botania:block/fel_pumpkin", - "y": 180 - }, - "facing=west": { - "model": "botania:block/fel_pumpkin", - "y": 270 - }, - "facing=east": { - "model": "botania:block/fel_pumpkin", - "y": 90 - } - } -} \ No newline at end of file diff --git a/src/main/resources/assets/botania/models/block/ender_eye_block.json b/src/generated/resources/assets/botania/models/block/ender_eye_block.json similarity index 60% rename from src/main/resources/assets/botania/models/block/ender_eye_block.json rename to src/generated/resources/assets/botania/models/block/ender_eye_block.json index 15c4282fb..3774d4946 100644 --- a/src/main/resources/assets/botania/models/block/ender_eye_block.json +++ b/src/generated/resources/assets/botania/models/block/ender_eye_block.json @@ -1,6 +1,6 @@ { - "parent": "minecraft:block/cube_all", + "parent": "block/cube_all", "textures": { "all": "botania:block/ender_eye_block" } -} +} \ No newline at end of file diff --git a/src/main/resources/assets/botania/models/block/ender_eye_block_powered.json b/src/generated/resources/assets/botania/models/block/ender_eye_block_powered.json similarity index 63% rename from src/main/resources/assets/botania/models/block/ender_eye_block_powered.json rename to src/generated/resources/assets/botania/models/block/ender_eye_block_powered.json index 1cbb97847..f198991c1 100644 --- a/src/main/resources/assets/botania/models/block/ender_eye_block_powered.json +++ b/src/generated/resources/assets/botania/models/block/ender_eye_block_powered.json @@ -1,6 +1,6 @@ { - "parent": "minecraft:block/cube_all", + "parent": "block/cube_all", "textures": { "all": "botania:block/ender_eye_block_powered" } -} +} \ No newline at end of file diff --git a/src/generated/resources/assets/botania/models/block/fel_pumpkin.json b/src/generated/resources/assets/botania/models/block/fel_pumpkin.json new file mode 100644 index 000000000..8fcedb2a1 --- /dev/null +++ b/src/generated/resources/assets/botania/models/block/fel_pumpkin.json @@ -0,0 +1,8 @@ +{ + "parent": "block/orientable", + "textures": { + "side": "block/pumpkin_side", + "front": "botania:block/fel_pumpkin", + "top": "block/pumpkin_top" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/botania/models/block/mana_detector.json b/src/generated/resources/assets/botania/models/block/mana_detector.json similarity index 60% rename from src/main/resources/assets/botania/models/block/mana_detector.json rename to src/generated/resources/assets/botania/models/block/mana_detector.json index da7d5290a..3ddc9875b 100644 --- a/src/main/resources/assets/botania/models/block/mana_detector.json +++ b/src/generated/resources/assets/botania/models/block/mana_detector.json @@ -1,6 +1,6 @@ { - "parent": "minecraft:block/cube_all", + "parent": "block/cube_all", "textures": { "all": "botania:block/mana_detector" } -} +} \ No newline at end of file diff --git a/src/generated/resources/assets/botania/models/block/mana_detector_powered.json b/src/generated/resources/assets/botania/models/block/mana_detector_powered.json new file mode 100644 index 000000000..d18b15001 --- /dev/null +++ b/src/generated/resources/assets/botania/models/block/mana_detector_powered.json @@ -0,0 +1,6 @@ +{ + "parent": "block/cube_all", + "textures": { + "all": "botania:block/mana_detector_powered" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/botania/models/block/petal_block.json b/src/generated/resources/assets/botania/models/block/petal_block.json similarity index 98% rename from src/main/resources/assets/botania/models/block/petal_block.json rename to src/generated/resources/assets/botania/models/block/petal_block.json index 937392ae9..3e2245d86 100644 --- a/src/main/resources/assets/botania/models/block/petal_block.json +++ b/src/generated/resources/assets/botania/models/block/petal_block.json @@ -3,4 +3,4 @@ "textures": { "all": "botania:block/petal_block" } -} +} \ No newline at end of file diff --git a/src/main/java/vazkii/botania/data/BlockstateProvider.java b/src/main/java/vazkii/botania/data/BlockstateProvider.java index a468b1297..22a4dc02f 100644 --- a/src/main/java/vazkii/botania/data/BlockstateProvider.java +++ b/src/main/java/vazkii/botania/data/BlockstateProvider.java @@ -16,7 +16,6 @@ import net.minecraft.item.DyeColor; import net.minecraft.state.EnumProperty; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.DoubleBlockHalf; -import net.minecraft.state.properties.SlabType; import net.minecraft.util.Direction; import net.minecraft.util.ResourceLocation; import net.minecraft.util.registry.Registry; @@ -26,6 +25,7 @@ import net.minecraftforge.client.model.generators.ExistingFileHelper; import net.minecraftforge.client.model.generators.ModelFile; import net.minecraftforge.client.model.generators.MultiPartBlockStateBuilder; +import vazkii.botania.common.Botania; import vazkii.botania.common.block.*; import vazkii.botania.common.block.decor.BlockBuriedPetals; import vazkii.botania.common.block.decor.BlockModMushroom; @@ -60,11 +60,16 @@ public class BlockstateProvider extends BlockStateProvider { Set blocks = Registry.BLOCK.stream() .filter(b -> LibMisc.MOD_ID.equals(Registry.BLOCK.getKey(b).getNamespace())) .collect(Collectors.toSet()); - // Manually written blockstates + models + // Manually written blockstate + models blocks.remove(craftCrate); blocks.remove(ghostRail); blocks.remove(solidVines); + // Manually written simpleBlock + manualModel(blocks, cocoon); + manualModel(blocks, corporeaCrystalCube); + manualModel(blocks, runeAltar); + // Single blocks String elfGlassName = Registry.BLOCK.getKey(elfGlass).getPath(); ConfiguredModel[] elfGlassFiles = IntStream.rangeClosed(0, 3) @@ -85,31 +90,33 @@ public class BlockstateProvider extends BlockStateProvider { blocks.remove(ModFluffBlocks.livingrockWall); blocks.remove(ModFluffBlocks.livingwoodWall); + String felName = Registry.BLOCK.getKey(felPumpkin).getPath(); + models().orientable(felName, new ResourceLocation("block/pumpkin_side"), prefix("block/" + felName), + new ResourceLocation("block/pumpkin_top")); + blocks.remove(felPumpkin); + // TESRs with only particles - particleOnly(animatedTorch, new ResourceLocation("block/redstone_torch")); - particleOnly(avatar, prefix("block/livingwood")); - particleOnly(bellows, prefix("block/livingwood")); - particleOnly(brewery, prefix("block/livingrock")); - particleOnly(corporeaIndex, prefix("block/elementium_block")); - particleOnly(lightRelayDetector, prefix("block/luminizer_detector")); + particleOnly(blocks, animatedTorch, new ResourceLocation("block/redstone_torch")); + particleOnly(blocks, avatar, prefix("block/livingwood")); + particleOnly(blocks, bellows, prefix("block/livingwood")); + particleOnly(blocks, brewery, prefix("block/livingrock")); + particleOnly(blocks, corporeaIndex, prefix("block/elementium_block")); + particleOnly(blocks, lightRelayDetector, prefix("block/luminizer_detector")); simpleBlock(fakeAir, models().getBuilder(Registry.BLOCK.getKey(ModBlocks.fakeAir).getPath())); - particleOnly(lightRelayFork, prefix("block/luminizer_fork")); - particleOnly(gaiaHead, new ResourceLocation("block/soul_sand")); - particleOnly(gaiaHeadWall, new ResourceLocation("block/soul_sand")); - particleOnly(gaiaPylon, prefix("block/elementium_block")); - particleOnly(hourglass, prefix("block/mana_glass")); - particleOnly(lightRelayDefault, prefix("block/luminizer")); - particleOnly(manaFlame, new ResourceLocation("block/fire_0")); - particleOnly(manaPylon, prefix("block/manasteel_block")); - particleOnly(naturaPylon, prefix("block/terrasteel_block")); - particleOnly(teruTeruBozu, new ResourceLocation("block/white_wool")); - particleOnly(lightRelayToggle, prefix("block/luminizer_toggle")); + blocks.remove(fakeAir); + particleOnly(blocks, lightRelayFork, prefix("block/luminizer_fork")); + particleOnly(blocks, gaiaHead, new ResourceLocation("block/soul_sand")); + particleOnly(blocks, gaiaHeadWall, new ResourceLocation("block/soul_sand")); + particleOnly(blocks, gaiaPylon, prefix("block/elementium_block")); + particleOnly(blocks, hourglass, prefix("block/mana_glass")); + particleOnly(blocks, lightRelayDefault, prefix("block/luminizer")); + particleOnly(blocks, manaFlame, new ResourceLocation("block/fire_0")); + particleOnly(blocks, manaPylon, prefix("block/manasteel_block")); + particleOnly(blocks, naturaPylon, prefix("block/terrasteel_block")); + particleOnly(blocks, teruTeruBozu, new ResourceLocation("block/white_wool")); + particleOnly(blocks, lightRelayToggle, prefix("block/luminizer_toggle")); - blocks.removeAll(Arrays.asList(animatedTorch, avatar, bellows, brewery, corporeaIndex, lightRelayDetector, - fakeAir, lightRelayFork, gaiaHead, gaiaHeadWall, gaiaPylon, hourglass, - lightRelayDefault, manaFlame, manaPylon, naturaPylon, teruTeruBozu, lightRelayToggle)); - - // Block types + // Block groups Predicate flowers = b -> b instanceof BlockSpecialFlower || b instanceof BlockModMushroom || b instanceof BlockModFlower; @@ -120,6 +127,24 @@ public class BlockstateProvider extends BlockStateProvider { simpleBlock(b, model); }); + takeAll(blocks, pump, tinyPotato).forEach(b -> { + String name = Registry.BLOCK.getKey(b).getPath(); + ModelFile file = models().getExistingFile(prefix("block/" + name)); + horizontalBlock(b, file); + }); + + takeAll(blocks, enderEye, manaDetector).forEach(b -> { + String name = Registry.BLOCK.getKey(b).getPath(); + ModelFile offFile = models().cubeAll(name, prefix("block/" + name)); + ModelFile onFile = models().cubeAll(name + "_powered", prefix("block/" + name + "_powered")); + getVariantBuilder(b).partialState().with(BlockStateProperties.POWERED, false).setModels(new ConfiguredModel(offFile)); + getVariantBuilder(b).partialState().with(BlockStateProperties.POWERED, true).setModels(new ConfiguredModel(onFile)); + }); + + ModelFile petalBlockModel = models().withExistingParent("petal_block", prefix("block/shapes/cube_all_tinted")) + .texture("all", prefix("block/petal_block")); + takeAll(blocks, b -> b instanceof BlockPetalBlock).forEach(b -> simpleBlock(b, petalBlockModel)); + takeAll(blocks, b -> b instanceof StairsBlock).forEach(b -> { String name = Registry.BLOCK.getKey(b).getPath(); String baseName = name.substring(0, name.length() - LibBlockNames.STAIR_SUFFIX.length()); @@ -199,7 +224,7 @@ public class BlockstateProvider extends BlockStateProvider { takeAll(blocks, b -> b instanceof BlockBuriedPetals).forEach(b -> { DyeColor color = ((BlockBuriedPetals) b).color; ResourceLocation wool = new ResourceLocation("block/" + color.func_176610_l() + "_wool"); - particleOnly(b, wool); + particleOnly(blocks, b, wool); }); takeAll(blocks, b -> b instanceof BlockAltar).forEach(b -> { @@ -219,18 +244,6 @@ public class BlockstateProvider extends BlockStateProvider { .partialState().with(RotatedPillarBlock.AXIS, Direction.Axis.X).setModels(new ConfiguredModel(file, 90, 90, false)) .partialState().with(RotatedPillarBlock.AXIS, Direction.Axis.Y).setModels(new ConfiguredModel(file)) .partialState().with(RotatedPillarBlock.AXIS, Direction.Axis.Z).setModels(new ConfiguredModel(file, 90, 0, false)); - } else if (b instanceof SlabBlock) { - ModelFile file = models().getExistingFile(prefix("block/" + name)); - ModelFile fullFile = models().getExistingFile(prefix("block/" + name.substring(0, name.length() - LibBlockNames.SLAB_SUFFIX.length()))); - getVariantBuilder(b) - .partialState().with(SlabBlock.TYPE, SlabType.BOTTOM).setModels(new ConfiguredModel(file)) - .partialState().with(SlabBlock.TYPE, SlabType.TOP).setModels(new ConfiguredModel(file, 180, 0, true)) - .partialState().with(SlabBlock.TYPE, SlabType.DOUBLE).setModels(new ConfiguredModel(fullFile)); - } else if (b instanceof StairsBlock) { - ModelFile stair = models().getExistingFile(prefix("block/" + name)); - ModelFile inner = models().getExistingFile(prefix("block/" + name + "_inner")); - ModelFile outer = models().getExistingFile(prefix("block/" + name + "_outer")); - stairsBlock((StairsBlock) b, stair, inner, outer); } else if (b instanceof FenceBlock) { ModelFile post = models().getExistingFile(prefix("block/" + name + "_post")); ModelFile side = models().getExistingFile(prefix("block/" + name + "_side")); @@ -248,34 +261,32 @@ public class BlockstateProvider extends BlockStateProvider { ModelFile noSide = models().getExistingFile(prefix("block/" + name + "_noside")); ModelFile noSideAlt = models().getExistingFile(prefix("block/" + name + "_noside_alt")); paneBlock((PaneBlock) b, post, side, sideAlt, noSide, noSideAlt); - } else if (b instanceof BlockPetalBlock) { - ModelFile file = models().getExistingFile(prefix("block/petal_block")); - getVariantBuilder(b).partialState().setModels(new ConfiguredModel(file)); - } else if (b == ModBlocks.enderEye || b == ModBlocks.manaDetector) { - ModelFile offFile = models().getExistingFile(prefix("block/" + name)); - ModelFile onFile = models().getExistingFile(prefix("block/" + name + "_powered")); - getVariantBuilder(b).partialState().with(BlockStateProperties.POWERED, false).setModels(new ConfiguredModel(offFile)); - getVariantBuilder(b).partialState().with(BlockStateProperties.POWERED, true).setModels(new ConfiguredModel(onFile)); - } else if (b == ModBlocks.tinyPotato || b == ModBlocks.felPumpkin || b == ModBlocks.pump) { - ModelFile file = models().getExistingFile(prefix("block/" + name)); - horizontalBlock(b, file); } else { simpleBlock(b, models().getExistingFile(prefix("block/" + name))); } }); } - private void particleOnly(Block b, ResourceLocation particle) { + private void particleOnly(Set blocks, Block b, ResourceLocation particle) { String name = Registry.BLOCK.getKey(b).getPath(); ModelFile f = models().getBuilder(name) .texture("particle", particle); simpleBlock(b, f); + blocks.remove(b); + } + + private void manualModel(Set blocks, Block b) { + String name = Registry.BLOCK.getKey(b).getPath(); + simpleBlock(b, models().getExistingFile(prefix("block/" + name))); + blocks.remove(b); } @SafeVarargs private static Iterable takeAll(Set src, T... items) { List ret = Arrays.asList(items); - src.removeAll(ret); + if (!src.removeAll(ret)) { + Botania.LOGGER.warn("takeAll array didn't yield anything ({})", Arrays.toString(items)); + } return ret; } @@ -291,6 +302,9 @@ public class BlockstateProvider extends BlockStateProvider { } } + if (ret.isEmpty()) { + Botania.LOGGER.warn("takeAll predicate yielded nothing", new Throwable()); + } return ret; } diff --git a/src/main/resources/assets/botania/models/block/fel_pumpkin.json b/src/main/resources/assets/botania/models/block/fel_pumpkin.json deleted file mode 100644 index 75a546a41..000000000 --- a/src/main/resources/assets/botania/models/block/fel_pumpkin.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "minecraft:block/orientable", - "textures": { - "top": "minecraft:block/pumpkin_top", - "front": "botania:block/fel_pumpkin", - "side": "minecraft:block/pumpkin_side" - } -} diff --git a/src/main/resources/assets/botania/models/block/mana_detector_powered.json b/src/main/resources/assets/botania/models/block/mana_detector_powered.json deleted file mode 100644 index 9d79a73ba..000000000 --- a/src/main/resources/assets/botania/models/block/mana_detector_powered.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "parent": "minecraft:block/cube_all", - "textures": { - "all": "botania:block/mana_detector_activated" - } -} diff --git a/src/main/resources/assets/botania/textures/block/mana_detector_activated.png b/src/main/resources/assets/botania/textures/block/mana_detector_powered.png similarity index 100% rename from src/main/resources/assets/botania/textures/block/mana_detector_activated.png rename to src/main/resources/assets/botania/textures/block/mana_detector_powered.png