private void Inventory_SlotModified(int id) { ContentConfig config = ItemSlotTrough.getContentConfig(Api.World, contentConfigs, inventory[id]); this.contentCode = config?.Code; if (Api.Side == EnumAppSide.Client) { currentMesh = GenMesh(); } MarkDirty(true); }
internal bool OnInteract(IPlayer byPlayer, BlockSelection blockSel) { ItemSlot handSlot = byPlayer.InventoryManager.ActiveHotbarSlot; if (handSlot.Empty) { return(false); } ItemStack[] stacks = GetNonEmptyContentStacks(); ContentConfig contentConf = ItemSlotTrough.getContentConfig(Api.World, contentConfigs, handSlot); if (contentConf == null) { return(false); } // Add new if (stacks.Length == 0) { if (handSlot.StackSize >= contentConf.QuantityPerFillLevel) { inventory[0].Itemstack = handSlot.TakeOut(contentConf.QuantityPerFillLevel); inventory[0].MarkDirty(); return(true); } return(false); } // Or merge bool canAdd = handSlot.Itemstack.Equals(Api.World, stacks[0], GlobalConstants.IgnoredStackAttributes) && handSlot.StackSize >= contentConf.QuantityPerFillLevel && stacks[0].StackSize < contentConf.QuantityPerFillLevel * contentConf.MaxFillLevels ; if (canAdd) { handSlot.TakeOut(contentConf.QuantityPerFillLevel); inventory[0].Itemstack.StackSize += contentConf.QuantityPerFillLevel; inventory[0].MarkDirty(); return(true); } return(false); }