Fix obj models having all faces in the same mesh, breaking material assignments and visibility in the process.

Reintroduce lost patch from the model loader, which would cause the custom values to be missing from generated models.
This commit is contained in:
David Quintana 2019-12-20 18:13:27 +01:00
parent 18e97a487d
commit ac61018806
3 changed files with 24 additions and 42 deletions

View file

@ -0,0 +1,10 @@
--- a/net/minecraft/client/renderer/model/ItemModelGenerator.java
+++ b/net/minecraft/client/renderer/model/ItemModelGenerator.java
@@ -36,6 +36,7 @@
map.put("particle", p_209579_2_.func_178300_b("particle") ? Either.left(p_209579_2_.func_228816_c_("particle")) : map.get("layer0"));
BlockModel blockmodel = new BlockModel((ResourceLocation)null, list, map, false, false, p_209579_2_.func_181682_g(), p_209579_2_.func_187966_f());
blockmodel.field_178317_b = p_209579_2_.field_178317_b;
+ blockmodel.customData.copyFrom(p_209579_2_.customData);
return blockmodel;
}

View file

@ -121,26 +121,14 @@ public class OBJModel implements IMultipartModelGeometry<OBJModel>
if (!Objects.equals(newMat, currentMat))
{
currentMat = newMat;
if (currentMesh != null && currentMesh.mat == null)
if (currentMesh != null && currentMesh.mat == null && currentMesh.faces.size() == 0)
{
currentMesh.mat = currentMat;
}
else
{
currentMesh = new ModelMesh(currentMat, currentSmoothingGroup);
if (currentObject != null)
{
currentObject.meshes.add(currentMesh);
}
else
{
if (currentGroup == null)
{
currentGroup = new ModelGroup("");
parts.put("", currentGroup);
}
currentGroup.meshes.add(currentMesh);
}
// Start new mesh
currentMesh = null;
}
}
break;
@ -216,26 +204,14 @@ public class OBJModel implements IMultipartModelGeometry<OBJModel>
if (!Objects.equals(currentSmoothingGroup, smoothingGroup))
{
currentSmoothingGroup = smoothingGroup;
if (currentMesh != null && currentMesh.smoothingGroup == null)
if (currentMesh != null && currentMesh.smoothingGroup == null && currentMesh.faces.size() == 0)
{
currentMesh.smoothingGroup = currentSmoothingGroup;
}
else
{
currentMesh = new ModelMesh(currentMat, currentSmoothingGroup);
if (currentObject != null)
{
currentObject.meshes.add(currentMesh);
}
else
{
if (currentGroup == null)
{
currentGroup = new ModelGroup("");
parts.put("", currentGroup);
}
currentGroup.meshes.add(currentMesh);
}
// Start new mesh
currentMesh = null;
}
}
break;
@ -246,19 +222,17 @@ public class OBJModel implements IMultipartModelGeometry<OBJModel>
String name = line[1];
if (objAboveGroup)
{
currentObject = new ModelObject(name);
if (currentMat != null || currentSmoothingGroup != null )
currentObject.meshes.add(new ModelMesh(currentMat, currentSmoothingGroup));
currentObject = new ModelObject(currentGroup.name() + "/" + name);
currentGroup.parts.put(name, currentObject);
}
else
{
currentGroup = new ModelGroup(name);
if (currentMat != null || currentSmoothingGroup != null )
currentGroup.meshes.add(new ModelMesh(currentMat, currentSmoothingGroup));
parts.put(name, currentGroup);
currentObject = null;
}
// Start new mesh
currentMesh = null;
break;
}
@ -270,18 +244,16 @@ public class OBJModel implements IMultipartModelGeometry<OBJModel>
objAboveGroup = true;
currentGroup = new ModelGroup(name);
if (currentMat != null || currentSmoothingGroup != null )
currentGroup.meshes.add(new ModelMesh(currentMat, currentSmoothingGroup));
parts.put(name, currentGroup);
currentObject = null;
}
else
{
currentObject = new ModelObject(name);
if (currentMat != null || currentSmoothingGroup != null )
currentObject.meshes.add(new ModelMesh(currentMat, currentSmoothingGroup));
currentObject = new ModelObject(currentGroup.name() + "/" + name);
currentGroup.parts.put(name, currentObject);
}
// Start new mesh
currentMesh = null;
break;
}
}

View file

@ -47,7 +47,7 @@ loaderVersion="[28,)"
modId="flower_pot_test"
[[mods]]
modId="player_xp_event_test"
[[mods]]
modId="custom_tnt_test"
##[[mods]]
## modId="custom_tnt_test"
[[mods]]
modId="new_model_loader_test"