Beispiel #1
0
        public override InteractResult OnActLeft(InteractionContext context)
        {
            try
            {
                if (context.BlockPosition == null || !context.BlockPosition.HasValue)
                {
                    return(InteractResult.Success);
                }

                Vector3i pos = context.BlockPosition.Value;

                pos.X = pos.X < 0 ? pos.X + Shared.Voxel.World.VoxelSize.X : pos.X;
                pos.Z = pos.Z < 0 ? pos.Z + Shared.Voxel.World.VoxelSize.Z : pos.Z;

                pos.X = pos.X % Shared.Voxel.World.VoxelSize.X;
                pos.Z = pos.Z % Shared.Voxel.World.VoxelSize.Z;

                UserSession userSession = WorldEditManager.GetUserSession(context.Player.User);
                userSession.SetFirstPosition(pos);

                context.Player.MsgLoc($"First Position set to ({pos.x}, {pos.y}, {pos.z})");
            }
            catch (Exception e)
            {
                Log.WriteError(Localizer.Do($"{e}"));
            }
            return(InteractResult.Success);
        }
        public static void Selclaim(User user)
        {
            try
            {
                Vector3i    pos      = user.Position.Round;
                Vector2i    claimPos = PlotUtil.NearestPlotPosInWorld(pos.XZ);
                UserSession session  = WorldEditManager.GetUserSession(user);

                session.SetFirstPosition(claimPos.X_Z(pos.Y - 1));
                session.SetSecondPosition(WorldEditUtils.SecondPlotPos(claimPos).X_Z(pos.Y - 1));

                user.Player.MsgLoc($"First Position set to {session.Selection.min}");
                user.Player.MsgLoc($"Second Position set to {session.Selection.max}");
            }
            catch (Exception e)
            {
                Log.WriteError(Localizer.Do($"{e}"));
            }
        }
        public static void SetPos1(User user)
        {
            try
            {
                Vector3 pos = user.Position;
                pos.X = pos.X < 0 ? pos.X + Shared.Voxel.World.VoxelSize.X : pos.X;
                pos.Z = pos.Z < 0 ? pos.Z + Shared.Voxel.World.VoxelSize.Z : pos.Z;
                pos.X = pos.X % Shared.Voxel.World.VoxelSize.X;
                pos.Z = pos.Z % Shared.Voxel.World.VoxelSize.Z;

                UserSession session = WorldEditManager.GetUserSession(user);
                session.SetFirstPosition(pos.Round);

                user.Player.MsgLoc($"First Position set to {pos}");
            }
            catch (Exception e)
            {
                Log.WriteError(Localizer.Do($"{e}"));
            }
        }