Fix relays

This commit is contained in:
Raoul Van den Berge
2016-07-05 16:32:54 +02:00
parent e628b5f77f
commit f1a03b226e
5 changed files with 37 additions and 15 deletions

View File

@@ -1,5 +1,9 @@
# Refined Storage Changelog # Refined Storage Changelog
### 0.8.6
**Bugfixes**
- Huge performance improvements to large networks
### 0.8.5 ### 0.8.5
**Bugfixes** **Bugfixes**
- Fixed crash when Tesla API is not installed - Fixed crash when Tesla API is not installed

View File

@@ -53,10 +53,15 @@ public interface INetworkNode {
boolean isConnected(); boolean isConnected();
/** /**
* @return If {@link INetworkNode#canUpdate()} can get called. Typically checks for connection status and redstone mode. * @return If {@link INetworkNode#canUpdate()} can get called, typically checks for connection status and redstone mode
*/ */
boolean canUpdate(); boolean canUpdate();
/**
* @return Whether this node can conduct a network signal
*/
boolean canConduct();
/** /**
* @return The network * @return The network
*/ */

View File

@@ -45,15 +45,15 @@ public abstract class TileNode extends TileBase implements INetworkNode, ISynchr
onConnectionChange(network, update); onConnectionChange(network, update);
} }
if (isActive()) {
updateNode();
}
if (active != isActive() && canSendConnectivityUpdate()) { if (active != isActive() && canSendConnectivityUpdate()) {
RefinedStorageUtils.updateBlock(worldObj, pos); RefinedStorageUtils.updateBlock(worldObj, pos);
active = isActive(); active = isActive();
} }
if (isActive()) {
updateNode();
}
} }
super.update(); super.update();
@@ -80,6 +80,11 @@ public abstract class TileNode extends TileBase implements INetworkNode, ISynchr
// NO OP // NO OP
} }
@Override
public boolean canConduct() {
return true;
}
@Override @Override
public INetworkMaster getNetwork() { public INetworkMaster getNetwork() {
return network; return network;

View File

@@ -2,7 +2,6 @@ package refinedstorage.tile;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import refinedstorage.RefinedStorage; import refinedstorage.RefinedStorage;
import refinedstorage.RefinedStorageBlocks;
import refinedstorage.container.ContainerRelay; import refinedstorage.container.ContainerRelay;
import refinedstorage.tile.config.RedstoneMode; import refinedstorage.tile.config.RedstoneMode;
@@ -25,13 +24,18 @@ public class TileRelay extends TileNode {
public void update() { public void update() {
super.update(); super.update();
if (connected && couldUpdate != canUpdate()) { if (network != null && couldUpdate != canUpdate()) {
couldUpdate = canUpdate(); couldUpdate = canUpdate();
worldObj.notifyNeighborsOfStateChange(pos, RefinedStorageBlocks.RELAY); network.rebuildNodes();
} }
} }
@Override
public boolean canConduct() {
return canUpdate();
}
@Override @Override
public Class<? extends Container> getContainer() { public Class<? extends Container> getContainer() {
return ContainerRelay.class; return ContainerRelay.class;

View File

@@ -383,8 +383,10 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
Queue<BlockPos> toCheck = new ArrayDeque<BlockPos>(); Queue<BlockPos> toCheck = new ArrayDeque<BlockPos>();
for (EnumFacing facing : EnumFacing.VALUES) { for (EnumFacing facing : EnumFacing.VALUES) {
checked.add(pos.offset(facing)); BlockPos pos = this.pos.offset(facing);
toCheck.add(pos.offset(facing));
checked.add(pos);
toCheck.add(pos);
} }
BlockPos currentPos; BlockPos currentPos;
@@ -397,14 +399,16 @@ public class TileController extends TileBase implements INetworkMaster, IEnergyR
INetworkNode node = tile.getCapability(RefinedStorageCapabilities.NETWORK_NODE_CAPABILITY, null); INetworkNode node = tile.getCapability(RefinedStorageCapabilities.NETWORK_NODE_CAPABILITY, null);
// @TODO: Care about relays
newNodes.add(node); newNodes.add(node);
newNodesPos.add(node.getPosition()); newNodesPos.add(node.getPosition());
if (node.canConduct()) {
for (EnumFacing facing : EnumFacing.VALUES) { for (EnumFacing facing : EnumFacing.VALUES) {
if (checked.add(currentPos.offset(facing))) { BlockPos pos = currentPos.offset(facing);
toCheck.add(currentPos.offset(facing));
if (checked.add(pos)) {
toCheck.add(pos);
}
} }
} }
} }