From b5a4bb86bb863bfdecc8227215ddb2ea25150e96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Mon, 4 Jan 2021 14:19:03 +0100 Subject: [PATCH] Needs to happen outside onLoad, world must be ready for querying. --- .../common/tileentity/ComputerTileEntity.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/li/cil/oc2/common/tileentity/ComputerTileEntity.java b/src/main/java/li/cil/oc2/common/tileentity/ComputerTileEntity.java index ee077f32..43dda312 100644 --- a/src/main/java/li/cil/oc2/common/tileentity/ComputerTileEntity.java +++ b/src/main/java/li/cil/oc2/common/tileentity/ComputerTileEntity.java @@ -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 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 optional : Devices.getDevices(this, (Direction) null)) { - optional.ifPresent(info -> busElement.addDevice(info.device)); - } } @Override