Add option to tool model to add a part with no material textures
Will be useful for slimeskulls later, or for multi-layer tool textures
@@ -152,6 +152,8 @@ public class ToolModel implements IModelGeometry<ToolModel> {
}
} else {
for (ToolPart part : toolParts) {
+ // if material variants, fetch textures from the material model
+ if (part.hasMaterials()) {
MaterialModel.getMaterialTextures(allTextures, owner, part.getName(false, false), null);
if (part.hasBroken()) {
MaterialModel.getMaterialTextures(allTextures, owner, part.getName(true, false), null);
@@ -162,6 +164,19 @@ public class ToolModel implements IModelGeometry<ToolModel> {
MaterialModel.getMaterialTextures(allTextures, owner, part.getName(true, true), null);
}
}
+ } else {
+ // static texture
+ allTextures.add(owner.resolveTexture(part.getName(false, false)));
+ if (part.hasBroken()) {
+ allTextures.add(owner.resolveTexture(part.getName(true, false)));
+ }
+ if (isLarge) {
+ allTextures.add(owner.resolveTexture(part.getName(false, true)));
+ if (part.hasBroken()) {
+ allTextures.add(owner.resolveTexture(part.getName(true, true)));
+ }
+ }
+ }
}
}
// load modifier models
@@ -247,6 +262,8 @@ public class ToolModel implements IModelGeometry<ToolModel> {
} else {
for (int i = parts.size() - 1; i >= 0; i--) {
ToolPart part = parts.get(i);
+ if (part.hasMaterials()) {
+ // part with materials
int index = part.getIndex();
MaterialId material = null;
if (index < materials.size()) {
@@ -257,6 +274,14 @@ public class ToolModel implements IModelGeometry<ToolModel> {
if (largeTransforms != null) {
MaterialModel.getPartQuads(largeConsumer, owner, spriteGetter, largeTransforms, part.getName(isBroken, true), -1, material, largePixels);
}
+ } else {
+ // part without materials
+ particle = spriteGetter.apply(owner.resolveTexture(part.getName(isBroken, false)));
+ smallConsumer.accept(ItemLayerModel.getQuadsForSprite(-1, particle, TransformationMatrix.identity()));
+ if (largeTransforms != null) {
+ largeConsumer.accept(ItemLayerModel.getQuadsForSprite(-1, spriteGetter.apply(owner.resolveTexture(part.getName(isBroken, true))), largeTransforms));
+ }
+ }
}
}
@@ -296,6 +321,11 @@ public class ToolModel implements IModelGeometry<ToolModel> {
return broken != null;
}
+ /** If true, this part has material variants */
+ public boolean hasMaterials() {
+ return index >= 0;
+ }
+
/**
* Gets the name for this part
* @param isBroken If true, this part is broken
@@ -316,7 +346,7 @@ public class ToolModel implements IModelGeometry<ToolModel> {
/** Reads a part from JSON */
public static ToolPart read(JsonObject json) {
String name = JSONUtils.getString(json, "name");
- int index = JSONUtils.getInt(json, "index");
+ int index = JSONUtils.getInt(json, "index", -1);
String broken = null;
if (json.has("broken")) {
broken = JSONUtils.getString(json, "broken");
