Example #1
0
        public LocalPlayer(Game game) : base(game)
        {
            DisplayName    = game.Username;
            SkinName       = game.Username;
            SkinIdentifier = "skin_255";
            physics        = new PhysicsComponent(game, this);
            Hacks          = new HacksComponent(game, this);

            Hacks.SpeedMultiplier = Options.GetFloat(OptionsKey.Speed, 0.1f, 50, 10);
            Hacks.PushbackPlacing = Options.GetBool(OptionsKey.PushbackPlacing, false);
            Hacks.NoclipSlide     = Options.GetBool(OptionsKey.NoclipSlide, false);
            Hacks.DoubleJump      = Options.GetBool(OptionsKey.DoubleJump, false);
            Hacks.Enabled         = Options.GetBool(OptionsKey.HacksEnabled, true);
            InitRenderingData();
        }
        bool CheckIsFree(PickedPos selected, byte newBlock)
        {
            Vector3 pos = (Vector3)selected.TranslatedPos;

            if (!CannotPassThrough(newBlock))
            {
                return(true);
            }
            if (IntersectsOtherPlayers(pos, newBlock))
            {
                return(false);
            }

            AABB blockBB = new AABB(pos + game.BlockInfo.MinBB[newBlock],
                                    pos + game.BlockInfo.MaxBB[newBlock]);
            AABB localBB = game.LocalPlayer.CollisionBounds;

            if (game.LocalPlayer.Hacks.Noclip || !localBB.Intersects(blockBB))
            {
                return(true);
            }
            HacksComponent hacks = game.LocalPlayer.Hacks;

            if (hacks.CanPushbackBlocks && hacks.PushbackPlacing && hacks.Enabled)
            {
                return(PushbackPlace(selected, blockBB));
            }

            localBB.Min.Y += 0.25f + Entity.Adjustment;
            if (localBB.Intersects(blockBB))
            {
                return(false);
            }

            // Push player up if they are jumping and trying to place a block underneath them.
            Vector3 p = game.LocalPlayer.Position;

            p.Y = pos.Y + game.BlockInfo.MaxBB[newBlock].Y + Entity.Adjustment;
            LocationUpdate update = LocationUpdate.MakePos(p, false);

            game.LocalPlayer.SetLocation(update, false);
            return(true);
        }