use of net.minecraft.entity.EntityClassification in project Arclight by IzzelAliz.
the class ServerChunkProviderMixin method tickChunks.
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
private void tickChunks() {
long i = this.world.getGameTime();
long j = i - this.lastGameTime;
this.lastGameTime = i;
WorldInfo worldinfo = this.world.getWorldInfo();
boolean flag = worldinfo.getGenerator() == WorldType.DEBUG_ALL_BLOCK_STATES;
boolean flag1 = this.world.getGameRules().getBoolean(GameRules.DO_MOB_SPAWNING) && !this.world.getPlayers().isEmpty();
if (!flag) {
this.world.getProfiler().startSection("pollingChunks");
int k = this.world.getGameRules().getInt(GameRules.RANDOM_TICK_SPEED);
BlockPos blockpos = this.world.getSpawnPoint();
boolean spawnAnimal = ((WorldBridge) this.world).bridge$ticksPerAnimalSpawns() != 0 && worldinfo.getGameTime() % ((WorldBridge) this.world).bridge$ticksPerAnimalSpawns() == 0;
boolean spawnMonster = ((WorldBridge) this.world).bridge$ticksPerMonsterSpawns() != 0 && worldinfo.getGameTime() % ((WorldBridge) this.world).bridge$ticksPerMonsterSpawns() == 0;
boolean spawnWater = ((WorldBridge) this.world).bridge$ticksPerWaterSpawns() != 0 && worldinfo.getGameTime() % ((WorldBridge) this.world).bridge$ticksPerWaterSpawns() == 0;
boolean spawnAmbient = ((WorldBridge) this.world).bridge$ticksPerAmbientSpawns() != 0 && worldinfo.getGameTime() % ((WorldBridge) this.world).bridge$ticksPerAmbientSpawns() == 0;
boolean flag2 = spawnAnimal;
this.world.getProfiler().startSection("naturalSpawnCount");
int l = this.ticketManager.getSpawningChunksCount();
EntityClassification[] aentityclassification = EntityClassification.values();
Object2IntMap<EntityClassification> object2intmap = this.world.countEntities();
this.world.getProfiler().endSection();
((ChunkManagerBridge) this.chunkManager).bridge$getLoadedChunksIterable().forEach((p_223434_10_) -> {
Optional<Chunk> optional = p_223434_10_.getEntityTickingFuture().getNow(ChunkHolder.UNLOADED_CHUNK).left();
if (optional.isPresent()) {
Chunk chunk = optional.get();
this.world.getProfiler().startSection("broadcast");
p_223434_10_.sendChanges(chunk);
this.world.getProfiler().endSection();
ChunkPos chunkpos = p_223434_10_.getPosition();
if (!((ChunkManagerBridge) this.chunkManager).bridge$isOutsideSpawningRadius(chunkpos)) {
chunk.setInhabitedTime(chunk.getInhabitedTime() + j);
if (flag1 && (this.spawnHostiles || this.spawnPassives) && this.world.getWorldBorder().contains(chunk.getPos())) {
this.world.getProfiler().startSection("spawner");
for (EntityClassification entityclassification : aentityclassification) {
boolean spawnThisTick = true;
int limit = entityclassification.getMaxNumberOfCreature();
switch(entityclassification) {
case MONSTER:
spawnThisTick = spawnMonster;
limit = ((WorldBridge) world).bridge$getWorld().getMonsterSpawnLimit();
break;
case CREATURE:
spawnThisTick = spawnAnimal;
limit = ((WorldBridge) world).bridge$getWorld().getAnimalSpawnLimit();
break;
case WATER_CREATURE:
spawnThisTick = spawnWater;
limit = ((WorldBridge) world).bridge$getWorld().getWaterAnimalSpawnLimit();
break;
case AMBIENT:
spawnThisTick = spawnAmbient;
limit = ((WorldBridge) world).bridge$getWorld().getAmbientSpawnLimit();
break;
}
if (!spawnThisTick || limit == 0) {
continue;
}
if (entityclassification != EntityClassification.MISC && (!entityclassification.getPeacefulCreature() || this.spawnPassives) && (entityclassification.getPeacefulCreature() || this.spawnHostiles) && (!entityclassification.getAnimal() || flag2)) {
int i1 = limit * l / field_217238_b;
if (object2intmap.getInt(entityclassification) <= i1) {
this.bridge$worldNaturalSpawn(entityclassification, this.world, chunk, blockpos);
}
}
}
this.world.getProfiler().endSection();
}
this.world.tickEnvironment(chunk, k);
}
}
});
this.world.getProfiler().startSection("customSpawners");
if (flag1) {
this.generator.spawnMobs(this.world, this.spawnHostiles, this.spawnPassives);
}
this.world.getProfiler().endSection();
this.world.getProfiler().endSection();
}
((ChunkManagerBridge) this.chunkManager).bridge$tickEntityTracker();
}
Aggregations