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));
}
}
}
}
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));
}
}
}
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);
}
}
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);
}
}
}
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());
}
}
}
Aggregations