public static bool Filter(VanillaSession real, Packet p) { Client player = real.Player; IEntity e = p as IEntity; if (e == null) return false; //Pass all own actions normally if (e.EID == player.EntityID) return false; Client namedPlayer = null; VanillaSession r = World.Main.GetPlayer(e.EID); if (r != null) namedPlayer = r.Player; byte pid = p.PacketID; //New named entity if (pid == SpawnPlayer.ID) { SpawnPlayer spawnNamedEntity = (SpawnPlayer)p; //Search by vanilla uuid since we ahv enot yet modified the packet if (namedPlayer == null) namedPlayer = PlayerList.GetPlayerByVanillaUUID(spawnNamedEntity.PlayerUUID); if (namedPlayer == null) { Debug.WriteLine("NamedEntity not found in player list: " + spawnNamedEntity.PlayerUUID); return false; //Still let through } //pass any none cloaked player if (namedPlayer.Settings.Cloaked == null) return false; //Invisible mode, hide everything about entity if (namedPlayer.Settings.Cloaked == MobType.None.ToString()) return true; if (namedPlayer.Settings.Cloaked == null) { //Debug.WriteLine ("Spawning player " + ne.PlayerName + " as nick " + np.Name); return false; } //Debug.WriteLine ("Spawning player " + ne.PlayerName + " cloaked as \"" + np.Cloaked + "\" nick: " + np.Name); MobType mt; try { mt = (MobType)Enum.Parse(typeof(MobType), namedPlayer.Settings.Cloaked); } catch (Exception) { Debug.WriteLine("Unknown cloak for " + namedPlayer.MinecraftUsername + ": " + namedPlayer.Settings.Cloaked); return false; } SpawnMob ms = new SpawnMob(mt); ms.EID = spawnNamedEntity.EID; ms.Pos = spawnNamedEntity.Position; ms.Pitch = spawnNamedEntity.Pitch; ms.Yaw = spawnNamedEntity.Yaw; //Add metadata to specific mobs - some already set in constructor if (ms.Type == MobType.MagmaCube || ms.Type == MobType.Slime) ms.Metadata.SetByte(16, 1); if (ms.Type == MobType.Ghast) ms.Metadata.SetByte(16, 0); if (ms.Type == MobType.Enderman) { ms.Metadata.SetByte(16, (sbyte)BlockID.Dirt); ms.Metadata.SetByte(17, 0); } if (ms.Type == MobType.Blaze) ms.Metadata.SetByte(16, 0); if (ms.Type == MobType.Sheep) ms.Metadata.SetByte(16, 0); if (ms.Type == MobType.Spider) ms.Metadata.SetByte(16, 0); player.Queue.Queue(ms); return true; } if (pid == DestroyEntities.ID) return false; //Not in list if (namedPlayer == null) return false; //Not cloaked if (namedPlayer.Settings.Cloaked == null) return false; //Invisible mode, hide everything about entity if (namedPlayer.Settings.Cloaked == MobType.None.ToString()) return true; //Else any mob if (pid == Animation.ID) return true; if (pid == EntityEquipment.ID) return true; return false; }
/// <summary> /// Update local state of entity /// </summary> public void Update(SpawnMob spawn) { UpdateMeta(spawn.Metadata); }
public void UpdateEntity(SpawnMob spawn) { Mob m = null; lock (entities) { if (entities.ContainsKey(spawn.EID)) m = entities[spawn.EID] as Mob; if (m == null) { m = new Mob(spawn.EID, spawn.Type); entities[spawn.EID] = m; } } m.Update(spawn); }
void Crash(Client player, string[] cmd, int iarg) { if (cmd.Length != iarg + 2) throw new ShowHelpException(); Client c = PlayerList.GetPlayerByUsernameOrName(cmd [iarg]); if (c == null) throw new ErrorException("player not found: " + cmd [iarg]); switch (cmd [iarg + 1]) { case "creeper": //Slows down the player player.TellSystem(Chat.Green, "Sending 5000 Creepers to " + c.Name); var msl = new List<PacketFromServer>(); for (int n = 1; n < 5000; n++) { SpawnMob ms = new SpawnMob(MobType.Creeper); ms.Pos = c.Session.Position; ms.EID = n; //TODO: fix valid metadata or else this only becomes a quick crash msl.Add(ms); } c.Queue.Queue(msl); return; case "zombie": SpawnMob sm = new SpawnMob(MineProxy.MobType.Zombie); sm.Metadata = new Metadata(); c.SendToClient(sm); c.Close("Internal Server Error"); return; } }