Skip to content

Instantly share code, notes, and snippets.

@TigerHix
Created October 1, 2014 06:22
Show Gist options
  • Save TigerHix/2cd7a3dc3cb8f4056690 to your computer and use it in GitHub Desktop.
Save TigerHix/2cd7a3dc3cb8f4056690 to your computer and use it in GitHub Desktop.
@Override
public Object getTeleportPacket(Location loc) {
Class<?> PacketPlayOutEntityTeleport = Util.getCraftClass("PacketPlayOutEntityTeleport");
Object packet = null;
try {
packet = PacketPlayOutEntityTeleport.getConstructor(new Class<?>[] {
int.class, int.class, int.class, int.class, byte.class, byte.class, boolean.class})
.newInstance(this.id,
loc.getBlockX() * 32,
loc.getBlockY() * 32,
loc.getBlockZ() * 32,
(byte) ((int) loc.getYaw() * 256 / 360),
(byte) ((int) loc.getPitch() * 256 / 360),
false);
} catch (Exception e) {
// Spigot 1653 patch start
try {
packet = PacketPlayOutEntityTeleport.getConstructor(new Class<?>[] {
int.class, int.class, int.class, int.class, byte.class, byte.class, boolean.class, boolean.class})
.newInstance(this.id,
loc.getBlockX() * 32,
loc.getBlockY() * 32,
loc.getBlockZ() * 32,
(byte) ((int) loc.getYaw() * 256 / 360),
(byte) ((int) loc.getPitch() * 256 / 360),
false,
true);
} catch (Exception e2) {
e2.printStackTrace();
}
// Spigot 1653 patch end
}
return packet;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment