mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-18 02:22:32 +00:00
Minor optimizations
This commit is contained in:
parent
1b0cbe486f
commit
e43d814169
@ -1,6 +1,5 @@
|
||||
package com.dfsek.terra.async;
|
||||
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.biome.grid.TerraBiomeGrid;
|
||||
import com.dfsek.terra.config.genconfig.structure.StructureConfig;
|
||||
@ -34,7 +33,7 @@ public class AsyncStructureFinder extends AsyncFeatureFinder<StructureConfig> {
|
||||
public boolean isValid(int x, int z, StructureConfig target) {
|
||||
World world = getWorld();
|
||||
Location spawn = target.getSpawn().getChunkSpawn(x, z, world.getSeed()).toLocation(world);
|
||||
if(!TerraWorld.getWorld(world).getConfig().getBiome((UserDefinedBiome) getGrid().getBiome(spawn)).getStructures().contains(target))
|
||||
if(!((UserDefinedBiome) getGrid().getBiome(spawn)).getConfig().getStructures().contains(target))
|
||||
return false;
|
||||
Random r2 = new FastRandom(spawn.hashCode());
|
||||
Structure struc = target.getStructure(r2);
|
||||
|
@ -60,7 +60,7 @@ public class UserDefinedCarver extends Carver {
|
||||
@Override
|
||||
public boolean isChunkCarved(World w, int chunkX, int chunkZ, Random random) {
|
||||
ConfigPack c = TerraWorld.getWorld(w).getConfig();
|
||||
return new FastRandom(random.nextLong() + hash).nextInt(100) < c.getBiome((UserDefinedBiome) TerraWorld.getWorld(w).getGrid().getBiome(chunkX << 4, chunkZ << 4, GenerationPhase.POPULATE)).getCarverChance(this);
|
||||
return new FastRandom(random.nextLong() + hash).nextInt(100) < ((UserDefinedBiome) TerraWorld.getWorld(w).getGrid().getBiome(chunkX << 4, chunkZ << 4, GenerationPhase.POPULATE)).getConfig().getCarverChance(this);
|
||||
}
|
||||
|
||||
private class UserDefinedWorm extends Worm {
|
||||
|
@ -25,7 +25,7 @@ public class BiomeCommand extends WorldCommand {
|
||||
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World w) {
|
||||
TerraBiomeGrid grid = TerraWorld.getWorld(sender.getWorld()).getGrid();
|
||||
UserDefinedBiome biome = (UserDefinedBiome) grid.getBiome(sender.getLocation(), GenerationPhase.POPULATE);
|
||||
LangUtil.send("command.biome.in", sender, TerraWorld.getWorld(w).getConfig().getBiome(biome).getID());
|
||||
LangUtil.send("command.biome.in", sender, biome.getID());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class BiomeInfoCommand extends WorldCommand {
|
||||
sender.sendMessage("Erodible: " + b.isErodible());
|
||||
|
||||
|
||||
BiomeConfig bio = cfg.getBiome(b);
|
||||
BiomeConfig bio = b.getConfig();
|
||||
List<StructureConfig> structureConfigs = bio.getStructures();
|
||||
|
||||
if(structureConfigs.size() == 0) sender.sendMessage("No Structures");
|
||||
|
@ -2,7 +2,6 @@ package com.dfsek.terra.config.base;
|
||||
|
||||
import com.dfsek.terra.Debug;
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.carving.UserDefinedCarver;
|
||||
import com.dfsek.terra.config.ConfigLoader;
|
||||
import com.dfsek.terra.config.exception.ConfigException;
|
||||
@ -274,13 +273,6 @@ public class ConfigPack extends YamlConfiguration {
|
||||
return dataFolder;
|
||||
}
|
||||
|
||||
public BiomeConfig getBiome(UserDefinedBiome b) {
|
||||
for(BiomeConfig biome : biomes.values()) {
|
||||
if(biome.getBiome().equals(b)) return biome;
|
||||
}
|
||||
throw new IllegalArgumentException("No BiomeConfig for provided biome.");
|
||||
}
|
||||
|
||||
public BiomeConfig getBiome(String id) {
|
||||
return biomes.get(id);
|
||||
}
|
||||
|
@ -13,11 +13,13 @@ import java.util.Map;
|
||||
public class BiomeSnowConfig extends TerraConfigSection {
|
||||
private final int[] snowHeights;
|
||||
private boolean doSnow = false;
|
||||
private final boolean physics;
|
||||
|
||||
public BiomeSnowConfig(TerraConfig parent) throws InvalidConfigurationException {
|
||||
super(parent);
|
||||
snowHeights = new int[256];
|
||||
List<Map<?, ?>> maps = parent.getMapList("snow");
|
||||
this.physics = getParent().getBoolean("snow-physics", false);
|
||||
if(maps.size() == 0) return;
|
||||
try {
|
||||
for(Map<?, ?> e : maps) {
|
||||
@ -41,4 +43,8 @@ public class BiomeSnowConfig extends TerraConfigSection {
|
||||
public boolean doSnow() {
|
||||
return doSnow;
|
||||
}
|
||||
|
||||
public boolean doPhysics() {
|
||||
return physics;
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class DebugFrame extends JFrame implements ActionListener {
|
||||
xp = (int) (((double) FastMath.floorMod(p.getLocation().getBlockX(), x) / x) * getWidth());
|
||||
zp = (int) (((double) FastMath.floorMod(p.getLocation().getBlockZ(), z) / z) * getHeight());
|
||||
}
|
||||
String str = TerraWorld.getWorld(p.getWorld()).getConfig().getBiome((UserDefinedBiome) TerraWorld.getWorld(p.getWorld()).getGrid().getBiome(p.getLocation(), GenerationPhase.POPULATE)).getID();
|
||||
String str = ((UserDefinedBiome) TerraWorld.getWorld(p.getWorld()).getGrid().getBiome(p.getLocation(), GenerationPhase.POPULATE)).getID();
|
||||
g.setColor(new Color(255, 255, 255, 128));
|
||||
g.fillRect(xp + 13, zp - 13, (int) (8 + 8.25 * str.length()), 33);
|
||||
g.setColor(Color.BLACK);
|
||||
|
@ -5,7 +5,6 @@ import com.dfsek.terra.TerraProfiler;
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.biome.grid.TerraBiomeGrid;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.genconfig.biome.BiomeConfig;
|
||||
import com.dfsek.terra.config.genconfig.biome.BiomeFloraConfig;
|
||||
import com.dfsek.terra.event.TreeGenerateEvent;
|
||||
@ -34,7 +33,7 @@ public class FloraPopulator extends GaeaBlockPopulator {
|
||||
private static boolean doTrees(@NotNull UserDefinedBiome biome, TerraWorld world, @NotNull Random random, @NotNull Chunk chunk, int x, int z) {
|
||||
for(Block block : getValidTreeSpawnsAt(chunk, x, z, new Range(0, 254))) {
|
||||
Tree tree = biome.getDecorator().getTrees().get(random);
|
||||
Range range = world.getConfig().getBiome(biome).getTreeRange(tree);
|
||||
Range range = biome.getConfig().getTreeRange(tree);
|
||||
if(!range.isInRange(block.getY())) continue;
|
||||
try {
|
||||
Location l = block.getLocation();
|
||||
@ -70,7 +69,6 @@ public class FloraPopulator extends GaeaBlockPopulator {
|
||||
int originX = chunk.getX() << 4;
|
||||
int originZ = chunk.getZ() << 4;
|
||||
TerraBiomeGrid grid = tw.getGrid();
|
||||
ConfigPack config = tw.getConfig();
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
UserDefinedBiome biome = (UserDefinedBiome) grid.getBiome((chunk.getX() << 4) + x, (chunk.getZ() << 4) + z, GenerationPhase.POPULATE);
|
||||
@ -84,7 +82,7 @@ public class FloraPopulator extends GaeaBlockPopulator {
|
||||
}
|
||||
if(biome.getDecorator().getFloraChance() <= 0) continue;
|
||||
try {
|
||||
BiomeConfig c = config.getBiome(biome);
|
||||
BiomeConfig c = biome.getConfig();
|
||||
BiomeFloraConfig f = c.getFlora();
|
||||
for(int i = 0; i < f.getFloraAttempts(); i++) {
|
||||
Flora item;
|
||||
|
@ -55,7 +55,7 @@ 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));
|
||||
BiomeConfig biome = ((UserDefinedBiome) g.getBiome(origX + x, origZ + z, GenerationPhase.PALETTE_APPLY)).getConfig();
|
||||
if(!biome.getSnow().doSnow()) continue;
|
||||
int y;
|
||||
Block b = null;
|
||||
@ -66,7 +66,7 @@ public class SnowPopulator extends GaeaBlockPopulator {
|
||||
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);
|
||||
chunk.getBlock(x, ++y, z).setBlockData(DataUtil.SNOW, biome.getSnow().doPhysics());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class StructurePopulator extends BlockPopulator {
|
||||
structure:
|
||||
for(StructureConfig conf : config.getAllStructures()) {
|
||||
Location spawn = conf.getSpawn().getNearestSpawn(cx + 8, cz + 8, world.getSeed()).toLocation(world);
|
||||
if(!config.getBiome((UserDefinedBiome) grid.getBiome(spawn)).getStructures().contains(conf)) continue;
|
||||
if(!((UserDefinedBiome) grid.getBiome(spawn)).getConfig().getStructures().contains(conf)) continue;
|
||||
Random r2 = new FastRandom(spawn.hashCode());
|
||||
Structure struc = conf.getStructure(r2);
|
||||
Rotation rotation = Rotation.fromDegrees(r2.nextInt(4) * 90);
|
||||
|
@ -2,7 +2,6 @@ package com.dfsek.terra.structure.spawn;
|
||||
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.genconfig.biome.BiomeConfig;
|
||||
import com.dfsek.terra.generation.config.WorldGenerator;
|
||||
import org.bukkit.World;
|
||||
@ -16,9 +15,8 @@ public class AirSpawn extends Requirement {
|
||||
@Override
|
||||
public boolean matches(int x, int y, int z) {
|
||||
TerraWorld tw = TerraWorld.getWorld(getWorld());
|
||||
ConfigPack wc = tw.getConfig();
|
||||
UserDefinedBiome b = (UserDefinedBiome) tw.getGrid().getBiome(x, z, GenerationPhase.POPULATE);
|
||||
BiomeConfig c = wc.getBiome(b);
|
||||
BiomeConfig c = b.getConfig();
|
||||
if(y <= c.getOcean().getSeaLevel()) return false;
|
||||
int yf = (int) (y - ((WorldGenerator) b.getGenerator()).getElevation(x, z));
|
||||
return b.getGenerator().getNoise(getNoise(), getWorld(), x, yf, z) <= 0;
|
||||
|
@ -16,7 +16,7 @@ public class OceanSpawn extends Requirement {
|
||||
public boolean matches(int x, int y, int z) {
|
||||
TerraWorld tw = TerraWorld.getWorld(getWorld());
|
||||
UserDefinedBiome b = (UserDefinedBiome) tw.getGrid().getBiome(x, z, GenerationPhase.POPULATE);
|
||||
BiomeConfig c = tw.getConfig().getBiome(b);
|
||||
BiomeConfig c = b.getConfig();
|
||||
if(y > c.getOcean().getSeaLevel()) return false;
|
||||
int yf = (int) (y - ((WorldGenerator) b.getGenerator()).getElevation(x, z));
|
||||
return b.getGenerator().getNoise(getNoise(), getWorld(), x, yf, z) <= 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user