use of net.minecraft.client.renderer.model.ItemCameraTransforms in project tetra by mickelus.
the class ModularModelLoader method read.
@Override
public ModularItemModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents) {
ItemCameraTransforms cameraTransforms = deserializationContext.deserialize(modelContents.get("display"), ItemCameraTransforms.class);
if (modelContents.has("variants")) {
Map<String, ItemCameraTransforms> transformVariants = deserializationContext.deserialize(modelContents.get("variants"), new TypeToken<Map<String, ItemCameraTransforms>>() {
}.getType());
ModularItemModel model = new ModularItemModel(cameraTransforms, transformVariants);
models.add(model);
return model;
}
ModularItemModel model = new ModularItemModel(cameraTransforms);
models.add(model);
return model;
}
use of net.minecraft.client.renderer.model.ItemCameraTransforms in project Magma-1.16.x by magmafoundation.
the class DataGeneratorTest method testModelResults.
private static <T extends ModelBuilder<T>> List<String> testModelResults(Map<ResourceLocation, T> models, ExistingFileHelper existingFileHelper, Set<ResourceLocation> toIgnore) {
List<String> ret = new ArrayList<>();
models.forEach((loc, model) -> {
if (toIgnore.contains(loc))
return;
JsonObject generated = model.toJson();
if (generated.has("parent")) {
generated.addProperty("parent", toVanillaModel(generated.get("parent").getAsString()));
}
try {
IResource vanillaResource = existingFileHelper.getResource(new ResourceLocation(loc.getPath()), ResourcePackType.CLIENT_RESOURCES, ".json", "models");
JsonObject existing = GSON.fromJson(new InputStreamReader(vanillaResource.getInputStream()), JsonObject.class);
JsonElement generatedDisplay = generated.remove("display");
JsonElement vanillaDisplay = existing.remove("display");
if (generatedDisplay == null && vanillaDisplay != null) {
ret.add("Model " + loc + " is missing transforms");
return;
} else if (generatedDisplay != null && vanillaDisplay == null) {
ret.add("Model " + loc + " has transforms when vanilla equivalent does not");
return;
} else if (generatedDisplay != null) {
// Both must be non-null
ItemCameraTransforms generatedTransforms = GSON.fromJson(generatedDisplay, ItemCameraTransforms.class);
ItemCameraTransforms vanillaTransforms = GSON.fromJson(vanillaDisplay, ItemCameraTransforms.class);
for (Perspective type : Perspective.values()) {
if (!generatedTransforms.getTransform(type.vanillaType).equals(vanillaTransforms.getTransform(type.vanillaType))) {
ret.add("Model " + loc + " has transforms that differ from vanilla equivalent for perspective " + type.name());
return;
}
}
}
JsonElement generatedTextures = generated.remove("textures");
JsonElement vanillaTextures = existing.remove("textures");
if (generatedTextures == null && vanillaTextures != null) {
ret.add("Model " + loc + " is missing textures");
} else if (generatedTextures != null && vanillaTextures == null) {
ret.add("Model " + loc + " has textures when vanilla equivalent does not");
} else if (generatedTextures != null) {
// Both must be non-null
for (Map.Entry<String, JsonElement> e : generatedTextures.getAsJsonObject().entrySet()) {
String vanillaTexture = vanillaTextures.getAsJsonObject().get(e.getKey()).getAsString();
if (!e.getValue().getAsString().equals(vanillaTexture)) {
ret.add("Texture for variable '" + e.getKey() + "' for model " + loc + " does not match vanilla equivalent");
}
}
if (generatedTextures.getAsJsonObject().size() != vanillaTextures.getAsJsonObject().size()) {
ret.add("Model " + loc + " is missing textures from vanilla equivalent");
}
}
if (!existing.equals(generated)) {
ret.add("Model " + loc + " does not match vanilla equivalent");
}
} catch (IOException e) {
throw new RuntimeException(e);
}
});
return ret;
}
Aggregations