diff --git a/src/main/java/net/brokenmoon/redcontrol/blockentities/MonitorEntity.java b/src/main/java/net/brokenmoon/redcontrol/blockentities/MonitorEntity.java index 1bfac77..9da1972 100644 --- a/src/main/java/net/brokenmoon/redcontrol/blockentities/MonitorEntity.java +++ b/src/main/java/net/brokenmoon/redcontrol/blockentities/MonitorEntity.java @@ -2,6 +2,7 @@ package net.brokenmoon.redcontrol.blockentities; import net.brokenmoon.redcontrol.RedControl; import net.minecraft.block.BlockState; +import net.minecraft.nbt.NbtCompound; import net.minecraft.util.math.BlockPos; public class MonitorEntity extends Peripheral { @@ -208,4 +209,53 @@ public class MonitorEntity extends Peripheral { this.keyBufferPos = nextPos; } } + + @Override + protected void writeNbt(NbtCompound nbt) { + nbt.putByteArray("keyBuffer", this.keyBuffer); + for(int i = 0; i < windowData.length; i++){ + nbt.putByteArray("winData" + i, windowData[i]); + } + + nbt.putInt("acessRow", accessRow); + nbt.putInt("cursorX", cursorX); + nbt.putInt("cursorY", cursorY); + nbt.putInt("cursorMode", cursorMode); + nbt.putInt("keyBufferStart", keyBufferStart); + nbt.putInt("keyBufferPos", keyBufferPos); + nbt.putInt("blitMode", blitMode); + nbt.putInt("blitXStartOrFill", blitXStartOrFill); + nbt.putInt("blitYStart", blitYStart); + nbt.putInt("blitXOffset", blitXOffset); + nbt.putInt("blitYOffset", blitYOffset); + nbt.putInt("blitWidth", blitWidth); + nbt.putInt("blitHeight", blitHeight); + + super.writeNbt(nbt); + } + + @Override + public void readNbt(NbtCompound nbt) { + this.keyBuffer = nbt.getByteArray("keyBuffer"); + + for(int i = 0; i < windowData.length; i++){ + windowData[i] = nbt.getByteArray("winData" + i); + } + + accessRow = nbt.getInt("accessRow"); + cursorX = nbt.getInt("cursorX"); + cursorY = nbt.getInt("cursorY"); + cursorMode = nbt.getInt("cursorMode"); + keyBufferStart = nbt.getInt("keyBufferStart"); + keyBufferPos = nbt.getInt("keyBufferPos"); + blitMode = nbt.getInt("blitMode"); + blitXStartOrFill = nbt.getInt("blitXStartOrFill"); + blitYStart = nbt.getInt("blitYStart"); + blitXOffset = nbt.getInt("blitXOffset"); + blitYOffset = nbt.getInt("blitYOffset"); + blitWidth = nbt.getInt("blitWidth"); + blitHeight = nbt.getInt("blitHeight"); + + super.readNbt(nbt); + } }