Skip to content

Commit bcb7b11

Browse files
committed
Fix log spam when loading transporter stacks that don't have a stored item (Soaryn/XyCraftTracker#59)
1 parent d08c062 commit bcb7b11

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/java/mekanism/common/content/transporter/TransporterStack.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import net.minecraft.core.HolderLookup;
2525
import net.minecraft.nbt.CompoundTag;
2626
import net.minecraft.nbt.NbtUtils;
27+
import net.minecraft.nbt.Tag;
2728
import net.minecraft.network.RegistryFriendlyByteBuf;
2829
import net.minecraft.network.codec.ByteBufCodecs;
2930
import net.minecraft.network.codec.StreamCodec;
@@ -135,7 +136,7 @@ public void write(HolderLookup.Provider provider, CompoundTag nbtTags) {
135136
NBTUtils.writeEnum(nbtTags, SerializationConstants.PATH_TYPE, pathType);
136137
}
137138
if (!itemStack.isEmpty()) {
138-
itemStack.save(provider, nbtTags);
139+
nbtTags.put(SerializationConstants.ITEM, itemStack.save(provider));
139140
}
140141
}
141142

@@ -146,7 +147,11 @@ public void read(HolderLookup.Provider provider, CompoundTag nbtTags) {
146147
NBTUtils.setEnumIfPresent(nbtTags, SerializationConstants.IDLE_DIR, Direction::from3DDataValue, dir -> idleDir = dir);
147148
NBTUtils.setBlockPosIfPresent(nbtTags, SerializationConstants.HOME_LOCATION, coord -> homeLocation = coord);
148149
NBTUtils.setEnumIfPresent(nbtTags, SerializationConstants.PATH_TYPE, Path.BY_ID, type -> pathType = type);
149-
itemStack = ItemStack.parseOptional(provider, nbtTags);
150+
if (nbtTags.contains(SerializationConstants.ITEM, Tag.TAG_COMPOUND)) {
151+
itemStack = ItemStack.parseOptional(provider, nbtTags.getCompound(SerializationConstants.ITEM));
152+
} else {//TODO - 1.22: Remove this legacy way of loading data
153+
itemStack = ItemStack.parseOptional(provider, nbtTags);
154+
}
150155
}
151156

152157
private void setPath(Level world, @NotNull List<BlockPos> path, @NotNull Path type, boolean updateFlowing) {

0 commit comments

Comments
 (0)