Search in sources :

Example 41 with EntityHuman

use of net.minecraft.server.v1_14_R1.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);
    Entity entity1 = entity.bJ();
    if (entity1 != null) {
        if ((entity1.dead) || (!entity1.w(entity))) {
            entity.stopRiding();
        }
    } else {
        if (!entity.dead) {
            try {
                entity.world.entityJoinedWorld(entity, true);
            } 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_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) EntityHuman(net.minecraft.server.v1_12_R1.EntityHuman) CrashReportSystemDetails(net.minecraft.server.v1_12_R1.CrashReportSystemDetails) CrashReport(net.minecraft.server.v1_12_R1.CrashReport) NPCHolder(net.citizensnpcs.npc.ai.NPCHolder) ReportedException(net.minecraft.server.v1_12_R1.ReportedException)

Example 42 with EntityHuman

use of net.minecraft.server.v1_14_R1.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.aR = yaw;
    if (!(handle instanceof EntityHuman)) {
        handle.aQ = yaw;
    }
    handle.aS = yaw;
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) EntityHuman(net.minecraft.server.v1_13_R2.EntityHuman) EntityLiving(net.minecraft.server.v1_13_R2.EntityLiving)

Example 43 with EntityHuman

use of net.minecraft.server.v1_14_R1.EntityHuman in project PaperDev by Kamillaova.

the class CraftLivingEntity method launchProjectile.

@SuppressWarnings("unchecked")
public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity) {
    net.minecraft.server.v1_12_R1.World world = ((CraftWorld) getWorld()).getHandle();
    net.minecraft.server.v1_12_R1.Entity launch = null;
    if (Snowball.class.isAssignableFrom(projectile)) {
        launch = new EntitySnowball(world, getHandle());
        // ItemSnowball
        ((EntityProjectile) launch).a(getHandle(), getHandle().pitch, getHandle().yaw, 0.0F, 1.5F, 1.0F);
    } else if (Egg.class.isAssignableFrom(projectile)) {
        launch = new EntityEgg(world, getHandle());
        // ItemEgg
        ((EntityProjectile) launch).a(getHandle(), getHandle().pitch, getHandle().yaw, 0.0F, 1.5F, 1.0F);
    } else if (EnderPearl.class.isAssignableFrom(projectile)) {
        launch = new EntityEnderPearl(world, getHandle());
        // ItemEnderPearl
        ((EntityProjectile) launch).a(getHandle(), getHandle().pitch, getHandle().yaw, 0.0F, 1.5F, 1.0F);
    } else if (Arrow.class.isAssignableFrom(projectile)) {
        if (TippedArrow.class.isAssignableFrom(projectile)) {
            launch = new EntityTippedArrow(world, getHandle());
            ((EntityTippedArrow) launch).setType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false)));
        } else if (SpectralArrow.class.isAssignableFrom(projectile)) {
            launch = new EntitySpectralArrow(world, getHandle());
        } else {
            launch = new EntityTippedArrow(world, getHandle());
        }
        // ItemBow
        ((EntityArrow) launch).a(getHandle(), getHandle().pitch, getHandle().yaw, 0.0F, 3.0F, 1.0F);
    } else if (ThrownPotion.class.isAssignableFrom(projectile)) {
        if (LingeringPotion.class.isAssignableFrom(projectile)) {
            launch = new EntityPotion(world, getHandle(), CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.LINGERING_POTION, 1)));
        } else {
            launch = new EntityPotion(world, getHandle(), CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.SPLASH_POTION, 1)));
        }
        // ItemSplashPotion
        ((EntityProjectile) launch).a(getHandle(), getHandle().pitch, getHandle().yaw, -20.0F, 0.5F, 1.0F);
    } else if (ThrownExpBottle.class.isAssignableFrom(projectile)) {
        launch = new EntityThrownExpBottle(world, getHandle());
        // ItemExpBottle
        ((EntityProjectile) launch).a(getHandle(), getHandle().pitch, getHandle().yaw, -20.0F, 0.7F, 1.0F);
    } else if (Fish.class.isAssignableFrom(projectile) && getHandle() instanceof EntityHuman) {
        launch = new EntityFishingHook(world, (EntityHuman) getHandle());
    } else if (Fireball.class.isAssignableFrom(projectile)) {
        Location location = getEyeLocation();
        Vector direction = location.getDirection().multiply(10);
        if (SmallFireball.class.isAssignableFrom(projectile)) {
            launch = new EntitySmallFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
        } else if (WitherSkull.class.isAssignableFrom(projectile)) {
            launch = new EntityWitherSkull(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
        } else if (DragonFireball.class.isAssignableFrom(projectile)) {
            launch = new EntityDragonFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
        } else {
            launch = new EntityLargeFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
        }
        ((EntityFireball) launch).projectileSource = this;
        launch.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    } else if (LlamaSpit.class.isAssignableFrom(projectile)) {
        Location location = getEyeLocation();
        Vector direction = location.getDirection();
        launch = new EntityLlamaSpit(world);
        ((EntityLlamaSpit) launch).shooter = getHandle();
        // EntityLlama
        ((EntityLlamaSpit) launch).shoot(direction.getX(), direction.getY(), direction.getZ(), 1.5F, 10.0F);
        launch.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    } else if (ShulkerBullet.class.isAssignableFrom(projectile)) {
        Location location = getEyeLocation();
        launch = new EntityShulkerBullet(world, getHandle(), null, null);
        launch.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    }
    Validate.notNull(launch, "Projectile not supported");
    if (velocity != null) {
        ((T) launch.getBukkitEntity()).setVelocity(velocity);
    }
    world.addEntity(launch);
    return (T) launch.getBukkitEntity();
}
Also used : EntityShulkerBullet(net.minecraft.server.v1_12_R1.EntityShulkerBullet) EntityWitherSkull(net.minecraft.server.v1_12_R1.EntityWitherSkull) EntityTippedArrow(net.minecraft.server.v1_12_R1.EntityTippedArrow) EntityLargeFireball(net.minecraft.server.v1_12_R1.EntityLargeFireball) EntityEnderPearl(net.minecraft.server.v1_12_R1.EntityEnderPearl) EntityFishingHook(net.minecraft.server.v1_12_R1.EntityFishingHook) EntityShulkerBullet(net.minecraft.server.v1_12_R1.EntityShulkerBullet) ShulkerBullet(org.bukkit.entity.ShulkerBullet) EntityDragonFireball(net.minecraft.server.v1_12_R1.EntityDragonFireball) EntityEgg(net.minecraft.server.v1_12_R1.EntityEgg) PotionData(org.bukkit.potion.PotionData) EntitySmallFireball(net.minecraft.server.v1_12_R1.EntitySmallFireball) DragonFireball(org.bukkit.entity.DragonFireball) EntityDragonFireball(net.minecraft.server.v1_12_R1.EntityDragonFireball) EntityLargeFireball(net.minecraft.server.v1_12_R1.EntityLargeFireball) EntityFireball(net.minecraft.server.v1_12_R1.EntityFireball) Fireball(org.bukkit.entity.Fireball) SmallFireball(org.bukkit.entity.SmallFireball) EntityTippedArrow(net.minecraft.server.v1_12_R1.EntityTippedArrow) TippedArrow(org.bukkit.entity.TippedArrow) EntitySpectralArrow(net.minecraft.server.v1_12_R1.EntitySpectralArrow) DragonFireball(org.bukkit.entity.DragonFireball) EntityDragonFireball(net.minecraft.server.v1_12_R1.EntityDragonFireball) EntityLlamaSpit(net.minecraft.server.v1_12_R1.EntityLlamaSpit) EntitySmallFireball(net.minecraft.server.v1_12_R1.EntitySmallFireball) EntityPotion(net.minecraft.server.v1_12_R1.EntityPotion) Fish(org.bukkit.entity.Fish) EntitySmallFireball(net.minecraft.server.v1_12_R1.EntitySmallFireball) SmallFireball(org.bukkit.entity.SmallFireball) CraftWorld(org.bukkit.craftbukkit.v1_12_R1.CraftWorld) Vector(org.bukkit.util.Vector) EntityFireball(net.minecraft.server.v1_12_R1.EntityFireball) EntityProjectile(net.minecraft.server.v1_12_R1.EntityProjectile) EntityArrow(net.minecraft.server.v1_12_R1.EntityArrow) SpectralArrow(org.bukkit.entity.SpectralArrow) EntityTippedArrow(net.minecraft.server.v1_12_R1.EntityTippedArrow) Arrow(org.bukkit.entity.Arrow) EntitySpectralArrow(net.minecraft.server.v1_12_R1.EntitySpectralArrow) TippedArrow(org.bukkit.entity.TippedArrow) EntityHuman(net.minecraft.server.v1_12_R1.EntityHuman) EntityThrownExpBottle(net.minecraft.server.v1_12_R1.EntityThrownExpBottle) EntityEgg(net.minecraft.server.v1_12_R1.EntityEgg) Egg(org.bukkit.entity.Egg) EntitySnowball(net.minecraft.server.v1_12_R1.EntitySnowball) EntityThrownExpBottle(net.minecraft.server.v1_12_R1.EntityThrownExpBottle) ThrownExpBottle(org.bukkit.entity.ThrownExpBottle) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack) Location(org.bukkit.Location)

Example 44 with EntityHuman

use of net.minecraft.server.v1_14_R1.EntityHuman in project PaperDev by Kamillaova.

the class ActivationRange method activateEntities.

/**
 * Find what entities are in range of the players in the world and set
 * active if in range.
 */
public static void activateEntities(World world) {
    MinecraftTimings.entityActivationCheckTimer.startTiming();
    final int miscActivationRange = world.spigotConfig.miscActivationRange;
    final int animalActivationRange = world.spigotConfig.animalActivationRange;
    final int monsterActivationRange = world.spigotConfig.monsterActivationRange;
    // Paper
    final int waterActivationRange = world.spigotConfig.waterActivationRange;
    int maxRange = Math.max(monsterActivationRange, animalActivationRange);
    maxRange = Math.max(maxRange, miscActivationRange);
    maxRange = Math.min((world.spigotConfig.viewDistance << 4) - 8, maxRange);
    // Paper
    Chunk chunk;
    for (EntityHuman player : world.players) {
        player.activatedTick = MinecraftServer.currentTick;
        maxBB = player.getBoundingBox().grow(maxRange, 256, maxRange);
        miscBB = player.getBoundingBox().grow(miscActivationRange, 256, miscActivationRange);
        animalBB = player.getBoundingBox().grow(animalActivationRange, 256, animalActivationRange);
        // Paper
        waterBB = player.getBoundingBox().grow(waterActivationRange, 256, waterActivationRange);
        monsterBB = player.getBoundingBox().grow(monsterActivationRange, 256, monsterActivationRange);
        int i = MathHelper.floor(maxBB.a / 16.0D);
        int j = MathHelper.floor(maxBB.d / 16.0D);
        int k = MathHelper.floor(maxBB.c / 16.0D);
        int l = MathHelper.floor(maxBB.f / 16.0D);
        for (int i1 = i; i1 <= j; ++i1) {
            for (int j1 = k; j1 <= l; ++j1) {
                if (// Paper
                (chunk = MCUtil.getLoadedChunkWithoutMarkingActive(world, i1, j1)) != null) {
                    // Paper
                    activateChunkEntities(chunk);
                }
            }
        }
    }
    MinecraftTimings.entityActivationCheckTimer.stopTiming();
}
Also used : EntityHuman(net.minecraft.server.v1_12_R1.EntityHuman) Chunk(net.minecraft.server.v1_12_R1.Chunk)

Aggregations

LivingEntity (org.bukkit.entity.LivingEntity)16 EntityHuman (net.minecraft.server.v1_12_R1.EntityHuman)9 EntityHuman (net.minecraft.server.v1_11_R1.EntityHuman)7 EntityHuman (net.minecraft.server.v1_8_R3.EntityHuman)6 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)5 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)5 EntityHuman (net.minecraft.server.v1_15_R1.EntityHuman)5 EntityHuman (net.minecraft.server.v1_10_R1.EntityHuman)4 Entity (net.minecraft.server.v1_11_R1.Entity)3 EntityLiving (net.minecraft.server.v1_11_R1.EntityLiving)3 EntityLiving (net.minecraft.server.v1_12_R1.EntityLiving)3 EntityHuman (net.minecraft.server.v1_13_R2.EntityHuman)3 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)2 SoliniaItemException (com.solinia.solinia.Exceptions.SoliniaItemException)2 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)2 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)2 Entity (net.minecraft.server.v1_12_R1.Entity)2 EntityLiving (net.minecraft.server.v1_15_R1.EntityLiving)2 EntityHuman (net.minecraft.server.v1_16_R3.EntityHuman)2 Entity (net.minecraft.server.v1_9_R1.Entity)2