// Pass API here because we attempt to use this before it's initialized to the blockentity. private void SyncFromNetworkInventory(ICoreAPI api, byte[] data = null) { byte[] serializedItems = data ?? null; if (serializedItems == null) { serializedItems = api.ModLoader.GetModSystem <TradeRoutesSystem>().TradeRoutesHandler.GetTree(this.networkId); } if (serializedItems == null) { return; } Inventory.FromTreeAttributes(TreeAttribute.CreateFromBytes(serializedItems)); }