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
This commit is contained in:
caelwarner 2022-11-30 00:37:47 -08:00
parent 94e3ed44ad
commit 574cd93a89
No known key found for this signature in database
GPG key ID: 514BEF5EADE889FF

View file

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