public override bool DoPlaceBlock(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel, ItemStack byItemStack) { bool flag = base.DoPlaceBlock(world, byPlayer, blockSel, byItemStack); if (flag && byPlayer.WorldData.CurrentGameMode == EnumGameMode.Creative) { BlockEntityTeleport bet = api.World.BlockAccessor.GetBlockEntity(blockSel.Position) as BlockEntityTeleport; if (bet != null && bet.State == EnumTeleportState.Normal && api.Side == EnumAppSide.Server) { TPNetManager.AddAvailableTeleport(byPlayer as IServerPlayer, blockSel.Position); } } return(flag); }
public override bool OnBlockInteractStart(IWorldAccessor world, IPlayer byPlayer, BlockSelection blockSel) { BlockEntityTeleport be = api.World.BlockAccessor.GetBlockEntity(blockSel.Position) as BlockEntityTeleport; if (be == null) { //api.World.BlockAccessor.SetBlock(BlockId, blockSel.Position); return(false); } if (be.Repaired && byPlayer.WorldData.EntityControls.Sneak) { be.OnShiftRightClick(); return(true); } ItemSlot slot = byPlayer.InventoryManager.ActiveHotbarSlot; if (slot.Empty) { return(base.OnBlockInteractStart(world, byPlayer, blockSel)); } if (!be.Repaired && slot.Itemstack.Collectible is ItemTemporalGear) { be.Repaired = true; if (byPlayer.WorldData.CurrentGameMode != EnumGameMode.Creative) { slot.TakeOut(1); slot.MarkDirty(); } if (api.Side == EnumAppSide.Server) { TPNetManager.AddAvailableTeleport(byPlayer as IServerPlayer, be.Pos); } world.PlaySoundAt(new AssetLocation("sounds/effect/latch"), blockSel.Position.X + 0.5, blockSel.Position.Y, blockSel.Position.Z + 0.5, byPlayer, true, 16); return(true); } return(false); }
private void OnGameTick(float dt) { if (animUtil?.animator?.ActiveAnimationCount == 0) { animUtil.StartAnimation(new AnimationMetaData() { Animation = "octagram", Code = "octagram", AnimationSpeed = 0.5f, EaseInSpeed = 1f, EaseOutSpeed = 1f }); animUtil.StartAnimation(new AnimationMetaData() { Animation = "gear", Code = "gear", AnimationSpeed = 0.25f, EaseInSpeed = 1f, EaseOutSpeed = 1f }); } if (!Active) { return; } toremove.Clear(); float bestSecondsPassed = 0; foreach (var val in tpingPlayers) { if (val.Value.State == EnumTeleportingEntityState.None) { if (Api.Side == EnumAppSide.Server) { IServerPlayer player = Api.World.PlayerByUid(val.Key) as IServerPlayer; TPNetManager.AddAvailableTeleport(player, Pos); } val.Value.State = EnumTeleportingEntityState.Teleporting; } val.Value.SecondsPassed += Math.Min(0.5f, dt); if (Api.World.ElapsedMilliseconds - val.Value.LastCollideMs > 300) { toremove.Add(val.Key); continue; } if (val.Value.SecondsPassed > 3 && val.Value.State == EnumTeleportingEntityState.Teleporting) { val.Value.State = EnumTeleportingEntityState.UI; if (Api.Side == EnumAppSide.Client && teleportDlg?.IsOpened() != true) { if (teleportDlg != null) { teleportDlg.Dispose(); } teleportDlg = new GuiDialogTeleport(Api as ICoreClientAPI, Pos); teleportDlg.TryOpen(); } } bestSecondsPassed = Math.Max(val.Value.SecondsPassed, bestSecondsPassed); } foreach (var playerUID in toremove) { tpingPlayers.Remove(playerUID); if (Api.Side == EnumAppSide.Client) { teleportDlg?.TryClose(); } } Active = tpingPlayers.Count > 0; if (Api.Side == EnumAppSide.Server) { for (int i = 0; i < 10; i++) { props.MinPos.Set(RandomParticleInCirclePos()); Api.World.SpawnParticles(props); } } if (Api.Side == EnumAppSide.Client) { bestSecondsPassed = Math.Min(bestSecondsPassed, 3); animUtil.activeAnimationsByAnimCode["octagram"].AnimationSpeed = (float)(0.5f * (1 + Math.Exp(bestSecondsPassed) * 0.3f)); } }