Exemplo n.º 1
0
        public override void DoInteraction(byte actionId, Player player)
        {
            player.Vehicle = EntityId;

            McpeSetEntityLink link = McpeSetEntityLink.CreateObject();

            link.linkType = (byte)McpeSetEntityLink.LinkActions.Ride;
            link.riderId  = player.EntityId;
            link.riddenId = EntityId;
            Level.RelayBroadcast(link);

            SendSetEntityData(player);
        }
Exemplo n.º 2
0
        public override void Mount(Entity rider)
        {
            if (rider is Player player)
            {
                Rider    = player;
                IsRidden = true;

                player.Vehicle = EntityId;

                McpeSetEntityLink link = McpeSetEntityLink.CreateObject();
                link.linkType = (byte)McpeSetEntityLink.LinkActions.Ride;
                link.riderId  = player.EntityId;
                link.riddenId = EntityId;
                Level.RelayBroadcast(link);

                SendSetEntityData(player);
            }
        }
Exemplo n.º 3
0
        public override void Unmount(Entity rider)
        {
            if (rider is Player player)
            {
                // Unmount ridden entity
                IsRiding = false;

                McpeSetEntityLink link = McpeSetEntityLink.CreateObject();
                link.linkType = (byte)McpeSetEntityLink.LinkActions.Remove;
                link.riderId  = player.EntityId;
                link.riddenId = EntityId;
                Level.RelayBroadcast(link);

                IsRidden  = false;
                IsRearing = false;
                BroadcastSetEntityData();

                player.Vehicle = 0;
                Rider          = null;

                player.BroadcastSetEntityData();
            }
        }
Exemplo n.º 4
0
 public virtual void HandleMcpeSetEntityLink(McpeSetEntityLink message)
 {
 }
 public abstract void HandleMcpeSetEntityLink(McpeSetEntityLink message);
Exemplo n.º 6
0
 public override void HandleMcpeSetEntityLink(McpeSetEntityLink message)
 {
 }
Exemplo n.º 7
0
        public Package Hookshot(McpeUseItem packet, Player player)
        {
            if (!(packet.face == -1 & player.Inventory.GetItemInHand().Id == 346))
            {
                return(packet);
            }
            player.Level.BroadcastMessage("test: arrow", type: MessageType.Raw); // Message typeはtip popup messageが選べる!

            const int force = 1;
            //Arrow arrow = new Arrow(player, player.Level, !(force < 1.0));
            Arrow arrow = new Arrow(player, player.Level);

            arrow.KnownPosition    = (PlayerLocation)player.KnownPosition.Clone();
            arrow.KnownPosition.Y += 1.62f;

            arrow.Velocity            = arrow.KnownPosition.GetHeadDirection() * (force * 2.0f * 1.5f);
            arrow.KnownPosition.Yaw   = (float)arrow.Velocity.GetYaw();
            arrow.KnownPosition.Pitch = (float)arrow.Velocity.GetPitch();
            arrow.BroadcastMovement   = true;
            arrow.DespawnOnImpact     = false;

            //arrow.HitEvent += testary;

            arrow.SpawnEntity();
            var setEntityLinkPk = McpeSetEntityLink.CreateObject();

            setEntityLinkPk.riderId  = 0;
            setEntityLinkPk.riddenId = arrow.EntityId;
            setEntityLinkPk.linkType = 2;

            /*    public static final byte TYPE_REMOVE = 0;
             *       public static final byte TYPE_RIDE = 1;
             *   public static final byte TYPE_PASSENGER = 2;
             */
            new Task(() => player.Level.RelayBroadcast(setEntityLinkPk)).Start();



            Level level  = player.Level;
            Mob   entity = new Mob(EntityType.Zombie, level)
            {
                KnownPosition = player.KnownPosition,
            };

            entity.SpawnEntity();
            entity.IsAngry = true;
            entity.


            Task.Run(() =>
            {
                PlayerLocation pos = null;
                while (arrow.Velocity.Length() > 0)
                {
                    pos = arrow.KnownPosition;

                    Thread.Sleep(100);
                }
                McpeMovePlayer mp = McpeMovePlayer.CreateObject();
                mp.entityId       = 0;
                mp.x       = pos.X;
                mp.y       = pos.Y;
                mp.z       = pos.Z;
                mp.pitch   = player.KnownPosition.Pitch;
                mp.headYaw = player.KnownPosition.HeadYaw;
                mp.yaw     = player.KnownPosition.Yaw;
                new Task(() => player.Level.RelayBroadcast(mp)).Start();

                /*Console.Write("done!!" + pos);
                 * Block block = BlockFactory.GetBlockById((byte)1);
                 * block.Coordinates = new BlockCoordinates((int)arrow.KnownPosition.X, (int)arrow.KnownPosition.Y - 2, (int)arrow.KnownPosition.Z);
                 * //arrow.Level.SetBlock(block);
                 *
                 * Block item = new Block(35);
                 * player.KnownPosition.Y -= 2;*/
            });
            return(packet);
        }
Exemplo n.º 8
0
 public override void HandleMcpeSetEntityLink(McpeSetEntityLink message)
 {
     UnhandledPackage(message);
 }