Skip to content

Commit

Permalink
No. Why? Should've added this earlier.
Browse files Browse the repository at this point in the history
  • Loading branch information
melontini committed Apr 26, 2024
1 parent b775df7 commit e044994
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
5 changes: 1 addition & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
### What's New:

* Added entity parameter to `cmd:explode`. The entity will be marked as the "creator" of the explosion and other entities will redirect their anger to the entity if affected by the explosion.
* Added fire parameter to `cmd:explode`. Creates fire, if true.
* Fixed `double` casts converting numbers to scientific notation.
* `long` and `int` casts no longer actually convert to their types, instead they truncate the trailing zeros.
* Added `hasContext` function to expressions. Allows checking if loot context has the required parameter: `if(hasContext("tool"), "Hi", "Bye")`
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.15.7
# Mod Properties
mod_version=0.3.0
mod_version=0.3.1
maven_group=me.melontini
archives_base_name=commander
# Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import me.melontini.commander.api.expression.Arithmetica;
import me.melontini.commander.impl.event.data.types.ExtractionTypes;
import me.melontini.commander.impl.util.functions.ClampFunction;
import me.melontini.commander.impl.util.functions.LerpFunction;
import me.melontini.commander.impl.util.functions.RangedRandomFunction;
import me.melontini.commander.impl.util.functions.StructContainsKeyFunction;
import me.melontini.commander.impl.util.functions.*;
import net.minecraft.loot.context.LootContext;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -68,6 +65,8 @@ public class EvalUtils {
.put("clamp", new ClampFunction())
//maps
.put("structContainsKey", new StructContainsKeyFunction())
//meta
.put("hasContext", new HasContextFunction())
// trigonometric
.put("acos", new AcosFunction())
.put("acosh", new AcosHFunction())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package me.melontini.commander.impl.util.functions;

import com.ezylang.evalex.EvaluationException;
import com.ezylang.evalex.Expression;
import com.ezylang.evalex.data.EvaluationValue;
import com.ezylang.evalex.functions.AbstractFunction;
import com.ezylang.evalex.functions.FunctionParameter;
import com.ezylang.evalex.parser.Token;

@FunctionParameter(name = "key")
public class HasContextFunction extends AbstractFunction {
@Override
public EvaluationValue evaluate(Expression expression, Token functionToken, EvaluationValue... par) throws EvaluationException {
return expression.convertValue(expression.getDataAccessor().getData(par[0].getStringValue()) != null);
}
}

0 comments on commit e044994

Please sign in to comment.