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