aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/graphs/paths
diff options
context:
space:
mode:
authorMartin Robertz <dream-master@gmx.net>2022-03-02 20:28:16 +0100
committerGitHub <noreply@github.com>2022-03-02 20:28:16 +0100
commitcdb0f7adbe069f258ebe653cf553eca04c87e8db (patch)
tree2a2b15f1df5fd20042f8a73bfea95bf5a15b4e6d /src/main/java/gregtech/api/graphs/paths
parent058ef46cb368f3a311a39b2a67110b080d373221 (diff)
downloadGT5-Unofficial-cdb0f7adbe069f258ebe653cf553eca04c87e8db.tar.gz
GT5-Unofficial-cdb0f7adbe069f258ebe653cf553eca04c87e8db.tar.bz2
GT5-Unofficial-cdb0f7adbe069f258ebe653cf553eca04c87e8db.zip
add locks to the node graph so paths can block power transfer #25 (#950)
Co-authored-by: bot <Krampus.sack.never@gmail.com>
Diffstat (limited to 'src/main/java/gregtech/api/graphs/paths')
-rw-r--r--src/main/java/gregtech/api/graphs/paths/NodePath.java15
-rw-r--r--src/main/java/gregtech/api/graphs/paths/PowerNodePath.java3
2 files changed, 16 insertions, 2 deletions
diff --git a/src/main/java/gregtech/api/graphs/paths/NodePath.java b/src/main/java/gregtech/api/graphs/paths/NodePath.java
index bdf82ec5b0..efdcd1aecb 100644
--- a/src/main/java/gregtech/api/graphs/paths/NodePath.java
+++ b/src/main/java/gregtech/api/graphs/paths/NodePath.java
@@ -1,11 +1,13 @@
package gregtech.api.graphs.paths;
+import gregtech.api.graphs.Lock;
import gregtech.api.metatileentity.BaseMetaPipeEntity;
import gregtech.api.metatileentity.MetaPipeEntity;
//to contain all info about the path between nodes
public class NodePath {
protected MetaPipeEntity[] mPipes;
+ public Lock lock;
public NodePath(MetaPipeEntity[] aCables) {
this.mPipes = aCables;
@@ -20,11 +22,20 @@ public class NodePath {
}
public void clearPath() {
- for (int i = 0; i < mPipes.length; i++) {
- BaseMetaPipeEntity tBasePipe = (BaseMetaPipeEntity) mPipes[i].getBaseMetaTileEntity();
+ for (MetaPipeEntity mPipe : mPipes) {
+ BaseMetaPipeEntity tBasePipe = (BaseMetaPipeEntity) mPipe.getBaseMetaTileEntity();
if (tBasePipe != null) {
tBasePipe.setNodePath(null);
}
}
}
+
+ public void reloadLocks() {
+ for (MetaPipeEntity pipe : mPipes) {
+ BaseMetaPipeEntity basePipe = (BaseMetaPipeEntity) pipe.getBaseMetaTileEntity();
+ if (basePipe != null) {
+ basePipe.reloadLocks();
+ }
+ }
+ }
}
diff --git a/src/main/java/gregtech/api/graphs/paths/PowerNodePath.java b/src/main/java/gregtech/api/graphs/paths/PowerNodePath.java
index 72b2edb334..d18d6bcdd3 100644
--- a/src/main/java/gregtech/api/graphs/paths/PowerNodePath.java
+++ b/src/main/java/gregtech/api/graphs/paths/PowerNodePath.java
@@ -37,6 +37,7 @@ public class PowerNodePath extends NodePath {
this.mVoltage = aVoltage;
}
if (aVoltage > mMaxVoltage) {
+ lock.addTileEntity(null);
for (MetaPipeEntity tCable : mPipes) {
if (((GT_MetaPipeEntity_Cable) tCable).mVoltage < this.mVoltage) {
BaseMetaPipeEntity tBaseCable = (BaseMetaPipeEntity) tCable.getBaseMetaTileEntity();
@@ -51,6 +52,7 @@ public class PowerNodePath extends NodePath {
private void reset(int aTimePassed) {
if (aTimePassed < 0 || aTimePassed > 100) {
mAmps = 0;
+ return;
}
mAmps = Math.max(0, mAmps - (mMaxAmps * aTimePassed));
}
@@ -58,6 +60,7 @@ public class PowerNodePath extends NodePath {
public void addAmps(long aAmps) {
this.mAmps += aAmps;
if (this.mAmps > mMaxAmps * 40) {
+ lock.addTileEntity(null);
for (MetaPipeEntity tCable : mPipes) {
if (((GT_MetaPipeEntity_Cable) tCable).mAmperage * 40 < this.mAmps) {
BaseMetaPipeEntity tBaseCable = (BaseMetaPipeEntity) tCable.getBaseMetaTileEntity();