-
Notifications
You must be signed in to change notification settings - Fork 1
I have added nodes to concat to get block position and to get block r… #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
|
@@ -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")); | ||
|
|
||
| } | ||
| } | ||
42 changes: 42 additions & 0 deletions
42
src/main/java/dev/propulsionteam/computed/content/nodes/vanilla/BlockLocationNode.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| }); | ||
| } | ||
| } |
43 changes: 43 additions & 0 deletions
43
src/main/java/dev/propulsionteam/computed/content/nodes/vanilla/BlockRotationNode.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)); | ||
| }); | ||
| } | ||
| } | ||
27 changes: 27 additions & 0 deletions
27
src/main/java/dev/propulsionteam/computed/content/nodes/vanilla/ConcatenateTextNode.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| }); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add back imports