public void OnBlockInteract(IPlayer byPlayer) { if (Sealed) { return; } FindMatchingRecipe(); if (api.Side == EnumAppSide.Client) { if (invDialog == null) { invDialog = new GuiDialogBarrel("Barrel", Inventory, pos, api as ICoreClientAPI); invDialog.OnClosed += () => { (api as ICoreClientAPI).Network.SendBlockEntityPacket(pos.X, pos.Y, pos.Z, (int)EnumBlockContainerPacketId.CloseInventory, null); byPlayer.InventoryManager.CloseInventory(inventory); }; } invDialog.TryOpen(); (api as ICoreClientAPI).Network.SendPacketClient(inventory.Open(byPlayer)); } else { byPlayer.InventoryManager.OpenInventory(inventory); } }
public override void OnInteract(EntityAgent byEntity, ItemSlot itemslot, Vec3d hitPosition, EnumInteractMode mode, ref EnumHandling handled) { bool inRange = (byEntity.World.Side == EnumAppSide.Client && byEntity.Pos.SquareDistanceTo(entity.Pos) <= 5) || (byEntity.World.Side == EnumAppSide.Server && byEntity.Pos.SquareDistanceTo(entity.Pos) <= 14); if (!IsHarvested || !inRange) { return; } EntityPlayer entityplr = byEntity as EntityPlayer; IPlayer player = entity.World.PlayerByUid(entityplr.PlayerUID); player.InventoryManager.OpenInventory(inv); if (entity.World.Side == EnumAppSide.Client && dlg == null) { dlg = new GuiDialogCarcassContents(inv, entity as EntityAgent, entity.Api as ICoreClientAPI); if (dlg.TryOpen()) { (entity.World.Api as ICoreClientAPI).Network.SendPacketClient(inv.Open(player)); } dlg.OnClosed += () => dlg = null; } }
public void OnBlockInteract(IPlayer byPlayer) { if (Api.World.Side == EnumAppSide.Client) { if (invDialog == null) { invDialog = new GuiDialogSingleSink("Cabinet Sink", Inventory, Pos, Api as ICoreClientAPI); invDialog.OnClosed += () => { invDialog = null; (Api as ICoreClientAPI).Network.SendBlockEntityPacket(Pos.X, Pos.Y, Pos.Z, (int)EnumBlockEntityPacketId.Close, null); byPlayer.InventoryManager.CloseInventory(inventory); animUtil.StopAnimation("lidopen"); Api.World.PlaySoundAt(new AssetLocation("game:sounds/block/largechestclose"), Pos.X, Pos.Y, Pos.Z); }; } if (Api.Side == EnumAppSide.Client) { animUtil.StartAnimation(new AnimationMetaData() { Animation = "lidopen", Code = "lidopen", AnimationSpeed = 1.8f, EaseOutSpeed = 6, EaseInSpeed = 15 }); Api.World.PlaySoundAt(new AssetLocation("game:sounds/block/largechestopen"), Pos.X, Pos.Y, Pos.Z); } invDialog.TryOpen(); (Api as ICoreClientAPI).Network.SendPacketClient(inventory.Open(byPlayer)); } else { byPlayer.InventoryManager.OpenInventory(inventory); } }
public GuiDialogTrader(InventoryTrader traderInventory, EntityAgent owningEntity, ICoreClientAPI capi, int rows = 4, int cols = 4) : base(capi) { auctionSys = capi.ModLoader.GetModSystem <ModSystemAuction>(); auctionSys.OnCellUpdateClient = () => { listElem?.ReloadCells(auctions); updateScrollbarBounds(); }; auctionSys.curTraderClient = owningEntity as EntityTrader; this.traderInventory = traderInventory; this.owningEntity = owningEntity; this.rows = rows; this.cols = cols; if (!auctionSys.createAuctionSlotByPlayer.TryGetValue(capi.World.Player.PlayerUID, out auctionSlotInv)) { auctionSys.createAuctionSlotByPlayer[capi.World.Player.PlayerUID] = auctionSlotInv = new InventoryGeneric(1, "auctionslot-" + capi.World.Player.PlayerUID, capi); } capi.Network.SendPacketClient(auctionSlotInv.Open(capi.World.Player)); Compose(); }