Small improvements
This commit is contained in:
@@ -7,15 +7,16 @@ import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import refinedstorage.api.autocrafting.ICraftingTask;
|
||||
import refinedstorage.api.network.IGridHandler;
|
||||
import refinedstorage.api.network.INetworkMaster;
|
||||
import refinedstorage.item.ItemWirelessGrid;
|
||||
import refinedstorage.network.GridPullFlags;
|
||||
|
||||
public class GridHandler implements IGridHandler {
|
||||
public static final int MAX_CRAFTING_PER_REQUEST = 500;
|
||||
|
||||
private NetworkMaster network;
|
||||
private INetworkMaster network;
|
||||
|
||||
public GridHandler(NetworkMaster network) {
|
||||
public GridHandler(INetworkMaster network) {
|
||||
this.network = network;
|
||||
}
|
||||
|
||||
|
||||
@@ -238,7 +238,7 @@ public class NetworkMaster implements INetworkMaster {
|
||||
if (energy.getEnergyStored() != lastEnergy) {
|
||||
world.updateComparatorOutputLevel(pos, RefinedStorageBlocks.CONTROLLER);
|
||||
|
||||
if (System.currentTimeMillis() - lastEnergyUpdate > 2500) {
|
||||
if (System.currentTimeMillis() - lastEnergyUpdate > 1500) {
|
||||
lastEnergyUpdate = System.currentTimeMillis();
|
||||
|
||||
RefinedStorageUtils.updateBlock(world, pos);
|
||||
|
||||
@@ -8,6 +8,7 @@ import refinedstorage.RefinedStorage;
|
||||
import refinedstorage.RefinedStorageGui;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.api.network.INetworkMaster;
|
||||
import refinedstorage.api.network.IWirelessGridHandler;
|
||||
import refinedstorage.api.network.WirelessGridConsumer;
|
||||
import refinedstorage.item.ItemWirelessGrid;
|
||||
@@ -17,14 +18,14 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class WirelessGridHandler implements IWirelessGridHandler {
|
||||
private NetworkMaster network;
|
||||
private INetworkMaster network;
|
||||
|
||||
private int range;
|
||||
|
||||
private List<WirelessGridConsumer> consumers = new ArrayList<WirelessGridConsumer>();
|
||||
private List<WirelessGridConsumer> consumersToRemove = new ArrayList<WirelessGridConsumer>();
|
||||
|
||||
public WirelessGridHandler(NetworkMaster network) {
|
||||
public WirelessGridHandler(INetworkMaster network) {
|
||||
this.network = network;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ public class TileRelay extends TileSlave {
|
||||
private boolean couldUpdate;
|
||||
|
||||
public TileRelay() {
|
||||
this.redstoneMode = RedstoneMode.LOW;
|
||||
setRedstoneMode(RedstoneMode.LOW);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,11 +22,10 @@ import java.util.Set;
|
||||
public abstract class TileSlave extends TileBase implements INetworkSlave, ISynchronizedContainer, IRedstoneModeConfig {
|
||||
public static final String NBT_CONNECTED = "Connected";
|
||||
|
||||
protected boolean connected;
|
||||
protected RedstoneMode redstoneMode = RedstoneMode.IGNORE;
|
||||
protected INetworkMaster network;
|
||||
private RedstoneMode redstoneMode = RedstoneMode.IGNORE;
|
||||
|
||||
private Set<String> visited = new HashSet<String>();
|
||||
protected boolean connected;
|
||||
protected INetworkMaster network;
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
@@ -84,13 +83,10 @@ public abstract class TileSlave extends TileBase implements INetworkSlave, ISync
|
||||
|
||||
@Override
|
||||
public void onNeighborChanged(World world) {
|
||||
visited.clear();
|
||||
|
||||
TileController controller = searchController(world, pos, visited);
|
||||
TileController controller = searchController(world, pos, new HashSet<Long>());
|
||||
|
||||
if (network == null) {
|
||||
if (controller != null) {
|
||||
// For backwards compatibility
|
||||
INetworkMaster network = NetworkMasterRegistry.get(world, controller.getPos());
|
||||
|
||||
if (network != null) {
|
||||
@@ -104,26 +100,26 @@ public abstract class TileSlave extends TileBase implements INetworkSlave, ISync
|
||||
}
|
||||
}
|
||||
|
||||
private TileController searchController(World world, BlockPos current, Set<String> visited) {
|
||||
String id = current.getX() + "," + current.getY() + "," + current.getZ();
|
||||
private TileController searchController(World world, BlockPos current, Set<Long> visits) {
|
||||
long pos = current.toLong();
|
||||
|
||||
if (visited.contains(id)) {
|
||||
if (visits.contains(pos)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
visited.add(id);
|
||||
visits.add(pos);
|
||||
|
||||
TileEntity tile = world.getTileEntity(current);
|
||||
|
||||
if (tile instanceof TileController) {
|
||||
return (TileController) tile;
|
||||
} else if (tile instanceof TileSlave) {
|
||||
if (visited.size() > 1 && tile instanceof TileRelay && !((TileRelay) tile).canUpdate()) {
|
||||
if (visits.size() > 1 && tile instanceof TileRelay && !((TileRelay) tile).canUpdate()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (EnumFacing dir : EnumFacing.VALUES) {
|
||||
TileController controller = searchController(world, current.offset(dir), visited);
|
||||
TileController controller = searchController(world, current.offset(dir), visits);
|
||||
|
||||
if (controller != null) {
|
||||
return controller;
|
||||
|
||||
Reference in New Issue
Block a user