Fixed StackOverFlow exception thrown with certain block designs
This commit is contained in:
@@ -30,7 +30,7 @@ public class Packets {
|
||||
|
||||
}
|
||||
|
||||
public static class SyncPacket implements Packet{
|
||||
public static class SyncPacket implements Packet, UnimportantPacket{
|
||||
public byte[] data;
|
||||
|
||||
@Override
|
||||
@@ -99,7 +99,7 @@ public class Packets {
|
||||
}
|
||||
}
|
||||
|
||||
public static class StateSyncPacket implements Packet{
|
||||
public static class StateSyncPacket implements Packet, UnimportantPacket{
|
||||
public int[] items;
|
||||
public float countdown, time;
|
||||
public int enemies, wave;
|
||||
|
||||
@@ -90,6 +90,8 @@ public class Block{
|
||||
public Array<BlockBar> bars = Array.with(new BlockBar(Color.RED, false, tile -> tile.entity.health / (float)tile.block().health));
|
||||
/**whether this block can be replaced in all cases*/
|
||||
public boolean alwaysReplace = false;
|
||||
/**whether this block has instant transfer checking. used for calculations to prevent infinite loops.*/
|
||||
public boolean instantTransfer = false;
|
||||
|
||||
public Block(String name) {
|
||||
this.name = name;
|
||||
|
||||
@@ -16,6 +16,7 @@ public class Junction extends Block{
|
||||
super(name);
|
||||
update = true;
|
||||
solid = true;
|
||||
instantTransfer = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,6 +24,7 @@ public class Sorter extends Block{
|
||||
super(name);
|
||||
update = true;
|
||||
solid = true;
|
||||
instantTransfer = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,13 +71,17 @@ public class Sorter extends Block{
|
||||
}else{
|
||||
Tile a = dest.getNearby(Mathf.mod(dir - 1, 4));
|
||||
Tile b = dest.getNearby(Mathf.mod(dir + 1, 4));
|
||||
boolean ac = a.block().acceptItem(item, a, dest);
|
||||
boolean bc = b.block().acceptItem(item, b, dest);
|
||||
boolean ac = !(a.block().instantTransfer && source.block().instantTransfer) &&
|
||||
a.block().acceptItem(item, a, dest);
|
||||
boolean bc = !(b.block().instantTransfer && source.block().instantTransfer) &&
|
||||
b.block().acceptItem(item, b, dest);
|
||||
|
||||
if(ac && !bc){
|
||||
to = a;
|
||||
}else if(bc && !ac){
|
||||
to = b;
|
||||
}else if(!bc && !ac){
|
||||
return null;
|
||||
}else{
|
||||
if(dest.getDump() == 0){
|
||||
to = a;
|
||||
|
||||
@@ -9,6 +9,8 @@ public class Splitter extends Block{
|
||||
|
||||
public Splitter(String name){
|
||||
super(name);
|
||||
solid = true;
|
||||
instantTransfer = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,7 @@ public class TunnelConveyor extends Block{
|
||||
update = true;
|
||||
solid = true;
|
||||
health = 70;
|
||||
instantTransfer = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user