Fixed devices not being updated when loading item list. Fix not applying loaded device data to existing devices.
Fixes initial robot state on placement.
This commit is contained in:
@@ -78,6 +78,16 @@ public abstract class AbstractGroupingDeviceBusElement<T extends AbstractGroupin
|
||||
if (sideTag.contains(GROUP_DATA_TAG_NAME, NBTTagIds.TAG_COMPOUND)) {
|
||||
groupData[i] = sideTag.getCompound(GROUP_DATA_TAG_NAME);
|
||||
}
|
||||
|
||||
// Immediately load data into devices, if we already have some.
|
||||
for (final T entry : groups.get(i)) {
|
||||
final CompoundTag devicesTag = groupData[i];
|
||||
entry.getDeviceDataKey().ifPresent(key -> {
|
||||
if (devicesTag.contains(key, NBTTagIds.TAG_COMPOUND)) {
|
||||
entry.getDevice().deserializeNBT(devicesTag.getCompound(key));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,13 +55,13 @@ public class DeviceItemStackHandler extends FixedSizeItemStackHandler {
|
||||
|
||||
public void loadItems(final CompoundTag tag) {
|
||||
super.deserializeNBT(tag);
|
||||
for (int slot = 0; slot < getSlots(); slot++) {
|
||||
busElement.updateDevices(slot, getStackInSlot(slot));
|
||||
}
|
||||
}
|
||||
|
||||
public void loadDevices(final CompoundTag tag) {
|
||||
busElement.load(tag);
|
||||
for (int slot = 0; slot < getSlots(); slot++) {
|
||||
busElement.updateDevices(slot, getStackInSlot(slot));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user