Ejemplo n.º 1
0
        public virtual void DoLogin(net.minecraft.src.Packet1Login packet1login)
        {
            net.minecraft.src.EntityPlayerMP entityplayermp = mcServer.serverConfigurationManager.Login(this, packet1login.username);
            if (entityplayermp != null)
            {
                mcServer.serverConfigurationManager.ReadPlayerDataFromFile(entityplayermp);
                entityplayermp.SetWorldHandler(mcServer.GetWorldServer(entityplayermp.dimension));

                //TODO: Cleanup all java.lang.StringBuilder instances
                //logger.Info((new java.lang.StringBuilder()).Append(GetUserAndIPString()).Append(" logged in with entity id ").Append(entityplayermp.entityId).Append(" at (").Append(entityplayermp.posX).Append(", ").Append(entityplayermp.posY).Append(", ").Append(entityplayermp.posZ).Append(")").ToString());
                logger.Info($"{GetUserAndIPString()} logged in with entity id {entityplayermp.entityId} at ({entityplayermp.posX}, {entityplayermp.posY}, {entityplayermp.posZ})");

                net.minecraft.src.WorldServer      worldserver      = mcServer.GetWorldServer(entityplayermp.dimension);
                net.minecraft.src.ChunkCoordinates chunkcoordinates = worldserver.GetSpawnPoint();
                net.minecraft.src.NetServerHandler netserverhandler = new net.minecraft.src.NetServerHandler(mcServer, netManager, entityplayermp);

                netserverhandler.SendPacket(new net.minecraft.src.Packet1Login(string.Empty, entityplayermp.entityId, worldserver.GetSeed(), unchecked ((byte)worldserver.worldProvider.worldType)));
                netserverhandler.SendPacket(new net.minecraft.src.Packet6SpawnPosition(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ));

                mcServer.serverConfigurationManager.Func_28170_a(entityplayermp, worldserver);

                //TODO: Defer login message to hook
                //mcServer.configManager.SendPacketToAllPlayers(new net.minecraft.src.Packet3Chat((new java.lang.StringBuilder()).Append("\xf7e").Append(entityplayermp.username).Append(" joined the game.").ToString()));
                mcServer.serverConfigurationManager.SendPacketToAllPlayers(new net.minecraft.src.Packet3Chat($"§e{entityplayermp.username} joined the game."));
                mcServer.serverConfigurationManager.PlayerLoggedIn(entityplayermp);

                netserverhandler.TeleportTo(entityplayermp.posX, entityplayermp.posY, entityplayermp.posZ, entityplayermp.rotationYaw, entityplayermp.rotationPitch);
                mcServer.networkServer.AddPlayer(netserverhandler);

                netserverhandler.SendPacket(new net.minecraft.src.Packet4UpdateTime(worldserver.GetWorldTime()));

                entityplayermp.Func_20057_k();
            }
            finishedProcessing = true;
        }
Ejemplo n.º 2
0
        public override void HandlePlace(net.minecraft.src.Packet15Place packet15place)
        {
            net.minecraft.src.WorldServer worldserver = mcServer.GetWorldServer(playerEntity
                                                                                .dimension);
            net.minecraft.src.ItemStack itemstack = playerEntity.inventory.GetCurrentItem();
            bool flag = worldserver.weirdIsOpCache = worldserver.worldProvider.worldType != 0 ||
                                                     mcServer.serverConfigurationManager.IsOp(playerEntity.username);

            if (packet15place.direction == 255)
            {
                if (itemstack == null)
                {
                    return;
                }
                playerEntity.itemInWorldManager.Func_6154_a(playerEntity, worldserver, itemstack);
            }
            else
            {
                int i = packet15place.xPosition;
                int j = packet15place.yPosition;
                int k = packet15place.zPosition;
                int l = packet15place.direction;
                net.minecraft.src.ChunkCoordinates chunkcoordinates = worldserver.GetSpawnPoint();
                int i1 = (int)net.minecraft.src.MathHelper.Abs(i - chunkcoordinates.posX);
                int j1 = (int)net.minecraft.src.MathHelper.Abs(k - chunkcoordinates.posZ);
                if (i1 > j1)
                {
                    j1 = i1;
                }
                if (hasMoved && playerEntity.GetDistanceSq((double)i + 0.5D, (double)j + 0.5D, (double
                                                                                                )k + 0.5D) < 64D && (j1 > 16 || flag))
                {
                    playerEntity.itemInWorldManager.ActiveBlockOrUseItem(playerEntity, worldserver, itemstack
                                                                         , i, j, k, l);
                }
                playerEntity.netServerHandler.SendPacket(new net.minecraft.src.Packet53BlockChange
                                                             (i, j, k, worldserver));
                if (l == 0)
                {
                    j--;
                }
                if (l == 1)
                {
                    j++;
                }
                if (l == 2)
                {
                    k--;
                }
                if (l == 3)
                {
                    k++;
                }
                if (l == 4)
                {
                    i--;
                }
                if (l == 5)
                {
                    i++;
                }
                playerEntity.netServerHandler.SendPacket(new net.minecraft.src.Packet53BlockChange
                                                             (i, j, k, worldserver));
            }
            itemstack = playerEntity.inventory.GetCurrentItem();
            if (itemstack != null && itemstack.stackSize == 0)
            {
                playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem] = null;
            }
            playerEntity.isChangingQuantityOnly = true;
            playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem] = net.minecraft.src.ItemStack
                                                                                       .CloneStack(playerEntity.inventory.mainInventory[playerEntity.inventory.currentItem
                                                                                                   ]);
            net.minecraft.src.Slot slot = playerEntity.currentCraftingInventory.Func_20127_a(
                playerEntity.inventory, playerEntity.inventory.currentItem);
            playerEntity.currentCraftingInventory.UpdateCraftingMatrix();
            playerEntity.isChangingQuantityOnly = false;
            if (!net.minecraft.src.ItemStack.AreItemStacksEqual(playerEntity.inventory.GetCurrentItem
                                                                    (), packet15place.itemStack))
            {
                SendPacket(new net.minecraft.src.Packet103SetSlot(playerEntity.currentCraftingInventory
                                                                  .windowId, slot.id, playerEntity.inventory.GetCurrentItem()));
            }
            worldserver.weirdIsOpCache = false;
        }
Ejemplo n.º 3
0
        public override void HandleBlockDig(net.minecraft.src.Packet14BlockDig packet14blockdig)
        {
            if (playerEntity.isDead)
            {
                return;                      // CRAFTBUKKIT
            }
            net.minecraft.src.WorldServer worldserver = mcServer.GetWorldServer(playerEntity
                                                                                .dimension);
            if (packet14blockdig.status == 4)
            {
                playerEntity.DropCurrentItem();
                return;
            }
            bool flag = worldserver.weirdIsOpCache = worldserver.worldProvider.worldType != 0 ||
                                                     mcServer.serverConfigurationManager.IsOp(playerEntity.username);
            bool flag1 = false;

            if (packet14blockdig.status == 0)
            {
                flag1 = true;
            }
            if (packet14blockdig.status == 2)
            {
                flag1 = true;
            }
            int i = packet14blockdig.xPosition;
            int j = packet14blockdig.yPosition;
            int k = packet14blockdig.zPosition;

            if (flag1)
            {
                double d  = playerEntity.posX - ((double)i + 0.5D);
                double d1 = playerEntity.posY - ((double)j + 0.5D);
                double d3 = playerEntity.posZ - ((double)k + 0.5D);
                double d5 = d * d + d1 * d1 + d3 * d3;
                if (d5 > 36D)
                {
                    return;
                }
            }
            net.minecraft.src.ChunkCoordinates chunkcoordinates = worldserver.GetSpawnPoint();
            int l  = (int)net.minecraft.src.MathHelper.Abs(i - chunkcoordinates.posX);
            int i1 = (int)net.minecraft.src.MathHelper.Abs(k - chunkcoordinates.posZ);

            if (l > i1)
            {
                i1 = l;
            }
            if (packet14blockdig.status == 0)
            {
                if (i1 > 16 || flag)
                {
                    playerEntity.itemInWorldManager.Func_324_a(i, j, k, packet14blockdig.face);
                }
                else
                {
                    playerEntity.netServerHandler.SendPacket(new net.minecraft.src.Packet53BlockChange
                                                                 (i, j, k, worldserver));
                }
            }
            else
            {
                if (packet14blockdig.status == 2)
                {
                    playerEntity.itemInWorldManager.Func_22045_b(i, j, k);
                    if (worldserver.GetBlockId(i, j, k) != 0)
                    {
                        playerEntity.netServerHandler.SendPacket(new net.minecraft.src.Packet53BlockChange
                                                                     (i, j, k, worldserver));
                    }
                }
                else
                {
                    if (packet14blockdig.status == 3)
                    {
                        double d2 = playerEntity.posX - ((double)i + 0.5D);
                        double d4 = playerEntity.posY - ((double)j + 0.5D);
                        double d6 = playerEntity.posZ - ((double)k + 0.5D);
                        double d7 = d2 * d2 + d4 * d4 + d6 * d6;
                        if (d7 < 256D)
                        {
                            playerEntity.netServerHandler.SendPacket(new net.minecraft.src.Packet53BlockChange
                                                                         (i, j, k, worldserver));
                        }
                    }
                }
            }
            worldserver.weirdIsOpCache = false;
        }