Skip to content

Commit

Permalink
Machines save inventory when harvested.
Browse files Browse the repository at this point in the history
  • Loading branch information
MauveCloud authored Oct 28, 2020
1 parent 84e20ac commit 9b0ee48
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,24 @@ public ArrayList<ItemStack> getDrops() {
break;
}
}
try {
if (hasValidMetaTileEntity()) {
NBTTagList tItemList = new NBTTagList();
for (int i = 0; i < mMetaTileEntity.getRealInventory().length; i++) {
ItemStack tStack = mMetaTileEntity.getRealInventory()[i];
if (tStack != null) {
NBTTagCompound tTag = new NBTTagCompound();
tTag.setInteger("IntSlot", i);
tStack.writeToNBT(tTag);
tItemList.appendTag(tTag);
}
}
tNBT.setTag("Inventory", tItemList);
}
} catch (Throwable e) {
GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!");
e.printStackTrace(GT_Log.err);
}
if (hasValidMetaTileEntity()) mMetaTileEntity.setItemNBT(tNBT);
if (!tNBT.hasNoTags()) rStack.setTagCompound(tNBT);
return new ArrayList<ItemStack>(Arrays.asList(rStack));
Expand Down

0 comments on commit 9b0ee48

Please sign in to comment.