Commit ca5c47f1 authored by Ticxo's avatar Ticxo
Browse files

Updated to use R3.1.5

parent 555dc5dd
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<groupId>com.ticxo.megmolang</groupId> <groupId>com.ticxo.megmolang</groupId>
<artifactId>Meg-Molang</artifactId> <artifactId>Meg-Molang</artifactId>
<version>R1.0.0</version> <version>R1.0.1</version>
<properties> <properties>
<maven.compiler.source>16</maven.compiler.source> <maven.compiler.source>16</maven.compiler.source>
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
<dependency> <dependency>
<groupId>com.ticxo.modelengine</groupId> <groupId>com.ticxo.modelengine</groupId>
<artifactId>api</artifactId> <artifactId>api</artifactId>
<version>R3.1.1</version> <version>R3.1.5</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
......
package com.ticxo.megml; package com.ticxo.megml;
import com.bedrockk.molang.runtime.MoParams; import com.bedrockk.molang.runtime.MoParams;
import com.ticxo.modelengine.api.animation.AnimationProperty; import com.ticxo.modelengine.api.animation.property.IAnimationProperty;
import com.ticxo.modelengine.api.entity.BaseEntity; import com.ticxo.modelengine.api.entity.BaseEntity;
import com.ticxo.modelengine.api.model.ModeledEntity; import com.ticxo.modelengine.api.model.ModeledEntity;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
...@@ -19,7 +19,7 @@ public class ModelQuery { ...@@ -19,7 +19,7 @@ public class ModelQuery {
private static final Vector ZERO = new Vector(); private static final Vector ZERO = new Vector();
public static final Map<String, BiFunction<MoParams, AnimationProperty, Object>> MODEL_QUERY = new HashMap<>() { public static final Map<String, BiFunction<MoParams, IAnimationProperty, Object>> MODEL_QUERY = new HashMap<>() {
{ {
put("anim_time", (params, property) -> property.getTime()); put("anim_time", (params, property) -> property.getTime());
put("body_y_rotation", (params, property) -> getBase(property).getYBodyRot()); put("body_y_rotation", (params, property) -> getBase(property).getYBodyRot());
...@@ -41,18 +41,18 @@ public class ModelQuery { ...@@ -41,18 +41,18 @@ public class ModelQuery {
return attr == null ? 0 : attr.getValue(); return attr == null ? 0 : attr.getValue();
} }
private static Object livingOrZero(AnimationProperty property, Function<LivingEntity, Object> function) { private static Object livingOrZero(IAnimationProperty property, Function<LivingEntity, Object> function) {
if(getBase(property).getOriginal() instanceof LivingEntity living) { if(getBase(property).getOriginal() instanceof LivingEntity living) {
return function.apply(living); return function.apply(living);
} }
return 0; return 0;
} }
private static BaseEntity<?> getBase(AnimationProperty property) { private static BaseEntity<?> getBase(IAnimationProperty property) {
return getModel(property).getBase(); return getModel(property).getBase();
} }
private static ModeledEntity getModel(AnimationProperty property) { private static ModeledEntity getModel(IAnimationProperty property) {
return property.getModel().getModeledEntity(); return property.getModel().getModeledEntity();
} }
......
package com.ticxo.megml; package com.ticxo.megml;
import com.bedrockk.molang.Expression; import com.bedrockk.molang.Expression;
import com.ticxo.modelengine.api.animation.AnimationProperty;
import com.ticxo.modelengine.api.animation.keyframe.IKeyframeData; import com.ticxo.modelengine.api.animation.keyframe.IKeyframeData;
import com.ticxo.modelengine.api.animation.property.IAnimationProperty;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import java.util.List; import java.util.List;
...@@ -14,7 +14,7 @@ public class QueryData implements IKeyframeData { ...@@ -14,7 +14,7 @@ public class QueryData implements IKeyframeData {
private final List<Expression> script; private final List<Expression> script;
@Override @Override
public double getValue(AnimationProperty property) { public double getValue(IAnimationProperty property) {
var runtime = manager.getOrCreateRuntime(property); var runtime = manager.getOrCreateRuntime(property);
try { try {
var value = runtime.execute(script); var value = runtime.execute(script);
......
...@@ -3,7 +3,7 @@ package com.ticxo.megml; ...@@ -3,7 +3,7 @@ package com.ticxo.megml;
import com.bedrockk.molang.MoLang; import com.bedrockk.molang.MoLang;
import com.bedrockk.molang.runtime.MoLangRuntime; import com.bedrockk.molang.runtime.MoLangRuntime;
import com.bedrockk.molang.runtime.struct.QueryStruct; import com.bedrockk.molang.runtime.struct.QueryStruct;
import com.ticxo.modelengine.api.animation.AnimationProperty; import com.ticxo.modelengine.api.animation.property.IAnimationProperty;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import java.util.Map; import java.util.Map;
...@@ -11,7 +11,7 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -11,7 +11,7 @@ import java.util.concurrent.ConcurrentHashMap;
public class RuntimeManager extends BukkitRunnable { public class RuntimeManager extends BukkitRunnable {
private final Map<AnimationProperty, MoLangRuntime> runtimes = new ConcurrentHashMap<>(); private final Map<IAnimationProperty, MoLangRuntime> runtimes = new ConcurrentHashMap<>();
@Override @Override
public void run() { public void run() {
...@@ -21,7 +21,7 @@ public class RuntimeManager extends BukkitRunnable { ...@@ -21,7 +21,7 @@ public class RuntimeManager extends BukkitRunnable {
} }
} }
public MoLangRuntime getOrCreateRuntime(AnimationProperty property) { public MoLangRuntime getOrCreateRuntime(IAnimationProperty property) {
return runtimes.computeIfAbsent(property, p -> { return runtimes.computeIfAbsent(property, p -> {
var runtime = MoLang.createRuntime(); var runtime = MoLang.createRuntime();
runtime.getEnvironment().getStructs().put("query", new QueryStruct<>(p, ModelQuery.MODEL_QUERY)); runtime.getEnvironment().getStructs().put("query", new QueryStruct<>(p, ModelQuery.MODEL_QUERY));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment