basic fix for submodel

This commit is contained in:
zimzaza4
2024-12-15 12:38:27 +08:00
parent d463176203
commit 8a0a1a3983

View File

@@ -5,6 +5,7 @@ import com.google.common.cache.CacheBuilder;
import com.ticxo.modelengine.api.animation.BlueprintAnimation; import com.ticxo.modelengine.api.animation.BlueprintAnimation;
import com.ticxo.modelengine.api.animation.handler.AnimationHandler; import com.ticxo.modelengine.api.animation.handler.AnimationHandler;
import com.ticxo.modelengine.api.entity.CullType; import com.ticxo.modelengine.api.entity.CullType;
import com.ticxo.modelengine.api.generator.blueprint.BlueprintBone;
import com.ticxo.modelengine.api.model.ActiveModel; import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity; import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.BoneBehaviorTypes; import com.ticxo.modelengine.api.model.bone.BoneBehaviorTypes;
@@ -197,20 +198,10 @@ public class EntityTask {
Map<String, Boolean> animUpdates = new HashMap<>(); Map<String, Boolean> animUpdates = new HashMap<>();
Set<String> anims = new HashSet<>(); Set<String> anims = new HashSet<>();
// if (GeyserModelEngine.getInstance().getEnablePartVisibilityModels().contains(model.getActiveModel().getBlueprint().getName())) { // if (GeyserModelEngine.getInstance().getEnablePartVisibilityModels().contains(model.getActiveModel().getBlueprint().getName())) {
model.getActiveModel().getBones().forEach((s, bone) -> {
String name = unstripName(bone).toLowerCase();
if (name.equals("hitbox") || model.getActiveModel().getBlueprint().getBones().forEach((s, bone) -> {
name.equals("shadow") || processBone(bone, boneUpdates);
name.equals("mount") ||
name.startsWith("p_") ||
name.startsWith("b_") ||
name.startsWith("ob_")) {
return;
}
boneUpdates.put(name, bone.isVisible());
}); });
// } // }
@@ -285,10 +276,31 @@ public class EntityTask {
} }
} }
private String unstripName(ModelBone bone) { private void processBone(BlueprintBone bone, Map<String, Boolean> map) {
String name = bone.getBoneId(); String name = unstripName(bone).toLowerCase();
if (bone.getBlueprintBone().getBehaviors().get("head") != null) { if (name.equals("hitbox") ||
if (!bone.getBlueprintBone().getBehaviors().get("head").isEmpty()) return "hi_" + name; name.equals("shadow") ||
name.equals("mount") ||
name.startsWith("p_") ||
name.startsWith("b_") ||
name.startsWith("ob_")) {
return;
}
for (BlueprintBone blueprintBone : bone.getChildren().values()) {
processBone(blueprintBone, map);
}
ModelBone activeBone = model.getActiveModel().getBones().get(bone.getName());
boolean visible = false;
if (activeBone != null) {
visible = activeBone.isVisible();
}
map.put(name, visible);
}
private String unstripName(BlueprintBone bone) {
String name = bone.getName();
if (bone.getBehaviors().get("head") != null) {
if (!bone.getBehaviors().get("head").isEmpty()) return "hi_" + name;
return "h_" + name; return "h_" + name;
} }