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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import de.blazemcworld.fireflow.code.widget.WidgetVec;
import de.blazemcworld.fireflow.space.PlayWorld;
import de.blazemcworld.fireflow.space.Space;
import de.blazemcworld.fireflow.space.SpaceManager;
import de.blazemcworld.fireflow.util.DummyPlayer;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
Expand Down Expand Up @@ -206,6 +207,7 @@ public boolean onUseItem(ServerPlayerEntity player, ItemStack stack, Hand hand)
}

public void exitPlay(ServerPlayerEntity player) {
SpaceManager.getSpaceForPlayer(player).bossBarManager.clearBossBars(player);
for (Node node : nodes) {
if (node instanceof OnPlayerLeaveNode n) {
n.onLeave(this, player);
Expand Down
31 changes: 31 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 @@ -3,6 +3,10 @@
import de.blazemcworld.fireflow.FireFlow;
import de.blazemcworld.fireflow.code.CodeEditor;
import de.blazemcworld.fireflow.code.node.impl.condition.*;
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.control.*;
import de.blazemcworld.fireflow.code.node.impl.dictionary.*;
import de.blazemcworld.fireflow.code.node.impl.entity.*;
Expand All @@ -25,6 +29,9 @@
import de.blazemcworld.fireflow.code.node.impl.player.movement.*;
import de.blazemcworld.fireflow.code.node.impl.player.statistic.*;
import de.blazemcworld.fireflow.code.node.impl.player.visual.*;
import de.blazemcworld.fireflow.code.node.impl.player.visual.bossbar.ClearBossbarsNode;
import de.blazemcworld.fireflow.code.node.impl.player.visual.bossbar.RemoveBossbarNode;
import de.blazemcworld.fireflow.code.node.impl.player.visual.bossbar.SetBossbarNode;
import de.blazemcworld.fireflow.code.node.impl.position.*;
import de.blazemcworld.fireflow.code.node.impl.string.*;
import de.blazemcworld.fireflow.code.node.impl.text.CombineTextsNode;
Expand Down Expand Up @@ -170,24 +177,38 @@ public static void init() {
.add(new TrimListNode<>(null))
)
.add(new Category("Number", Items.CLOCK)
.add(new Category("Math Constants", Items.TARGET)
.add(new EulersNode())
.add(new GoldenRatioNode())
.add(new PiNode())
.add(new TauNode())
)
.add(new AbsoluteNumberNode())
.add(new AddNumbersNode())
.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", Items.PLAYER_HEAD)
.add(new Category("Gameplay", Items.GRASS_BLOCK)
Expand All @@ -213,6 +234,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 @@ -221,6 +243,7 @@ public static void init() {
)
.add(new Category("Meta", Items.COMMAND_BLOCK)
.add(new GetPlayerNameNode())
.add(new GetPlayerPingNode())
.add(new GetPlayerUUIDNode())
.add(new IsPlayingNode())
.add(new KickPlayerNode())
Expand Down Expand Up @@ -254,6 +277,11 @@ public static void init() {
.add(new SetPlayerSaturationNode())
)
.add(new Category("Visual", Items.ENDER_PEARL)
.add(new Category("Bossbar", Items.ENDER_DRAGON_SPAWN_EGG)
.add(new SetBossbarNode())
.add(new RemoveBossbarNode())
.add(new ClearBossbarsNode())
)
.add(new BroadcastNode())
.add(new SendActionbarNode())
.add(new SendBlockChangeNode())
Expand Down Expand Up @@ -297,7 +325,9 @@ public static void init() {
)
.add(new Category("Vector", Items.ARROW)
.add(new AddVectorsNode())
.add(new DotProductNode())
.add(new GetVectorComponentNode())
.add(new GetVectorLengthNode())
.add(new PackVectorNode())
.add(new ReflectVectorNode())
.add(new RoundVectorAxesNode())
Expand All @@ -318,6 +348,7 @@ public static void init() {
.add(new SetBlockNode())
.add(new SetBlockTagNode<>(null))
.add(new SetRegionNode())
.add(new TimestampNode())
)
.add(new Category("Function", Items.COMMAND_BLOCK).markFunctions())
.finish();
Expand Down
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 net.minecraft.item.Items;

public class AverageNumberNode extends Node {

public AverageNumberNode() {
super("average_number", "Average Number", "Returns the average number of a set.", Items.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 net.minecraft.item.Items;

public class CosineNode extends Node {
public CosineNode() {
super("cosine", "Cosine", "Generates the trigonometric cosine function of a number.", Items.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 net.minecraft.item.Items;

import java.util.Random;

public class GaussianDistributionNode extends Node {

public GaussianDistributionNode() {
super("gaussian_distribution", "Gaussian Distribution", "Generate a normally distributed random number", Items.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 net.minecraft.item.Items;

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.", Items.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 net.minecraft.item.Items;

public class MaxNumberNode extends Node {

public MaxNumberNode() {
super("max_number", "Maximum Number", "Returns the highest number in a set.", Items.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 net.minecraft.item.Items;

public class MinNumberNode extends Node {

public MinNumberNode() {
super("min_number", "Minimum Number", "Returns the lowest number in a set.", Items.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,49 @@
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 net.minecraft.item.Items;

import java.util.Objects;

public class SineNode extends Node {
public SineNode() {
super("sine", "Sine", "Generates the trigonometric sine function of a number.", Items.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