9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-25 09:59:20 +00:00

应当支持trim

This commit is contained in:
XiaoMoMi
2025-07-01 02:55:16 +08:00
parent c58bc5448e
commit 2db43db95e
3 changed files with 16 additions and 11 deletions

View File

@@ -672,7 +672,7 @@ public abstract class AbstractItemManager<I> extends AbstractModelGenerator impl
List<String> cases = entry.getKey().fallbackOrMapPrimary(List::of);
for (String caseValue : cases) {
Number legacyValue = predicate.toLegacyValue(caseValue);
if (predicate instanceof TrimMaterialSelectProperty property && property.isArmor(materialId)) {
if (predicate instanceof TrimMaterialSelectProperty) {
if (legacyValue.floatValue() > 1f) {
continue;
}
@@ -713,7 +713,7 @@ public abstract class AbstractItemManager<I> extends AbstractModelGenerator impl
materialId,
customModelData
);
} else if (predicate instanceof TrimMaterialSelectProperty property && property.isArmor(materialId)) {
} else if (predicate instanceof TrimMaterialSelectProperty) {
processModelRecursively(
model.fallBack(),
mergePredicates(

View File

@@ -787,6 +787,7 @@ public abstract class AbstractPackManager implements PackManager {
@SuppressWarnings("DuplicatedCode")
private void validateResourcePack(Path path) {
long time1 = System.currentTimeMillis();
Path[] rootPaths;
try {
rootPaths = FileUtils.collectOverlays(path).toArray(new Path[0]);
@@ -917,6 +918,9 @@ public abstract class AbstractPackManager implements PackManager {
}
}
long time2 = System.currentTimeMillis();
this.plugin.debug(() -> "Took " + (time2 - time1) + "ms collecting assets");
// 验证font的贴图是否存在
label: for (Map.Entry<Key, Collection<Key>> entry : imageToFonts.asMap().entrySet()) {
Key key = entry.getKey();
@@ -930,6 +934,9 @@ public abstract class AbstractPackManager implements PackManager {
TranslationManager.instance().log("warning.config.resource_pack.generation.missing_font_texture", entry.getValue().stream().distinct().toList().toString(), imagePath);
}
long time3 = System.currentTimeMillis();
this.plugin.debug(() -> "Took " + (time3 - time2) + "ms verifying font textures");
// 验证物品模型是否存在,验证的同时去收集贴图
label: for (Map.Entry<Key, Collection<Key>> entry : modelToItems.asMap().entrySet()) {
Key modelResourceLocation = entry.getKey();
@@ -975,6 +982,9 @@ public abstract class AbstractPackManager implements PackManager {
TranslationManager.instance().log("warning.config.resource_pack.generation.missing_block_model", entry.getValue().stream().distinct().toList().toString(), modelPath);
}
long time4 = System.currentTimeMillis();
this.plugin.debug(() -> "Took " + (time4 - time3) + "ms verifying models and their parents");
// 验证贴图是否存在
boolean enableObf = Config.enableObfuscation() && Config.enableRandomResourceLocation();
label: for (Map.Entry<Key, Collection<Key>> entry : imageToModels.asMap().entrySet()) {
@@ -1007,6 +1017,9 @@ public abstract class AbstractPackManager implements PackManager {
TranslationManager.instance().log("warning.config.resource_pack.generation.texture_not_in_atlas", key.toString());
}
}
long time5 = System.currentTimeMillis();
this.plugin.debug(() -> "Took " + (time5 - time4) + "ms verifying model textures");
}
private void verifyParentModelAndCollectTextures(Key sourceModelLocation, JsonObject sourceModelJson, Path[] rootPaths, Multimap<Key, Key> imageToModels, Set<Key> collected) {

View File

@@ -39,10 +39,7 @@ public class TrimMaterialSelectProperty implements SelectProperty, LegacyModelPr
@Override
public String legacyPredicateId(Key material) {
if (isArmor(material)) {
return "trim_type";
}
return null;
return "trim_type";
}
@Override
@@ -54,11 +51,6 @@ public class TrimMaterialSelectProperty implements SelectProperty, LegacyModelPr
return f;
}
public boolean isArmor(Key material) {
String s = material.toString();
return s.contains("helmet") || s.contains("chestplate") || s.contains("leggings") || s.contains("boots");
}
public static class Factory implements SelectPropertyFactory {
@Override
public SelectProperty create(Map<String, Object> arguments) {