Search in sources :

Example 6 with EntityInsentient

use of net.minecraft.server.v1_13_R2.EntityInsentient in project Citizens2 by CitizensDev.

the class NMSImpl method updateAI.

public static void updateAI(EntityLiving entity) {
    if (entity instanceof EntityInsentient) {
        EntityInsentient handle = (EntityInsentient) entity;
        handle.getEntitySenses().a();
        NMSImpl.updateNavigation(handle.getNavigation());
        handle.getControllerMove().a();
        handle.getControllerLook().a();
        handle.getControllerJump().b();
    } else if (entity instanceof EntityHumanNPC) {
        ((EntityHumanNPC) entity).updateAI();
    }
}
Also used : EntityInsentient(net.minecraft.server.v1_13_R2.EntityInsentient) EntityHumanNPC(net.citizensnpcs.nms.v1_13_R2.entity.EntityHumanNPC)

Example 7 with EntityInsentient

use of net.minecraft.server.v1_13_R2.EntityInsentient 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_13_R2.PathEntity) LivingEntity(org.bukkit.entity.LivingEntity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) CraftEntity(org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity) Entity(net.minecraft.server.v1_13_R2.Entity) EntityInsentient(net.minecraft.server.v1_13_R2.EntityInsentient) ControllerJump(net.minecraft.server.v1_13_R2.ControllerJump) EntityHumanNPC(net.citizensnpcs.nms.v1_13_R2.entity.EntityHumanNPC)

Example 8 with EntityInsentient

use of net.minecraft.server.v1_13_R2.EntityInsentient in project Citizens2 by CitizensDev.

the class PlayerPathfinderNormal method a.

@Override
public PathType a(IBlockAccess var1, int var2, int var3, int var4, EntityInsentient var5, int var6, int var7, int var8, boolean var9, boolean var10) {
    EnumSet var11 = EnumSet.noneOf(PathType.class);
    PathType var12 = PathType.BLOCKED;
    double var13 = var5.width / 2.0D;
    BlockPosition var15 = new BlockPosition(var5);
    var12 = this.a(var1, var2, var3, var4, var6, var7, var8, var9, var10, var11, var12, var15);
    if (var11.contains(PathType.FENCE)) {
        return PathType.FENCE;
    } else {
        PathType var16 = PathType.BLOCKED;
        Iterator var17 = var11.iterator();
        while (var17.hasNext()) {
            PathType var18 = (PathType) var17.next();
            if (var5.a(var18) < 0.0F) {
                return var18;
            }
            if (var5.a(var18) >= var5.a(var16)) {
                var16 = var18;
            }
        }
        if (var12 == PathType.OPEN && var5.a(var16) == 0.0F) {
            return PathType.OPEN;
        } else {
            return var16;
        }
    }
}
Also used : PathType(net.minecraft.server.v1_13_R2.PathType) EnumSet(java.util.EnumSet) MutableBlockPosition(net.minecraft.server.v1_13_R2.BlockPosition.MutableBlockPosition) BlockPosition(net.minecraft.server.v1_13_R2.BlockPosition) Iterator(java.util.Iterator)

Example 9 with EntityInsentient

use of net.minecraft.server.v1_13_R2.EntityInsentient 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 = Util.getDragonYaw(handle.getBukkitEntity(), xDiff, zDiff);
        } 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 10 with EntityInsentient

use of net.minecraft.server.v1_13_R2.EntityInsentient 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_12_R1.EntityLiving) AttributeInstance(net.minecraft.server.v1_12_R1.AttributeInstance) EntityInsentient(net.minecraft.server.v1_12_R1.EntityInsentient) NavigationAbstract(net.minecraft.server.v1_12_R1.NavigationAbstract) EntityHumanNPC(net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC)

Aggregations

LivingEntity (org.bukkit.entity.LivingEntity)43 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)42 Location (org.bukkit.Location)18 EntityInsentient (net.minecraft.server.v1_16_R3.EntityInsentient)12 EntityInsentient (net.minecraft.server.v1_15_R1.EntityInsentient)11 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)9 CommandException (net.citizensnpcs.api.command.exception.CommandException)8 EntityHumanNPC (net.citizensnpcs.nms.v1_15_R1.entity.EntityHumanNPC)8 EntityHumanNPC (net.citizensnpcs.nms.v1_16_R3.entity.EntityHumanNPC)8 EntityInsentient (net.minecraft.server.v1_12_R1.EntityInsentient)8 EntityInsentient (net.minecraft.server.v1_14_R1.EntityInsentient)8 CancelReason (net.citizensnpcs.api.ai.event.CancelReason)7 EntityHumanNPC (net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC)7 EntityHumanNPC (net.citizensnpcs.nms.v1_14_R1.entity.EntityHumanNPC)7 MCNavigator (net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator)7 EntityInsentient (net.minecraft.server.v1_11_R1.EntityInsentient)7 PathEntity (net.minecraft.server.v1_13_R2.PathEntity)7 PathEntity (net.minecraft.server.v1_15_R1.PathEntity)7 PathEntity (net.minecraft.server.v1_16_R3.PathEntity)7 Vector (org.bukkit.util.Vector)7