mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-26 23:02:04 -04:00
Fix colours in SpawnEntity packets not being converted into fallback colours for clients that don't support TextColors CPE extension.
This commit is contained in:
parent
2349a81f79
commit
cbbb7bda0e
@ -33,7 +33,7 @@ namespace MCGalaxy {
|
||||
internal static HandlePlace[] placeHandlers = new Block.HandlePlace[256];
|
||||
|
||||
/// <summary> Returns whether this block handles the player walking through this block at the given coordinates. </summary>
|
||||
/// <remarks>If this returns true, the usual 'checking dirt/grass below' behaviour is skipped. </remarks>
|
||||
/// <remarks>If this returns true, the usual 'death check' behaviour is skipped. </remarks>
|
||||
public delegate bool HandleWalkthrough(Player p, byte block, ushort x, ushort y, ushort z);
|
||||
internal static HandleWalkthrough[] walkthroughHandlers = new Block.HandleWalkthrough[256];
|
||||
|
||||
|
@ -83,7 +83,7 @@ namespace MCGalaxy.BlockBehaviour {
|
||||
p.checkpointX = x; p.checkpointY = y; p.checkpointZ = z;
|
||||
int index = p.level.PosToInt(x, y, z);
|
||||
if (index != p.lastCheckpointIndex) {
|
||||
p.SendSpawn(0xFF, p.color + p.truename, p.pos[0], (ushort)((y - 1) * 32 + 51), p.pos[2], p.rot[0], p.rot[1]);
|
||||
p.SpawnEntity(p, 0xFF, p.pos[0], (ushort)((y - 1) * 32 + 51), p.pos[2], p.rot[0], p.rot[1]);
|
||||
p.lastCheckpointIndex = index;
|
||||
}
|
||||
return true;
|
||||
|
@ -105,7 +105,7 @@ namespace MCGalaxy.Commands {
|
||||
}
|
||||
|
||||
void HandleCreate(Player p, string[] parts) {
|
||||
if (!CheckAdditionalPerm(p, 1)) { MessageNeedPerms(p, "can create a chatroom.", 1); return; }
|
||||
if (!CheckAdditionalPerm(p, 1)) { MessageNeedPerms(p, "can create a chatroom.", 1); return; }
|
||||
if (parts.Length <= 1) {
|
||||
Player.SendMessage(p, "You need to provide a new chatroom name.");
|
||||
return;
|
||||
@ -139,7 +139,7 @@ namespace MCGalaxy.Commands {
|
||||
}
|
||||
|
||||
if (!canDeleteForce) {
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
foreach (Player pl in players) {
|
||||
if (pl != p && pl.Chatroom == room) {
|
||||
Player.SendMessage(p, "Sorry, someone else is in the chatroom");
|
||||
|
@ -63,7 +63,7 @@ namespace MCGalaxy
|
||||
}
|
||||
|
||||
protected void MessageNeedPerms(Player p, string action, int num = 1) {
|
||||
int perm = CommandOtherPerms.GetPerm(this, num)
|
||||
int perm = CommandOtherPerms.GetPerm(this, num);
|
||||
Group grp = Group.findPermInt(perm);
|
||||
if (grp == null)
|
||||
Player.SendMessage(p, "Onlys rank with a permission level greater than &a" + perm + "%Scan " + action);
|
||||
|
@ -35,7 +35,7 @@ namespace MCGalaxy.Commands {
|
||||
foreach (Player pl in players) {
|
||||
if (pl.level != p.level || p == pl || !Player.CanSee(p, pl) || pl.Game.Referee) continue;
|
||||
p.SendDespawn(pl.id);
|
||||
Player.SpawnEntity(pl, p, pl.id, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1], "");
|
||||
p.SpawnEntity(pl, pl.id, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1], "");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -269,7 +269,7 @@ namespace MCGalaxy.Commands
|
||||
case "lvl":
|
||||
case "map":
|
||||
case "m":
|
||||
if ((CheckAdditionalPerm(p))
|
||||
if (CheckAdditionalPerm(p))
|
||||
{
|
||||
foreach (Player who in p.level.players)
|
||||
{
|
||||
@ -289,7 +289,7 @@ namespace MCGalaxy.Commands
|
||||
case "pls":
|
||||
case "pl":
|
||||
case "p":
|
||||
if CheckAdditionalPerm(p))
|
||||
if (CheckAdditionalPerm(p))
|
||||
{
|
||||
TntWarsGame gm = TntWarsGame.GetTntWarsGame(p);
|
||||
if (gm == null)
|
||||
|
@ -74,7 +74,7 @@ namespace MCGalaxy.Commands
|
||||
if (p.hidden)
|
||||
{
|
||||
if (who != null)
|
||||
p.SendSpawn(who.id, who.color + who.truename, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1]);
|
||||
p.SpawnEntity(who, who.id, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1]);
|
||||
if (!stealth)
|
||||
{
|
||||
Command.all.Find("hide").Use(p, "");
|
||||
@ -104,7 +104,7 @@ namespace MCGalaxy.Commands
|
||||
if (p.following != "")
|
||||
{
|
||||
who = PlayerInfo.Find(p.following);
|
||||
p.SendSpawn(who.id, who.color + who.truename, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1]);
|
||||
p.SpawnEntity(who, who.id, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1]);
|
||||
}
|
||||
who = PlayerInfo.Find(message);
|
||||
p.following = who.name;
|
||||
|
@ -144,7 +144,7 @@ namespace MCGalaxy.Commands {
|
||||
Player[] players = PlayerInfo.Online.Items;
|
||||
foreach (Player pl in players) {
|
||||
if (pl.level != p.level || pl.hidden || p == pl) continue;
|
||||
Player.SpawnEntity(pl, p, pl.id, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1], "");
|
||||
p.SpawnEntity(pl, pl.id, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1], "");
|
||||
}
|
||||
Player.GlobalSpawn(p, x, y, z, rotX, rotY, true);
|
||||
|
||||
|
@ -89,7 +89,7 @@ namespace MCGalaxy.Games
|
||||
ushort y1 = (ushort)((1 + y) * 32);
|
||||
ushort z1 = (ushort)((0.5 + z) * 32);
|
||||
rotx = spawns[rnd].rotx;
|
||||
p.SendSpawn(0xFF, p.name, x1, y1, z1, (byte)rotx, 0);
|
||||
p.SpawnEntity(p, 0xFF, x1, y1, z1, (byte)rotx, 0);
|
||||
//p.health = 100;
|
||||
}
|
||||
else
|
||||
@ -99,7 +99,7 @@ namespace MCGalaxy.Games
|
||||
ushort z = (ushort)((0.5 + mapOn.spawnz) * 32);
|
||||
ushort rotx = mapOn.rotx;
|
||||
ushort roty = mapOn.roty;
|
||||
p.SendSpawn(0xFF, p.name, x, y, z, (byte)rotx, (byte)roty);
|
||||
p.SpawnEntity(p, 0xFF, x, y, z, (byte)rotx, (byte)roty);
|
||||
}
|
||||
//p.spawning = false;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ namespace MCGalaxy.Games {
|
||||
player.SendMessage("Sending you to the correct map.");
|
||||
Command.all.Find("goto").Use(player, mapon.name);
|
||||
}
|
||||
player.SendSpawn(0xFF, player.color + player.truename, x1, y1, z1, (byte)0, (byte)0);
|
||||
p.SpawnEntity(p, 0xFF, x1, y1, z1, 0, 0);
|
||||
}
|
||||
|
||||
squaresLeft.Clear();
|
||||
|
@ -475,27 +475,30 @@ namespace MCGalaxy {
|
||||
if ((p.hidden || p.Game.Referee) && !self) continue;
|
||||
|
||||
if (p != other) {
|
||||
SpawnEntity(p, other, p.id, x, y, z, rotx, roty, possession);
|
||||
other.SpawnEntity(p, p.id, x, y, z, rotx, roty, possession);
|
||||
} else if (self) {
|
||||
other.pos = new ushort[3] { x, y, z }; other.rot = new byte[2] { rotx, roty };
|
||||
other.oldpos = other.pos; other.basepos = other.pos; other.oldrot = other.rot;
|
||||
SpawnEntity(p, other, 0xFF, x, y, z, rotx, roty, possession);
|
||||
other.SpawnEntity(other, 0xFF, x, y, z, rotx, roty, possession);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static void SpawnEntity(Player p, Player dst, byte id, ushort x, ushort y, ushort z,
|
||||
internal void SpawnEntity(Player p, byte id, ushort x, ushort y, ushort z,
|
||||
byte rotx, byte roty, string possession = "") {
|
||||
if (!Server.zombie.Running || !p.Game.Infected) {
|
||||
dst.SendSpawn(id, p.color + p.truename + possession, x, y, z, rotx, roty); return;
|
||||
string col = p.color;
|
||||
if (col.Length >= 2 && !Colors.IsStandardColor(col[1]) && !HasCpeExt(CpeExt.TextColors))
|
||||
col = "&" + Colors.GetFallback(col[1]);
|
||||
SendSpawn(id, col + p.truename + possession, x, y, z, rotx, roty); return;
|
||||
}
|
||||
|
||||
if (Server.zombie.ZombieName != "" && !dst.Game.Aka)
|
||||
dst.SendSpawn(id, Colors.red + Server.zombie.ZombieName + possession, x, y, z, rotx, roty);
|
||||
if (Server.zombie.ZombieName != "" && !Game.Aka)
|
||||
SendSpawn(id, Colors.red + Server.zombie.ZombieName + possession, x, y, z, rotx, roty);
|
||||
else
|
||||
dst.SendSpawn(id, Colors.red + p.truename + possession, x, y, z, rotx, roty);
|
||||
if (dst.HasCpeExt(CpeExt.ChangeModel) && id != 0xFF)
|
||||
dst.SendChangeModel(id, "zombie");
|
||||
SendSpawn(id, Colors.red + p.truename + possession, x, y, z, rotx, roty);
|
||||
if (HasCpeExt(CpeExt.ChangeModel) && id != 0xFF)
|
||||
SendChangeModel(id, "zombie");
|
||||
}
|
||||
|
||||
public static void GlobalDespawn(Player p, bool self) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user