Last few tweaks to make bookshelf loot generation work properly

This commit is contained in:
Electroblob77
2020-07-06 22:54:10 +01:00
parent 651eb8834b
commit 9aac386ec9
@@ -93,16 +93,17 @@ public class TileEntityBookshelf extends TileEntityLockableLoot implements ITick
@Override
public void setInventorySlotContents(int slot, ItemStack stack){
this.fillWithLoot(null);
boolean wasEmpty = inventory.get(slot).isEmpty();
super.setInventorySlotContents(slot, stack);
// This must be done in the tile entity because containers only exist for player interaction, not hoppers etc.
if(wasEmpty != stack.isEmpty()) this.sync();
this.markDirty();
}
@Override
public void fillWithLoot(@Nullable EntityPlayer player){
if(world.getLootTableManager() != null) super.fillWithLoot(player); // IntelliJ is wrong, it can be null
if(world != null && world.getLootTableManager() != null) super.fillWithLoot(player); // IntelliJ is wrong, it can be null
}
@Override