From 574cd93a89d49d8ac50b865b9b7f83955fa16ffc Mon Sep 17 00:00:00 2001 From: caelwarner Date: Wed, 30 Nov 2022 00:37:47 -0800 Subject: [PATCH] Serialize hasAttachedComputer in ComputerBehaviour - This eliminates some edge cases were peripherals don't realize they're being controlled by a computer on a world save and load --- .../compat/computercraft/ComputerBehaviour.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/simibubi/create/compat/computercraft/ComputerBehaviour.java b/src/main/java/com/simibubi/create/compat/computercraft/ComputerBehaviour.java index dc2c8cbba..86c4c19b7 100644 --- a/src/main/java/com/simibubi/create/compat/computercraft/ComputerBehaviour.java +++ b/src/main/java/com/simibubi/create/compat/computercraft/ComputerBehaviour.java @@ -7,6 +7,7 @@ import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour; import com.simibubi.create.foundation.tileEntity.behaviour.BehaviourType; import dan200.computercraft.api.peripheral.IPeripheral; +import net.minecraft.nbt.CompoundTag; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.common.capabilities.CapabilityToken; @@ -46,6 +47,18 @@ public class ComputerBehaviour extends TileEntityBehaviour { } } + @Override + public void read(CompoundTag nbt, boolean clientPacket) { + hasAttachedComputer = nbt.getBoolean("HasAttachedComputer"); + super.read(nbt, clientPacket); + } + + @Override + public void write(CompoundTag nbt, boolean clientPacket) { + nbt.putBoolean("HasAttachedComputer", hasAttachedComputer); + super.write(nbt, clientPacket); + } + public void setHasAttachedComputer(boolean hasAttachedComputer) { this.hasAttachedComputer = hasAttachedComputer; }