Handle some types of disguises better for head rotations and other disguises

This commit is contained in:
libraryaddict 2020-05-01 14:49:22 +12:00
parent 54f2896255
commit 824edfe698
No known key found for this signature in database
GPG Key ID: 052E4FBCD257AEA4

View File

@ -4,6 +4,7 @@ import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.reflect.StructureModifier;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.packets.IPacketHandler;
import me.libraryaddict.disguise.utilities.packets.LibsPackets;
@ -11,6 +12,7 @@ import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.ShulkerBullet;
/**
* Created by libraryaddict on 3/01/2019.
@ -30,9 +32,51 @@ public class PacketHandlerHeadRotation implements IPacketHandler {
Location loc = entity.getLocation();
byte pitch = DisguiseUtilities
.getPitch(disguise.getType(), entity.getType(), (byte) (int) (loc.getPitch() * 256.0F / 360.0F));
byte yaw = DisguiseUtilities.getYaw(disguise.getType(), entity.getType(), sentPacket.getBytes().read(0));
DisguiseType entityType = DisguiseType.getType(entity);
byte pitch;
byte yaw;
switch (entityType) {
case LLAMA_SPIT:
case FIREBALL:
case SMALL_FIREBALL:
case DRAGON_FIREBALL:
case FIREWORK:
case SHULKER_BULLET:
case ARROW:
case TIPPED_ARROW:
case SPECTRAL_ARROW:
case EGG:
case TRIDENT:
case THROWN_EXP_BOTTLE:
case EXPERIENCE_ORB:
case SPLASH_POTION:
case ENDER_CRYSTAL:
case FALLING_BLOCK:
case ITEM_FRAME:
case ENDER_SIGNAL:
case ENDER_PEARL:
case DROPPED_ITEM:
case EVOKER_FANGS:
case SNOWBALL:
case PAINTING:
case PRIMED_TNT:
if (sentPacket.getBytes().read(0) == 0 && entity.getVelocity().lengthSquared() > 0) {
loc.setDirection(entity.getVelocity());
pitch = DisguiseUtilities.getPitch(disguise.getType(), DisguiseType.PLAYER,
(byte) (int) (loc.getPitch() * 256.0F / 360.0F));
yaw = DisguiseUtilities.getYaw(disguise.getType(), DisguiseType.PLAYER,
(byte) (int) (loc.getYaw() * 256.0F / 360.0F));
break;
}
default:
pitch = DisguiseUtilities.getPitch(disguise.getType(), entity.getType(),
(byte) (int) (loc.getPitch() * 256.0F / 360.0F));
yaw = DisguiseUtilities
.getYaw(disguise.getType(), entity.getType(), (byte) (int) (loc.getYaw() * 256.0F / 360.0F));
break;
}
PacketContainer rotation = new PacketContainer(PacketType.Play.Server.ENTITY_HEAD_ROTATION);