Skip to content

Commit 047f7c5

Browse files
lc-1337Alexdoru
andauthored
Allow sync null able (#1184)
Co-authored-by: Alexdoru <57050655+Alexdoru@users.noreply.github.com>
1 parent 4382a3f commit 047f7c5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/main/java/appeng/container/guisync/SynchronizedField.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,14 @@ private CustomField(Object source, Field field, String name) {
226226

227227
@Override
228228
protected void writeValue(ByteBuf buf, Object value) {
229+
buf.writeBoolean(value != null);
230+
if (value == null) return;
229231
((IGuiPacketWritable) value).writeToPacket(buf);
230232
}
231233

232234
@Override
233235
protected Object readValue(ByteBuf data) {
236+
if (!data.readBoolean()) return null;
234237
var factory = factories.computeIfAbsent(fieldType, CustomField::getFactory);
235238
return factory.apply(data);
236239
}

0 commit comments

Comments
 (0)