mirror of
https://github.com/GeyserExtensionists/GeyserModelEngine.git
synced 2025-12-19 15:09:18 +00:00
use int property
This commit is contained in:
@@ -33,7 +33,7 @@ import static re.imc.geysermodelengine.model.ModelEntity.MODEL_ENTITIES;
|
|||||||
@Setter
|
@Setter
|
||||||
public class EntityTask {
|
public class EntityTask {
|
||||||
|
|
||||||
private static final String STOP_ANIMATION_PROPERTY = "anim_stop";
|
private static final String ANIMATION_PROPERTY = "modelengine:anim";
|
||||||
ModelEntity model;
|
ModelEntity model;
|
||||||
|
|
||||||
int tick = 0;
|
int tick = 0;
|
||||||
@@ -51,8 +51,8 @@ public class EntityTask {
|
|||||||
|
|
||||||
|
|
||||||
String lastAnimation = "";
|
String lastAnimation = "";
|
||||||
String currentAnimProperty = "anim_spawn";
|
int currentAnimProperty = 1;
|
||||||
String lastAnimProperty = "";
|
int lastAnimProperty = -1;
|
||||||
|
|
||||||
boolean looping = true;
|
boolean looping = true;
|
||||||
|
|
||||||
@@ -149,11 +149,11 @@ public class EntityTask {
|
|||||||
} else if (base.isJumping() && hasAnimation("jump")) {
|
} else if (base.isJumping() && hasAnimation("jump")) {
|
||||||
playAnimation("jump", 30);
|
playAnimation("jump", 30);
|
||||||
} else if (base.isWalking() && hasAnimation("walk")) {
|
} else if (base.isWalking() && hasAnimation("walk")) {
|
||||||
setAnimationProperty("modelengine:anim_walk");
|
setAnimationProperty(3);
|
||||||
// playAnimation("walk", 20);
|
// playAnimation("walk", 20);
|
||||||
} else if (hasAnimation("idle")) {
|
} else if (hasAnimation("idle")) {
|
||||||
// playAnimation("idle", 0);
|
// playAnimation("idle", 0);
|
||||||
setAnimationProperty("modelengine:anim_idle");
|
setAnimationProperty(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (animationCooldown.get() > 0) {
|
if (animationCooldown.get() > 0) {
|
||||||
@@ -162,6 +162,7 @@ public class EntityTask {
|
|||||||
|
|
||||||
Optional<Player> player = viewers.stream().findAny();
|
Optional<Player> player = viewers.stream().findAny();
|
||||||
if (player.isEmpty()) return;
|
if (player.isEmpty()) return;
|
||||||
|
|
||||||
updateEntityProperties(player.get(), false);
|
updateEntityProperties(player.get(), false);
|
||||||
|
|
||||||
// do not actually use this, atleast bundle these up ;(
|
// do not actually use this, atleast bundle these up ;(
|
||||||
@@ -225,9 +226,7 @@ public class EntityTask {
|
|||||||
lastColor = color;
|
lastColor = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAnimationProperty(String currentAnimProperty) {
|
public void setAnimationProperty(int currentAnimProperty) {
|
||||||
model.getViewers().forEach(viewer -> viewer.sendActionBar("CURRENT P AN:" + currentAnimProperty));
|
|
||||||
|
|
||||||
this.lastAnimProperty = currentAnimProperty;
|
this.lastAnimProperty = currentAnimProperty;
|
||||||
this.currentAnimProperty = currentAnimProperty;
|
this.currentAnimProperty = currentAnimProperty;
|
||||||
}
|
}
|
||||||
@@ -255,18 +254,20 @@ public class EntityTask {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int animationUpdate = -1;
|
||||||
|
|
||||||
|
if (ignore || !(lastAnimProperty == currentAnimProperty)) {
|
||||||
if (ignore || !lastAnimProperty.equals(currentAnimProperty)) {
|
|
||||||
if (animationCooldown.get() == 0) {
|
if (animationCooldown.get() == 0) {
|
||||||
updates.put("modelengine:" + lastAnimProperty, false);
|
animationUpdate = currentAnimProperty;
|
||||||
updates.put("modelengine:" + currentAnimProperty, true);
|
|
||||||
} else {
|
} else {
|
||||||
updates.put("modelengine:" + lastAnimProperty, false);
|
animationUpdate = 0;
|
||||||
updates.put("modelengine:" + STOP_ANIMATION_PROPERTY, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (animationUpdate != -1) {
|
||||||
|
EntityUtils.sendIntProperty(player, entity, ANIMATION_PROPERTY, animationUpdate);
|
||||||
|
}
|
||||||
if (updates.isEmpty()) return;
|
if (updates.isEmpty()) return;
|
||||||
|
|
||||||
EntityUtils.sendBoolProperties(player, entity, updates);
|
EntityUtils.sendBoolProperties(player, entity, updates);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,8 +332,8 @@ public class EntityTask {
|
|||||||
|
|
||||||
|
|
||||||
if (play) {
|
if (play) {
|
||||||
setAnimationProperty(STOP_ANIMATION_PROPERTY);
|
setAnimationProperty(0);
|
||||||
model.getViewers().forEach(viewer -> updateEntityProperties(viewer, false));
|
|
||||||
currentAnimationPriority.set(p);
|
currentAnimationPriority.set(p);
|
||||||
|
|
||||||
String id = "animation." + activeModel.getBlueprint().getName().toLowerCase() + "." + animationProperty.getName().toLowerCase();
|
String id = "animation." + activeModel.getBlueprint().getName().toLowerCase() + "." + animationProperty.getName().toLowerCase();
|
||||||
|
|||||||
Reference in New Issue
Block a user