Fixed #1248
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
### 1.4.10
|
||||
- Improved performance of network scanning (raoulvdberge)
|
||||
- Fixed crash when attempting to get direction of a node (raoulvdberge)
|
||||
|
||||
### 1.4.9
|
||||
- Fixed bug where inventory data was lost sometimes upon opening the world (raoulvdberge)
|
||||
|
@@ -6,7 +6,18 @@ import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* A factory for reading network nodes from the disk. Used in a {@link INetworkNodeRegistry}.
|
||||
*/
|
||||
public interface INetworkNodeFactory {
|
||||
/**
|
||||
* Creates a network node.
|
||||
*
|
||||
* @param tag the tag on disk
|
||||
* @param world the world
|
||||
* @param pos the pos
|
||||
* @return the network node
|
||||
*/
|
||||
@Nonnull
|
||||
INetworkNode create(NBTTagCompound tag, World world, BlockPos pos);
|
||||
}
|
||||
|
@@ -20,9 +20,7 @@ public class NetworkNodeListener {
|
||||
|
||||
if (e.phase == TickEvent.Phase.END) {
|
||||
for (INetworkNode node : API.instance().getNetworkNodeManager(e.world).all()) {
|
||||
if (e.world.isBlockLoaded(node.getPos())) {
|
||||
node.update();
|
||||
}
|
||||
node.update();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -29,6 +29,8 @@ public abstract class NetworkNode implements INetworkNode, INetworkNeighborhoodA
|
||||
protected int ticks;
|
||||
protected RedstoneMode redstoneMode = RedstoneMode.IGNORE;
|
||||
|
||||
private EnumFacing direction;
|
||||
|
||||
private boolean couldUpdate;
|
||||
private boolean active;
|
||||
|
||||
@@ -164,9 +166,16 @@ public abstract class NetworkNode implements INetworkNode, INetworkNeighborhoodA
|
||||
return world.getTileEntity(pos.offset(getDirection()));
|
||||
}
|
||||
|
||||
// @TODO: Caching
|
||||
public EnumFacing getDirection() {
|
||||
return ((TileBase) world.getTileEntity(pos)).getDirection();
|
||||
if (direction == null) {
|
||||
resetDirection();
|
||||
}
|
||||
|
||||
return direction;
|
||||
}
|
||||
|
||||
public void resetDirection() {
|
||||
this.direction = ((TileBase) world.getTileEntity(pos)).getDirection();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@@ -48,6 +48,13 @@ public abstract class TileNode<N extends NetworkNode> extends TileBase implement
|
||||
return getNode().writeConfiguration(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirection(EnumFacing direction) {
|
||||
super.setDirection(direction);
|
||||
|
||||
getNode().resetDirection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readConfiguration(NBTTagCompound tag) {
|
||||
getNode().readConfiguration(tag);
|
||||
@@ -138,7 +145,6 @@ public abstract class TileNode<N extends NetworkNode> extends TileBase implement
|
||||
this.legacyTag = null;
|
||||
}
|
||||
|
||||
// @TODO: This needs to be redone. Perhaps we need to reuse the node registry for this.
|
||||
public abstract N createNode(World world, BlockPos pos);
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user