Skip to content

Commit 81a7810

Browse files
authored
Fix #45: C2ME compatibility (toNbt called from other thread) (#49)
1 parent 7064bf2 commit 81a7810

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main/java/dev/technici4n/moderndynamics/pipe/PipeBlockEntity.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,10 @@ public void toTag(CompoundTag nbt) {
162162

163163
if (!level.isClientSide()) { // WTHIT calls this on the client side
164164
for (NodeHost host : getHosts()) {
165-
host.separateNetwork();
165+
if (hostsRegistered) {
166+
host.separateNetwork();
167+
}
168+
166169
host.writeNbt(nbt);
167170
}
168171
}
@@ -173,7 +176,10 @@ public void fromTag(CompoundTag nbt) {
173176
connectionBlacklist = nbt.getByte("connectionBlacklist");
174177

175178
for (NodeHost host : getHosts()) {
176-
host.separateNetwork();
179+
if (hostsRegistered) {
180+
host.separateNetwork();
181+
}
182+
177183
host.readNbt(nbt);
178184
}
179185
}

0 commit comments

Comments
 (0)