Search in sources :

Example 21 with EntityInsentient

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

the class NMSImpl method look.

@Override
public void look(org.bukkit.entity.Entity from, org.bukkit.entity.Entity to) {
    Entity handle = NMSImpl.getHandle(from), target = NMSImpl.getHandle(to);
    BAD_CONTROLLER_LOOK.add(EntityType.SHULKER);
    if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType())) {
        if (to instanceof LivingEntity) {
            look(from, ((LivingEntity) to).getEyeLocation(), false, true);
        } else {
            look(from, to.getLocation(), false, true);
        }
    } else if (handle instanceof EntityInsentient) {
        ((EntityInsentient) handle).getControllerLook().a(target, ((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(target, 10F, 40F);
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) 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) EntityLiving(net.minecraft.server.v1_12_R1.EntityLiving) EntityInsentient(net.minecraft.server.v1_12_R1.EntityInsentient) EntityHumanNPC(net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC)

Example 22 with EntityInsentient

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

the class NMSImpl method updateNavigationWorld.

@Override
public void updateNavigationWorld(org.bukkit.entity.Entity entity, World world) {
    if (NAVIGATION_WORLD_FIELD == null)
        return;
    Entity en = NMSImpl.getHandle(entity);
    if (en == null || !(en instanceof EntityInsentient))
        return;
    EntityInsentient handle = (EntityInsentient) en;
    WorldServer worldHandle = ((CraftWorld) world).getHandle();
    try {
        NAVIGATION_WORLD_FIELD.set(handle.getNavigation(), worldHandle);
    } catch (Exception e) {
        Messaging.logTr(Messages.ERROR_UPDATING_NAVIGATION_WORLD, e.getMessage());
    }
}
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) EntityInsentient(net.minecraft.server.v1_12_R1.EntityInsentient) WorldServer(net.minecraft.server.v1_12_R1.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld) ReportedException(net.minecraft.server.v1_12_R1.ReportedException) CommandException(net.citizensnpcs.api.command.exception.CommandException)

Example 23 with EntityInsentient

use of net.minecraft.server.v1_12_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_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) EntityInsentient(net.minecraft.server.v1_12_R1.EntityInsentient) ControllerJump(net.minecraft.server.v1_12_R1.ControllerJump) EntityHumanNPC(net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC)

Example 24 with EntityInsentient

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

the class PlayerControllerMove method a.

@Override
public void a() {
    this.a.bg = 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) {
            this.a.bf = (0.0F);
            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);
        if (!(this.a instanceof EntitySlime)) {
            speed.setValue(0.1D * this.e);
        }
        float movement = (float) (this.e * speed.getValue()) * 10;
        this.a.k(movement);
        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_12_R1.AttributeInstance) EntitySlime(net.minecraft.server.v1_12_R1.EntitySlime) EntityHumanNPC(net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC)

Example 25 with EntityInsentient

use of net.minecraft.server.v1_12_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);
    PathType localPathType1 = PathType.BLOCKED;
    BlockPosition localBlockPosition = new BlockPosition(paramEntityInsentient);
    localPathType1 = a(paramIBlockAccess, paramInt1, paramInt2, paramInt3, paramInt4, paramInt5, paramInt6, paramBoolean1, paramBoolean2, localEnumSet, localPathType1, localBlockPosition);
    if (localEnumSet.contains(PathType.FENCE)) {
        return PathType.FENCE;
    }
    Object localObject = PathType.BLOCKED;
    for (PathType localPathType2 : localEnumSet) {
        if (paramEntityInsentient.a(localPathType2) < 0.0F) {
            return localPathType2;
        }
        if (paramEntityInsentient.a(localPathType2) >= paramEntityInsentient.a((PathType) localObject)) {
            localObject = localPathType2;
        }
    }
    if ((localPathType1 == PathType.OPEN) && (paramEntityInsentient.a((PathType) localObject) == 0.0F)) {
        return PathType.OPEN;
    }
    return (PathType) localObject;
}
Also used : PathType(net.minecraft.server.v1_12_R1.PathType) MutableBlockPosition(net.minecraft.server.v1_12_R1.BlockPosition.MutableBlockPosition) BlockPosition(net.minecraft.server.v1_12_R1.BlockPosition)

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_12_R1.entity.EntityHumanNPC)6 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 CommandException (net.citizensnpcs.api.command.exception.CommandException)4 EntityHumanNPC (net.citizensnpcs.nms.v1_10_R1.entity.EntityHumanNPC)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_12_R1.Entity)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 PathEntity (net.minecraft.server.v1_11_R1.PathEntity)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 Location (org.bukkit.Location)3