Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/main/java/de/blazemcworld/fireflow/code/node/NodeList.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
import de.blazemcworld.fireflow.code.node.impl.item.*;
import de.blazemcworld.fireflow.code.node.impl.list.*;
import de.blazemcworld.fireflow.code.node.impl.number.*;
import de.blazemcworld.fireflow.code.node.impl.number.constants.EulersNode;
import de.blazemcworld.fireflow.code.node.impl.number.constants.GoldenRatioNode;
import de.blazemcworld.fireflow.code.node.impl.number.constants.PiNode;
import de.blazemcworld.fireflow.code.node.impl.number.constants.TauNode;
import de.blazemcworld.fireflow.code.node.impl.player.gameplay.*;
import de.blazemcworld.fireflow.code.node.impl.player.inventory.*;
import de.blazemcworld.fireflow.code.node.impl.player.meta.*;
Expand Down Expand Up @@ -164,29 +168,45 @@ public static void init() {
.add(new TrimListNode<>(null))
)
.add(new Category("Number", Material.CLOCK)
.add(new Category("Math Constants", Material.TARGET)
.add(new EulersNode())
.add(new GoldenRatioNode())
.add(new PiNode())
.add(new TauNode())
)
.add(new AbsoluteNumberNode())
.add(new AddNumbersNode())
.add(new ArcTan2Node())
.add(new AverageNumberNode())
.add(new BasicNoiseNode())
.add(new ClampNumberNode())
.add(new CosineNode())
.add(new DivideNumbersNode())
.add(new GaussianDistributionNode())
.add(new GreaterEqualNode())
.add(new GreaterThanNode())
.add(new LerpNumbersNode())
.add(new LessEqualNode())
.add(new LessThanNode())
.add(new MaxNumberNode())
.add(new MinNumberNode())
.add(new ModuloNode())
.add(new MultiplyNumbersNode())
.add(new ParseNumberNode())
.add(new RandomNumberNode())
.add(new RemainderNode())
.add(new RoundNumberNode())
.add(new SetToExponentialNode())
.add(new SineNode())
.add(new SquareRootNode())
.add(new SubtractNumbersNode())
.add(new TangentNode())
)
.add(new Category("Player", Material.PLAYER_HEAD)
.add(new Category("Gameplay", Material.GRASS_BLOCK)
.add(new ClearPlayerEffectsNode())
.add(new DamagePlayerNode())
.add(new GetPlayerInputNode())
.add(new GivePlayerEffectNode())
.add(new IsPlayerInvulnerableNode())
.add(new KillPlayerNode())
Expand All @@ -207,6 +227,7 @@ public static void init() {
.add(new PlayerHasItemNode())
.add(new PlayerItemHasCooldownNode())
.add(new SetHeldSlotNode())
.add(new SetPlayerArmorNode())
.add(new SetPlayerInventoryNode())
.add(new SetPlayerInventorySlotNode())
.add(new SetPlayerItemCooldownNode())
Expand All @@ -215,6 +236,7 @@ public static void init() {
)
.add(new Category("Meta", Material.COMMAND_BLOCK)
.add(new GetPlayerNameNode())
.add(new GetPlayerPingNode())
.add(new GetPlayerUUIDNode())
.add(new IsPlayingNode())
.add(new KickPlayerNode())
Expand Down Expand Up @@ -254,6 +276,7 @@ public static void init() {
.add(new SendMessageNode())
.add(new SendTitleNode())
.add(new SetPlayerSkinNode())
.add(new SetTablistNode())
)
)
.add(new Category("Position", Material.COMPASS)
Expand Down Expand Up @@ -291,7 +314,9 @@ public static void init() {
)
.add(new Category("Vector", Material.ARROW)
.add(new AddVectorsNode())
.add(new DotProductNode())
.add(new GetVectorComponentNode())
.add(new GetVectorLengthNode())
.add(new PackVectorNode())
.add(new ReflectVectorNode())
.add(new RoundVectorAxesNode())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package de.blazemcworld.fireflow.code.node.impl.number;

import de.blazemcworld.fireflow.code.node.Node;
import de.blazemcworld.fireflow.code.type.NumberType;
import de.blazemcworld.fireflow.code.type.StringType;
import org.bukkit.Material;

public class ArcTan2Node extends Node {
public ArcTan2Node() {
super("arc_tan_2", "Arc Tangent 2", "Generates the arc tangent of 2 numbers.", Material.FIRE_CORAL_FAN);
Input<Double> left = new Input<>("left", "Left", NumberType.INSTANCE);
Input<Double> right = new Input<>("right", "Right", NumberType.INSTANCE);
Input<String> inputUnit = new Input<>("input_unit", "Input Unit", StringType.INSTANCE).options("Degrees","Radians");
Output<Double> result = new Output<>("result", "Result", NumberType.INSTANCE);

result.valueFrom((ctx) -> {
double leftInput = left.getValue(ctx);
double rightInput = right.getValue(ctx);
if(inputUnit.getValue(ctx).equals("Degrees")) {
return Math.toDegrees(Math.atan2(leftInput, rightInput));
} else {
return Math.atan2(leftInput, rightInput);
}
});
}

@Override
public Node copy() {
return new ArcTan2Node();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package de.blazemcworld.fireflow.code.node.impl.number;

import de.blazemcworld.fireflow.code.node.Node;
import de.blazemcworld.fireflow.code.type.NumberType;
import org.bukkit.Material;

public class AverageNumberNode extends Node {

public AverageNumberNode() {
super("average_number", "Average Number", "Returns the average number of a set.", Material.RAW_COPPER);

Varargs<Double> numbers = new Varargs<>("numbers", "Numbers", NumberType.INSTANCE);
Output<Double> result = new Output<>("result", "Result", NumberType.INSTANCE);

result.valueFrom((ctx) -> {
return numbers.getVarargs(ctx)
.stream()
.mapToDouble(Double::doubleValue)
.average()
.orElse(0.0);
});
}

@Override
public Node copy() {
return new AverageNumberNode();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package de.blazemcworld.fireflow.code.node.impl.number;

import de.blazemcworld.fireflow.code.node.Node;
import de.blazemcworld.fireflow.code.type.NumberType;
import de.blazemcworld.fireflow.code.type.StringType;
import org.bukkit.Material;

public class CosineNode extends Node {
public CosineNode() {
super("cosine", "Cosine", "Generates the trigonometric cosine function of a number.", Material.BUBBLE_CORAL_FAN);
Input<Double> value = new Input<>("value", "Value", NumberType.INSTANCE);
Input<String> mode = new Input<>("mode", "Mode", StringType.INSTANCE).options("cos","cosh","acos");
Input<String> inputUnit = new Input<>("input_unit", "Input Unit", StringType.INSTANCE).options("Degrees","Radians");
Output<Double> result = new Output<>("result", "Result", NumberType.INSTANCE);

result.valueFrom((ctx) -> {
double valueInput = value.getValue(ctx);
switch (mode.getValue(ctx)) {
case "cos" -> {
if (inputUnit.getValue(ctx).equals("Degrees")) {
return Math.cos(Math.toRadians(valueInput));
} else {
return Math.cos(valueInput);
}
}
case "acos" -> {
if (inputUnit.getValue(ctx).equals("Degrees")) {
return Math.toDegrees(Math.acos(valueInput));
} else {
return Math.acos(valueInput);
}
}
case "cosh" -> {
return Math.cosh(valueInput);
}
default -> {
return 0.0;
}
}
});
}

@Override
public Node copy() {
return new CosineNode();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package de.blazemcworld.fireflow.code.node.impl.number;

import de.blazemcworld.fireflow.code.node.Node;
import de.blazemcworld.fireflow.code.type.NumberType;
import de.blazemcworld.fireflow.code.type.StringType;
import org.bukkit.Material;

import java.util.Random;

public class GaussianDistributionNode extends Node {

public GaussianDistributionNode() {
super("gaussian_distribution", "Gaussian Distribution", "Generate a normally distributed random number", Material.POLAR_BEAR_SPAWN_EGG);
Input<String> mode = new Input<>("mode", "Mode", StringType.INSTANCE)
.options("Normal", "Folded");
Input<Double> mean = new Input<>("mean", "μ (Mean midpoint)", NumberType.INSTANCE);
Input<Double> deviation = new Input<>("max", "σ (Standard deviation)", NumberType.INSTANCE);
Output<Double> output = new Output<>("output", "Output", NumberType.INSTANCE);

output.valueFrom((ctx -> {
Random random = new Random();
double outputMean = mean.getValue(ctx);
double outputDeviation = deviation.getValue(ctx);

return switch (mode.getValue(ctx)) {
case "Normal" -> outputMean + outputDeviation * random.nextGaussian();
case "Folded" -> outputMean + outputDeviation * Math.abs(random.nextGaussian());

default -> 0.0;
};
}));
}

@Override
public Node copy() {
return new GaussianDistributionNode();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package de.blazemcworld.fireflow.code.node.impl.number;

import de.blazemcworld.fireflow.code.node.Node;
import de.blazemcworld.fireflow.code.type.NumberType;
import org.bukkit.Material;

public class LerpNumbersNode extends Node {

public LerpNumbersNode() {
super("lerp_numbers", "Lerp", "Calculates a value between two inputs by linearly interpolating based on a factor t, where t = 0 returns the start value, t = 1 returns the end value, and values in between produce a proportional blend.", Material.REPEATER);

Input<Double> left = new Input<>("left", "Left", NumberType.INSTANCE);
Input<Double> right = new Input<>("right", "Right", NumberType.INSTANCE);
Input<Double> time = new Input<>("time", "Time (0-1)", NumberType.INSTANCE);
Output<Double> result = new Output<>("result", "Result", NumberType.INSTANCE);

result.valueFrom((ctx) -> {
double leftValue = left.getValue(ctx);
double rightValue = right.getValue(ctx);
double timeValue = Math.clamp(time.getValue(ctx),0,1);
return leftValue + (rightValue - leftValue) * timeValue;
});
}

@Override
public Node copy() {
return new LerpNumbersNode();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package de.blazemcworld.fireflow.code.node.impl.number;

import de.blazemcworld.fireflow.code.node.Node;
import de.blazemcworld.fireflow.code.type.NumberType;
import org.bukkit.Material;

public class MaxNumberNode extends Node {

public MaxNumberNode() {
super("max_number", "Maximum Number", "Returns the highest number in a set.", Material.NETHERITE_SCRAP);

Varargs<Double> numbers = new Varargs<>("numbers", "Numbers", NumberType.INSTANCE);
Output<Double> result = new Output<>("result", "Result", NumberType.INSTANCE);

result.valueFrom((ctx) -> {
return numbers.getVarargs(ctx)
.stream()
.max(Double::compareTo)
.orElse(0.0);
});
}

@Override
public Node copy() {
return new MaxNumberNode();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package de.blazemcworld.fireflow.code.node.impl.number;

import de.blazemcworld.fireflow.code.node.Node;
import de.blazemcworld.fireflow.code.type.NumberType;
import org.bukkit.Material;

public class MinNumberNode extends Node {

public MinNumberNode() {
super("min_number", "Minimum Number", "Returns the lowest number in a set.", Material.DISC_FRAGMENT_5);

Varargs<Double> numbers = new Varargs<>("numbers", "Numbers", NumberType.INSTANCE);
Output<Double> result = new Output<>("result", "Result", NumberType.INSTANCE);

result.valueFrom((ctx) -> {
return numbers.getVarargs(ctx)
.stream()
.min(Double::compareTo)
.orElse(0.0);
});
}

@Override
public Node copy() {
return new MinNumberNode();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package de.blazemcworld.fireflow.code.node.impl.number;

import de.blazemcworld.fireflow.code.node.Node;
import de.blazemcworld.fireflow.code.type.NumberType;
import de.blazemcworld.fireflow.code.type.StringType;
import org.bukkit.Material;

public class SineNode extends Node {
public SineNode() {
super("sine", "Sine", "Generates the trigonometric sine function of a number.", Material.TUBE_CORAL_FAN);
Input<Double> value = new Input<>("value", "Value", NumberType.INSTANCE);
Input<String> mode = new Input<>("mode", "Mode", StringType.INSTANCE).options("sin","sinh","asin");
Input<String> inputUnit = new Input<>("input_unit", "Input Unit", StringType.INSTANCE).options("Degrees","Radians");
Output<Double> result = new Output<>("result", "Result", NumberType.INSTANCE);

result.valueFrom((ctx) -> {
double valueInput = value.getValue(ctx);
switch (mode.getValue(ctx)) {
case "sin" -> {
if (inputUnit.getValue(ctx).equals("Degrees")) {
return Math.sin(Math.toRadians(valueInput));
} else {
return Math.sin(valueInput);
}
}
case "asin" -> {
if (inputUnit.getValue(ctx).equals("Degrees")) {
return Math.toDegrees(Math.asin(valueInput));
} else {
return Math.asin(valueInput);
}
}
case "sinh" -> {
return Math.sinh(valueInput);
}
default -> {
return 0.0;
}
}
});
}

@Override
public Node copy() {
return new SineNode();
}
}
Loading