Search in sources :

Example 46 with EntityHuman

use of net.minecraft.server.v1_16_R3.EntityHuman in project Village_Defense by Plajer.

the class RidableIronGolem method g.

@Override
public void g(float f, float f1) {
    EntityLiving entityliving = (EntityLiving) bt();
    if (entityliving == null) {
        for (final Entity e : passengers) {
            if (e instanceof EntityHuman) {
                entityliving = (EntityLiving) e;
                break;
            }
        }
        if (entityliving == null) {
            P = 0.5f;
            this.l((float) 0.12);
            super.g(f, f1);
            return;
        }
    }
    final float yaw = entityliving.yaw;
    this.yaw = yaw;
    lastYaw = yaw;
    pitch = entityliving.pitch * 0.5f;
    setYawPitch(this.yaw, pitch);
    final float yaw2 = this.yaw;
    aM = yaw2;
    aO = yaw2;
    f = entityliving.bd * 0.75F;
    f1 = entityliving.be;
    if (f1 <= 0.0f) {
        f1 *= 0.25F;
    }
    this.l((float) 0.12);
    super.g(f, f1);
    P = 1.0F;
}
Also used : Entity(net.minecraft.server.v1_9_R1.Entity) EntityHuman(net.minecraft.server.v1_9_R1.EntityHuman) EntityLiving(net.minecraft.server.v1_9_R1.EntityLiving)

Example 47 with EntityHuman

use of net.minecraft.server.v1_16_R3.EntityHuman in project Citizens2 by CitizensDev.

the class NMSImpl method flyingMoveLogic.

public static void flyingMoveLogic(EntityLiving entity, float f, float f1) {
    if (entity.bM()) {
        if ((entity.V())) {
            double d0 = entity.locY;
            float f3 = 0.8F;
            float f4 = 0.02F;
            float f2 = EnchantmentManager.b(entity);
            if (f2 > 3.0F) {
                f2 = 3.0F;
            }
            if (!entity.onGround) {
                f2 *= 0.5F;
            }
            if (f2 > 0.0F) {
                f3 += (0.54600006F - f3) * f2 / 3.0F;
                f4 += (entity.bI() * 1.0F - f4) * f2 / 3.0F;
            }
            entity.a(f, f1, f4);
            entity.move(entity.motX, entity.motY, entity.motZ);
            entity.motX *= f3;
            entity.motY *= 0.800000011920929D;
            entity.motZ *= f3;
            entity.motY -= 0.02D;
            if ((entity.positionChanged) && (entity.c(entity.motX, entity.motY + 0.6000000238418579D - entity.locY + d0, entity.motZ))) {
                entity.motY = 0.30000001192092896D;
            }
        } else if ((entity.ab())) {
            double d0 = entity.locY;
            entity.a(f, f1, 0.02F);
            entity.move(entity.motX, entity.motY, entity.motZ);
            entity.motX *= 0.5D;
            entity.motY *= 0.5D;
            entity.motZ *= 0.5D;
            entity.motY -= 0.02D;
            if ((entity.positionChanged) && (entity.c(entity.motX, entity.motY + 0.6000000238418579D - entity.locY + d0, entity.motZ))) {
                entity.motY = 0.30000001192092896D;
            }
        } else {
            float f5 = 0.91F;
            if (entity.onGround) {
                f5 = entity.world.getType(new BlockPosition(MathHelper.floor(entity.locX), MathHelper.floor(entity.getBoundingBox().b) - 1, MathHelper.floor(entity.locZ))).getBlock().frictionFactor * 0.91F;
            }
            float f6 = 0.16277136F / (f5 * f5 * f5);
            float f3;
            if (entity.onGround) {
                f3 = entity.bI() * f6;
            } else {
                f3 = entity.aM;
            }
            entity.a(f, f1, f3);
            f5 = 0.91F;
            if (entity.onGround) {
                f5 = entity.world.getType(new BlockPosition(MathHelper.floor(entity.locX), MathHelper.floor(entity.getBoundingBox().b) - 1, MathHelper.floor(entity.locZ))).getBlock().frictionFactor * 0.91F;
            }
            if (entity.k_()) {
                float f4 = 0.15F;
                entity.motX = MathHelper.a(entity.motX, -f4, f4);
                entity.motZ = MathHelper.a(entity.motZ, -f4, f4);
                entity.fallDistance = 0.0F;
                if (entity.motY < -0.15D) {
                    entity.motY = -0.15D;
                }
                boolean flag = (entity.isSneaking()) && ((entity instanceof EntityHuman));
                if ((flag) && (entity.motY < 0.0D)) {
                    entity.motY = 0.0D;
                }
            }
            entity.move(entity.motX, entity.motY, entity.motZ);
            if ((entity.positionChanged) && (entity.k_())) {
                entity.motY = 0.2D;
            }
            if ((entity.world.isClientSide) && ((!entity.world.isLoaded(new BlockPosition((int) entity.locX, 0, (int) entity.locZ))) || (!entity.world.getChunkAtWorldCoords(new BlockPosition((int) entity.locX, 0, (int) entity.locZ)).o()))) {
                if (entity.locY > 0.0D) {
                    entity.motY = -0.1D;
                } else {
                    entity.motY = 0.0D;
                }
            } else {
                entity.motY -= 0.08D;
            }
            entity.motY *= 0.9800000190734863D;
            entity.motX *= f5;
            entity.motZ *= f5;
        }
    }
    entity.aA = entity.aB;
    double d0 = entity.locX - entity.lastX;
    double d1 = entity.locZ - entity.lastZ;
    float f2 = MathHelper.sqrt(d0 * d0 + d1 * d1) * 4.0F;
    if (f2 > 1.0F) {
        f2 = 1.0F;
    }
    entity.aB += (f2 - entity.aB) * 0.4F;
    entity.aC += entity.aB;
}
Also used : EntityHuman(net.minecraft.server.v1_8_R3.EntityHuman) BlockPosition(net.minecraft.server.v1_8_R3.BlockPosition)

Example 48 with EntityHuman

use of net.minecraft.server.v1_16_R3.EntityHuman in project Citizens2 by CitizensDev.

the class NMSImpl method tick.

@Override
public boolean tick(org.bukkit.entity.Entity next) {
    Entity entity = NMSImpl.getHandle(next);
    if (!entity.dead) {
        try {
            entity.world.g(entity);
        } catch (Throwable throwable) {
            CrashReport crashreport = CrashReport.a(throwable, "Ticking player");
            CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked");
            entity.appendEntityCrashDetails(crashreportsystemdetails);
            throw new ReportedException(crashreport);
        }
    }
    boolean removeFromPlayerList = ((NPCHolder) entity).getNPC().data().get("removefromplayerlist", Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
    if (entity.dead) {
        entity.world.removeEntity(entity);
        return true;
    } else if (!removeFromPlayerList) {
        if (!entity.world.players.contains(entity)) {
            entity.world.players.add((EntityHuman) entity);
        }
        return true;
    } else {
        entity.world.players.remove(entity);
    }
    return false;
}
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) EntityHuman(net.minecraft.server.v1_8_R3.EntityHuman) CrashReportSystemDetails(net.minecraft.server.v1_8_R3.CrashReportSystemDetails) CrashReport(net.minecraft.server.v1_8_R3.CrashReport) NPCHolder(net.citizensnpcs.npc.ai.NPCHolder) ReportedException(net.minecraft.server.v1_8_R3.ReportedException)

Example 49 with EntityHuman

use of net.minecraft.server.v1_16_R3.EntityHuman in project Citizens2 by CitizensDev.

the class NMSImpl method setHeadYaw.

@Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
    if (!(entity instanceof LivingEntity))
        return;
    EntityLiving handle = (EntityLiving) getHandle(entity);
    yaw = Util.clampYaw(yaw);
    handle.aJ = yaw;
    if (!(handle instanceof EntityHuman))
        handle.aI = yaw;
    handle.aK = yaw;
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) EntityHuman(net.minecraft.server.v1_8_R3.EntityHuman) EntityLiving(net.minecraft.server.v1_8_R3.EntityLiving)

Example 50 with EntityHuman

use of net.minecraft.server.v1_16_R3.EntityHuman in project Citizens2 by CitizensDev.

the class NMSImpl method setHeadYaw.

@Override
public void setHeadYaw(org.bukkit.entity.Entity entity, float yaw) {
    if (!(entity instanceof LivingEntity))
        return;
    EntityLiving handle = (EntityLiving) getHandle(entity);
    yaw = Util.clampYaw(yaw);
    handle.aO = yaw;
    if (!(handle instanceof EntityHuman)) {
        handle.aN = yaw;
    }
    handle.aP = yaw;
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) EntityHuman(net.minecraft.server.v1_11_R1.EntityHuman) EntityLiving(net.minecraft.server.v1_11_R1.EntityLiving)

Aggregations

net.minecraft.server.v1_16_R3 (net.minecraft.server.v1_16_R3)20 CraftItemStack (org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack)19 MyPetApi (de.Keyle.MyPet.MyPetApi)18 EntitySize (de.Keyle.MyPet.api.entity.EntitySize)18 MyPet (de.Keyle.MyPet.api.entity.MyPet)18 EntityMyPet (de.Keyle.MyPet.compat.v1_16_R3.entity.EntityMyPet)18 InvocationTargetException (java.lang.reflect.InvocationTargetException)18 Pair (com.mojang.datafixers.util.Pair)17 Util (de.Keyle.MyPet.api.Util)17 EquipmentSlot (de.Keyle.MyPet.api.entity.EquipmentSlot)17 Arrays (java.util.Arrays)17 Bukkit (org.bukkit.Bukkit)17 ENTITY_LIVING_broadcastItemBreak (de.Keyle.MyPet.compat.v1_16_R3.CompatManager.ENTITY_LIVING_broadcastItemBreak)15 LivingEntity (org.bukkit.entity.LivingEntity)15 Configuration (de.Keyle.MyPet.api.Configuration)10 EntityHuman (net.minecraft.server.v1_11_R1.EntityHuman)7 PetState (de.Keyle.MyPet.api.entity.MyPet.PetState)6 EntityHuman (net.minecraft.server.v1_12_R1.EntityHuman)6 EntityHuman (net.minecraft.server.v1_8_R3.EntityHuman)6 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)5