Search in sources :

Example 1 with EntityEnderDragon

use of net.minecraft.server.v1_11_R1.EntityEnderDragon in project FireAPI by FireBlade-Serv.

the class FireBossBar method gen.

public void gen(String title) {
    EntityEnderDragon ew = new EntityEnderDragon(((CraftWorld) this.p.getWorld()).getHandle());
    Location loc = this.p.getLocation();
    ew.setInvisible(true);
    ew.setLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getPitch(), loc.getYaw());
    ew.setCustomName(title);
    PacketPlayOutSpawnEntityLiving pel = new PacketPlayOutSpawnEntityLiving(ew);
    ((CraftPlayer) this.p).getHandle().playerConnection.sendPacket(pel);
}
Also used : EntityEnderDragon(net.minecraft.server.v1_8_R3.EntityEnderDragon) PacketPlayOutSpawnEntityLiving(net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving) CraftPlayer(org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer) Location(org.bukkit.Location)

Example 2 with EntityEnderDragon

use of net.minecraft.server.v1_11_R1.EntityEnderDragon in project Citizens2 by CitizensDev.

the class NMSImpl method look.

@Override
public void look(org.bukkit.entity.Entity entity, Location to, boolean headOnly, boolean immediate) {
    Entity handle = NMSImpl.getHandle(entity);
    if (immediate || headOnly || BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType()) || (!(handle instanceof EntityInsentient) && !(handle instanceof EntityHumanNPC))) {
        Location fromLocation = entity.getLocation(FROM_LOCATION);
        double xDiff, yDiff, zDiff;
        xDiff = to.getX() - fromLocation.getX();
        yDiff = to.getY() - fromLocation.getY();
        zDiff = to.getZ() - fromLocation.getZ();
        double distanceXZ = Math.sqrt(xDiff * xDiff + zDiff * zDiff);
        double distanceY = Math.sqrt(distanceXZ * distanceXZ + yDiff * yDiff);
        double yaw = Math.toDegrees(Math.acos(xDiff / distanceXZ));
        double pitch = Math.toDegrees(Math.acos(yDiff / distanceY)) - 90;
        if (zDiff < 0.0)
            yaw += Math.abs(180 - yaw) * 2;
        if (handle instanceof EntityEnderDragon) {
            yaw = getDragonYaw(handle, to.getX(), to.getZ());
        } else {
            yaw = yaw - 90;
        }
        if (headOnly) {
            setHeadYaw(entity, (float) yaw);
        } else {
            look(entity, (float) yaw, (float) pitch);
        }
        return;
    }
    if (handle instanceof EntityInsentient) {
        ((EntityInsentient) handle).getControllerLook().a(to.getX(), to.getY(), to.getZ(), 10, ((EntityInsentient) handle).bQ());
        while (((EntityInsentient) handle).aK >= 180F) {
            ((EntityInsentient) handle).aK -= 360F;
        }
        while (((EntityInsentient) handle).aK < -180F) {
            ((EntityInsentient) handle).aK += 360F;
        }
    } else if (handle instanceof EntityHumanNPC) {
        ((EntityHumanNPC) handle).setTargetLook(to);
    }
}
Also used : PathEntity(net.minecraft.server.v1_8_R3.PathEntity) LivingEntity(org.bukkit.entity.LivingEntity) Entity(net.minecraft.server.v1_8_R3.Entity) CraftEntity(org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) EntityEnderDragon(net.minecraft.server.v1_8_R3.EntityEnderDragon) EntityInsentient(net.minecraft.server.v1_8_R3.EntityInsentient) EntityHumanNPC(net.citizensnpcs.nms.v1_8_R3.entity.EntityHumanNPC) Location(org.bukkit.Location)

Example 3 with EntityEnderDragon

use of net.minecraft.server.v1_11_R1.EntityEnderDragon in project Citizens2 by CitizensDev.

the class NMSImpl method look.

@Override
public void look(org.bukkit.entity.Entity entity, Location to, boolean headOnly, boolean immediate) {
    Entity handle = NMSImpl.getHandle(entity);
    if (immediate || headOnly || BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType()) || (!(handle instanceof EntityInsentient) && !(handle instanceof EntityHumanNPC))) {
        Location fromLocation = entity.getLocation(FROM_LOCATION);
        double xDiff, yDiff, zDiff;
        xDiff = to.getX() - fromLocation.getX();
        yDiff = to.getY() - fromLocation.getY();
        zDiff = to.getZ() - fromLocation.getZ();
        double distanceXZ = Math.sqrt(xDiff * xDiff + zDiff * zDiff);
        double distanceY = Math.sqrt(distanceXZ * distanceXZ + yDiff * yDiff);
        double yaw = Math.toDegrees(Math.acos(xDiff / distanceXZ));
        double pitch = Math.toDegrees(Math.acos(yDiff / distanceY)) - 90;
        if (zDiff < 0.0)
            yaw += Math.abs(180 - yaw) * 2;
        if (handle instanceof EntityEnderDragon) {
            yaw = getDragonYaw(handle, to.getX(), to.getZ());
        } else {
            yaw = yaw - 90;
        }
        if (headOnly) {
            setHeadYaw(entity, (float) yaw);
        } else {
            look(entity, (float) yaw, (float) pitch);
        }
        return;
    }
    if (handle instanceof EntityInsentient) {
        ((EntityInsentient) handle).getControllerLook().a(to.getX(), to.getY(), to.getZ(), ((EntityInsentient) handle).O(), ((EntityInsentient) handle).N());
        while (((EntityLiving) handle).aP >= 180F) {
            ((EntityLiving) handle).aP -= 360F;
        }
        while (((EntityLiving) handle).aP < -180F) {
            ((EntityLiving) handle).aP += 360F;
        }
    } else if (handle instanceof EntityHumanNPC) {
        ((EntityHumanNPC) handle).setTargetLook(to);
    }
}
Also used : PathEntity(net.minecraft.server.v1_12_R1.PathEntity) LivingEntity(org.bukkit.entity.LivingEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) CraftEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity) Entity(net.minecraft.server.v1_12_R1.Entity) EntityEnderDragon(net.minecraft.server.v1_12_R1.EntityEnderDragon) EntityInsentient(net.minecraft.server.v1_12_R1.EntityInsentient) EntityHumanNPC(net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC) Location(org.bukkit.Location)

Example 4 with EntityEnderDragon

use of net.minecraft.server.v1_11_R1.EntityEnderDragon in project Citizens2 by CitizensDev.

the class NMSImpl method look.

@Override
public void look(org.bukkit.entity.Entity entity, Location to, boolean headOnly, boolean immediate) {
    Entity handle = NMSImpl.getHandle(entity);
    if (immediate || headOnly || BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType()) || (!(handle instanceof EntityInsentient) && !(handle instanceof EntityHumanNPC))) {
        Location fromLocation = entity.getLocation(FROM_LOCATION);
        double xDiff, yDiff, zDiff;
        xDiff = to.getX() - fromLocation.getX();
        yDiff = to.getY() - fromLocation.getY();
        zDiff = to.getZ() - fromLocation.getZ();
        double distanceXZ = Math.sqrt(xDiff * xDiff + zDiff * zDiff);
        double distanceY = Math.sqrt(distanceXZ * distanceXZ + yDiff * yDiff);
        double yaw = Math.toDegrees(Math.acos(xDiff / distanceXZ));
        double pitch = Math.toDegrees(Math.acos(yDiff / distanceY)) - 90;
        if (zDiff < 0.0)
            yaw += Math.abs(180 - yaw) * 2;
        if (handle instanceof EntityEnderDragon) {
            yaw = getDragonYaw(handle, to.getX(), to.getZ());
        } else {
            yaw = yaw - 90;
        }
        if (headOnly) {
            setHeadYaw(entity, (float) yaw);
        } else {
            look(entity, (float) yaw, (float) pitch);
        }
        return;
    }
    if (handle instanceof EntityInsentient) {
        ((EntityInsentient) handle).getControllerLook().a(to.getX(), to.getY(), to.getZ(), ((EntityInsentient) handle).cL(), ((EntityInsentient) handle).N());
        while (((EntityLiving) handle).aP >= 180F) {
            ((EntityLiving) handle).aP -= 360F;
        }
        while (((EntityLiving) handle).aP < -180F) {
            ((EntityLiving) handle).aP += 360F;
        }
    } else if (handle instanceof EntityHumanNPC) {
        ((EntityHumanNPC) handle).setTargetLook(to);
    }
}
Also used : PathEntity(net.minecraft.server.v1_11_R1.PathEntity) LivingEntity(org.bukkit.entity.LivingEntity) CraftEntity(org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) Entity(net.minecraft.server.v1_11_R1.Entity) EntityEnderDragon(net.minecraft.server.v1_11_R1.EntityEnderDragon) EntityInsentient(net.minecraft.server.v1_11_R1.EntityInsentient) EntityHumanNPC(net.citizensnpcs.nms.v1_11_R1.entity.EntityHumanNPC) Location(org.bukkit.Location)

Example 5 with EntityEnderDragon

use of net.minecraft.server.v1_11_R1.EntityEnderDragon in project Citizens2 by CitizensDev.

the class NMSImpl method look.

@Override
public void look(org.bukkit.entity.Entity entity, Location to, boolean headOnly, boolean immediate) {
    Entity handle = NMSImpl.getHandle(entity);
    if (immediate || headOnly || BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType()) || (!(handle instanceof EntityInsentient) && !(handle instanceof EntityHumanNPC))) {
        Location fromLocation = entity.getLocation(FROM_LOCATION);
        double xDiff, yDiff, zDiff;
        xDiff = to.getX() - fromLocation.getX();
        yDiff = to.getY() - fromLocation.getY();
        zDiff = to.getZ() - fromLocation.getZ();
        double distanceXZ = Math.sqrt(xDiff * xDiff + zDiff * zDiff);
        double distanceY = Math.sqrt(distanceXZ * distanceXZ + yDiff * yDiff);
        double yaw = Math.toDegrees(Math.acos(xDiff / distanceXZ));
        double pitch = Math.toDegrees(Math.acos(yDiff / distanceY)) - 90;
        if (zDiff < 0.0)
            yaw += Math.abs(180 - yaw) * 2;
        if (handle instanceof EntityEnderDragon) {
            yaw = getDragonYaw(handle, to.getX(), to.getZ());
        } else {
            yaw = yaw - 90;
        }
        if (headOnly) {
            setHeadYaw(entity, (float) yaw);
        } else {
            look(entity, (float) yaw, (float) pitch);
        }
        return;
    }
    if (handle instanceof EntityInsentient) {
        ((EntityInsentient) handle).getControllerLook().a(to.getX(), to.getY(), to.getZ(), ((EntityInsentient) handle).cJ(), ((EntityInsentient) handle).N());
        while (((EntityInsentient) handle).aQ >= 180F) {
            ((EntityInsentient) handle).aQ -= 360F;
        }
        while (((EntityInsentient) handle).aQ < -180F) {
            ((EntityInsentient) handle).aQ += 360F;
        }
    } else if (handle instanceof EntityHumanNPC) {
        ((EntityHumanNPC) handle).setTargetLook(to);
    }
}
Also used : PathEntity(net.minecraft.server.v1_10_R1.PathEntity) LivingEntity(org.bukkit.entity.LivingEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) CraftEntity(org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity) Entity(net.minecraft.server.v1_10_R1.Entity) EntityEnderDragon(net.minecraft.server.v1_10_R1.EntityEnderDragon) EntityInsentient(net.minecraft.server.v1_10_R1.EntityInsentient) EntityHumanNPC(net.citizensnpcs.nms.v1_10_R1.entity.EntityHumanNPC) Location(org.bukkit.Location)

Aggregations

Location (org.bukkit.Location)5 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)4 LivingEntity (org.bukkit.entity.LivingEntity)4 EntityEnderDragon (net.minecraft.server.v1_8_R3.EntityEnderDragon)2 EntityHumanNPC (net.citizensnpcs.nms.v1_10_R1.entity.EntityHumanNPC)1 EntityHumanNPC (net.citizensnpcs.nms.v1_11_R1.entity.EntityHumanNPC)1 EntityHumanNPC (net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC)1 EntityHumanNPC (net.citizensnpcs.nms.v1_8_R3.entity.EntityHumanNPC)1 Entity (net.minecraft.server.v1_10_R1.Entity)1 EntityEnderDragon (net.minecraft.server.v1_10_R1.EntityEnderDragon)1 EntityInsentient (net.minecraft.server.v1_10_R1.EntityInsentient)1 PathEntity (net.minecraft.server.v1_10_R1.PathEntity)1 Entity (net.minecraft.server.v1_11_R1.Entity)1 EntityEnderDragon (net.minecraft.server.v1_11_R1.EntityEnderDragon)1 EntityInsentient (net.minecraft.server.v1_11_R1.EntityInsentient)1 PathEntity (net.minecraft.server.v1_11_R1.PathEntity)1 Entity (net.minecraft.server.v1_12_R1.Entity)1 EntityEnderDragon (net.minecraft.server.v1_12_R1.EntityEnderDragon)1 EntityInsentient (net.minecraft.server.v1_12_R1.EntityInsentient)1 PathEntity (net.minecraft.server.v1_12_R1.PathEntity)1