Search in sources :

Example 6 with EntityInsentient

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

the class PlayerPathfinderNormal method a.

@Override
public PathType a(IBlockAccess paramIBlockAccess, int paramInt1, int paramInt2, int paramInt3, EntityInsentient paramEntityInsentient, int paramInt4, int paramInt5, int paramInt6, boolean paramBoolean1, boolean paramBoolean2) {
    EnumSet<PathType> localEnumSet = EnumSet.noneOf(PathType.class);
    Object localObject1 = PathType.BLOCKED;
    double d = paramEntityInsentient.width / 2.0D;
    BlockPosition localBlockPosition = new BlockPosition(paramEntityInsentient);
    for (int i = paramInt1; i < paramInt1 + paramInt4; i++) {
        for (int k = paramInt2; k < paramInt2 + paramInt5; k++) {
            for (int m = paramInt3; m < paramInt3 + paramInt6; m++) {
                PathType localPathType2 = a(paramIBlockAccess, i, k, m);
                if ((localPathType2 == PathType.DOOR_WOOD_CLOSED) && (paramBoolean1) && (paramBoolean2)) {
                    localPathType2 = PathType.WALKABLE;
                }
                if ((localPathType2 == PathType.DOOR_OPEN) && (!paramBoolean2)) {
                    localPathType2 = PathType.BLOCKED;
                }
                if ((localPathType2 == PathType.RAIL) && (!(paramIBlockAccess.getType(localBlockPosition).getBlock() instanceof BlockMinecartTrackAbstract)) && (!(paramIBlockAccess.getType(localBlockPosition.down()).getBlock() instanceof BlockMinecartTrackAbstract))) {
                    localPathType2 = PathType.FENCE;
                }
                if ((i == paramInt1) && (k == paramInt2) && (m == paramInt3)) {
                    localObject1 = localPathType2;
                }
                if ((k > paramInt2) && (localPathType2 != PathType.OPEN)) {
                    AxisAlignedBB localAxisAlignedBB = new AxisAlignedBB(i - d + 0.5D, paramInt2 + 0.001D, m - d + 0.5D, i + d + 0.5D, paramInt2 + paramEntityInsentient.length, m + d + 0.5D);
                    if (!paramEntityInsentient.world.b(localAxisAlignedBB)) {
                        localPathType2 = PathType.OPEN;
                    }
                }
                localEnumSet.add(localPathType2);
            }
        }
    }
    if (localEnumSet.contains(PathType.FENCE)) {
        return PathType.FENCE;
    }
    Object localObject2 = PathType.BLOCKED;
    for (PathType localPathType1 : localEnumSet) {
        if (paramEntityInsentient.a(localPathType1) < 0.0F) {
            return localPathType1;
        }
        if (paramEntityInsentient.a(localPathType1) >= paramEntityInsentient.a((PathType) localObject2)) {
            localObject2 = localPathType1;
        }
    }
    if ((localObject1 == PathType.OPEN) && (paramEntityInsentient.a((PathType) localObject2) == 0.0F)) {
        return PathType.OPEN;
    }
    return (PathType) localObject2;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_10_R1.AxisAlignedBB) PathType(net.minecraft.server.v1_10_R1.PathType) MutableBlockPosition(net.minecraft.server.v1_10_R1.BlockPosition.MutableBlockPosition) BlockPosition(net.minecraft.server.v1_10_R1.BlockPosition) BlockMinecartTrackAbstract(net.minecraft.server.v1_10_R1.BlockMinecartTrackAbstract) PathPoint(net.minecraft.server.v1_10_R1.PathPoint)

Example 7 with EntityInsentient

use of net.minecraft.server.v1_10_R1.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_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 8 with EntityInsentient

use of net.minecraft.server.v1_10_R1.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_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 9 with EntityInsentient

use of net.minecraft.server.v1_10_R1.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 = 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 10 with EntityInsentient

use of net.minecraft.server.v1_10_R1.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 = 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)

Aggregations

LivingEntity (org.bukkit.entity.LivingEntity)14 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)13 EntityInsentient (net.minecraft.server.v1_12_R1.EntityInsentient)7 EntityHumanNPC (net.citizensnpcs.nms.v1_10_R1.entity.EntityHumanNPC)5 EntityHumanNPC (net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC)5 EntityInsentient (net.minecraft.server.v1_10_R1.EntityInsentient)5 EntityInsentient (net.minecraft.server.v1_11_R1.EntityInsentient)5 EntityInsentient (net.minecraft.server.v1_8_R3.EntityInsentient)5 Location (org.bukkit.Location)5 CraftEntity (org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity)5 CommandException (net.citizensnpcs.api.command.exception.CommandException)4 EntityHumanNPC (net.citizensnpcs.nms.v1_11_R1.entity.EntityHumanNPC)4 EntityHumanNPC (net.citizensnpcs.nms.v1_8_R3.entity.EntityHumanNPC)4 Entity (net.minecraft.server.v1_10_R1.Entity)3 PathEntity (net.minecraft.server.v1_10_R1.PathEntity)3 Entity (net.minecraft.server.v1_11_R1.Entity)3 Entity (net.minecraft.server.v1_12_R1.Entity)3 PathEntity (net.minecraft.server.v1_12_R1.PathEntity)3 Entity (net.minecraft.server.v1_8_R3.Entity)3 PathEntity (net.minecraft.server.v1_8_R3.PathEntity)3