Search in sources :

Example 1 with EntityHumanNPC

use of net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC in project Citizens2 by CitizensDev.

the class NMSImpl method updatePathfindingRange.

@Override
public void updatePathfindingRange(NPC npc, float pathfindingRange) {
    if (!npc.isSpawned() || !npc.getEntity().getType().isAlive())
        return;
    EntityLiving en = NMSImpl.getHandle((LivingEntity) npc.getEntity());
    if (!(en instanceof EntityInsentient)) {
        if (en instanceof EntityHumanNPC) {
            ((EntityHumanNPC) en).updatePathfindingRange(pathfindingRange);
        }
        return;
    }
    if (PATHFINDING_RANGE == null)
        return;
    EntityInsentient handle = (EntityInsentient) en;
    NavigationAbstract navigation = handle.getNavigation();
    try {
        AttributeInstance inst = (AttributeInstance) PATHFINDING_RANGE.get(navigation);
        inst.setValue(pathfindingRange);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}
Also used : EntityLiving(net.minecraft.server.v1_10_R1.EntityLiving) AttributeInstance(net.minecraft.server.v1_10_R1.AttributeInstance) EntityInsentient(net.minecraft.server.v1_10_R1.EntityInsentient) NavigationAbstract(net.minecraft.server.v1_10_R1.NavigationAbstract) EntityHumanNPC(net.citizensnpcs.nms.v1_10_R1.entity.EntityHumanNPC)

Example 2 with EntityHumanNPC

use of net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC in project Citizens2 by CitizensDev.

the class PlayerControllerMove method c.

@Override
public void c() {
    this.a.bf = 0F;
    if (this.f) {
        this.f = false;
        int i = MathHelper.floor(this.a.getBoundingBox().b + 0.5D);
        double d0 = this.b - this.a.locX;
        double d1 = this.d - this.a.locZ;
        double d2 = this.c - i;
        double d3 = d0 * d0 + d2 * d2 + d1 * d1;
        if (d3 < 2.500000277905201E-007D)
            return;
        float f = (float) Math.toDegrees(Math.atan2(d1, d0)) - 90.0F;
        this.a.yaw = a(this.a.yaw, f, 90.0F);
        NMS.setHeadYaw(a.getBukkitEntity(), this.a.yaw);
        AttributeInstance speed = this.a.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);
        speed.setValue(0.1D * this.e);
        float movement = (float) (this.e * speed.getValue()) * 10;
        this.a.bg = movement;
        if (shouldSlimeJump() || ((d2 > 0.0D) && (d0 * d0 + d1 * d1 < 1.0D))) {
            this.h = cg();
            this.h /= 3;
            if (this.a instanceof EntityHumanNPC) {
                ((EntityHumanNPC) this.a).getControllerJump().a();
            } else {
                ((EntityInsentient) this.a).getControllerJump().a();
            }
        }
    }
}
Also used : AttributeInstance(net.minecraft.server.v1_10_R1.AttributeInstance) EntityHumanNPC(net.citizensnpcs.nms.v1_10_R1.entity.EntityHumanNPC)

Example 3 with EntityHumanNPC

use of net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC in project Citizens2 by CitizensDev.

the class NMSImpl method setShouldJump.

@Override
public void setShouldJump(org.bukkit.entity.Entity entity) {
    Entity handle = NMSImpl.getHandle(entity);
    if (handle == null)
        return;
    if (handle instanceof EntityInsentient) {
        ControllerJump controller = ((EntityInsentient) handle).getControllerJump();
        controller.a();
    } else if (handle instanceof EntityHumanNPC) {
        ((EntityHumanNPC) handle).setShouldJump();
    }
}
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) EntityInsentient(net.minecraft.server.v1_8_R3.EntityInsentient) ControllerJump(net.minecraft.server.v1_8_R3.ControllerJump) EntityHumanNPC(net.citizensnpcs.nms.v1_8_R3.entity.EntityHumanNPC)

Example 4 with EntityHumanNPC

use of net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC in project Citizens2 by CitizensDev.

the class NMSImpl method updatePathfindingRange.

@Override
public void updatePathfindingRange(NPC npc, float pathfindingRange) {
    if (!npc.isSpawned() || !npc.getEntity().getType().isAlive())
        return;
    EntityLiving en = NMSImpl.getHandle((LivingEntity) npc.getEntity());
    if (!(en instanceof EntityInsentient)) {
        if (en instanceof EntityHumanNPC) {
            ((EntityHumanNPC) en).updatePathfindingRange(pathfindingRange);
        }
        return;
    }
    if (PATHFINDING_RANGE == null)
        return;
    EntityInsentient handle = (EntityInsentient) en;
    NavigationAbstract navigation = handle.getNavigation();
    try {
        AttributeInstance inst = (AttributeInstance) PATHFINDING_RANGE.get(navigation);
        inst.setValue(pathfindingRange);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}
Also used : EntityLiving(net.minecraft.server.v1_8_R3.EntityLiving) AttributeInstance(net.minecraft.server.v1_8_R3.AttributeInstance) EntityInsentient(net.minecraft.server.v1_8_R3.EntityInsentient) NavigationAbstract(net.minecraft.server.v1_8_R3.NavigationAbstract) EntityHumanNPC(net.citizensnpcs.nms.v1_8_R3.entity.EntityHumanNPC)

Example 5 with EntityHumanNPC

use of net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC 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)

Aggregations

SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)13 LivingEntity (org.bukkit.entity.LivingEntity)9 EntityHumanNPC (net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC)7 EntityHumanNPC (net.citizensnpcs.nms.v1_10_R1.entity.EntityHumanNPC)6 EntityHumanNPC (net.citizensnpcs.nms.v1_11_R1.entity.EntityHumanNPC)6 EntityHumanNPC (net.citizensnpcs.nms.v1_8_R3.entity.EntityHumanNPC)6 EntityInsentient (net.minecraft.server.v1_12_R1.EntityInsentient)5 EntityInsentient (net.minecraft.server.v1_10_R1.EntityInsentient)4 EntityInsentient (net.minecraft.server.v1_11_R1.EntityInsentient)4 Entity (net.minecraft.server.v1_12_R1.Entity)4 EntityInsentient (net.minecraft.server.v1_8_R3.EntityInsentient)4 Location (org.bukkit.Location)4 Player (org.bukkit.entity.Player)4 Entity (net.minecraft.server.v1_10_R1.Entity)3 Entity (net.minecraft.server.v1_11_R1.Entity)3 PathEntity (net.minecraft.server.v1_12_R1.PathEntity)3 Entity (net.minecraft.server.v1_8_R3.Entity)3 CraftEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity)3 AttributeInstance (net.minecraft.server.v1_10_R1.AttributeInstance)2 PathEntity (net.minecraft.server.v1_10_R1.PathEntity)2