Terminal: sync internal buffer inventory to client

This commit is contained in:
Shadowfacts 2019-10-29 21:00:15 -04:00
parent 68e612c63c
commit 5d62e60bb2
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 3 additions and 0 deletions

View File

@ -99,6 +99,7 @@ class TerminalBlockEntity: DeviceBlockEntity(PhyBlockEntities.TERMINAL), Invento
override fun onInvChange(inv: Inventory) { override fun onInvChange(inv: Inventory) {
if (inv == internalBuffer) { if (inv == internalBuffer) {
markDirty() markDirty()
sync()
} }
} }
@ -113,6 +114,7 @@ class TerminalBlockEntity: DeviceBlockEntity(PhyBlockEntities.TERMINAL), Invento
} }
override fun toClientTag(tag: CompoundTag): CompoundTag { override fun toClientTag(tag: CompoundTag): CompoundTag {
tag.put("InternalBuffer", internalBuffer.toTag())
val list = ListTag() val list = ListTag()
tag.put("CachedNetItems", list) tag.put("CachedNetItems", list)
for ((stack, amount) in cachedNetItems) { for ((stack, amount) in cachedNetItems) {
@ -124,6 +126,7 @@ class TerminalBlockEntity: DeviceBlockEntity(PhyBlockEntities.TERMINAL), Invento
} }
override fun fromClientTag(tag: CompoundTag) { override fun fromClientTag(tag: CompoundTag) {
internalBuffer.fromTag(tag.getList("InternalBuffer", 10))
val list = tag.getList("CachedNetItems", 10) val list = tag.getList("CachedNetItems", 10)
cachedNetItems.clear() cachedNetItems.clear()
for (entryTag in list) { for (entryTag in list) {