Fixed machines breaking on long distances
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
- Fixed problems relating to Crafting Upgrade (scheduling a task wrongly, blocking other tasks, etc) (raoulvdberge)
|
- Fixed problems relating to Crafting Upgrade (scheduling a task wrongly, blocking other tasks, etc) (raoulvdberge)
|
||||||
- Interface now supports Crafting Upgrade (raoulvdberge)
|
- Interface now supports Crafting Upgrade (raoulvdberge)
|
||||||
- When shift clicking a recipe in the Crafting Grid, the player inventory is now leveraged as well (raoulvdberge)
|
- When shift clicking a recipe in the Crafting Grid, the player inventory is now leveraged as well (raoulvdberge)
|
||||||
|
- Fixed machines breaking on long distances (raoulvdberge)
|
||||||
|
|
||||||
### 0.9.4
|
### 0.9.4
|
||||||
- Little fixes in German translation (ThexXTURBOXx)
|
- Little fixes in German translation (ThexXTURBOXx)
|
||||||
|
|||||||
@@ -21,6 +21,13 @@ public interface INetworkNodeGraph {
|
|||||||
*/
|
*/
|
||||||
List<INetworkNode> all();
|
List<INetworkNode> all();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces an old network node with a new one.
|
||||||
|
*
|
||||||
|
* @param node The node
|
||||||
|
*/
|
||||||
|
void replace(INetworkNode node);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disconnects and notifies all connected nodes.
|
* Disconnects and notifies all connected nodes.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -136,6 +136,12 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
|||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void replace(INetworkNode node) {
|
||||||
|
nodes.remove(node);
|
||||||
|
nodes.add(node);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnectAll() {
|
public void disconnectAll() {
|
||||||
for (INetworkNode node : nodes) {
|
for (INetworkNode node : nodes) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package refinedstorage.tile;
|
package refinedstorage.tile;
|
||||||
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@@ -15,11 +16,14 @@ public abstract class TileNode extends TileBase implements INetworkNode, IRedsto
|
|||||||
public static final TileDataParameter<Integer> REDSTONE_MODE = RedstoneMode.createParameter();
|
public static final TileDataParameter<Integer> REDSTONE_MODE = RedstoneMode.createParameter();
|
||||||
|
|
||||||
private static final String NBT_CONNECTED = "Connected";
|
private static final String NBT_CONNECTED = "Connected";
|
||||||
|
private static final String NBT_NETWORK = "Network";
|
||||||
|
|
||||||
private RedstoneMode redstoneMode = RedstoneMode.IGNORE;
|
private RedstoneMode redstoneMode = RedstoneMode.IGNORE;
|
||||||
private boolean active;
|
private boolean active;
|
||||||
private boolean update;
|
private boolean update;
|
||||||
|
|
||||||
|
private BlockPos networkPos;
|
||||||
|
|
||||||
protected boolean connected;
|
protected boolean connected;
|
||||||
protected INetworkMaster network;
|
protected INetworkMaster network;
|
||||||
|
|
||||||
@@ -41,6 +45,18 @@ public abstract class TileNode extends TileBase implements INetworkNode, IRedsto
|
|||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
if (!worldObj.isRemote) {
|
if (!worldObj.isRemote) {
|
||||||
|
if (networkPos != null) {
|
||||||
|
TileEntity tile = worldObj.getTileEntity(networkPos);
|
||||||
|
|
||||||
|
if (tile instanceof INetworkMaster) {
|
||||||
|
((INetworkMaster) tile).getNodeGraph().replace(this);
|
||||||
|
|
||||||
|
onConnected((INetworkMaster) tile);
|
||||||
|
}
|
||||||
|
|
||||||
|
networkPos = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (update != canUpdate() && network != null) {
|
if (update != canUpdate() && network != null) {
|
||||||
update = canUpdate();
|
update = canUpdate();
|
||||||
|
|
||||||
@@ -71,6 +87,8 @@ public abstract class TileNode extends TileBase implements INetworkNode, IRedsto
|
|||||||
this.network = network;
|
this.network = network;
|
||||||
|
|
||||||
onConnectionChange(network, true);
|
onConnectionChange(network, true);
|
||||||
|
|
||||||
|
markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -79,6 +97,8 @@ public abstract class TileNode extends TileBase implements INetworkNode, IRedsto
|
|||||||
|
|
||||||
this.connected = false;
|
this.connected = false;
|
||||||
this.network = null;
|
this.network = null;
|
||||||
|
|
||||||
|
markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onConnectionChange(INetworkMaster network, boolean state) {
|
public void onConnectionChange(INetworkMaster network, boolean state) {
|
||||||
@@ -129,6 +149,10 @@ public abstract class TileNode extends TileBase implements INetworkNode, IRedsto
|
|||||||
if (tag.hasKey(RedstoneMode.NBT)) {
|
if (tag.hasKey(RedstoneMode.NBT)) {
|
||||||
redstoneMode = RedstoneMode.getById(tag.getInteger(RedstoneMode.NBT));
|
redstoneMode = RedstoneMode.getById(tag.getInteger(RedstoneMode.NBT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tag.hasKey(NBT_NETWORK)) {
|
||||||
|
networkPos = BlockPos.fromLong(tag.getLong(NBT_NETWORK));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -137,6 +161,10 @@ public abstract class TileNode extends TileBase implements INetworkNode, IRedsto
|
|||||||
|
|
||||||
tag.setInteger(RedstoneMode.NBT, redstoneMode.ordinal());
|
tag.setInteger(RedstoneMode.NBT, redstoneMode.ordinal());
|
||||||
|
|
||||||
|
if (network != null) {
|
||||||
|
tag.setLong(NBT_NETWORK, network.getPosition().toLong());
|
||||||
|
}
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user