Skip to content

Commit 33fc47f

Browse files
committed
fix serialization
1 parent fda61ab commit 33fc47f

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

src/main/java/appeng/client/gui/implementations/GuiStorageReshuffle.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ protected void actionPerformed(final GuiButton btn) {
278278
}
279279
} else if (btn == this.scanButton) {
280280
NetworkHandler.instance.sendToServer(new PacketValueConfig("Reshuffle.Scan", ""));
281+
this.container.report = null;
281282
}
282283
} catch (final IOException e) {
283284
AELog.debug(e);

src/main/java/appeng/container/implementations/ContainerStorageReshuffle.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import java.util.ArrayList;
66
import java.util.List;
77
import java.util.Map;
8-
import java.util.Objects;
98

109
import net.minecraft.client.Minecraft;
1110
import net.minecraft.entity.player.EntityPlayer;
@@ -104,7 +103,7 @@ public void detectAndSendChanges() {
104103
this.reshuffleProcessedItems = this.tile.getReshuffleProcessedItems();
105104

106105
final ReshuffleReport current = this.tile.getReshuffleReport();
107-
if (!Objects.equals(current, this.report)) {
106+
if (current != this.report) {
108107
this.report = current;
109108
}
110109

@@ -128,6 +127,7 @@ public void onUpdate(final String field, final Object oldValue, final Object new
128127
}
129128

130129
public void startReshuffle(EntityPlayer player, boolean confirmed) {
130+
this.report = null;
131131
this.tile.startReshuffle(player, confirmed);
132132
}
133133

src/main/java/appeng/helpers/ReshuffleReport.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public enum ChangeType {
7878
public final Set<IAEStackType<?>> allowedTypes;
7979
public final boolean voidProtection;
8080
public final long startTime;
81-
public long endTime;
81+
public long endTime = 0;
8282

8383
public int totalItemTypesBefore = 0;
8484
public int totalItemTypesAfter = 0;
@@ -112,8 +112,8 @@ public ReshuffleReport(final Set<IAEStackType<?>> allowedTypes, final boolean vo
112112
// For IGuiPacketWritable
113113
public ReshuffleReport(final ByteBuf buf) {
114114
this.allowedTypes = new HashSet<>();
115-
final int size = buf.readInt();
116-
for (int i = 0; i < size; i++) {
115+
final int sizeTypes = buf.readInt();
116+
for (int i = 0; i < sizeTypes; i++) {
117117
final String typeId = ByteBufUtils.readUTF8String(buf);
118118
if (buf.readBoolean()) {
119119
this.allowedTypes.add(AEStackTypeRegistry.getType(typeId));
@@ -133,15 +133,18 @@ public ReshuffleReport(final ByteBuf buf) {
133133
this.itemsProcessed = buf.readInt();
134134
this.itemsSkipped = buf.readInt();
135135

136-
for (int i = 0; i < buf.readInt(); i++) {
136+
final int sizeSkippedItemsList = buf.readInt();
137+
for (int i = 0; i < sizeSkippedItemsList; i++) {
137138
this.skippedItemsList.add(Platform.readStackByte(buf));
138139
}
139140

140-
for (int i = 0; i < buf.readInt(); i++) {
141+
final int sizeLostItems = buf.readInt();
142+
for (int i = 0; i < sizeLostItems; i++) {
141143
this.lostItems.add(ItemChange.read(buf));
142144
}
143145

144-
for (int i = 0; i < buf.readInt(); i++) {
146+
final int sizeGainedItems = buf.readInt();
147+
for (int i = 0; i < sizeGainedItems; i++) {
145148
this.gainedItems.add(ItemChange.read(buf));
146149
}
147150
}
@@ -232,7 +235,10 @@ public void generateReport(Map<IAEStackType<?>, IMEMonitor<?>> monitors, Set<IAE
232235
final IAEStack<?> before = beforeSnapshot.findPrecise(lookup);
233236
final IAEStack<?> after = afterSnapshot.findPrecise(lookup);
234237

235-
ItemChange change = new ItemChange(lookup, before.getStackSize(), after.getStackSize());
238+
ItemChange change = new ItemChange(
239+
lookup,
240+
before == null ? 0 : before.getStackSize(),
241+
after == null ? 0 : after.getStackSize());
236242

237243
switch (change.changeType) {
238244
case GAINED:

0 commit comments

Comments
 (0)