Use new map chunk packet constructor

This commit is contained in:
Dan Mulloy 2018-07-15 13:47:36 -04:00 committed by Alexander Meech
parent b71055b0b4
commit 469b3816cc
4 changed files with 14 additions and 11 deletions

View File

@ -105,7 +105,8 @@ public class MultiBlockUpdaterAgent
{
for(Player p : players)
{
UtilPlayer.sendPacket(p, new PacketPlayOutMapChunk(c, true, 65535));
int protocol = UtilPlayer.getProtocol(p);
UtilPlayer.sendPacket(p, new PacketPlayOutMapChunk(protocol, c, true, 65535));
}
}
else

View File

@ -1167,7 +1167,7 @@ public class UtilPlayer
}
Packet packet;
int protocol = ((CraftPlayer) player).getHandle().getProtocol();
int protocol = getProtocol(player);
Location location = player.getLocation();
if (protocol >= ProtocolVersion.v1_12)
@ -1209,7 +1209,7 @@ public class UtilPlayer
teleportUniform(players, locations, Entity::teleport);
}
public static int getProtocolVersion(Player player)
public static int getProtocol(Player player)
{
return ((CraftPlayer) player).getHandle().getProtocol();
}

View File

@ -554,7 +554,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
if (pDisguise.getSleepingDirection() != null)
{
for (Packet packet : getBedPackets(pDisguise))
for (Packet packet : getBedPackets(protocol, pDisguise))
{
handlePacket(packet, packetVerifier);
}
@ -821,14 +821,15 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
{
List<Packet> packets = new ArrayList<>();
PacketPlayOutMapChunk chunk = new PacketPlayOutMapChunk(_bedChunk, true, '\uffff');
EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle();
int protocol = nmsPlayer.getProtocol();
PacketPlayOutMapChunk chunk = new PacketPlayOutMapChunk(protocol, _bedChunk, true, '\uffff');
chunk.a = BED_POS_NORTH[0] >> 4;
chunk.b = BED_POS_NORTH[2] >> 4;
packets.add(chunk);
EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle();
_spawnPacketMap.entrySet().stream()
.filter(entry -> entry.getValue().size() > 0 && entry.getValue().getFirst() instanceof DisguisePlayer && ((DisguisePlayer) entry.getValue().getFirst()).getSleepingDirection() != null)
.filter(entry -> this.containsSpawnDisguise(player, entry.getValue().getFirst()))
@ -838,7 +839,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
if (tracker != null && tracker.trackedPlayers.contains(nmsPlayer))
{
packets.addAll(getBedPackets((DisguisePlayer) entry.getValue().getFirst()));
packets.addAll(getBedPackets(protocol, (DisguisePlayer) entry.getValue().getFirst()));
}
});
@ -853,7 +854,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
*
* fixme can we make this better at all?!?!?!
*/
private List<Packet> getBedPackets(DisguisePlayer playerDisguise)
private List<Packet> getBedPackets(int protocol, DisguisePlayer playerDisguise)
{
int[] coords = getCoordsFor(playerDisguise);
@ -874,7 +875,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
double d2 = posZ + (targetZ - posZ) / (double) partitions;
PacketPlayOutMapChunk chunk = new PacketPlayOutMapChunk(_bedChunk, true, '\uffff');
PacketPlayOutMapChunk chunk = new PacketPlayOutMapChunk(protocol, _bedChunk, true, '\uffff');
chunk.a = (int) Math.floor(d0) >> 4;
chunk.b = (int) Math.floor(d2) >> 4;
packets.add(chunk);

View File

@ -153,7 +153,8 @@ public abstract class Crumbleable
for (Player player : UtilServer.getPlayers())
{
UtilPlayer.sendPacket(player, new PacketPlayOutMapChunk(chunk, false, mask));
int protocol = UtilPlayer.getProtocol(player);
UtilPlayer.sendPacket(player, new PacketPlayOutMapChunk(protocol, chunk, false, mask));
}
_lastChunk = System.currentTimeMillis();