use of com.integral.enigmaticlegacy.packets.clients.PacketPlayerSetlook in project Enigmatic-Legacy by Aizistral-Studios.
the class EyeOfNebula method triggerActiveAbility.
public void triggerActiveAbility(World world, ServerPlayerEntity player, ItemStack stack) {
if (SuperpositionHandler.hasSpellstoneCooldown(player))
return;
LivingEntity target = SuperpositionHandler.getObservedEntity(player, world, 3.0F, (int) ConfigHandler.EYE_OF_NEBULA_PHASE_RANGE.getValue());
if (target != null) {
Vector3 targetPos = Vector3.fromEntityCenter(target);
Vector3 chaserPos = Vector3.fromEntityCenter(player);
// Vector3 targetSight = new Vector3(target.getLookVec());
Vector3 dir = targetPos.subtract(chaserPos);
dir = dir.normalize();
dir = dir.multiply(1.5D);
dir = targetPos.add(dir);
// player.
world.playSound(null, player.getPosition(), SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 1.0F, (float) (0.8F + (Math.random() * 0.2D)));
EnigmaticLegacy.packetInstance.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(player.posX, player.posY, player.posZ, 128, player.dimension)), new PacketPortalParticles(player.posX, player.posY + (player.getHeight() / 2), player.posZ, 72, 1.0F, false));
player.setPositionAndUpdate(dir.x, target.posY + 0.25D, dir.z);
EnigmaticLegacy.packetInstance.send(PacketDistributor.PLAYER.with(() -> (ServerPlayerEntity) player), new PacketPlayerSetlook(target.posX, target.posY - 1.0D + (target.getHeight() / 2), target.posZ));
world.playSound(null, player.getPosition(), SoundEvents.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 1.0F, (float) (0.8F + (Math.random() * 0.2D)));
EnigmaticLegacy.packetInstance.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(player.posX, player.posY, player.posZ, 128, player.dimension)), new PacketRecallParticles(player.posX, player.posY + (player.getHeight() / 2), player.posZ, 24, false));
SuperpositionHandler.setSpellstoneCooldown(player, ConfigHandler.EYE_OF_NEBULA_COOLDOWN.getValue());
}
}
Aggregations