mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-18 10:32:30 +00:00
Add snow to profiler, improve snow performance.
This commit is contained in:
parent
aa378b40ec
commit
59e1d6f146
@ -20,6 +20,7 @@ public class TerraProfiler extends WorldProfiler {
|
||||
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "CaveTime")
|
||||
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "StructureTime")
|
||||
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "StructurePasteTime")
|
||||
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "SnowTime")
|
||||
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "CaveBlockUpdate");
|
||||
profilerMap.put(w, this);
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import com.dfsek.terra.config.TerraConfig;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.genconfig.StructureConfig;
|
||||
import com.dfsek.terra.config.genconfig.biome.BiomeConfig;
|
||||
import com.dfsek.terra.config.genconfig.biome.BiomeSnowConfig;
|
||||
import com.dfsek.terra.config.lang.LangUtil;
|
||||
import com.dfsek.terra.generation.TerraChunkGenerator;
|
||||
import org.bukkit.World;
|
||||
@ -36,13 +37,51 @@ public class BiomeInfoCommand extends WorldCommand {
|
||||
sender.sendMessage("Biome info for \"" + b.getID() + "\".");
|
||||
sender.sendMessage("Vanilla biome: " + b.getVanillaBiome());
|
||||
sender.sendMessage("Erodible: " + b.isErodible());
|
||||
|
||||
|
||||
BiomeConfig bio = cfg.getBiome(b);
|
||||
List<StructureConfig> structureConfigs = bio.getStructures();
|
||||
|
||||
if(structureConfigs.size() == 0) sender.sendMessage("No Structures");
|
||||
else {
|
||||
sender.sendMessage("-------Structures-------");
|
||||
|
||||
List<StructureConfig> structureConfigs = cfg.getBiome(b).getStructures();
|
||||
|
||||
for(StructureConfig c : structureConfigs) {
|
||||
sender.sendMessage(" - " + c.getID());
|
||||
}
|
||||
}
|
||||
|
||||
// Get snow info
|
||||
BiomeSnowConfig snowConfig = bio.getSnow();
|
||||
StringBuilder snowMessage = new StringBuilder("----------Snow----------\n");
|
||||
int comp = snowConfig.getSnowChance(0);
|
||||
int compHeight = 0;
|
||||
boolean changed = false;
|
||||
// Rebuild original snow data (rather than simply getting it, since it may have changed during initial assembly, if any overlaps occurred)
|
||||
for(int i = 0; i <= 255; i++) {
|
||||
int snow = snowConfig.getSnowChance(i);
|
||||
if(snow != comp) {
|
||||
changed = true;
|
||||
snowMessage.append("Y=")
|
||||
.append(compHeight)
|
||||
.append("-")
|
||||
.append(i)
|
||||
.append(": ")
|
||||
.append(comp)
|
||||
.append("% snow\n");
|
||||
comp = snow;
|
||||
compHeight = i;
|
||||
}
|
||||
}
|
||||
if(!changed) {
|
||||
snowMessage.append("Y=0")
|
||||
.append("-255")
|
||||
.append(": ")
|
||||
.append(comp)
|
||||
.append("% snow\n");
|
||||
}
|
||||
sender.sendMessage(snowMessage.toString());
|
||||
|
||||
sender.sendMessage("Do snow: " + snowConfig.doSnow());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
package com.dfsek.terra.population;
|
||||
|
||||
import com.dfsek.terra.TerraProfiler;
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.biome.TerraBiomeGrid;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.base.ConfigUtil;
|
||||
import com.dfsek.terra.config.genconfig.biome.BiomeConfig;
|
||||
import com.dfsek.terra.util.DataUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
@ -15,6 +17,7 @@ import org.bukkit.block.data.BlockData;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.polydev.gaea.generation.GenerationPhase;
|
||||
import org.polydev.gaea.population.GaeaBlockPopulator;
|
||||
import org.polydev.gaea.profiler.ProfileFuture;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
@ -43,6 +46,7 @@ public class SnowPopulator extends GaeaBlockPopulator {
|
||||
}
|
||||
@Override
|
||||
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
||||
try (ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("SnowTime")) {
|
||||
int origX = chunk.getX() << 4;
|
||||
int origZ = chunk.getZ() << 4;
|
||||
TerraWorld w = TerraWorld.getWorld(world);
|
||||
@ -50,16 +54,20 @@ public class SnowPopulator extends GaeaBlockPopulator {
|
||||
TerraBiomeGrid g = w.getGrid();
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
BiomeConfig biome = w.getConfig().getBiome((UserDefinedBiome) g.getBiome(origX + x, origZ + z, GenerationPhase.PALETTE_APPLY));
|
||||
if(!biome.getSnow().doSnow()) continue;
|
||||
int y;
|
||||
Block b = null;
|
||||
for(y = 254; y > 0; y--) {
|
||||
b = chunk.getBlock(x, y, z);
|
||||
if(! b.getType().isAir()) break;
|
||||
}
|
||||
if(random.nextInt(100) >= w.getConfig().getBiome((UserDefinedBiome) g.getBiome(origX+x, origZ+z, GenerationPhase.PALETTE_APPLY)).getSnow().getSnowChance(y)) continue;
|
||||
if(random.nextInt(100) >= biome.getSnow().getSnowChance(y))
|
||||
continue;
|
||||
if(blacklistSpawn.contains(b.getType()) || b.isPassable()) continue;
|
||||
chunk.getBlock(x, ++ y, z).setBlockData(DataUtil.SNOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user