Needs to happen outside onLoad, world must be ready for querying.

This commit is contained in:
Florian Nücke
2021-01-04 14:19:03 +01:00
parent 8017e203a3
commit b5a4bb86bb

View File

@@ -108,6 +108,7 @@ public final class ComputerTileEntity extends AbstractTileEntity implements ITic
private RunState runState;
private ITextComponent bootError;
private int loadDevicesDelay;
private boolean hasAddedOwnDevices;
private boolean isNeighborUpdateScheduled;
///////////////////////////////////////////////////////////////////
@@ -287,6 +288,15 @@ public final class ComputerTileEntity extends AbstractTileEntity implements ITic
chunk = world.getChunkAt(getPos());
}
// Always add devices provided for the computer itself, even if there's no
// adjacent cable. Because that would just be weird.
if (!hasAddedOwnDevices) {
hasAddedOwnDevices = true;
for (final LazyOptional<BlockDeviceInfo> optional : Devices.getDevices(this, (Direction) null)) {
optional.ifPresent(info -> busElement.addDevice(info.device));
}
}
if (isNeighborUpdateScheduled) {
isNeighborUpdateScheduled = false;
world.notifyNeighborsOfStateChange(getPos(), getBlockState().getBlock());
@@ -505,12 +515,6 @@ public final class ComputerTileEntity extends AbstractTileEntity implements ITic
busElement.initialize();
virtualMachine.rtcMinecraft.setWorld(getWorld());
// Always add devices provided for the computer itself, even if there's no
// adjacent cable. Because that would just be weird.
for (final LazyOptional<BlockDeviceInfo> optional : Devices.getDevices(this, (Direction) null)) {
optional.ifPresent(info -> busElement.addDevice(info.device));
}
}
@Override