public override void OnHeldInteractStop(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel) { if (byEntity.World.Side == EnumAppSide.Client) { ILoadedSound sound = ObjectCacheUtil.TryGet <ILoadedSound>(api, "temporalGearSound"); sound?.Stop(); sound?.Dispose(); } if (blockSel == null || secondsUsed < 3.45) { return; } slot.TakeOut(1); slot.MarkDirty(); //(byEntity as EntityPlayer)?.Player?.InventoryManager.BroadcastHotbarSlot(); if (byEntity.World.Side == EnumAppSide.Client) { byEntity.World.PlaySoundAt(new AssetLocation("sounds/effect/portal.ogg"), byEntity, null, false); particlesHeld.MinSize = 0.25f; particlesHeld.MaxSize = 0.5f; particlesHeld.MinQuantity = 300; Vec3d pos = blockSel.Position.ToVec3d().Add(blockSel.HitPosition); SpawnParticles(byEntity.World, pos, true); } if (byEntity.World.Side == EnumAppSide.Server && byEntity is EntityPlayer) { IServerPlayer plr = byEntity.World.PlayerByUid((byEntity as EntityPlayer).PlayerUID) as IServerPlayer; int uses = api.World.Config.GetString("temporalGearRespawnUses", "-1").ToInt(); plr.SetSpawnPosition(new PlayerSpawnPos() { x = byEntity.ServerPos.XYZInt.X, y = byEntity.ServerPos.XYZInt.Y, z = byEntity.ServerPos.XYZInt.Z, yaw = byEntity.ServerPos.Yaw, pitch = byEntity.ServerPos.Pitch, RemainingUses = uses }); } }
public override void OnHeldInteractStop(float secondsUsed, IItemSlot slot, IEntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel) { if (byEntity.World.Side == EnumAppSide.Client) { ILoadedSound sound = byEntity.World.Api.ObjectCache["temporalGearSound"] as ILoadedSound; sound?.Stop(); sound?.Dispose(); //Console.WriteLine("sound stop"); } if (blockSel == null || secondsUsed < 3.45) { return; } slot.TakeOut(1); slot.MarkDirty(); if (byEntity.World.Side == EnumAppSide.Client) { byEntity.World.PlaySoundAt(new AssetLocation("sounds/effect/portal.ogg"), byEntity, null, false); particlesHeld.minSize = 0.25f; particlesHeld.maxSize = 0.5f; particlesHeld.minQuantity = 300; Vec3d pos = blockSel.Position.ToVec3d().Add(blockSel.HitPosition); SpawnParticles(byEntity.World, pos, true); } if (byEntity.World.Side == EnumAppSide.Server && byEntity is EntityPlayer) { IServerPlayer plr = byEntity.World.PlayerByUid((byEntity as EntityPlayer).PlayerUID) as IServerPlayer; ICoreServerAPI sapi = byEntity.World.Api as ICoreServerAPI; plr.SetSpawnPosition(new PlayerSpawnPos(byEntity.ServerPos.XYZInt.X, byEntity.ServerPos.XYZInt.Y, byEntity.ServerPos.XYZInt.Z) { yaw = byEntity.ServerPos.Yaw, pitch = byEntity.ServerPos.Pitch }); } }