Fixed network node scanning allowing multiple controllers in some cases. Fixes #2069
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
- Fixed client FPS stalling when using "@" mod search in the Grid (raoulvdberge)
|
||||
- Fixed fluid inputs/outputs in the Pattern Grid not being set when you re-insert a Pattern with fluid inputs/outputs (raoulvdberge)
|
||||
- Fixed bug where the Pattern Grid doesn't update it's output slot when manually configuring a crafting pattern (raoulvdberge)
|
||||
- Fixed network node scanning allowing multiple controllers in some cases (raoulvdberge)
|
||||
|
||||
### 1.6.9
|
||||
- Fixed OpenComputers "unknown error" when using extract item API (raoulvdberge)
|
||||
|
@@ -1,20 +1,19 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.network;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.raoulvdberge.refinedstorage.RSBlocks;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkNodeGraph;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkNodeVisitor;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.ICoverable;
|
||||
import com.raoulvdberge.refinedstorage.item.itemblock.ItemBlockController;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileController;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -56,6 +55,7 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// End little hack.
|
||||
|
||||
operator.apply(controllerWorld, pos, facing.getOpposite());
|
||||
}
|
||||
@@ -111,23 +111,18 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
return controller.getWorld();
|
||||
}
|
||||
|
||||
private void removeOtherController(World world, BlockPos otherControllerPos) {
|
||||
if (!controller.getPos().equals(otherControllerPos)) {
|
||||
IBlockState state = world.getBlockState(otherControllerPos);
|
||||
private void dropConflictingBlock(World world, BlockPos pos) {
|
||||
if (!controller.getPos().equals(pos)) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
|
||||
TileController otherController = (TileController) world.getTileEntity(otherControllerPos);
|
||||
NonNullList<ItemStack> drops = NonNullList.create();
|
||||
state.getBlock().getDrops(drops, world, pos, state, 0);
|
||||
|
||||
ItemStack stackToSpawn = ItemBlockController.createStack(new ItemStack(RSBlocks.CONTROLLER, 1, state.getBlock().getMetaFromState(state)), otherController.getEnergy().getStored());
|
||||
world.setBlockToAir(pos);
|
||||
|
||||
world.setBlockToAir(otherControllerPos);
|
||||
|
||||
InventoryHelper.spawnItemStack(
|
||||
world,
|
||||
otherControllerPos.getX(),
|
||||
otherControllerPos.getY(),
|
||||
otherControllerPos.getZ(),
|
||||
stackToSpawn
|
||||
);
|
||||
for (ItemStack drop : drops) {
|
||||
InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), drop);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,25 +138,27 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
public void apply(World world, BlockPos pos, EnumFacing side) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if (tile != null) {
|
||||
if (tile instanceof TileController) {
|
||||
removeOtherController(world, pos);
|
||||
} else if (tile.hasCapability(NETWORK_NODE_PROXY_CAPABILITY, side)) {
|
||||
INetworkNodeProxy otherNodeProxy = NETWORK_NODE_PROXY_CAPABILITY.cast(tile.getCapability(NETWORK_NODE_PROXY_CAPABILITY, side));
|
||||
INetworkNode otherNode = otherNodeProxy.getNode();
|
||||
if (tile != null && tile.hasCapability(NETWORK_NODE_PROXY_CAPABILITY, side)) {
|
||||
INetworkNodeProxy otherNodeProxy = NETWORK_NODE_PROXY_CAPABILITY.cast(tile.getCapability(NETWORK_NODE_PROXY_CAPABILITY, side));
|
||||
INetworkNode otherNode = otherNodeProxy.getNode();
|
||||
|
||||
if (foundNodes.add(otherNode)) {
|
||||
if (!nodes.contains(otherNode)) {
|
||||
// We can't let the node connect immediately
|
||||
// We can only let the node connect AFTER the nodes list has changed in the graph
|
||||
// This is so that storage nodes can refresh the item/fluid cache, and the item/fluid cache will notice it then (otherwise not)
|
||||
newNodes.add(otherNode);
|
||||
}
|
||||
// This will work for regular nodes and for controllers too since controllers are internally a INetworkNode (and return themselves in INetworkNode#getNetwork).
|
||||
if (otherNode.getNetwork() != null && otherNode.getNetwork() != controller) {
|
||||
dropConflictingBlock(world, tile.getPos());
|
||||
return;
|
||||
}
|
||||
|
||||
previousNodes.remove(otherNode);
|
||||
|
||||
toCheck.add(new Visitor(otherNode, world, pos, side, tile));
|
||||
if (foundNodes.add(otherNode)) {
|
||||
if (!nodes.contains(otherNode)) {
|
||||
// We can't let the node connect immediately
|
||||
// We can only let the node connect AFTER the nodes list has changed in the graph
|
||||
// This is so that storage nodes can refresh the item/fluid cache, and the item/fluid cache will notice it then (otherwise not)
|
||||
newNodes.add(otherNode);
|
||||
}
|
||||
|
||||
previousNodes.remove(otherNode);
|
||||
|
||||
toCheck.add(new Visitor(otherNode, world, pos, side, tile));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user