This commit is contained in:
raoulvdberge
2017-05-25 15:15:32 +02:00
parent a45529426b
commit 6f8daec55d
5 changed files with 31 additions and 6 deletions

View File

@@ -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)

View File

@@ -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);
}

View File

@@ -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();
}
}

View File

@@ -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

View File

@@ -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