Skip to content
Merged
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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ mod_version=1.0.0
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
mod_group_id=dev.propulsionteam.computed
mod_group_id=dev.propulsionteam.computed
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add back imports

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import dev.propulsionteam.computed.content.nodes.vanilla.RedstoneInputNode;
import dev.propulsionteam.computed.content.nodes.vanilla.RedstonePortNode;
import dev.propulsionteam.computed.content.nodes.vanilla.WorldTimeNode;
import dev.propulsionteam.computed.content.nodes.vanilla.BlockLocationNode;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the 3 needed imports.

import dev.propulsionteam.computed.content.nodes.vanilla.BlockRotationNode;
import dev.propulsionteam.computed.content.nodes.vanilla.ConcatenateTextNode;
import dev.propulsionteam.computed.content.nodes.widgets.ButtonWidgetNode;
import dev.propulsionteam.computed.content.nodes.widgets.ClockWidgetNode;
import dev.propulsionteam.computed.content.nodes.widgets.ColorSourceNode;
Expand Down Expand Up @@ -74,6 +77,18 @@ public static void register() {
NodeMenuRegistry.addNodeEntry(
MENU_VANILLA, BlockPresenceNode.TYPE_ID, Component.literal("Block Presence"));

NodeRegistry.register(BlockLocationNode.TYPE_ID, BlockLocationNode::new);
NodeMenuRegistry.addNodeEntry(
MENU_VANILLA, BlockLocationNode.TYPE_ID, Component.literal("Block Location"));

NodeRegistry.register(ConcatenateTextNode.TYPE_ID, ConcatenateTextNode::new);
NodeMenuRegistry.addNodeEntry(
MENU_VANILLA, ConcatenateTextNode.TYPE_ID, Component.literal("Concatenate Strings"));

NodeRegistry.register(BlockRotationNode.TYPE_ID, BlockRotationNode::new);
NodeMenuRegistry.addNodeEntry(
MENU_VANILLA, BlockRotationNode.TYPE_ID, Component.literal("Block Rotation"));

NodeMenuRegistry.registerCategory(MENU_WIDGETS, Component.literal("Widgets"), NodeMenuRegistry.ROOT);
NodeMenuRegistry.registerCategory(MENU_PERIPHERALS, Component.literal("Peripherals"), NodeMenuRegistry.ROOT);

Expand All @@ -100,5 +115,6 @@ public static void register() {

NodeRegistry.register(WidgetNodeIds.PROGRESS_BAR_WIDGET, ProgressBarWidgetNode::new);
NodeMenuRegistry.addNodeEntry(MENU_WIDGETS, WidgetNodeIds.PROGRESS_BAR_WIDGET, Component.literal("Progress Bar Widget"));

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package dev.propulsionteam.computed.content.nodes.vanilla;

import dev.devce.websnodelib.api.WNode;
import dev.devce.websnodelib.api.elements.WLabel;
import dev.propulsionteam.computed.Computed;
import dev.propulsionteam.computed.content.blocks.ComputedGraphExecution;
import dev.propulsionteam.computed.content.blocks.ComputerBlockEntity;
import dev.ryanhcode.sable.companion.SableCompanion;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.phys.Vec3;

public final class BlockLocationNode extends WNode {

public static final ResourceLocation TYPE_ID =
ResourceLocation.fromNamespaceAndPath(Computed.MODID, "block_location");

public BlockLocationNode(int x, int y) {
super(TYPE_ID, "Block Location", x, y);
addOutput("X", 0xFFFF0000);
addOutput("Y", 0xFF00FF00);
addOutput("Z", 0xFF0000FF);

addElement(new WLabel("Position of this computer"));

setEvaluator(n -> {
ComputerBlockEntity host = ComputedGraphExecution.hostOrNull();
if (host == null) return;

BlockPos pos = host.getBlockPos();

Vec3 worldPos = SableCompanion.INSTANCE.projectOutOfSubLevel(
host.getLevel(),
(net.minecraft.core.Position) Vec3.atCenterOf(pos)
);

n.getOutputs().get(0).setValue(worldPos.x);
n.getOutputs().get(1).setValue(worldPos.y);
n.getOutputs().get(2).setValue(worldPos.z);
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package dev.propulsionteam.computed.content.nodes.vanilla;

import dev.devce.websnodelib.api.WNode;
import dev.devce.websnodelib.api.elements.WLabel;
import dev.propulsionteam.computed.Computed;
import dev.propulsionteam.computed.content.blocks.ComputedGraphExecution;
import dev.propulsionteam.computed.content.blocks.ComputerBlockEntity;
import dev.ryanhcode.sable.companion.SableCompanion;
import dev.ryanhcode.sable.companion.SubLevelAccess;
import net.minecraft.resources.ResourceLocation;
import org.joml.Vector3d;

public final class BlockRotationNode extends WNode {

public static final ResourceLocation TYPE_ID =
ResourceLocation.fromNamespaceAndPath(Computed.MODID, "block_rotation");

public BlockRotationNode(int x, int y) {
super(TYPE_ID, "Block Rotation", x, y);
addOutput("Yaw", 0xFFFF0000);
addOutput("Pitch", 0xFF00FF00);
addOutput("Roll", 0xFF0000FF);

addElement(new WLabel("rotation of this computer"));

setEvaluator(n -> {
ComputerBlockEntity host = ComputedGraphExecution.hostOrNull();
if (host == null) return;

SableCompanion sable = SableCompanion.INSTANCE;

SubLevelAccess subLevel = sable.getContaining(host);
if (subLevel == null) return;

Vector3d euler = new Vector3d();
subLevel.logicalPose().orientation().getEulerAnglesYXZ(euler);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pitch would sometimes loop back to 180 when it shouldnt this fixes that.


n.getOutputs().get(0).setValue(Math.toDegrees(euler.y));
n.getOutputs().get(1).setValue(Math.toDegrees(euler.x));
n.getOutputs().get(2).setValue(Math.toDegrees(euler.z));
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package dev.propulsionteam.computed.content.nodes.vanilla;

import dev.devce.websnodelib.api.WNode;
import dev.devce.websnodelib.api.WPin;
import dev.devce.websnodelib.api.elements.WLabel;
import dev.propulsionteam.computed.Computed;
import net.minecraft.resources.ResourceLocation;

public final class ConcatenateTextNode extends WNode {

public static final ResourceLocation TYPE_ID =
ResourceLocation.fromNamespaceAndPath(Computed.MODID, "concatenate_strings");

public ConcatenateTextNode(int x, int y) {
super(TYPE_ID, "Concatenate", x, y);
addInput("A", WPin.DataType.STRING, 0xFFFF0000);
addInput("B", WPin.DataType.STRING, 0xFF0000FF);
addOutput("text",WPin.DataType.STRING ,0xFF00FF00);

addElement(new WLabel("A + B = AB"));

setEvaluator(n -> {
String concatedString = n.getInputs().get(0).getStringValue() + n.getInputs().get(1).getStringValue();
n.getOutputs().get(0).setStringValue(concatedString);
});
}
}
Loading