Search in sources :

Example 1 with EntityType

use of net.minecraft.entity.EntityType in project minecolonies by Minecolonies.

the class AbstractShipRaidEvent method onUpdate.

@Override
public void onUpdate() {
    status = EventStatus.PROGRESSING;
    colony.getRaiderManager().setNightsSinceLastRaid(0);
    if (spawners.size() <= 0 && raiders.size() == 0 && respawns.isEmpty()) {
        status = EventStatus.WAITING;
        return;
    }
    updateRaidBar();
    if (!respawns.isEmpty()) {
        for (final Tuple<EntityType<?>, BlockPos> entry : respawns) {
            final BlockPos spawnPos = ShipBasedRaiderUtils.getLoadedPositionTowardsCenter(entry.getB(), colony, MAX_LANDING_DISTANCE, spawnPoint, MIN_CENTER_DISTANCE, 10);
            if (spawnPos != null) {
                RaiderMobUtils.spawn(entry.getA(), 1, spawnPos, colony.getWorld(), colony, id);
            }
        }
        respawns.clear();
        return;
    }
    spawners.removeIf(spawner -> colony.getWorld() != null && WorldUtil.isBlockLoaded(colony.getWorld(), spawner) && colony.getWorld().getBlockState(spawner).getBlock() != Blocks.SPAWNER);
    // Spawns landing troops.
    if (raiders.size() < spawners.size() * 2) {
        BlockPos spawnPos = ShipBasedRaiderUtils.getLoadedPositionTowardsCenter(spawnPoint, colony, MAX_LANDING_DISTANCE, spawnPoint, MIN_CENTER_DISTANCE, 10);
        if (spawnPos != null) {
            // Find nice position on the ship
            if (spawnPos.distSqr(spawnPoint) < 25) {
                spawnPos = ShipBasedRaiderUtils.findSpawnPosOnShip(spawnPos, colony.getWorld(), 3);
            }
            RaiderMobUtils.spawn(getNormalRaiderType(), shipSize.normal, spawnPos, colony.getWorld(), colony, id);
            RaiderMobUtils.spawn(getArcherRaiderType(), shipSize.archer, spawnPos, colony.getWorld(), colony, id);
            RaiderMobUtils.spawn(getBossRaiderType(), shipSize.boss, spawnPos, colony.getWorld(), colony, id);
        }
    }
    // Mark entities when spies exist
    if (colony.getRaiderManager().areSpiesEnabled()) {
        for (final Entity entity : getEntities()) {
            if (entity instanceof LivingEntity) {
                ((LivingEntity) entity).addEffect(new EffectInstance(Effects.GLOWING, 550));
            }
        }
    }
}
Also used : EntityType(net.minecraft.entity.EntityType) LivingEntity(net.minecraft.entity.LivingEntity) MobSpawnerTileEntity(net.minecraft.tileentity.MobSpawnerTileEntity) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) TileEntity(net.minecraft.tileentity.TileEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) BlockPos(net.minecraft.util.math.BlockPos) EffectInstance(net.minecraft.potion.EffectInstance)

Example 2 with EntityType

use of net.minecraft.entity.EntityType in project minecolonies by Minecolonies.

the class HordeRaidEvent method onUpdate.

@Override
public void onUpdate() {
    if (status == EventStatus.PREPARING) {
        prepareEvent();
    }
    updateRaidBar();
    colony.getRaiderManager().setNightsSinceLastRaid(0);
    if (horde.hordeSize <= 0) {
        status = EventStatus.DONE;
    }
    if (!respawns.isEmpty()) {
        for (final Tuple<EntityType<?>, BlockPos> entry : respawns) {
            final BlockPos spawnPos = ShipBasedRaiderUtils.getLoadedPositionTowardsCenter(entry.getB(), colony, MAX_RESPAWN_DEVIATION, spawnPoint, MIN_CENTER_DISTANCE, 10);
            if (spawnPos != null) {
                RaiderMobUtils.spawn(entry.getA(), 1, spawnPos, colony.getWorld(), colony, id);
            }
        }
        respawns.clear();
        return;
    }
    if (boss.size() + archers.size() + normal.size() < horde.numberOfBosses + horde.numberOfRaiders + horde.numberOfArchers) {
        final BlockPos spawnPos = ShipBasedRaiderUtils.getLoadedPositionTowardsCenter(spawnPoint, colony, MAX_RESPAWN_DEVIATION, spawnPoint, MIN_CENTER_DISTANCE, 10);
        if (spawnPos != null) {
            spawnHorde(spawnPos, colony, id, horde.numberOfBosses - boss.size(), horde.numberOfArchers - archers.size(), horde.numberOfRaiders - normal.size());
        }
    }
    if (horde.numberOfBosses + horde.numberOfRaiders + horde.numberOfArchers < Math.round(horde.initialSize * 0.05)) {
        status = EventStatus.DONE;
    }
    for (final Entity entity : getEntities()) {
        if (!entity.isAlive() || !WorldUtil.isEntityBlockLoaded(colony.getWorld(), new BlockPos(entity.position()))) {
            entity.remove();
            respawns.add(new Tuple<>(entity.getType(), new BlockPos(entity.position())));
            continue;
        }
        if (colony.getRaiderManager().areSpiesEnabled()) {
            ((LivingEntity) entity).addEffect(new EffectInstance(Effects.GLOWING, 550));
        }
    }
}
Also used : EntityType(net.minecraft.entity.EntityType) LivingEntity(net.minecraft.entity.LivingEntity) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) BlockPos(net.minecraft.util.math.BlockPos) EffectInstance(net.minecraft.potion.EffectInstance)

Example 3 with EntityType

use of net.minecraft.entity.EntityType in project MCDoom by AzureDoom.

the class SummonerEntity method spawnWave.

public void spawnWave() {
    Random rand = new Random();
    List<EntityType<?>> givenList = Arrays.asList(ModEntityTypes.IMP, ModEntityTypes.LOST_SOUL, ModEntityTypes.IMP_STONE);
    for (int i = 0; i < 1; i++) {
        int randomIndex = rand.nextInt(givenList.size());
        EntityType<?> randomElement = givenList.get(randomIndex);
        Entity fireballentity = randomElement.create(world);
        fireballentity.refreshPositionAndAngles(this.getX() + 2.0D, this.getY() + 0.5D, this.getZ() + 2.0D, 0, 0);
        world.spawnEntity(fireballentity);
    }
    for (int i = 0; i < 1; i++) {
        int randomIndex = rand.nextInt(givenList.size());
        EntityType<?> randomElement = givenList.get(randomIndex);
        Entity fireballentity1 = randomElement.create(world);
        fireballentity1.refreshPositionAndAngles(this.getX() + -2.0D, this.getY() + 0.5D, this.getZ() + -2.0D, 0, 0);
        world.spawnEntity(fireballentity1);
    }
    for (int i = 0; i < 1; i++) {
        int randomIndex = rand.nextInt(givenList.size());
        EntityType<?> randomElement = givenList.get(randomIndex);
        Entity fireballentity11 = randomElement.create(world);
        fireballentity11.refreshPositionAndAngles(this.getX() + 1.0D, this.getY() + 0.5D, this.getZ() + 1.0D, 0, 0);
        world.spawnEntity(fireballentity11);
    }
    for (int i = 0; i < 1; i++) {
        int randomIndex = rand.nextInt(givenList.size());
        EntityType<?> randomElement = givenList.get(randomIndex);
        Entity fireballentity111 = randomElement.create(world);
        fireballentity111.refreshPositionAndAngles(this.getX() + -1.0D, this.getY() + 0.5D, this.getZ() + -1.0D, 0, 0);
        world.spawnEntity(fireballentity111);
    }
}
Also used : EntityType(net.minecraft.entity.EntityType) DoomFireEntity(mod.azure.doom.entity.projectiles.entity.DoomFireEntity) MerchantEntity(net.minecraft.entity.passive.MerchantEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) Entity(net.minecraft.entity.Entity) DemonEntity(mod.azure.doom.entity.DemonEntity) Random(java.util.Random) SplittableRandom(java.util.SplittableRandom)

Example 4 with EntityType

use of net.minecraft.entity.EntityType in project MCDoom by AzureDoom.

the class GoreNestEntity method spawnWave.

public void spawnWave() {
    Random rand = new Random();
    List<EntityType<?>> givenList = Arrays.asList(ModEntityTypes.HELLKNIGHT, ModEntityTypes.POSSESSEDSCIENTIST, ModEntityTypes.IMP, ModEntityTypes.PINKY, ModEntityTypes.CACODEMON, ModEntityTypes.CHAINGUNNER, ModEntityTypes.GARGOYLE, ModEntityTypes.HELLKNIGHT2016, ModEntityTypes.LOST_SOUL, ModEntityTypes.POSSESSEDSOLDIER, ModEntityTypes.SHOTGUNGUY, ModEntityTypes.UNWILLING, ModEntityTypes.ZOMBIEMAN, ModEntityTypes.ARACHNOTRON, ModEntityTypes.ARCHVILE, ModEntityTypes.MECHAZOMBIE, ModEntityTypes.PAIN, ModEntityTypes.MANCUBUS);
    SplittableRandom random = new SplittableRandom();
    int r = random.nextInt(-3, 3);
    for (int k = 1; k < 5; ++k) {
        for (int i = 0; i < 1; i++) {
            int randomIndex = rand.nextInt(givenList.size());
            EntityType<?> randomElement = givenList.get(randomIndex);
            Entity fireballentity = randomElement.create(world);
            fireballentity.refreshPositionAndAngles(this.getX() + r, this.getY() + 0.5D, this.getZ() + r, 0, 0);
            world.spawnEntity(fireballentity);
        }
    }
}
Also used : EntityType(net.minecraft.entity.EntityType) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) DemonEntity(mod.azure.doom.entity.DemonEntity) Random(java.util.Random) SplittableRandom(java.util.SplittableRandom) SplittableRandom(java.util.SplittableRandom)

Example 5 with EntityType

use of net.minecraft.entity.EntityType in project Fragile-Glass by fredtargaryen.

the class EntityConfigLoader method parseLine.

/**
 * Parse one line of the file.
 */
@Override
protected void parseLine(boolean add, int changeIndex) throws ConfigLoadException {
    String[] values = line.split(" ");
    // Validate number of values on row
    if (values.length < 3) {
        throw new ConfigLoadException("There must be at least 3 values here.");
    } else {
        try {
            // Get collection of entities described on this line
            Collection<EntityType<?>> entityTypes = KeyParser.getAllEntityTypesForString(values[0]);
            for (EntityType et : entityTypes) {
                // Validate minSpeed and silently clamp to >= 0
                double minSpeedSquared = Double.parseDouble(values[1]);
                minSpeedSquared = Math.max(minSpeedSquared * minSpeedSquared, 0.0);
                // Validate maxSpeed and silently clamp to <= max speed
                double maxSpeedSquared = Double.parseDouble(values[2]);
                maxSpeedSquared = Math.min(maxSpeedSquared * maxSpeedSquared, DataReference.MAXIMUM_ENTITY_SPEED_SQUARED);
                // Ensure minSpeed <= maxSpeed. If not, silently swap the values
                if (minSpeedSquared > maxSpeedSquared) {
                    double temp = minSpeedSquared;
                    minSpeedSquared = maxSpeedSquared;
                    maxSpeedSquared = temp;
                }
                this.entities.put(et, new BreakerData(minSpeedSquared, maxSpeedSquared, Arrays.copyOfRange(values, 3, values.length)));
            }
        } catch (NumberFormatException nfe) {
            // Thrown when speed values can't be parsed as Doubles
            throw new ConfigLoadException("One of your speed values can't be read as a decimal number.");
        } catch (Exception e) {
            throw new ConfigLoadException(e.getMessage());
        }
    }
}
Also used : EntityType(net.minecraft.entity.EntityType) BreakerData(com.fredtargaryen.fragileglass.config.behaviour.data.BreakerData)

Aggregations

EntityType (net.minecraft.entity.EntityType)38 Entity (net.minecraft.entity.Entity)15 CompoundNBT (net.minecraft.nbt.CompoundNBT)10 ResourceLocation (net.minecraft.util.ResourceLocation)10 BlockPos (net.minecraft.util.math.BlockPos)10 LivingEntity (net.minecraft.entity.LivingEntity)9 PlayerEntity (net.minecraft.entity.player.PlayerEntity)7 ItemStack (net.minecraft.item.ItemStack)7 ArrayList (java.util.ArrayList)4 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)4 EffectInstance (net.minecraft.potion.EffectInstance)4 World (net.minecraft.world.World)4 List (java.util.List)3 Nonnull (javax.annotation.Nonnull)3 MobEntity (net.minecraft.entity.MobEntity)3 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)3 IPlacementHandler (com.ldtteam.structurize.placement.handlers.placement.IPlacementHandler)2 HashMap (java.util.HashMap)2 Random (java.util.Random)2 SplittableRandom (java.util.SplittableRandom)2