mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
Add multiblock creation algorithm for boiler
This commit is contained in:
1 parent
e23409e2a5
commit
3a2eeac52d
4 files changed
+203
-46
No files matched your search
@@ -289,7 +289,7 @@ public abstract class UpdateProtocol<T extends SynchronizedData<T>>
|
||||
* @param z - z coordinate
|
||||
* @return
|
||||
*/
|
||||
private boolean isViableNode(int x, int y, int z)
|
||||
public boolean isViableNode(int x, int y, int z)
|
||||
{
|
||||
TileEntity tile = pointer.getWorldObj().getTileEntity(x, y, z);
|
||||
|
||||
@@ -534,4 +534,48 @@ public abstract class UpdateProtocol<T extends SynchronizedData<T>>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class NodeCounter
|
||||
{
|
||||
public Set<Coord4D> iterated = new HashSet<Coord4D>();
|
||||
|
||||
public NodeChecker checker;
|
||||
|
||||
public NodeCounter(NodeChecker c)
|
||||
{
|
||||
checker = c;
|
||||
}
|
||||
|
||||
public void loop(Coord4D pos)
|
||||
{
|
||||
iterated.add(pos);
|
||||
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
Coord4D coord = pos.getFromSide(side);
|
||||
|
||||
if(!iterated.contains(coord) && checker.isValid(coord))
|
||||
{
|
||||
loop(coord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int calculate(Coord4D coord)
|
||||
{
|
||||
if(!checker.isValid(coord))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
loop(coord);
|
||||
|
||||
return iterated.size();
|
||||
}
|
||||
}
|
||||
|
||||
public static interface NodeChecker
|
||||
{
|
||||
public boolean isValid(Coord4D coord);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user