diff --git a/gradle.properties b/gradle.properties index e5e4d49..ec7ac38 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 \ No newline at end of file diff --git a/src/main/java/dev/propulsionteam/computed/content/ComputedNodes.java b/src/main/java/dev/propulsionteam/computed/content/ComputedNodes.java index a074f40..8d6e463 100644 --- a/src/main/java/dev/propulsionteam/computed/content/ComputedNodes.java +++ b/src/main/java/dev/propulsionteam/computed/content/ComputedNodes.java @@ -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; +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; @@ -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); @@ -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")); + } } diff --git a/src/main/java/dev/propulsionteam/computed/content/nodes/vanilla/BlockLocationNode.java b/src/main/java/dev/propulsionteam/computed/content/nodes/vanilla/BlockLocationNode.java new file mode 100644 index 0000000..f8967c8 --- /dev/null +++ b/src/main/java/dev/propulsionteam/computed/content/nodes/vanilla/BlockLocationNode.java @@ -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); + }); + } +} \ No newline at end of file diff --git a/src/main/java/dev/propulsionteam/computed/content/nodes/vanilla/BlockRotationNode.java b/src/main/java/dev/propulsionteam/computed/content/nodes/vanilla/BlockRotationNode.java new file mode 100644 index 0000000..daa18eb --- /dev/null +++ b/src/main/java/dev/propulsionteam/computed/content/nodes/vanilla/BlockRotationNode.java @@ -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); + + 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)); + }); + } +} \ No newline at end of file diff --git a/src/main/java/dev/propulsionteam/computed/content/nodes/vanilla/ConcatenateTextNode.java b/src/main/java/dev/propulsionteam/computed/content/nodes/vanilla/ConcatenateTextNode.java new file mode 100644 index 0000000..f11b046 --- /dev/null +++ b/src/main/java/dev/propulsionteam/computed/content/nodes/vanilla/ConcatenateTextNode.java @@ -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); + }); + } +} \ No newline at end of file