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