Skip to content

Commit

Permalink
remove empty items created by the item loading safeguard
Browse files Browse the repository at this point in the history
  • Loading branch information
absoluteAquarian committed Feb 3, 2024
1 parent 406ecf0 commit 4c1768c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Components/TEStorageHeart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,8 @@ internal void DestroyUnloadedGlobalItemData(bool net = false) {

internal void TryDeleteExactItem(string itemData) {
Item clone = Utility.FromBase64NoCompression(itemData);
if (clone.IsAir)
return;

foreach (TEStorageUnit unit in GetStorageUnits().OfType<TEStorageUnit>()) {
if (unit.IsEmpty || !unit.HasItem(clone, ignorePrefix: true))
Expand Down
2 changes: 1 addition & 1 deletion Components/TEStorageUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ public override void LoadData(TagCompound tag)
{
base.LoadData(tag);
ClearItemsData();
foreach (Item item in tag.GetList<TagCompound>("Items").Select(Utility.SafelyLoadItem))
foreach (Item item in tag.GetList<TagCompound>("Items").Select(Utility.SafelyLoadItem).Where(static i => !i.IsAir))
{
items.Add(item);
ItemData data = new(item);
Expand Down
2 changes: 1 addition & 1 deletion ItemTypeOrderedSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void Load(TagCompound tag)
{
if (tag.GetList<TagCompound>(_name) is { Count: > 0 } listV1)
{
_items = listV1.Select(Utility.SafelyLoadItem).ToList();
_items = listV1.Select(Utility.SafelyLoadItem).Where(static i => !i.IsAir).ToList();
}
else if (tag.GetList<int>(_name + Suffix) is { Count: > 0 } listV2)
{
Expand Down

0 comments on commit 4c1768c

Please sign in to comment.