2026-05-13 11:25:40 +02:00

56 lines
1.8 KiB
Java

package com.hbm.uninos;
import com.hbm.lib.Library;
import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.fauxpointtwelve.DirPos;
public class GenNode<N extends NodeNet> {
public BlockPos[] positions;
public DirPos[] connections;
/** Quick reminder that this CAN and WILL be null for the first tick between the node being created
* and the nodepsace update loop establishing a network. always check hasValidNet beforehand! */
public N net;
public boolean expired = false;
public boolean recentlyChanged = true;
/** Used for distinguishing the node type when saving it to UNINOS' node map */
public INetworkProvider networkProvider;
public GenNode(INetworkProvider<N> provider, BlockPos... positions) {
this.networkProvider = provider;
this.positions = positions;
}
public GenNode<N> setConnections(DirPos... connections) {
this.connections = connections;
return this;
}
public GenNode<N> setStandardConnections(int xCoord, int yCoord, int zCoord) {
return this.setConnections(
new DirPos(xCoord + 1, yCoord, zCoord, Library.POS_X),
new DirPos(xCoord - 1, yCoord, zCoord, Library.NEG_X),
new DirPos(xCoord, yCoord + 1, zCoord, Library.POS_Y),
new DirPos(xCoord, yCoord - 1, zCoord, Library.NEG_Y),
new DirPos(xCoord, yCoord, zCoord + 1, Library.POS_Z),
new DirPos(xCoord, yCoord, zCoord - 1, Library.NEG_Z));
}
public GenNode<N> addConnection(DirPos connection) {
DirPos[] newCons = new DirPos[this.connections.length + 1];
for(int i = 0; i < this.connections.length; i++) newCons[i] = this.connections[i];
newCons[newCons.length - 1] = connection;
this.connections = newCons;
return this;
}
public boolean hasValidNet() {
return this.net != null && this.net.isValid();
}
public void setNet(N net) {
this.net = net;
this.recentlyChanged = true;
}
}