Last active
August 29, 2015 14:04
-
-
Save Bastian/efb17de1d3990bc1cb26 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package de.oppermann.bastian.lib.listener; | |
import net.minecraft.server.v1_7_R4.PacketPlayInFlying; | |
import org.bukkit.Bukkit; | |
import org.bukkit.entity.EntityType; | |
import org.bukkit.event.EventHandler; | |
import org.bukkit.event.Listener; | |
import de.oppermann.bastian.lib.events.AsyncIncomingPacketEvent; | |
import de.oppermann.bastian.lib.miscellaneous.DisguiseManager; | |
import de.oppermann.bastian.lib.miscellaneous.ReflectionUtil; | |
/** | |
* Intern required class. | |
* <p> | |
* Do not call any method of it! | |
* This class is used for internal purposes and can lead to serious errors if it is used. | |
*/ | |
public class AsyncIncommingPacketListener implements Listener { | |
@EventHandler | |
public void onIncommingPacket(AsyncIncomingPacketEvent event) { | |
if (event.getPlayer() == null) { | |
return; | |
} | |
if (DisguiseManager.getDisguiseType(event.getPlayer()) == EntityType.ENDER_DRAGON) { | |
if (event.getPacket() instanceof PacketPlayInFlying) { | |
PacketPlayInFlying packet = (PacketPlayInFlying) event.getPacket(); | |
float yaw = ReflectionUtil.getField(packet, "yaw"); | |
if (yaw == 0) { | |
return; | |
} | |
ReflectionUtil.setPrivateField(packet, "yaw", yaw - 180F); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment