public virtual void OnUpdate() { net.minecraft.src.WorldServer worldserver = playerManager.GetMinecraftServer(); if (dirtyCount == 0) { return; } if (dirtyCount == 1) { int i = chunkX * 16 + minX; int l = minY; int k1 = chunkZ * 16 + minZ; SendPacketToPlayersInInstance(new net.minecraft.src.Packet53BlockChange(i, l, k1, worldserver)); if (net.minecraft.src.Block.isBlockContainer[worldserver.GetBlockId(i, l, k1)]) { UpdateTileEntity(worldserver.GetBlockTileEntity(i, l, k1)); } } else { if (dirtyCount == 10) { minY = (minY / 2) * 2; maxY = (maxY / 2 + 1) * 2; int j = minX + chunkX * 16; int i1 = minY; int l1 = minZ + chunkZ * 16; int j2 = (maxX - minX) + 1; int l2 = (maxY - minY) + 2; int i3 = (maxZ - minZ) + 1; SendPacketToPlayersInInstance(new net.minecraft.src.Packet51MapChunk(j, i1, l1, j2, l2, i3, worldserver)); List <TileEntity> list = worldserver.GetTileEntityList(j, i1, l1, j + j2, i1 + l2, l1 + i3); for (int j3 = 0; j3 < list.Count; j3++) { UpdateTileEntity((net.minecraft.src.TileEntity)list[j3]); } } else { SendPacketToPlayersInInstance(new net.minecraft.src.Packet52MultiBlockChange(chunkX, chunkZ, dirtyBlocks, dirtyCount, worldserver)); for (int k = 0; k < dirtyCount; k++) { // CRAFTBUKKIT start -- Fixes TileEntity updates occurring upon a multi-block change; dirtyCount -> dirtyBlocks[i] int j1 = chunkX * 16 + (dirtyBlocks[k] >> 12 & 0xf); int i2 = dirtyBlocks[k] & 0xff; int k2 = chunkZ * 16 + (dirtyBlocks[k] >> 8 & 0xf); // CRAFTBUKKIT end if (net.minecraft.src.Block.isBlockContainer[worldserver.GetBlockId(j1, i2, k2)]) { //System.Console.Out.WriteLine("Sending!"); UpdateTileEntity(worldserver.GetBlockTileEntity(j1, i2, k2)); } } } } dirtyCount = 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; }
public virtual net.minecraft.src.EntityPlayerMP RecreatePlayerEntity(net.minecraft.src.EntityPlayerMP entityplayermp, int i) { mcServer.GetEntityTracker(entityplayermp.dimension).RemoveTrackedPlayerSymmetric( entityplayermp); mcServer.GetEntityTracker(entityplayermp.dimension).UntrackEntity(entityplayermp); GetPlayerManager(entityplayermp.dimension).RemovePlayer(entityplayermp); playerEntities.Remove(entityplayermp); mcServer.GetWorldServer(entityplayermp.dimension).RemovePlayer(entityplayermp); net.minecraft.src.ChunkCoordinates chunkcoordinates = entityplayermp.GetSpawnChunk (); entityplayermp.dimension = i; net.minecraft.src.EntityPlayerMP entityplayermp1 = new net.minecraft.src.EntityPlayerMP (mcServer, mcServer.GetWorldServer(entityplayermp.dimension), entityplayermp.username , new net.minecraft.src.ItemInWorldManager(mcServer.GetWorldServer(entityplayermp .dimension))); entityplayermp1.entityId = entityplayermp.entityId; entityplayermp1.netServerHandler = entityplayermp.netServerHandler; net.minecraft.src.WorldServer worldserver = mcServer.GetWorldServer(entityplayermp .dimension); if (chunkcoordinates != null) { net.minecraft.src.ChunkCoordinates chunkcoordinates1 = net.minecraft.src.EntityPlayer .Func_25051_a(mcServer.GetWorldServer(entityplayermp.dimension), chunkcoordinates ); if (chunkcoordinates1 != null) { entityplayermp1.SetLocationAndAngles((float)chunkcoordinates1.posX + 0.5F, (float )chunkcoordinates1.posY + 0.1F, (float)chunkcoordinates1.posZ + 0.5F, 0.0F, 0.0F ); entityplayermp1.SetSpawnChunk(chunkcoordinates); } else { entityplayermp1.netServerHandler.SendPacket(new net.minecraft.src.Packet70Bed (0)); } } worldserver.chunkProviderServer.LoadChunk((int)entityplayermp1.posX >> 4, (int)entityplayermp1 .posZ >> 4); for (; worldserver.GetCollidingBoundingBoxes(entityplayermp1, entityplayermp1.boundingBox ).Count != 0; entityplayermp1.SetPosition(entityplayermp1.posX, entityplayermp1. posY + 1.0D, entityplayermp1.posZ)) { } entityplayermp1.netServerHandler.SendPacket(new net.minecraft.src.Packet9Respawn (unchecked ((byte)entityplayermp1.dimension))); entityplayermp1.netServerHandler.TeleportTo(entityplayermp1.posX, entityplayermp1 .posY, entityplayermp1.posZ, entityplayermp1.rotationYaw, entityplayermp1.rotationPitch ); Func_28170_a(entityplayermp1, worldserver); GetPlayerManager(entityplayermp1.dimension).AddPlayer(entityplayermp1); worldserver.AddEntity(entityplayermp1); playerEntities.Add(entityplayermp1); entityplayermp1.Func_20057_k(); entityplayermp1.Func_22068_s(); return(entityplayermp1); }
public override void HandleUpdateSign(net.minecraft.src.Packet130UpdateSign packet130updatesign) { if (this.playerEntity.isDead) { return; // CRAFTBUKKIT } net.minecraft.src.WorldServer worldserver = mcServer.GetWorldServer(playerEntity.dimension); if (worldserver.BlockExists(packet130updatesign.xPosition, packet130updatesign.yPosition, packet130updatesign.zPosition)) { net.minecraft.src.TileEntity tileentity = worldserver.GetBlockTileEntity(packet130updatesign.xPosition, packet130updatesign.yPosition, packet130updatesign.zPosition); if (tileentity is net.minecraft.src.TileEntitySign) { net.minecraft.src.TileEntitySign tileentitysign = (net.minecraft.src.TileEntitySign)tileentity; if (!tileentitysign.GetEditable()) { mcServer.LogWarning((new java.lang.StringBuilder()).Append("Player ").Append(playerEntity.username).Append(" just tried to change non-editable sign").ToString()); this.SendPacket(new Packet130UpdateSign(packet130updatesign.xPosition, packet130updatesign.yPosition, packet130updatesign.zPosition, tileentitysign.Lines)); // CRAFTBUKKIT return; } } for (int i = 0; i < 4; i++) { bool lineValid = true; if (packet130updatesign.signLines[i].Length > 15) { lineValid = false; } else { for (int l = 0; l < packet130updatesign.signLines[i].Length; l++) { if (net.minecraft.src.ChatAllowedCharacters.allowedCharacters.IndexOf(packet130updatesign.signLines[i][l]) < 0) { lineValid = false; } } } if (!lineValid) { packet130updatesign.signLines[i] = "!?"; } } if (tileentity is net.minecraft.src.TileEntitySign) { int x = packet130updatesign.xPosition; int y = packet130updatesign.yPosition; int z = packet130updatesign.zPosition; net.minecraft.src.TileEntitySign tileentitysign1 = (net.minecraft.src.TileEntitySign)tileentity; for (int j1 = 0; j1 < 4; j1++) { tileentitysign1.Lines[j1] = packet130updatesign.signLines[j1]; } tileentitysign1.SetEditable(false); tileentitysign1.OnInventoryChanged(); worldserver.MarkBlockNeedsUpdate(x, y, z); } } }
public WorldManager(net.minecraft.server.MinecraftServer minecraftserver, net.minecraft.src.WorldServer worldserver) { // Referenced classes of package net.minecraft.src: // IWorldAccess, WorldServer, WorldProvider, EntityTracker, // ServerConfigurationManager, Packet61DoorChange, Entity, TileEntity, // EntityPlayer mcServer = minecraftserver; field_28134_b = worldserver; }
public SecondaryWorldServer(net.minecraft.server.MinecraftServer minecraftserver, net.minecraft.src.ISaveHandler isavehandler, string s, int i, long l, net.minecraft.src.WorldServer worldserver ) : base(minecraftserver, isavehandler, s, i, l) { // Referenced classes of package net.minecraft.src: // WorldServer, ISaveHandler WorldMaps = worldserver.WorldMaps; }
public ItemInWorldManager(net.minecraft.src.WorldServer worldserver) { // Referenced classes of package net.minecraft.src: // WorldServer, Block, EntityPlayer, ItemStack, // EntityPlayerMP, Packet53BlockChange, NetServerHandler, InventoryPlayer, // World field_672_d = 0.0F; thisWorld = worldserver; }
public virtual void Func_28172_a(net.minecraft.src.EntityPlayerMP entityplayermp) { playerManagerObj[0].RemovePlayer(entityplayermp); playerManagerObj[1].RemovePlayer(entityplayermp); GetPlayerManager(entityplayermp.dimension).AddPlayer(entityplayermp); net.minecraft.src.WorldServer worldserver = mcServer.GetWorldServer(entityplayermp .dimension); worldserver.chunkProviderServer.LoadChunk((int)entityplayermp.posX >> 4, (int)entityplayermp .posZ >> 4); }
public virtual void Func_28170_a(net.minecraft.src.EntityPlayerMP entityplayermp, net.minecraft.src.WorldServer worldserver) { entityplayermp.netServerHandler.SendPacket(new net.minecraft.src.Packet4UpdateTime (worldserver.GetWorldTime())); if (worldserver.Func_27068_v()) { entityplayermp.netServerHandler.SendPacket(new net.minecraft.src.Packet70Bed (1)); } }
public ChunkProviderServer(net.minecraft.src.WorldServer worldserver, net.minecraft.src.IChunkLoader ichunkloader, net.minecraft.src.IChunkProvider ichunkprovider) { // Referenced classes of package net.minecraft.src: // IChunkProvider, EmptyChunk, ChunkCoordIntPair, WorldServer, // ChunkCoordinates, Chunk, IChunkLoader, IProgressUpdate field_725_a = new HashSet <int>(); chunkLoadOverride = false; id2ChunkMap = new NullSafeDictionary <int, Chunk>(); field_727_f = new List <Chunk>(); dummyChunk = new net.minecraft.src.EmptyChunk(worldserver, new byte[32768], 0, 0); world = worldserver; chunkLoader = ichunkloader; serverChunkGenerator = ichunkprovider; }
public override void HandleUseEntity(net.minecraft.src.Packet7UseEntity packet7useentity) { if (this.playerEntity.isDead) { return; // CRAFTBUKKIT } net.minecraft.src.WorldServer worldserver = mcServer.GetWorldServer(playerEntity.dimension); net.minecraft.src.Entity entity = worldserver.Func_6158_a(packet7useentity.targetEntity); ItemStack itemInHand = this.playerEntity.inventory.GetCurrentItem(); // CRAFTBUKKIT if (entity != null && playerEntity.CanEntityBeSeen(entity) && playerEntity.GetDistanceSqToEntity(entity) < 36D) { if (packet7useentity.isLeftClick == 0) { playerEntity.UseCurrentItemOnEntity(entity); // CRAFTBUKKIT start - update the client if the item is an infinite one if (itemInHand != null && itemInHand.stackSize <= -1) { this.playerEntity.UpdateInventory(this.playerEntity.currentCraftingInventory); } // CRAFTBUKKIT end } else if (packet7useentity.isLeftClick == 1) { // CRAFTBUKKIT start if ((entity is EntityItem) || (entity is EntityArrow)) { String type = entity.GetType().Name; KickPlayer("Attacking an " + type + " is not permitted"); logger.Warning("Player " + playerEntity.username + " tried to attack an " + type + ", so I have disconnected them for exploiting."); return; } // CRAFTBUKKIT end playerEntity.AttackTargetEntityWithCurrentItem(entity); // CRAFTBUKKIT start - update the client if the item is an infinite one if (itemInHand != null && itemInHand.stackSize <= -1) { this.playerEntity.UpdateInventory(this.playerEntity.currentCraftingInventory); } // CRAFTBUKKIT end } } }
public virtual void PlayerLoggedIn(net.minecraft.src.EntityPlayerMP entityplayermp) { playerEntities.Add(entityplayermp); SharpBukkitPlayers[entityplayermp.username.ToLower()] = new SharpBukkitPlayer(entityplayermp); //SHARP net.minecraft.src.WorldServer worldserver = mcServer.GetWorldServer(entityplayermp .dimension); worldserver.chunkProviderServer.LoadChunk((int)entityplayermp.posX >> 4, (int)entityplayermp .posZ >> 4); for (; worldserver.GetCollidingBoundingBoxes(entityplayermp, entityplayermp.boundingBox ).Count != 0; entityplayermp.SetPosition(entityplayermp.posX, entityplayermp.posY + 1.0D, entityplayermp.posZ)) { } worldserver.AddEntity(entityplayermp); GetPlayerManager(entityplayermp.dimension).AddPlayer(entityplayermp); }
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; }
public virtual void HandleCommand(net.minecraft.src.ServerCommand servercommand) { //TODO: Put this somewhere else /* SharpBukkit command handler */ { PluginManager.ParseInvocation(servercommand.command, out string command, out string[] oargs); bool isOP = servercommand.commandListener is net.minecraft.server.MinecraftServer || (servercommand.commandListener is net.minecraft.src.NetServerHandler && minecraftServer.serverConfigurationManager.IsOp(servercommand.commandListener.GetUsername())); bool isPlayer = servercommand.commandListener is net.minecraft.src.NetServerHandler; IEnumerable <(ReflSharpBukkitCommand, string)> cmds = PluginManager.Commands .Where(p => p.Name == command) .Select(p => (p, p.HasInvocationProblem(oargs, isOP, isPlayer))); if (cmds.Count() > 0) { var vcmds = cmds.Where(p => p.Item2 == null); (ReflSharpBukkitCommand nearestcommand, string invokeprob) = PluginManager.NearestSignature(oargs.Length, vcmds); if (nearestcommand != null) { object[] args = nearestcommand.PrepareArgs(oargs); SharpBukkitCommandController controller = null; try { controller = (SharpBukkitCommandController)Activator.CreateInstance(nearestcommand.Method.DeclaringType); controller.Server = minecraftServer; controller.User = servercommand.commandListener; controller.FullMessage = servercommand.command; controller.CurrentCommand = nearestcommand; if (controller.PreExecution()) { try { nearestcommand.Method.Invoke(controller, args); } finally { if (controller != null) { controller.AlwaysAfterExecute(); } } } } finally { if (controller != null) { controller.Always(); } } } else { servercommand.commandListener.Log(PluginManager.NearestSignature(oargs.Length, cmds).Item2); } } else { servercommand.commandListener.Log("Command not found"); } } /* ============================== */ return; //TODO: comment all code after this string s = servercommand.command; net.minecraft.src.ICommandListener icommandlistener = servercommand.commandListener; string s1 = icommandlistener.GetUsername(); net.minecraft.src.ServerConfigurationManager serverconfigurationmanager = minecraftServer.serverConfigurationManager; if (s.ToLower().StartsWith("help") || s.ToLower().StartsWith("?")) { PrintHelp(icommandlistener); } else { if (s.ToLower().StartsWith("list")) { icommandlistener.Log((new java.lang.StringBuilder()).Append("Connected players: ").Append(serverconfigurationmanager.GetPlayerList()).ToString()); } else { if (s.ToLower().StartsWith("stop")) { SendNoticeToOps(s1, "Stopping the server.."); minecraftServer.InitiateShutdown(); } else { if (s.ToLower().StartsWith("save-all")) { SendNoticeToOps(s1, "Forcing save.."); if (serverconfigurationmanager != null) { serverconfigurationmanager.SavePlayers(); } for (int i = 0; i < minecraftServer.worlds.Count; i++) { net.minecraft.src.WorldServer worldserver = minecraftServer.worlds[i]; worldserver.SaveWorld(true, null); } SendNoticeToOps(s1, "Save complete."); } else { if (s.ToLower().StartsWith("save-off")) { SendNoticeToOps(s1, "Disabling level saving.."); for (int j = 0; j < minecraftServer.worlds.Count; j++) { net.minecraft.src.WorldServer worldserver1 = minecraftServer.worlds[j]; worldserver1.canSave = true; } } else { if (s.ToLower().StartsWith("save-on")) { SendNoticeToOps(s1, "Enabling level saving.."); for (int k = 0; k < minecraftServer.worlds.Count; k++) { net.minecraft.src.WorldServer worldserver2 = minecraftServer.worlds[k]; worldserver2.canSave = false; } } else { if (s.ToLower().StartsWith("op ")) { string s2 = s.Substring(s.IndexOf(" ")).Trim(); serverconfigurationmanager.OpPlayer(s2); SendNoticeToOps(s1, (new java.lang.StringBuilder()).Append("Opping ").Append(s2). ToString()); serverconfigurationmanager.SendChatMessageToPlayer(s2, "§eYou are now op!"); } else { if (s.ToLower().StartsWith("deop ")) { string s3 = s.Substring(s.IndexOf(" ")).Trim(); serverconfigurationmanager.DeopPlayer(s3); serverconfigurationmanager.SendChatMessageToPlayer(s3, "§eYou are no longer op!" ); SendNoticeToOps(s1, (new java.lang.StringBuilder()).Append("De-opping ").Append(s3 ).ToString()); } else { if (s.ToLower().StartsWith("ban-ip ")) { string s4 = s.Substring(s.IndexOf(" ")).Trim(); serverconfigurationmanager.BanIP(s4); SendNoticeToOps(s1, (new java.lang.StringBuilder()).Append("Banning ip ").Append( s4).ToString()); } else { if (s.ToLower().StartsWith("pardon-ip ")) { string s5 = s.Substring(s.IndexOf(" ")).Trim(); serverconfigurationmanager.PardonIP(s5); SendNoticeToOps(s1, (new java.lang.StringBuilder()).Append("Pardoning ip ").Append (s5).ToString()); } else { if (s.ToLower().StartsWith("ban ")) { string s6 = s.Substring(s.IndexOf(" ")).Trim(); serverconfigurationmanager.BanPlayer(s6); SendNoticeToOps(s1, (new java.lang.StringBuilder()).Append("Banning ").Append(s6) .ToString()); net.minecraft.src.EntityPlayerMP entityplayermp = serverconfigurationmanager.GetPlayerEntity (s6); if (entityplayermp != null) { entityplayermp.netServerHandler.KickPlayer("Banned by admin"); } } else { if (s.ToLower().StartsWith("pardon ")) { string s7 = s.Substring(s.IndexOf(" ")).Trim(); serverconfigurationmanager.PardonPlayer(s7); SendNoticeToOps(s1, (new java.lang.StringBuilder()).Append("Pardoning ").Append(s7 ).ToString()); } else { if (s.ToLower().StartsWith("kick ")) { string s8 = s.Substring(s.IndexOf(" ")).Trim(); net.minecraft.src.EntityPlayerMP entityplayermp1 = null; for (int l = 0; l < serverconfigurationmanager.playerEntities.Count; l++) { net.minecraft.src.EntityPlayerMP entityplayermp5 = (net.minecraft.src.EntityPlayerMP )serverconfigurationmanager.playerEntities[l]; if (s8.Equals(entityplayermp5.username, System.StringComparison.OrdinalIgnoreCase)) { entityplayermp1 = entityplayermp5; } } if (entityplayermp1 != null) { entityplayermp1.netServerHandler.KickPlayer("Kicked by admin"); SendNoticeToOps(s1, (new java.lang.StringBuilder()).Append("Kicking ").Append(entityplayermp1 .username).ToString()); } else { icommandlistener.Log((new java.lang.StringBuilder()).Append("Can't find user ").Append (s8).Append(". No kick.").ToString()); } } else { if (s.ToLower().StartsWith("tp ")) { string[] @as = s.Split(" "); if (@as.Length == 3) { net.minecraft.src.EntityPlayerMP entityplayermp2 = serverconfigurationmanager.GetPlayerEntity (@as[1]); net.minecraft.src.EntityPlayerMP entityplayermp3 = serverconfigurationmanager.GetPlayerEntity (@as[2]); if (entityplayermp2 == null) { icommandlistener.Log((new java.lang.StringBuilder()).Append("Can't find user ").Append (@as[1]).Append(". No tp.").ToString()); } else { if (entityplayermp3 == null) { icommandlistener.Log((new java.lang.StringBuilder()).Append("Can't find user ").Append (@as[2]).Append(". No tp.").ToString()); } else { if (entityplayermp2.dimension != entityplayermp3.dimension) { icommandlistener.Log((new java.lang.StringBuilder()).Append("User ").Append(@as[1 ]).Append(" and ").Append(@as[2]).Append(" are in different dimensions. No tp.") .ToString()); } else { entityplayermp2.netServerHandler.TeleportTo(entityplayermp3.posX, entityplayermp3 .posY, entityplayermp3.posZ, entityplayermp3.rotationYaw, entityplayermp3.rotationPitch ); SendNoticeToOps(s1, (new java.lang.StringBuilder()).Append("Teleporting ").Append (@as[1]).Append(" to ").Append(@as[2]).Append(".").ToString()); } } } } else { icommandlistener.Log("Syntax error, please provice a source and a target."); } } else { if (s.ToLower().StartsWith("give ")) { string[] as1 = s.Split(" "); if (as1.Length != 3 && as1.Length != 4) { return; } string s9 = as1[1]; net.minecraft.src.EntityPlayerMP entityplayermp4 = serverconfigurationmanager.GetPlayerEntity (s9); if (entityplayermp4 != null) { try { int j1 = System.Convert.ToInt32(as1[2]); if (net.minecraft.src.Item.itemsList[j1] != null) { SendNoticeToOps(s1, (new java.lang.StringBuilder()).Append("Giving ").Append(entityplayermp4 .username).Append(" some ").Append(j1).ToString()); int i2 = 1; if (as1.Length > 3) { i2 = TryParse(as1[3], 1); } if (i2 < 1) { i2 = 1; } if (i2 > 64) { i2 = 64; } entityplayermp4.DropPlayerItem(new net.minecraft.src.ItemStack(j1, i2, 0)); } else { icommandlistener.Log((new java.lang.StringBuilder()).Append("There's no item with id " ).Append(j1).ToString()); } } catch (System.FormatException) { icommandlistener.Log((new java.lang.StringBuilder()).Append("There's no item with id " ).Append(as1[2]).ToString()); } } else { icommandlistener.Log((new java.lang.StringBuilder()).Append("Can't find user ").Append (s9).ToString()); } } else { if (s.ToLower().StartsWith("time ")) { string[] as2 = s.Split(" "); if (as2.Length != 3) { return; } string s10 = as2[1]; try { int i1 = System.Convert.ToInt32(as2[2]); if (s10.Equals("add", System.StringComparison.OrdinalIgnoreCase)) { for (int k1 = 0; k1 < minecraftServer.worlds.Count; k1++) { net.minecraft.src.WorldServer worldserver3 = minecraftServer.worlds[k1]; worldserver3.Func_32005_b(worldserver3.GetWorldTime() + (long)i1); } SendNoticeToOps(s1, (new java.lang.StringBuilder()).Append("Added ").Append(i1).Append(" to time").ToString()); } else { if (s10.Equals("set", System.StringComparison.OrdinalIgnoreCase)) { for (int l1 = 0; l1 < minecraftServer.worlds.Count; l1++) { net.minecraft.src.WorldServer worldserver4 = minecraftServer.worlds[l1]; worldserver4.Func_32005_b(i1); } SendNoticeToOps(s1, (new java.lang.StringBuilder()).Append("Set time to ").Append(i1).ToString()); } else { icommandlistener.Log("Unknown method, use either \"add\" or \"set\""); } } } catch (System.FormatException) { icommandlistener.Log((new java.lang.StringBuilder()).Append("Unable to convert time value, ").Append(as2[2]).ToString()); } } else { if (s.ToLower().StartsWith("say ")) { s = s.Substring(s.IndexOf(" ")).Trim(); minecraftLogger.Info((new java.lang.StringBuilder()).Append("[").Append(s1).Append("] ").Append(s).ToString()); //Console.WriteLine((new java.lang.StringBuilder()).Append("[").Append(s1).Append("] ").Append(s).ToString()); serverconfigurationmanager.SendPacketToAllPlayers(new net.minecraft.src.Packet3Chat ((new java.lang.StringBuilder()).Append("§d[Server] ").Append(s).ToString())); } else { if (s.ToLower().StartsWith("tell ")) { string[] as3 = s.Split(" "); if (as3.Length >= 3) { s = s.Substring(s.IndexOf(" ")).Trim(); s = s.Substring(s.IndexOf(" ")).Trim(); minecraftLogger.Info((new java.lang.StringBuilder()).Append("[").Append(s1).Append("->").Append(as3[1]).Append("] ").Append(s).ToString()); Console.WriteLine((new java.lang.StringBuilder()).Append("[").Append(s1).Append("->").Append(as3[1]).Append("] ").Append(s).ToString()); s = (new java.lang.StringBuilder()).Append("§7").Append(s1).Append(" whispers " ).Append(s).ToString(); minecraftLogger.Info(s); //Console.WriteLine(s); if (!serverconfigurationmanager.SendPacketToPlayer(as3[1], new net.minecraft.src.Packet3Chat (s))) { icommandlistener.Log("There's no player by that name online."); } } } else { if (s.ToLower().StartsWith("whitelist ")) { HandleWhitelist(s1, s, icommandlistener); } else { //Console.WriteLine("Unknown console command. Type \"help\" for help."); minecraftLogger.Info("Unknown console command. Type \"help\" for help."); } } } } } } } } } } } } } } } } } } } }
public virtual void OnUpdateEntity(bool flag) { base.OnUpdate(); for (int i = 0; i < inventory.GetSizeInventory(); i++) { net.minecraft.src.ItemStack itemstack = inventory.GetStackInSlot(i); if (itemstack == null || !net.minecraft.src.Item.itemsList[itemstack.itemID].Func_28019_b () || netServerHandler.GetNumChunkDataPackets() > 2) { continue; } net.minecraft.src.Packet packet = ((net.minecraft.src.ItemMapBase)net.minecraft.src.Item .itemsList[itemstack.itemID]).Func_28022_b(itemstack, worldObj, this); if (packet != null) { netServerHandler.SendPacket(packet); } } if (flag && chunkCoordIntPairQueue.Count > 0) { net.minecraft.src.ChunkCoordIntPair chunkcoordintpair = (net.minecraft.src.ChunkCoordIntPair )chunkCoordIntPairQueue[0]; if (chunkcoordintpair != null) { bool flag1 = false; if (netServerHandler.GetNumChunkDataPackets() < 4) { flag1 = true; } if (flag1) { net.minecraft.src.WorldServer worldserver = mcServer.GetWorldServer(dimension); chunkCoordIntPairQueue.Remove(chunkcoordintpair); netServerHandler.SendPacket(new net.minecraft.src.Packet51MapChunk(chunkcoordintpair .X * 16, 0, chunkcoordintpair.Z * 16, 16, 128, 16, worldserver)); System.Collections.Generic.List <TileEntity> list = worldserver.GetTileEntityList(chunkcoordintpair.X * 16, 0, chunkcoordintpair.Z * 16, chunkcoordintpair.X * 16 + 16 , 128, chunkcoordintpair.Z * 16 + 16); for (int j = 0; j < list.Count; j++) { GetTileEntityInfo((net.minecraft.src.TileEntity)list[j]); } } } } if (inPortal) { if (mcServer.propertyManager.GetBoolean("allow-nether", true)) { if (currentCraftingInventory != personalCraftingInventory) { UsePersonalCraftingInventory(); } if (ridingEntity != null) { MountEntity(ridingEntity); } else { timeInPortal += 0.0125F; if (timeInPortal >= 1.0F) { timeInPortal = 1.0F; timeUntilPortal = 10; mcServer.serverConfigurationManager.SendPlayerToOtherDimension(this); } } inPortal = false; } } else { if (timeInPortal > 0.0F) { timeInPortal -= 0.05F; } if (timeInPortal < 0.0F) { timeInPortal = 0.0F; } } if (timeUntilPortal > 0) { timeUntilPortal--; } if (health != lastHealth) { netServerHandler.SendPacket(new net.minecraft.src.Packet8UpdateHealth(health )); lastHealth = health; } }
public override void HandleFlying(net.minecraft.src.Packet10Flying packet10flying ) { net.minecraft.src.WorldServer worldserver = mcServer.GetWorldServer(playerEntity .dimension); field_22003_h = true; if (!hasMoved) { double d = packet10flying.yPosition - lastPosY; if (packet10flying.xPosition == lastPosX && d * d < 0.01D && packet10flying.zPosition == lastPosZ) { hasMoved = true; } } if (hasMoved) { if (playerEntity.ridingEntity != null) { float f = playerEntity.rotationYaw; float f1 = playerEntity.rotationPitch; playerEntity.ridingEntity.UpdateRiderPosition(); double d2 = playerEntity.posX; double d4 = playerEntity.posY; double d6 = playerEntity.posZ; double d8 = 0.0D; double d9 = 0.0D; if (packet10flying.rotating) { f = packet10flying.yaw; f1 = packet10flying.pitch; } if (packet10flying.moving && packet10flying.yPosition == -999D && packet10flying. stance == -999D) { d8 = packet10flying.xPosition; d9 = packet10flying.zPosition; } playerEntity.onGround = packet10flying.onGround; playerEntity.OnUpdateEntity(true); playerEntity.MoveEntity(d8, 0.0D, d9); playerEntity.SetPositionAndRotation(d2, d4, d6, f, f1); playerEntity.motionX = d8; playerEntity.motionZ = d9; if (playerEntity.ridingEntity != null) { worldserver.Func_12017_b(playerEntity.ridingEntity, true); } if (playerEntity.ridingEntity != null) { playerEntity.ridingEntity.UpdateRiderPosition(); } mcServer.serverConfigurationManager.Func_613_b(playerEntity); lastPosX = playerEntity.posX; lastPosY = playerEntity.posY; lastPosZ = playerEntity.posZ; worldserver.UpdateEntity(playerEntity); return; } if (playerEntity.IsSleeping()) { playerEntity.OnUpdateEntity(true); playerEntity.SetPositionAndRotation(lastPosX, lastPosY, lastPosZ, playerEntity.rotationYaw , playerEntity.rotationPitch); worldserver.UpdateEntity(playerEntity); return; } double d1 = playerEntity.posY; lastPosX = playerEntity.posX; lastPosY = playerEntity.posY; lastPosZ = playerEntity.posZ; double d3 = playerEntity.posX; double d5 = playerEntity.posY; double d7 = playerEntity.posZ; float f2 = playerEntity.rotationYaw; float f3 = playerEntity.rotationPitch; if (packet10flying.moving && packet10flying.yPosition == -999D && packet10flying. stance == -999D) { packet10flying.moving = false; } if (packet10flying.moving) { d3 = packet10flying.xPosition; d5 = packet10flying.yPosition; d7 = packet10flying.zPosition; double d10 = packet10flying.stance - packet10flying.yPosition; if (!playerEntity.IsSleeping() && (d10 > 1.6499999999999999D || d10 < 0.10000000000000001D )) { KickPlayer("Illegal stance"); logger.Warning((new java.lang.StringBuilder()).Append(playerEntity.username).Append (" had an illegal stance: ").Append(d10).ToString()); return; } if (System.Math.Abs(packet10flying.xPosition) > 32000000D || System.Math.Abs(packet10flying .zPosition) > 32000000D) { KickPlayer("Illegal position"); return; } } if (packet10flying.rotating) { f2 = packet10flying.yaw; f3 = packet10flying.pitch; } playerEntity.OnUpdateEntity(true); playerEntity.ySize = 0.0F; playerEntity.SetPositionAndRotation(lastPosX, lastPosY, lastPosZ, f2, f3); if (!hasMoved) { return; } double d11 = d3 - playerEntity.posX; double d12 = d5 - playerEntity.posY; double d13 = d7 - playerEntity.posZ; double d14 = d11 * d11 + d12 * d12 + d13 * d13; if (d14 > 100D) { logger.Warning((new java.lang.StringBuilder()).Append(playerEntity.username).Append (" moved too quickly!").ToString()); KickPlayer("You moved too quickly :( (Hacking?)"); return; } float f4 = 0.0625F; bool flag = worldserver.GetCollidingBoundingBoxes(playerEntity, playerEntity.boundingBox .Copy().GetInsetBoundingBox(f4, f4, f4)).Count == 0; playerEntity.MoveEntity(d11, d12, d13); d11 = d3 - playerEntity.posX; d12 = d5 - playerEntity.posY; if (d12 > -0.5D || d12 < 0.5D) { d12 = 0.0D; } d13 = d7 - playerEntity.posZ; d14 = d11 * d11 + d12 * d12 + d13 * d13; bool flag1 = false; if (d14 > 0.0625D && !playerEntity.IsSleeping()) { flag1 = true; logger.Warning((new java.lang.StringBuilder()).Append(playerEntity.username).Append (" moved wrongly!").ToString()); System.Console.Out.WriteLine((new java.lang.StringBuilder()).Append("Got position " ).Append(d3).Append(", ").Append(d5).Append(", ").Append(d7).ToString()); System.Console.Out.WriteLine((new java.lang.StringBuilder()).Append("Expected "). Append(playerEntity.posX).Append(", ").Append(playerEntity.posY).Append(", ").Append (playerEntity.posZ).ToString()); } playerEntity.SetPositionAndRotation(d3, d5, d7, f2, f3); bool flag2 = worldserver.GetCollidingBoundingBoxes(playerEntity, playerEntity.boundingBox .Copy().GetInsetBoundingBox(f4, f4, f4)).Count == 0; if (flag && (flag1 || !flag2) && !playerEntity.IsSleeping()) { TeleportTo(lastPosX, lastPosY, lastPosZ, f2, f3); return; } net.minecraft.src.AxisAlignedBB axisalignedbb = playerEntity.boundingBox.Copy().Expand (f4, f4, f4).AddCoord(0.0D, -0.55000000000000004D, 0.0D); if (!mcServer.allowFlight && !worldserver.Func_27069_b(axisalignedbb)) { if (d12 >= -0.03125D) { playerInAirTime++; if (playerInAirTime > 80) { logger.Warning((new java.lang.StringBuilder()).Append(playerEntity.username).Append (" was kicked for floating too long!").ToString()); KickPlayer("Flying is not enabled on this server"); return; } } } else { playerInAirTime = 0; } playerEntity.onGround = packet10flying.onGround; mcServer.serverConfigurationManager.Func_613_b(playerEntity); playerEntity.HandleFalling(playerEntity.posY - d1, packet10flying.onGround); } }
public virtual void SendPlayerToOtherDimension(net.minecraft.src.EntityPlayerMP entityplayermp ) { net.minecraft.src.WorldServer worldserver = mcServer.GetWorldServer(entityplayermp .dimension); int i = 0; if (entityplayermp.dimension == -1) { i = 0; } else { i = -1; } entityplayermp.dimension = i; net.minecraft.src.WorldServer worldserver1 = mcServer.GetWorldServer(entityplayermp .dimension); entityplayermp.netServerHandler.SendPacket(new net.minecraft.src.Packet9Respawn (unchecked ((byte)entityplayermp.dimension))); worldserver.RemovePlayer(entityplayermp); entityplayermp.isDead = false; double d = entityplayermp.posX; double d1 = entityplayermp.posZ; double d2 = 8D; if (entityplayermp.dimension == -1) { d /= d2; d1 /= d2; entityplayermp.SetLocationAndAngles(d, entityplayermp.posY, d1, entityplayermp.rotationYaw , entityplayermp.rotationPitch); if (entityplayermp.IsEntityAlive()) { worldserver.UpdateEntityWithOptionalForce(entityplayermp, false); } } else { d *= d2; d1 *= d2; entityplayermp.SetLocationAndAngles(d, entityplayermp.posY, d1, entityplayermp.rotationYaw , entityplayermp.rotationPitch); if (entityplayermp.IsEntityAlive()) { worldserver.UpdateEntityWithOptionalForce(entityplayermp, false); } } if (entityplayermp.IsEntityAlive()) { worldserver1.AddEntity(entityplayermp); entityplayermp.SetLocationAndAngles(d, entityplayermp.posY, d1, entityplayermp.rotationYaw , entityplayermp.rotationPitch); worldserver1.UpdateEntityWithOptionalForce(entityplayermp, false); worldserver1.chunkProviderServer.chunkLoadOverride = true; (new net.minecraft.src.PortalTravelAgent()).SetExitLocation(worldserver1, entityplayermp ); worldserver1.chunkProviderServer.chunkLoadOverride = false; } Func_28172_a(entityplayermp); entityplayermp.netServerHandler.TeleportTo(entityplayermp.posX, entityplayermp .posY, entityplayermp.posZ, entityplayermp.rotationYaw, entityplayermp.rotationPitch ); entityplayermp.SetWorldHandler(worldserver1); Func_28170_a(entityplayermp, worldserver1); Func_30008_g(entityplayermp); }
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; }