mirror of
https://github.com/xSquishyLiam/mc-GeyserModelEngine-plugin.git
synced 2025-12-19 14:59:19 +00:00
fix
This commit is contained in:
@@ -7,7 +7,6 @@ import com.ticxo.modelengine.api.animation.ModelState;
|
|||||||
import com.ticxo.modelengine.api.animation.handler.AnimationHandler;
|
import com.ticxo.modelengine.api.animation.handler.AnimationHandler;
|
||||||
import com.ticxo.modelengine.api.animation.property.IAnimationProperty;
|
import com.ticxo.modelengine.api.animation.property.IAnimationProperty;
|
||||||
import com.ticxo.modelengine.api.entity.CullType;
|
import com.ticxo.modelengine.api.entity.CullType;
|
||||||
import com.ticxo.modelengine.api.entity.Dummy;
|
|
||||||
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.ModelBone;
|
import com.ticxo.modelengine.api.model.bone.ModelBone;
|
||||||
@@ -25,7 +24,6 @@ import re.imc.geysermodelengine.util.BooleanPacker;
|
|||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@@ -35,9 +33,6 @@ import static re.imc.geysermodelengine.model.ModelEntity.MODEL_ENTITIES;
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class EntityTask {
|
public class EntityTask {
|
||||||
|
|
||||||
private static final String STOP_ANIMATION_PROPERTY = "anim_stop";
|
|
||||||
private static final Map<String, Boolean> ALL_PROPERTIES = Map.of("modelengine:anim_walk", false, "modelengine:anim_idle", false, "modelengine:anim_stop", false);
|
|
||||||
ModelEntity model;
|
ModelEntity model;
|
||||||
|
|
||||||
int tick = 0;
|
int tick = 0;
|
||||||
@@ -49,7 +44,7 @@ public class EntityTask {
|
|||||||
Color lastColor = null;
|
Color lastColor = null;
|
||||||
Map<String, Integer> lastIntSet = new ConcurrentHashMap<>();
|
Map<String, Integer> lastIntSet = new ConcurrentHashMap<>();
|
||||||
Cache<String, Boolean> lastPlayedAnim = CacheBuilder.newBuilder()
|
Cache<String, Boolean> lastPlayedAnim = CacheBuilder.newBuilder()
|
||||||
.expireAfterWrite(50, TimeUnit.MILLISECONDS).build();
|
.expireAfterWrite(30, TimeUnit.MILLISECONDS).build();
|
||||||
|
|
||||||
private BukkitRunnable syncTask;
|
private BukkitRunnable syncTask;
|
||||||
private BukkitRunnable asyncTask;
|
private BukkitRunnable asyncTask;
|
||||||
@@ -210,8 +205,7 @@ public class EntityTask {
|
|||||||
|
|
||||||
Map<String, Boolean> boneUpdates = new HashMap<>();
|
Map<String, Boolean> boneUpdates = new HashMap<>();
|
||||||
Map<String, Boolean> animUpdates = new HashMap<>();
|
Map<String, Boolean> animUpdates = new HashMap<>();
|
||||||
Set<String> overrideAnimUpdates = new HashSet<>();
|
Set<String> anims = new HashSet<>();
|
||||||
Set<String> defaultAnims = 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) -> {
|
model.getActiveModel().getBones().forEach((s, bone) -> {
|
||||||
String name = unstripName(bone).toLowerCase();
|
String name = unstripName(bone).toLowerCase();
|
||||||
@@ -226,32 +220,27 @@ public class EntityTask {
|
|||||||
boneUpdates.put(name, bone.isVisible());
|
boneUpdates.put(name, bone.isVisible());
|
||||||
});
|
});
|
||||||
// }
|
// }
|
||||||
for (ModelState state : ModelState.values()) {
|
|
||||||
AnimationHandler.DefaultProperty p = model.getActiveModel().getAnimationHandler().getDefaultProperty(state);
|
AnimationHandler handler = model.getActiveModel().getAnimationHandler();
|
||||||
if (p != null){
|
Set<String> priority = model.getActiveModel().getBlueprint().getAnimationDescendingPriority();
|
||||||
defaultAnims.add(p.getAnimation());
|
for (String animId : priority) {
|
||||||
|
if (handler.isPlayingAnimation(animId)) {
|
||||||
|
BlueprintAnimation anim = model.getActiveModel().getBlueprint().getAnimations().get(animId);
|
||||||
|
|
||||||
|
anims.add(animId);
|
||||||
|
if (anim.isOverride() && anim.getLoopMode() == BlueprintAnimation.LoopMode.ONCE) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
model.getActiveModel().getBlueprint().getAnimations().forEach((s, anim) -> {
|
for (String id : priority) {
|
||||||
if (anim.isOverride() && !defaultAnims.contains(s) && (model.getActiveModel().getAnimationHandler().isPlayingAnimation(s) || forceAnimSet.contains(s))) {
|
if (anims.contains(id)) {
|
||||||
overrideAnimUpdates.add(s);
|
animUpdates.put(id, true);
|
||||||
}
|
|
||||||
});
|
|
||||||
model.getActiveModel().getBlueprint().getAnimations().forEach((s, anim) -> {
|
|
||||||
if (overrideAnimUpdates.isEmpty()) {
|
|
||||||
animUpdates.put(s, model.getActiveModel().getAnimationHandler().isPlayingAnimation(s) || forceAnimSet.contains(s));
|
|
||||||
} else {
|
} else {
|
||||||
if (overrideAnimUpdates.contains(s)) {
|
animUpdates.put(id, false);
|
||||||
animUpdates.put(s, true);
|
|
||||||
} else if (defaultAnims.contains(s)) {
|
|
||||||
animUpdates.put(s, false);
|
|
||||||
} else {
|
|
||||||
animUpdates.put(s, model.getActiveModel().getAnimationHandler().isPlayingAnimation(s) || forceAnimSet.contains(s));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
|
||||||
Set<String> lastPlayed = new HashSet<>(lastPlayedAnim.asMap().keySet());
|
Set<String> lastPlayed = new HashSet<>(lastPlayedAnim.asMap().keySet());
|
||||||
|
|
||||||
@@ -265,6 +254,7 @@ public class EntityTask {
|
|||||||
animUpdates.put(anim, true);
|
animUpdates.put(anim, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (boneUpdates.isEmpty() && animUpdates.isEmpty()) return;
|
if (boneUpdates.isEmpty() && animUpdates.isEmpty()) return;
|
||||||
|
|
||||||
Map<String, Integer> intUpdates = new HashMap<>();
|
Map<String, Integer> intUpdates = new HashMap<>();
|
||||||
|
|||||||
Reference in New Issue
Block a user