Read desc
Fixed disguises facing direction not updating automatically to the correct direction. Its not 100% perfect, but the alternative is to delay the packet another tick which is not realistic as people could change disguises in that time.
This commit is contained in:
parent
2f85d35df1
commit
94a7237803
@ -80,13 +80,16 @@ public class PacketsManager {
|
||||
else {
|
||||
event.setPacket(packets[0]);
|
||||
final PacketContainer[] delayedPackets = new PacketContainer[packets.length - 1];
|
||||
for (int i = 1; i < packets.length; i++)
|
||||
for (int i = 1; i < packets.length; i++) {
|
||||
delayedPackets[i - 1] = packets[i];
|
||||
}
|
||||
if (delayedPackets.length > 0) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
for (PacketContainer packet : delayedPackets)
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(observer, packet);
|
||||
for (PacketContainer packet : delayedPackets) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(observer, packet, false);
|
||||
}
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -94,6 +97,7 @@ public class PacketsManager {
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// Now add a client listener to cancel them interacting with uninteractable disguised entitys.
|
||||
// You ain't supposed to be allowed to 'interact' with a item that cannot be clicked.
|
||||
@ -290,7 +294,7 @@ public class PacketsManager {
|
||||
spawnPackets[1] = new PacketContainer(Packets.Server.ENTITY_HEAD_ROTATION);
|
||||
StructureModifier<Object> mods = spawnPackets[1].getModifier();
|
||||
mods.write(0, disguisedEntity.getEntityId());
|
||||
mods.write(1, (byte) (int) Math.floor(loc.getYaw() * 256.0F / 360.0F));
|
||||
mods.write(1, yaw);
|
||||
}
|
||||
return spawnPackets;
|
||||
}
|
||||
@ -624,15 +628,35 @@ public class PacketsManager {
|
||||
if (fakeId > 0) {
|
||||
// Here I grab the packets to convert them to, So I can display them as if the disguise sent them.
|
||||
PacketContainer[] packets = transformPacket(event.getPacket(), event.getPlayer());
|
||||
try {
|
||||
for (PacketContainer packet : packets) {
|
||||
final PacketContainer[] delayedPackets = new PacketContainer[packets.length - 1];
|
||||
final Player observer = event.getPlayer();
|
||||
for (int i = 0; i < packets.length; i++) {
|
||||
PacketContainer packet = packets[i];
|
||||
if (packet.equals(event.getPacket()))
|
||||
packet = packet.deepClone();
|
||||
packet.getModifier().write(0, fakeId);
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false);
|
||||
if (i == 0) {
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(observer, packet, false);
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
} else {
|
||||
delayedPackets[i - 1] = packets[i];
|
||||
}
|
||||
}
|
||||
if (delayedPackets.length > 0) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
for (PacketContainer packet : delayedPackets) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(observer, packet, false);
|
||||
}
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (event.getPacketID() == Packets.Server.ENTITY_METADATA) {
|
||||
@ -652,15 +676,6 @@ public class PacketsManager {
|
||||
} else {
|
||||
switch (event.getPacketID()) {
|
||||
case Packets.Server.NAMED_ENTITY_SPAWN:
|
||||
case Packets.Server.ATTACH_ENTITY:
|
||||
case Packets.Server.REL_ENTITY_MOVE:
|
||||
case Packets.Server.REL_ENTITY_MOVE_LOOK:
|
||||
case Packets.Server.ENTITY_LOOK:
|
||||
case Packets.Server.ENTITY_TELEPORT:
|
||||
case Packets.Server.ENTITY_HEAD_ROTATION:
|
||||
case Packets.Server.MOB_EFFECT:
|
||||
case Packets.Server.ENTITY_EQUIPMENT:
|
||||
if (event.getPacketID() == Packets.Server.NAMED_ENTITY_SPAWN) {
|
||||
PacketContainer packet = new PacketContainer(Packets.Server.ENTITY_METADATA);
|
||||
StructureModifier<Object> mods = packet.getModifier();
|
||||
mods.write(0, entity.getEntityId());
|
||||
@ -675,7 +690,16 @@ public class PacketsManager {
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
case Packets.Server.ATTACH_ENTITY:
|
||||
case Packets.Server.REL_ENTITY_MOVE:
|
||||
case Packets.Server.REL_ENTITY_MOVE_LOOK:
|
||||
case Packets.Server.ENTITY_LOOK:
|
||||
case Packets.Server.ENTITY_TELEPORT:
|
||||
case Packets.Server.ENTITY_HEAD_ROTATION:
|
||||
case Packets.Server.MOB_EFFECT:
|
||||
case Packets.Server.ENTITY_EQUIPMENT:
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user