Skip to content

Commit

Permalink
Merge pull request #27 from MoSadie/26-inventory-issue
Browse files Browse the repository at this point in the history
Fix Major Inventory Bug
  • Loading branch information
MoSadie authored Jul 8, 2022
2 parents bb81f48 + 9c28f56 commit c5df07a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version=2.1.0
version=2.1.1
mc_version=1.18.2
forge_version=40.1.0
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.mosadie.exponentialpower.entities.BaseClasses;

import io.github.mosadie.exponentialpower.Config;
import io.github.mosadie.exponentialpower.ExponentialPower;
import io.github.mosadie.exponentialpower.container.ContainerEnderGeneratorBE;
import io.github.mosadie.exponentialpower.energy.generator.ForgeEnergyConnection;
import io.github.mosadie.exponentialpower.items.EnderCell;
Expand Down Expand Up @@ -76,24 +77,31 @@ public void saveAdditional(CompoundTag nbt) {
nbtTagList.add(itemTag);
}
}
CompoundTag invNbt = new CompoundTag();
invNbt.put("Items", nbtTagList);
nbt.put("Items", invNbt);

nbt.put("Items", nbtTagList);
}

@Override
public void load(CompoundTag nbt) {
super.load(nbt);

if (nbt.contains("Items", Tag.TAG_COMPOUND)) {
ListTag tagList = nbt.getList("Items", Tag.TAG_COMPOUND);
for (int i = 0; i < tagList.size(); i++) {
CompoundTag itemTags = tagList.getCompound(i);
int slot = itemTags.getInt("Slot");
ListTag tagList;

if (slot >= 0 && slot < getContainerSize()) {
setItem(slot, ItemStack.of(itemTags));
}
if (nbt.contains("Items", Tag.TAG_COMPOUND)) { // Load older NBT item structure.
ExponentialPower.LOGGER.warn("Upgrading old NBT item tag on save!");
tagList = nbt.getCompound("Items").getList("Items", Tag.TAG_COMPOUND);
} else if (nbt.contains("Items", Tag.TAG_LIST)) {
tagList = nbt.getList("Items", Tag.TAG_COMPOUND);
} else {
return;
}

for (int i = 0; i < tagList.size(); i++) {
CompoundTag itemTags = tagList.getCompound(i);
int slot = itemTags.getInt("Slot");

if (slot >= 0 && slot < getContainerSize()) {
setItem(slot, ItemStack.of(itemTags));
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion update.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"homepage": "https://github.com/MoSadie/ExponentialPower",
"1.18.2": {
"2.1.1": "See https://github.com/MoSadie/ExponentialPower/releases/tag/2.1.1",
"2.1.0.1": "See https://github.com/MoSadie/ExponentialPower/releases/tag/2.1.0.1",
"2.1.0": "See https://github.com/MoSadie/ExponentialPower/releases/tag/v2.1.0"
},
Expand Down Expand Up @@ -37,7 +38,7 @@
"1.0.0": "See https://github.com/MoSadie/ExponentialPower/releases/tag/v1.0"
},
"promos": {
"1.18.2-recommended": "2.1.0.1",
"1.18.2-recommended": "2.1.1",
"1.16.5-recommended": "2.0.1",
"1.16.4-recommended": "2.0.1",
"1.12.2-recommended": "1.4.1",
Expand Down

0 comments on commit c5df07a

Please sign in to comment.