Search in sources :

Example 1 with PacketWitherParticles

use of com.integral.enigmaticlegacy.packets.clients.PacketWitherParticles in project Enigmatic-Legacy by Aizistral-Studios.

the class EnigmaticItem method launchWitherSkull.

private void launchWitherSkull(World world, PlayerEntity player, boolean invulnerable) {
    world.playEvent((PlayerEntity) null, 1024, new BlockPos(player), 0);
    Vector3 look = new Vector3(player.getLookVec()).multiply(1, 0, 1);
    double playerRot = Math.toRadians(player.rotationYaw + 90);
    if (look.x == 0 && look.z == 0)
        look = new Vector3(Math.cos(playerRot), 0, Math.sin(playerRot));
    look = look.normalize().multiply(-2);
    double div = -0.75 + (random.nextDouble() * 0.75);
    double mod = -0.5D + (random.nextDouble() * 6D);
    Vector3 pl = look.add(Vector3.fromEntityCenter(player)).add(0, 1.6, div * 0.1);
    Vector3 axis = look.normalize().crossProduct(new Vector3(-1, 0, -1)).normalize();
    double rot = mod * Math.PI / 4D - Math.PI / 2D;
    Vector3 axis1 = axis.multiply(div * 3.5D + 5D).rotate(rot, look);
    if (axis1.y < 0)
        axis1 = axis1.multiply(1, -1, 1);
    Vector3 end = pl.add(axis1);
    // end = end.add(0, -1, 0);\
    UltimateWitherSkullEntity witherskullentity = new UltimateWitherSkullEntity(world, player);
    if (invulnerable) {
        witherskullentity.setSkullInvulnerable(true);
    }
    witherskullentity.posX = end.x;
    witherskullentity.posY = end.y;
    witherskullentity.posZ = end.z;
    world.addEntity(witherskullentity);
    EnigmaticLegacy.packetInstance.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(witherskullentity.posX, witherskullentity.posY, witherskullentity.posZ, 64, witherskullentity.dimension)), new PacketWitherParticles(witherskullentity.posX, witherskullentity.posY + (witherskullentity.getHeight() / 2), witherskullentity.posZ, 8, false));
}
Also used : UltimateWitherSkullEntity(com.integral.enigmaticlegacy.entities.UltimateWitherSkullEntity) BlockPos(net.minecraft.util.math.BlockPos) Vector3(com.integral.enigmaticlegacy.helpers.Vector3) PacketWitherParticles(com.integral.enigmaticlegacy.packets.clients.PacketWitherParticles)

Aggregations

UltimateWitherSkullEntity (com.integral.enigmaticlegacy.entities.UltimateWitherSkullEntity)1 Vector3 (com.integral.enigmaticlegacy.helpers.Vector3)1 PacketWitherParticles (com.integral.enigmaticlegacy.packets.clients.PacketWitherParticles)1 BlockPos (net.minecraft.util.math.BlockPos)1