Search in sources :

Example 46 with EntityInsentient

use of net.minecraft.server.v1_14_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.jump();
    } else if (handle instanceof EntityHumanNPC) {
        ((EntityHumanNPC) handle).setShouldJump();
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) Entity(net.minecraft.server.v1_14_R1.Entity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) PathEntity(net.minecraft.server.v1_14_R1.PathEntity) CraftEntity(org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity) EntityInsentient(net.minecraft.server.v1_14_R1.EntityInsentient) ControllerJump(net.minecraft.server.v1_14_R1.ControllerJump) EntityHumanNPC(net.citizensnpcs.nms.v1_14_R1.entity.EntityHumanNPC)

Example 47 with EntityInsentient

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

the class PlayerControllerMove method a.

@Override
public void a() {
    this.a.bd = 0F;
    if (this.f) {
        this.f = false;
        int i = MathHelper.floor(this.a.getBoundingBox().minY + 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.bd = 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.3D * this.e);
        } else {
            speed.setValue(0.2D * this.e);
        }
        float movement = (float) (this.e * speed.getValue());
        this.a.o(movement);
        this.a.bd = movement;
        if (shouldSlimeJump() || ((d2 >= NMS.getStepHeight(a.getBukkitEntity())) && (d0 * d0 + d1 * d1 < 1.0D))) {
            this.h = cg();
            this.h /= 3;
            if (this.a instanceof EntityHumanNPC) {
                ((EntityHumanNPC) this.a).getControllerJump().jump();
            } else {
                ((EntityInsentient) this.a).getControllerJump().jump();
            }
        }
    }
}
Also used : AttributeInstance(net.minecraft.server.v1_14_R1.AttributeInstance) EntitySlime(net.minecraft.server.v1_14_R1.EntitySlime) EntityHumanNPC(net.citizensnpcs.nms.v1_14_R1.entity.EntityHumanNPC)

Example 48 with EntityInsentient

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

the class PlayerPathfinder method a.

@Override
public PathEntity a(IWorldReader var0, EntityInsentient var1, Set<BlockPosition> var2, float var3, int var4) {
    this.a.a();
    this.e.a(var0, var1);
    PathPoint var5 = this.e.b();
    Map var6 = var2.stream().collect(Collectors.toMap((var0x) -> {
        return this.e.a((double) var0x.getX(), (double) var0x.getY(), (double) var0x.getZ());
    }, Function.identity()));
    PathEntity var7 = this.a(var5, var6, var3, var4);
    this.e.a();
    return var7;
}
Also used : PathEntity(net.minecraft.server.v1_14_R1.PathEntity) BlockPosition(net.minecraft.server.v1_14_R1.BlockPosition) Iterator(java.util.Iterator) Path(net.minecraft.server.v1_14_R1.Path) Pathfinder(net.minecraft.server.v1_14_R1.Pathfinder) Set(java.util.Set) Setting(net.citizensnpcs.Settings.Setting) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) EntityHumanNPC(net.citizensnpcs.nms.v1_14_R1.entity.EntityHumanNPC) List(java.util.List) Stream(java.util.stream.Stream) Lists(com.google.common.collect.Lists) PathDestination(net.minecraft.server.v1_14_R1.PathDestination) Map(java.util.Map) Optional(java.util.Optional) EntityInsentient(net.minecraft.server.v1_14_R1.EntityInsentient) Comparator(java.util.Comparator) IWorldReader(net.minecraft.server.v1_14_R1.IWorldReader) PathPoint(net.minecraft.server.v1_14_R1.PathPoint) PathPoint(net.minecraft.server.v1_14_R1.PathPoint) PathEntity(net.minecraft.server.v1_14_R1.PathEntity) Map(java.util.Map)

Example 49 with EntityInsentient

use of net.minecraft.server.v1_14_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.invoke(handle.getNavigation(), worldHandle);
    } catch (Exception e) {
        Messaging.logTr(Messages.ERROR_UPDATING_NAVIGATION_WORLD, e.getMessage());
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
Also used : CraftEntity(org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity) LivingEntity(org.bukkit.entity.LivingEntity) Entity(net.minecraft.server.v1_15_R1.Entity) SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) PathEntity(net.minecraft.server.v1_15_R1.PathEntity) EntityInsentient(net.minecraft.server.v1_15_R1.EntityInsentient) WorldServer(net.minecraft.server.v1_15_R1.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_15_R1.CraftWorld) ReportedException(net.minecraft.server.v1_15_R1.ReportedException) CommandException(net.citizensnpcs.api.command.exception.CommandException)

Example 50 with EntityInsentient

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

the class NMSImpl method attack.

@Override
public void attack(LivingEntity attacker, LivingEntity btarget) {
    EntityLiving handle = getHandle(attacker);
    EntityLiving target = getHandle(btarget);
    if (handle instanceof EntityPlayer) {
        EntityPlayer humanHandle = (EntityPlayer) handle;
        humanHandle.attack(target);
        PlayerAnimation.ARM_SWING.play(humanHandle.getBukkitEntity());
        return;
    }
    if (handle instanceof EntityInsentient) {
        ((EntityInsentient) handle).B(target);
        return;
    }
    AttributeInstance attackDamage = handle.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE);
    float f = (float) (attackDamage == null ? 1 : attackDamage.getValue());
    int i = 0;
    if (target instanceof EntityLiving) {
        f += EnchantmentManager.a(handle.getItemInMainHand(), target.getMonsterType());
        i += EnchantmentManager.a(Enchantments.KNOCKBACK, handle);
    }
    boolean flag = target.damageEntity(DamageSource.mobAttack(handle), f);
    if (!flag)
        return;
    if (i > 0) {
        target.f(-Math.sin(handle.yaw * Math.PI / 180.0F) * i * 0.5F, 0.1D, Math.cos(handle.yaw * Math.PI / 180.0F) * i * 0.5F);
        handle.setMot(handle.getMot().d(0.6, 1, 0.6));
    }
    int fireAspectLevel = EnchantmentManager.getFireAspectEnchantmentLevel(handle);
    if (fireAspectLevel > 0) {
        target.setOnFire(fireAspectLevel * 4);
    }
}
Also used : EntityLiving(net.minecraft.server.v1_15_R1.EntityLiving) AttributeInstance(net.minecraft.server.v1_15_R1.AttributeInstance) EntityPlayer(net.minecraft.server.v1_15_R1.EntityPlayer) EntityInsentient(net.minecraft.server.v1_15_R1.EntityInsentient) PathPoint(net.minecraft.server.v1_15_R1.PathPoint)

Aggregations

LivingEntity (org.bukkit.entity.LivingEntity)43 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)42 Location (org.bukkit.Location)19 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_14_R1.entity.EntityHumanNPC)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 MCNavigator (net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator)7 EntityInsentient (net.minecraft.server.v1_11_R1.EntityInsentient)7 PathEntity (net.minecraft.server.v1_14_R1.PathEntity)7 PathEntity (net.minecraft.server.v1_15_R1.PathEntity)7 PathEntity (net.minecraft.server.v1_16_R3.PathEntity)7 EntityInsentient (net.minecraft.server.v1_8_R3.EntityInsentient)7