Skip to content

Commit

Permalink
Nodeflow update and misc changes for 3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiDragon committed Jan 22, 2024
1 parent 5003769 commit 48b4988
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 13 deletions.
Binary file modified .github/media/right_click_menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:

jobs:
publish:
uses: MattiDragon/MattiDragon/.github/workflows/publish-mc-mod.yaml@c066f67d80ff22e0b63bb5ad5c4ac83f583ad211
uses: MattiDragon/MattiDragon/.github/workflows/publish-mc-mod.yaml@275ad65025060abab92dd3a080dae735e89565e7
with:
version-type: ${{ inputs.version-type }}
minecraft-versions: ${{ inputs.minecraft-versions }}
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ There you can set the mode of each side of the cable. Make one side an interface
Open up the controller, add some nodes and connect them.
Select your interface in the configuration of a node and you should have a working network.

<img src="https://github.com/MattiDragon/AdvancedNetworking/raw/1.19.3/.github/media/room.png" width="50%"/>
<img src="https://github.com/MattiDragon/AdvancedNetworking/raw/1.20.4/.github/media/room.png" width="50%"/>

## Features
### Cables
Expand All @@ -23,15 +23,15 @@ Click on them with a stick or any wrench from other mods to quickly change the m
More advanced configuration can be accessed by sneak-clicking on the cable.
Cables automatically connect to each other and controllers, but not other blocks. For those you will need to set the cable to interface mode.

<img src="https://github.com/MattiDragon/AdvancedNetworking/raw/1.19.3/.github/media/cables.png" width="50%"/>
<img src="https://github.com/MattiDragon/AdvancedNetworking/raw/1.20.4/.github/media/cables.png" width="50%"/>

### Controllers
Controllers house your programs. They have a node based UI where you can perform routing of resources and all kinds of logic.
You can add nodes from the `Add Nodes` menu and it's submenus.
Deleting nodes can be done by right-clicking and selecting `Delete` or using the `Delete Nodes` mode.
Nodes can also be duplicated from the right-clicking menu. You can freely move around by dragging and zoom by scrolling in the editor.

<img src="https://github.com/MattiDragon/AdvancedNetworking/raw/1.19.3/.github/media/right_click_menu.png" width="50%"/>
<img src="https://github.com/MattiDragon/AdvancedNetworking/raw/1.20.4/.github/media/right_click_menu.png" width="50%"/>

### Resource Transfer and Streams
Some of the most important nodes are for transfer of energy, items and fluids.
Expand All @@ -40,7 +40,7 @@ There are also nodes for getting the capacity and fill level of storages. These
The filter and limit nodes allows you to control what items are transferred.
The limit node sets a maximum number of items to transfer and the filter blocks certain items from passing through.

<img src="https://github.com/MattiDragon/AdvancedNetworking/raw/1.19.3/.github/media/fluids.png" width="50%"/>
<img src="https://github.com/MattiDragon/AdvancedNetworking/raw/1.20.4/.github/media/fluids.png" width="50%"/>

## Other Info
### Modpack permission
Expand All @@ -57,7 +57,6 @@ I intend to try and stay compatible with as many mods as possible, but might aba

### Porting and Forking
You can read my policy on [forking and porting mods](https://gist.github.com/MattiDragon/6b9e71e8516447f53f0d5fb296ab8868).
This mod will not be ported to anything older than 1.19.4 due to that version adding necessary client features.

## Licencing
The mod is licensed under the Apache License, Version 2.0.
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ dependencies {

sourceSets {
testmod {
compileClasspath += main.compileClasspath
compileClasspath += main.output
runtimeClasspath += main.runtimeClasspath
runtimeClasspath += main.output
compileClasspath += client.compileClasspath
compileClasspath += client.output
runtimeClasspath += client.runtimeClasspath
runtimeClasspath += client.output
}
}

Expand Down
11 changes: 10 additions & 1 deletion changelog/3.1.0+1.20.4.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
* Make interfaces use names from attached containers as fallback
* Add interface groups
* They allow you to interact with multiple interfaces as one
* They allow you to interact with multiple interfaces as one
* Added support for color tagging nodes
* Added support for setting a custom name for a node
* Made tooltips only show on the config/error button
* Fixed context menu sometimes going outside the screen
* Generally improved the UI
* Missing containers no longer cause an error.
* This was required to get groups working properly
* This is useful if you have containers that might sometimes be missing
* Connection in the editor are now textured
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ maven_group=io.github.mattidragon
archives_base_name=advanced-networking

fabric_version=0.91.2+1.20.4
nodeflow_version=1.0.1-mc.1.20.4
nodeflow_version=1.1.0-mc.1.20.4
graphlib_version=1.4.0+1.20.4
energy_version=3.0.0
yacl_version=3.3.1+1.20.4
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package io.github.mattidragon.advancednetworking.test;

import io.github.mattidragon.advancednetworking.AdvancedNetworking;
import io.github.mattidragon.advancednetworking.block.CableBlock;
import io.github.mattidragon.advancednetworking.graph.node.item.storage.ItemSourceNode;
import io.github.mattidragon.advancednetworking.graph.node.item.storage.ItemTargetNode;
import io.github.mattidragon.advancednetworking.test.util.AdvancedNetworkingGameTest;
import io.github.mattidragon.advancednetworking.test.util.AdvancedNetworkingTestContext;
import io.github.mattidragon.nodeflow.graph.Graph;
import net.minecraft.block.Blocks;
import net.minecraft.block.LeverBlock;
import net.minecraft.block.entity.DecoratedPotBlockEntity;
import net.minecraft.block.enums.BlockFace;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.test.GameTest;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;

public class GroupMoveTests implements AdvancedNetworkingGameTest {
@GameTest(templateName = AdvancedNetworkingGameTest.EMPTY_4x4x4)
public void moveItemsWithGroup(AdvancedNetworkingTestContext context) {
var controllerPos = new BlockPos(1, 1, 1);
var controller = context.controller(controllerPos);
var cable1 = context.cable(controllerPos.east(), CableBlock.SOUTH, CableBlock.NORTH);
var cable2 = context.cable(controllerPos.east(2), CableBlock.SOUTH, CableBlock.NORTH);

cable1.setGroup(Direction.NORTH, "IN");
cable2.setGroup(Direction.NORTH, "IN");
cable1.setGroup(Direction.SOUTH, "OUT");
cable2.setGroup(Direction.SOUTH, "OUT");

context.setBlockState(controllerPos.up(), Blocks.LEVER.getDefaultState().with(LeverBlock.FACE, BlockFace.FLOOR));

context.setBlockState(controllerPos.east().south(), Blocks.DECORATED_POT);
context.setBlockState(controllerPos.east().north(), Blocks.DECORATED_POT);
context.setBlockState(controllerPos.east(2).south(), Blocks.DECORATED_POT);
context.setBlockState(controllerPos.east(2).north(), Blocks.DECORATED_POT);

context.getBlockEntity(controllerPos.east().north(), DecoratedPotBlockEntity.class)
.setStack(0, new ItemStack(Items.DIRT, 64));
context.getBlockEntity(controllerPos.east(2).north(), DecoratedPotBlockEntity.class)
.setStack(0, new ItemStack(Items.DIRT, 64));

var graph = new Graph(AdvancedNetworking.ENVIRONMENT);

var sourceNode = new ItemSourceNode(graph);
sourceNode.interfaceId = "IN";
sourceNode.isGroup = true;
graph.addNode(sourceNode);
var targetNode = new ItemTargetNode(graph);
targetNode.interfaceId = "OUT";
targetNode.isGroup = true;
graph.addNode(targetNode);

graph.addConnection(targetNode.getInputs()[0], sourceNode.getOutputs()[0]);
controller.setGraph(graph, null, null);

context.toggleLever(controllerPos.up());
context.waitAndRun(20, () -> {
context.expectPotWith(controllerPos.east().south(), Items.DIRT, 64);
context.expectPotWith(controllerPos.east(2).south(), Items.DIRT, 64);
context.expectEmptyPot(controllerPos.east().north());
context.expectEmptyPot(controllerPos.east(2).north());
context.complete();
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import io.github.mattidragon.advancednetworking.block.ControllerBlockEntity;
import io.github.mattidragon.advancednetworking.registry.ModBlocks;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.DecoratedPotBlockEntity;
import net.minecraft.item.Item;
import net.minecraft.registry.Registries;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.test.GameTestException;
import net.minecraft.test.GameTestState;
Expand Down Expand Up @@ -34,6 +36,18 @@ public void expectEmptyContainer(BlockPos pos) {
}
}

public void expectEmptyPot(BlockPos pos) {
try {
var blockPos = this.getAbsolutePos(pos);
var blockEntity = this.getWorld().getBlockEntity(blockPos);
if (blockEntity instanceof DecoratedPotBlockEntity pot && !pot.isEmpty()) {
throw new GameTestException("Container should be empty");
}
} catch (GameTestException e) {
throwPositionedException(e.getMessage(), pos);
}
}

@Override
public void expectContainerWith(BlockPos pos, Item item) {
try {
Expand All @@ -43,6 +57,20 @@ public void expectContainerWith(BlockPos pos, Item item) {
}
}

public void expectPotWith(BlockPos pos, Item item, int count) {
try {
BlockPos blockPos = this.getAbsolutePos(pos);
BlockEntity blockEntity = this.getWorld().getBlockEntity(blockPos);
if (!(blockEntity instanceof DecoratedPotBlockEntity pot)) {
throw new GameTestException("Expected a container at " + pos + ", found " + Registries.BLOCK_ENTITY_TYPE.getId(blockEntity.getType()));
} else if (pot.count(item) != count) {
throw new GameTestException("Container should contain: " + item);
}
} catch (GameTestException e) {
throwPositionedException(e.getMessage(), pos);
}
}

public ControllerBlockEntity controller(BlockPos pos) {
setBlockState(pos, ModBlocks.CONTROLLER);
return getBlockEntity(pos, ControllerBlockEntity.class);
Expand Down
3 changes: 2 additions & 1 deletion src/testmod/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"entrypoints": {
"fabric-gametest" : [
"io.github.mattidragon.advancednetworking.test.SimpleMoveTests",
"io.github.mattidragon.advancednetworking.test.RedstoneTests"
"io.github.mattidragon.advancednetworking.test.RedstoneTests",
"io.github.mattidragon.advancednetworking.test.GroupMoveTests"
]
}
}

0 comments on commit 48b4988

Please sign in to comment.