More powernet fixes
This commit is contained in:
parent
14d22e2442
commit
4a0fd93363
2 changed files with 18 additions and 6 deletions
|
@ -85,23 +85,29 @@ public class TRPowerNet {
|
|||
this.rebuild();
|
||||
}
|
||||
|
||||
public void buildEndpoint(){
|
||||
for(CableMultipart cable : cables){
|
||||
public static void buildEndpoint(TRPowerNet net){
|
||||
ArrayList<CableMultipart> parts = new ArrayList<>();
|
||||
ArrayList<CableMultipart> partsToMerge = new ArrayList<>();
|
||||
parts.addAll(net.cables);
|
||||
for(CableMultipart cable : parts){
|
||||
for(EnumFacing facing : EnumFacing.VALUES){
|
||||
BlockPos pos = cable.getPos().offset(facing);
|
||||
TileEntity tile = cable.getWorld().getTileEntity(pos);
|
||||
if(tile != null && tile instanceof IEnergyInterfaceTile){
|
||||
IEnergyInterfaceTile eit = (IEnergyInterfaceTile) tile;
|
||||
addConnection(eit, facing);
|
||||
net.addConnection(eit, facing);
|
||||
}
|
||||
CableMultipart cableMultipart = CableMultipart.getPartFromWorld(cable.getWorld(), pos, null);
|
||||
if(cableMultipart != null){
|
||||
if(cableMultipart.getNetwork() != this){
|
||||
cableMultipart.findAndJoinNetwork(cableMultipart.getWorld(), cableMultipart.getPos());
|
||||
if(cableMultipart.getNetwork() != net){
|
||||
partsToMerge.add(cableMultipart);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for(CableMultipart cableMultipart : partsToMerge){
|
||||
cableMultipart.mergeWith = net;
|
||||
}
|
||||
}
|
||||
|
||||
public void rebuild() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue