/// <summary> /// Attempts to flip the inventory slots. /// </summary> /// <param name="owningPlayer">The player owner of the invnetory slots.</param> /// <param name="invIds">The IDs of the player inventory.</param> /// <param name="slotIds">The IDs of the target inventory.</param> /// <param name="lastChanged">The times these ids were last changed.</param> public virtual bool TryFlipItemStack(IPlayer owningPlayer, string[] invIds, int[] slotIds, long[] lastChanged) { // 0 = source slot // 1 = target slot ItemSlot[] slots = GetSlotsIfExists(owningPlayer, invIds, slotIds); if (slots[0] == null || slots[1] == null) { return(false); } InventoryBase targetInv = (InventoryBase)owningPlayer.InventoryManager.GetInventory(invIds[1]); // 4. Try to move the item stack return(targetInv.TryFlipItems(slotIds[1], slots[0]) != null); }
/// <summary> /// Attempts to get specified slots if the slots exists. /// </summary> /// <param name="player">The player owning the slots</param> /// <param name="invIds">The inventory IDs</param> /// <param name="slotIds">The slot ids</param> /// <returns>The slots obtained.</returns> public virtual ItemSlot[] GetSlotsIfExists(IPlayer player, string[] invIds, int[] slotIds) { ItemSlot[] slots = new ItemSlot[2]; // 1. Both inventories must exist and be modifiable InventoryBase sourceInv = (InventoryBase)player.InventoryManager.GetInventory(invIds[0]); InventoryBase targetInv = (InventoryBase)player.InventoryManager.GetInventory(invIds[1]); if (sourceInv == null || targetInv == null) { return(slots); } if (!sourceInv.CanPlayerModify(player, player.Entity.Pos) || !targetInv.CanPlayerModify(player, player.Entity.Pos)) { return(slots); } // 3. Source and Dest slot must exist slots[0] = sourceInv[slotIds[0]]; slots[1] = targetInv[slotIds[1]]; return(slots); }
public ItemSlotBarrelInput(InventoryBase inventory) : base(inventory) { }
public ItemSlotInput(InventoryBase inventory, int outputSlotId) : base(inventory) { this.outputSlotId = outputSlotId; }
/// <summary> /// Create a new instance of an item slot /// </summary> /// <param name="inventory"></param> public ItemSlot(InventoryBase inventory) { this.inventory = inventory; }
public ItemSlotCreative(InventoryBase inventory) : base(inventory) { }
public ItemSlotUniversal(InventoryBase inventory) : base(inventory) { }
public ItemSlotOutput(InventoryBase inventory) : base(inventory) { }
public ItemSlotSurvival(InventoryBase inventory) : base(inventory) { }
public ItemSlotCharacter(EnumCharacterDressType type, InventoryBase inventory) : base(inventory) { this.type = type; }
public DummySlot(ItemStack stack, InventoryBase inv) : base(inv) { this.itemstack = stack; }
public ItemSlotOffhand(InventoryBase inventory) : base(inventory) { this.BackgroundIcon = "offhand"; }