Search in sources :

Example 1 with PacketPlayerSetlook

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());
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) PacketPlayerSetlook(com.integral.enigmaticlegacy.packets.clients.PacketPlayerSetlook) PacketRecallParticles(com.integral.enigmaticlegacy.packets.clients.PacketRecallParticles) Vector3(com.integral.enigmaticlegacy.helpers.Vector3) PacketPortalParticles(com.integral.enigmaticlegacy.packets.clients.PacketPortalParticles) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity)

Aggregations

Vector3 (com.integral.enigmaticlegacy.helpers.Vector3)1 PacketPlayerSetlook (com.integral.enigmaticlegacy.packets.clients.PacketPlayerSetlook)1 PacketPortalParticles (com.integral.enigmaticlegacy.packets.clients.PacketPortalParticles)1 PacketRecallParticles (com.integral.enigmaticlegacy.packets.clients.PacketRecallParticles)1 LivingEntity (net.minecraft.entity.LivingEntity)1 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)1