Fix BlockStateProvider item models not knowing about block models

Add tests for this case
This commit is contained in:
tterrag 2020-12-10 21:33:49 -05:00
parent b7fb6484d7
commit a57a240c13
5 changed files with 19 additions and 3 deletions

View File

@ -41,10 +41,12 @@ c4d268471ee793597917c966d1aaed29e438d366 assets/data_gen_test/models/block/oak_t
2abb8b11c91441badd91b7c52f5f8ba3226c92de assets/data_gen_test/models/block/oak_trapdoor_open.json
560d419e3d542cb0509bca078988308d387c15a9 assets/data_gen_test/models/block/oak_trapdoor_top.json
556f0d997250661e0401fba13a4afd1bb0627dcc assets/data_gen_test/models/block/stone.json
556f0d997250661e0401fba13a4afd1bb0627dcc assets/data_gen_test/models/block/test_block.json
db2cd929128c8a6e8e0b02437f90ad8d24238206 assets/data_gen_test/models/block/torch.json
81ce9ac0a7f4ed7a94d5496b918987a6f5a24988 assets/data_gen_test/models/block/wall_torch.json
6b40df2a47c13cd00e295244b6cf74462938359d assets/data_gen_test/models/item/fishing_rod.json
7fecdc30a209fca790df79b973c30b9e84415e0b assets/data_gen_test/models/item/fishing_rod_cast.json
098d8b38409fff6cc14a4e56355bedb1fc5931d1 assets/data_gen_test/models/item/test_block.json
b029993275f16569b0edf093362f55df6ea6f9be assets/data_gen_test/models/item/test_block_model.json
726e1884e53151492ca05bd752c67031603570f6 assets/data_gen_test/models/item/test_generated_model.json
1767c874758bd7c3235db446b6219e6e1edd25b4 assets/minecraft/blockstates/acacia_door.json

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "minecraft:block/stone"
}
}

View File

@ -0,0 +1,3 @@
{
"parent": "data_gen_test:block/test_block"
}

View File

@ -95,7 +95,7 @@ public abstract class BlockStateProvider implements IDataProvider {
this.blockModels = new BlockModelProvider(gen, modid, exFileHelper) {
@Override protected void registerModels() {}
};
this.itemModels = new ItemModelProvider(gen, modid, exFileHelper) {
this.itemModels = new ItemModelProvider(gen, modid, this.blockModels.existingFileHelper) {
@Override protected void registerModels() {}
};
}

View File

@ -41,6 +41,7 @@ import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
import com.google.common.collect.ObjectArrays;
import com.google.common.collect.Sets;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
@ -438,7 +439,7 @@ public class DataGeneratorTest
ModelFile barrel = models().cubeBottomTop("barrel", mcLoc("block/barrel_side"), mcLoc("block/barrel_bottom"), mcLoc("block/barrel_top"));
ModelFile barrelOpen = models().cubeBottomTop("barrel_open", mcLoc("block/barrel_side"), mcLoc("block/barrel_bottom"), mcLoc("block/barrel_top_open"));
directionalBlock(Blocks.BARREL, state -> state.get(BarrelBlock.PROPERTY_OPEN) ? barrelOpen : barrel); // Testing custom state interpreter
logBlock((RotatedPillarBlock) Blocks.ACACIA_LOG);
stairsBlock((StairsBlock) Blocks.ACACIA_STAIRS, "acacia", mcLoc("block/acacia_planks"));
@ -457,6 +458,9 @@ public class DataGeneratorTest
simpleBlock(Blocks.TORCH, models().torch("torch", mcLoc("block/torch")));
horizontalBlock(Blocks.WALL_TORCH, models().torchWall("wall_torch", mcLoc("block/torch")), 90);
models().cubeAll("test_block", mcLoc("block/stone"));
itemModels().withExistingParent("test_block", modLoc("block/test_block"));
}
// Testing the outputs
@ -465,6 +469,7 @@ public class DataGeneratorTest
// Vanilla doesn't generate these models yet, so they have minor discrepancies that are hard to test
// This list should probably be cleared and investigated after each major version update
private static final Set<ResourceLocation> IGNORED_MODELS = ImmutableSet.of(new ResourceLocation(MODID, "block/cube"));
private static final Set<ResourceLocation> CUSTOM_MODELS = ImmutableSet.of(new ResourceLocation(MODID, "block/test_block"));
private List<String> errors = new ArrayList<>();
@ -472,7 +477,7 @@ public class DataGeneratorTest
public void act(DirectoryCache cache) throws IOException
{
super.act(cache);
this.errors.addAll(testModelResults(models().generatedModels, models().existingFileHelper, IGNORED_MODELS));
this.errors.addAll(testModelResults(models().generatedModels, models().existingFileHelper, Sets.union(IGNORED_MODELS, CUSTOM_MODELS)));
this.registeredBlocks.forEach((block, state) -> {
if (IGNORED_BLOCKS.contains(block)) return;
JsonObject generated = state.toJson();