Fix jar inventory size mismatch. Fixes #441

This commit is contained in:
Sollace 2024-09-16 20:43:43 +01:00
parent 512ae4d126
commit 9424a3f2ba
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB

View file

@ -30,15 +30,16 @@ public record ItemsJarContents (
TileData tile,
List<ItemStack> stacks
) implements JarContents, SidedInventory {
private static final int[] SLOTS = IntStream.range(0, 16).toArray();
private static final int MAX_SIZE = 16;
private static final int[] SLOTS = IntStream.range(0, MAX_SIZE).toArray();
public ItemsJarContents(TileData tile) {
this(tile, new ArrayList<>());
this(tile, new ArrayList<>(MAX_SIZE));
}
public ItemsJarContents(TileData tile, NbtCompound compound) {
this(tile, NbtSerialisable.ITEM_STACK.readAll(compound.getList("items", NbtElement.COMPOUND_TYPE))
.limit(15)
.limit(MAX_SIZE)
.collect(Collectors.toList()));
}
@ -115,7 +116,7 @@ public record ItemsJarContents (
@Override
public int size() {
return 15;
return MAX_SIZE;
}
@Override