private ItemSlot onNewSlot(int slotId, InventoryGeneric self) { EnumCharacterDressType type = (EnumCharacterDressType)slotId; ItemSlotCharacter slot = new ItemSlotCharacter(type, self); iconByDressType.TryGetValue(type, out slot.BackgroundIcon); return(slot); }
protected override ItemSlot NewSlot(int slotId) { if (slotId == 15) { return(new ItemSlotSurvival(this)); } EnumCharacterDressType type = (EnumCharacterDressType)slotId; ItemSlotCharacter slot = new ItemSlotCharacter(type, this); iconByDressType.TryGetValue(type, out slot.BackgroundIcon); return(slot); }
public override void OnInteract(EntityAgent byEntity, ItemSlot slot, Vec3d hitPosition, EnumInteractMode mode) { IPlayer plr = (byEntity as EntityPlayer)?.Player; if (plr != null && !byEntity.World.Claims.TryAccess(plr, Pos.AsBlockPos, EnumBlockAccessFlags.Use)) { plr.InventoryManager.ActiveHotbarSlot.MarkDirty(); WatchedAttributes.MarkAllDirty(); return; } if (mode == EnumInteractMode.Interact && byEntity.RightHandItemSlot != null) { ItemSlot handslot = byEntity.RightHandItemSlot; if (handslot.Empty) { // Start from armor slot because it can't wear clothes atm for (int i = 0; i < GearInventory.Count; i++) { ItemSlot gslot = GearInventory[i]; if (gslot.Empty) { continue; } if (gslot.TryPutInto(byEntity.World, handslot) > 0) { return; } } } else { if (!ItemSlotCharacter.IsDressType(slot.Itemstack, EnumCharacterDressType.ArmorBody) && !ItemSlotCharacter.IsDressType(slot.Itemstack, EnumCharacterDressType.ArmorHead) && !ItemSlotCharacter.IsDressType(slot.Itemstack, EnumCharacterDressType.ArmorLegs)) { (byEntity.World.Api as ICoreClientAPI)?.TriggerIngameError(this, "cantplace", "Cannot place dresses on armor stands"); return; } } WeightedSlot sinkslot = GearInventory.GetBestSuitedSlot(handslot); if (sinkslot.weight > 0 && sinkslot.slot != null) { handslot.TryPutInto(byEntity.World, sinkslot.slot); return; } bool empty = true; for (int i = 0; i < GearInventory.Count; i++) { ItemSlot gslot = GearInventory[i]; empty &= gslot.Empty; } if (empty && byEntity.Controls.Sneak) { ItemStack stack = new ItemStack(byEntity.World.GetItem(new AssetLocation("armorstand"))); if (!byEntity.TryGiveItemStack(stack)) { byEntity.World.SpawnItemEntity(stack, ServerPos.XYZ); } Die(); return; } } if (!Alive || World.Side == EnumAppSide.Client || mode == 0) { //base.OnInteract(byEntity, slot, hitPosition, mode); return; } base.OnInteract(byEntity, slot, hitPosition, mode); }