public override void Initialize(ICoreAPI api) { base.Initialize(api); inventory.LateInitialize(BlockCode + "-" + Pos.ToString(), api); inventory.ResolveBlocksOrItems(); }
public override void Initialize(ICoreAPI api) { base.Initialize(api); inventory.LateInitialize("toolrack-" + pos.ToString(), api); inventory.ResolveBlocksOrItems(); if (api is ICoreClientAPI) { loadToolMeshes(); } }
public bool MergeWith(TreeAttribute blockEntityAttributes) { InventoryGeneric otherinv = new InventoryGeneric(1, BlockCode, null, null, null); otherinv.FromTreeAttributes(blockEntityAttributes.GetTreeAttribute("inventory")); otherinv.Api = Api; otherinv.ResolveBlocksOrItems(); if (!inventory[0].Empty && otherinv[0].Itemstack.Equals(Api.World, inventory[0].Itemstack, GlobalConstants.IgnoredStackAttributes)) { int quantityToMove = Math.Min(otherinv[0].StackSize, Math.Max(0, MaxStackSize - inventory[0].StackSize)); inventory[0].Itemstack.StackSize += quantityToMove; otherinv[0].TakeOut(quantityToMove); if (otherinv[0].StackSize > 0) { BlockPos uppos = Pos.UpCopy(); Block upblock = Api.World.BlockAccessor.GetBlock(uppos); if (upblock.Replaceable > 6000) { ((IBlockItemPile)Block).Construct(otherinv[0], Api.World, uppos, null); } } MarkDirty(true); TriggerPileChanged(); } return(true); }
public override void Initialize(ICoreAPI api) { base.Initialize(api); _inv.Api = api; _inv.LateInitialize("gravestone-" + Pos.X + "/" + Pos.Y + "/" + Pos.Z, api); _inv.ResolveBlocksOrItems(); }
public override void Initialize(ICoreAPI api) { base.Initialize(api); if (energyStorage == null) { energyStorage = new FluxStorage(MyMiniLib.GetAttributeInt(Block, "storage", 10000), MyMiniLib.GetAttributeInt(Block, "input", 1000), MyMiniLib.GetAttributeInt(Block, "output", 1000)); } inventory.LateInitialize("charger-" + Pos.ToString(), api); inventory.ResolveBlocksOrItems(); if (api is ICoreClientAPI) { loadToolMeshes(); } else { RegisterGameTickListener(OnTick, 250); } }
public override void FromBytes(BinaryReader reader, bool forClient) { base.FromBytes(reader, forClient); if (WatchedAttributes != null) { string inventoryID = WatchedAttributes.GetString("invid"); int qslots = WatchedAttributes.GetInt("qslots", 0); Inventory = new InventoryGeneric(qslots, inventoryID, Api); Inventory.FromTreeAttributes(WatchedAttributes); if (Api != null) { Inventory.ResolveBlocksOrItems(); } } }