use of org.bukkit.craftbukkit.v1_7_R1.entity.CraftEntity in project Denizen-For-Bukkit by DenizenScript.
the class DenizenNetworkManagerImpl method tryProcessTeleportPacketForAttach.
public void tryProcessTeleportPacketForAttach(ClientboundTeleportEntityPacket packet, Entity e, Vector relative) throws IllegalAccessException {
EntityAttachmentHelper.EntityAttachedToMap attList = EntityAttachmentHelper.toEntityToData.get(e.getUUID());
if (attList != null) {
for (EntityAttachmentHelper.PlayerAttachMap attMap : attList.attachedToMap.values()) {
EntityAttachmentHelper.AttachmentData att = attMap.getAttachment(player.getUUID());
if (attMap.attached.isValid() && att != null) {
ClientboundTeleportEntityPacket pNew = new ClientboundTeleportEntityPacket(copyPacket(packet));
ENTITY_ID_PACKTELENT.setInt(pNew, att.attached.getBukkitEntity().getEntityId());
Vector resultPos = new Vector(POS_X_PACKTELENT.getDouble(pNew), POS_Y_PACKTELENT.getDouble(pNew), POS_Z_PACKTELENT.getDouble(pNew)).add(relative);
if (att.positionalOffset != null) {
resultPos = att.fixedForOffset(resultPos, e.getYRot(), e.getXRot());
byte yaw, pitch;
if (att.noRotate) {
Entity attachedEntity = ((CraftEntity) att.attached.getBukkitEntity()).getHandle();
yaw = EntityAttachmentHelper.compressAngle(attachedEntity.getYRot());
pitch = EntityAttachmentHelper.compressAngle(attachedEntity.getXRot());
} else {
yaw = packet.getyRot();
pitch = packet.getxRot();
}
if (att.noPitch) {
Entity attachedEntity = ((CraftEntity) att.attached.getBukkitEntity()).getHandle();
pitch = EntityAttachmentHelper.compressAngle(attachedEntity.getXRot());
}
byte newYaw = EntityAttachmentHelper.adaptedCompressedAngle(yaw, att.positionalOffset.getYaw());
pitch = EntityAttachmentHelper.adaptedCompressedAngle(pitch, att.positionalOffset.getPitch());
POS_X_PACKTELENT.setDouble(pNew, resultPos.getX());
POS_Y_PACKTELENT.setDouble(pNew, resultPos.getY());
POS_Z_PACKTELENT.setDouble(pNew, resultPos.getZ());
YAW_PACKTELENT.setByte(pNew, newYaw);
PITCH_PACKTELENT.setByte(pNew, pitch);
if (NMSHandler.debugPackets) {
Debug.log("Attach Teleport Packet: " + pNew.getClass().getCanonicalName() + " for " + att.attached.getUUID() + " sent to " + player.getName() + " with raw yaw " + yaw + " adapted to " + newYaw);
}
}
att.visiblePositions.put(player.getUUID(), resultPos.clone());
oldManager.send(pNew);
}
}
}
if (e.passengers != null && !e.passengers.isEmpty()) {
for (Entity ent : e.passengers) {
tryProcessTeleportPacketForAttach(packet, ent, new Vector(ent.getX() - e.getX(), ent.getY() - e.getY(), ent.getZ() - e.getZ()));
}
}
}
Aggregations