mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-15 21:31:05 +00:00
profile more things
This commit is contained in:
@@ -18,7 +18,7 @@ public class OreHolderLoader implements TypeLoader<OreHolder> {
|
|||||||
Map<String, Object> map = (Map<String, Object>) o;
|
Map<String, Object> map = (Map<String, Object>) o;
|
||||||
|
|
||||||
for(Map.Entry<String, Object> entry : map.entrySet()) {
|
for(Map.Entry<String, Object> entry : map.entrySet()) {
|
||||||
holder.add(configLoader.loadClass(Ore.class, entry.getKey()), (OreConfig) configLoader.loadType(OreConfig.class, entry.getValue()));
|
holder.add(configLoader.loadClass(Ore.class, entry.getKey()), configLoader.loadClass(OreConfig.class, entry.getValue()), entry.getKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
return holder;
|
return holder;
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public class CavePopulator implements TerraBlockPopulator, Chunkified {
|
|||||||
Map<Location, BlockData> shiftCandidate = new HashMap<>();
|
Map<Location, BlockData> shiftCandidate = new HashMap<>();
|
||||||
Set<Block> updateNeeded = new HashSet<>();
|
Set<Block> updateNeeded = new HashSet<>();
|
||||||
c.carve(chunk.getX(), chunk.getZ(), world, (v, type) -> {
|
c.carve(chunk.getX(), chunk.getZ(), world, (v, type) -> {
|
||||||
|
try(ProfileFrame ignored = main.getProfiler().profile("carving:" + c.getConfig().getID())) {
|
||||||
Block b = chunk.getBlock(v.getBlockX(), v.getBlockY(), v.getBlockZ());
|
Block b = chunk.getBlock(v.getBlockX(), v.getBlockY(), v.getBlockZ());
|
||||||
BlockData m = b.getBlockData();
|
BlockData m = b.getBlockData();
|
||||||
BlockType re = m.getBlockType();
|
BlockType re = m.getBlockType();
|
||||||
@@ -82,6 +83,7 @@ public class CavePopulator implements TerraBlockPopulator, Chunkified {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
for(Map.Entry<Location, BlockData> entry : shiftCandidate.entrySet()) {
|
for(Map.Entry<Location, BlockData> entry : shiftCandidate.entrySet()) {
|
||||||
Location l = entry.getKey();
|
Location l = entry.getKey();
|
||||||
|
|||||||
@@ -40,11 +40,13 @@ public class OrePopulator implements TerraBlockPopulator {
|
|||||||
BiomeTemplate config = ((UserDefinedBiome) b).getConfig();
|
BiomeTemplate config = ((UserDefinedBiome) b).getConfig();
|
||||||
int finalCx = cx;
|
int finalCx = cx;
|
||||||
int finalCz = cz;
|
int finalCz = cz;
|
||||||
config.getOreHolder().forEach((ore, oreConfig) -> {
|
config.getOreHolder().forEach((id, orePair) -> {
|
||||||
int amount = oreConfig.getAmount().get(random);
|
try(ProfileFrame ignored = main.getProfiler().profile("ore:" + id)) {
|
||||||
|
int amount = orePair.getRight().getAmount().get(random);
|
||||||
for(int i = 0; i < amount; i++) {
|
for(int i = 0; i < amount; i++) {
|
||||||
Vector3 location = new Vector3(random.nextInt(16) + 16 * finalCx, oreConfig.getHeight().get(random), random.nextInt(16) + 16 * finalCz);
|
Vector3 location = new Vector3(random.nextInt(16) + 16 * finalCx, orePair.getRight().getHeight().get(random), random.nextInt(16) + 16 * finalCz);
|
||||||
ore.generate(location, chunk, random);
|
orePair.getLeft().generate(location, chunk, random);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class TreePopulator implements TerraBlockPopulator {
|
|||||||
for(int z = 0; z < 16; z += 2) {
|
for(int z = 0; z < 16; z += 2) {
|
||||||
UserDefinedBiome biome = (UserDefinedBiome) provider.getBiome((chunk.getX() << 4) + x, (chunk.getZ() << 4) + z);
|
UserDefinedBiome biome = (UserDefinedBiome) provider.getBiome((chunk.getX() << 4) + x, (chunk.getZ() << 4) + z);
|
||||||
for(TreeLayer layer : biome.getConfig().getTrees()) {
|
for(TreeLayer layer : biome.getConfig().getTrees()) {
|
||||||
if(layer.getDensity() >= random.nextDouble() * 100)
|
if(layer.getDensity() >= random.nextDouble() * 100) {
|
||||||
layer.place(chunk, new Vector2(offset(random, x), offset(random, z)));
|
layer.place(chunk, new Vector2(offset(random, x), offset(random, z)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -50,3 +50,4 @@ public class TreePopulator implements TerraBlockPopulator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ public abstract class Ore {
|
|||||||
protected TerraPlugin main;
|
protected TerraPlugin main;
|
||||||
|
|
||||||
public Ore(BlockData material, MaterialSet replaceable, boolean applyGravity, TerraPlugin main) {
|
public Ore(BlockData material, MaterialSet replaceable, boolean applyGravity, TerraPlugin main) {
|
||||||
|
|
||||||
this.material = material;
|
this.material = material;
|
||||||
this.replaceable = replaceable;
|
this.replaceable = replaceable;
|
||||||
this.applyGravity = applyGravity;
|
this.applyGravity = applyGravity;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.dfsek.terra.world.population.items.ores;
|
package com.dfsek.terra.world.population.items.ores;
|
||||||
|
|
||||||
import com.dfsek.terra.api.util.GlueList;
|
import com.dfsek.terra.api.util.GlueList;
|
||||||
|
import com.dfsek.terra.api.util.generic.pair.ImmutablePair;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
@@ -11,22 +12,24 @@ import java.util.function.BiConsumer;
|
|||||||
public class OreHolder {
|
public class OreHolder {
|
||||||
private final List<Entry> entries = new GlueList<>();
|
private final List<Entry> entries = new GlueList<>();
|
||||||
|
|
||||||
public void forEach(BiConsumer<Ore, OreConfig> consumer) {
|
public void forEach(BiConsumer<String, ImmutablePair<Ore, OreConfig>> consumer) {
|
||||||
entries.forEach(entry -> consumer.accept(entry.getOre(), entry.getConfig()));
|
entries.forEach(entry -> consumer.accept(entry.getId(), ImmutablePair.of(entry.getOre(), entry.getConfig())));
|
||||||
}
|
}
|
||||||
|
|
||||||
public OreHolder add(Ore ore, OreConfig config) {
|
public OreHolder add(Ore ore, OreConfig config, String id) {
|
||||||
entries.add(new Entry(ore, config));
|
entries.add(new Entry(ore, config, id));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class Entry {
|
private static final class Entry {
|
||||||
private final Ore ore;
|
private final Ore ore;
|
||||||
private final OreConfig config;
|
private final OreConfig config;
|
||||||
|
private final String id;
|
||||||
|
|
||||||
private Entry(Ore ore, OreConfig config) {
|
private Entry(Ore ore, OreConfig config, String id) {
|
||||||
this.ore = ore;
|
this.ore = ore;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OreConfig getConfig() {
|
public OreConfig getConfig() {
|
||||||
@@ -36,5 +39,9 @@ public class OreHolder {
|
|||||||
public Ore getOre() {
|
public Ore getOre() {
|
||||||
return ore;
|
return ore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ import com.dfsek.terra.api.math.vector.Location;
|
|||||||
import com.dfsek.terra.api.platform.handle.WorldHandle;
|
import com.dfsek.terra.api.platform.handle.WorldHandle;
|
||||||
import com.dfsek.terra.api.platform.world.Tree;
|
import com.dfsek.terra.api.platform.world.Tree;
|
||||||
import com.dfsek.terra.api.util.collections.MaterialSet;
|
import com.dfsek.terra.api.util.collections.MaterialSet;
|
||||||
|
import com.dfsek.terra.profiler.ProfileFrame;
|
||||||
import org.bukkit.TreeType;
|
import org.bukkit.TreeType;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class BukkitTree implements Tree {
|
public class BukkitTree implements Tree {
|
||||||
@@ -41,8 +43,10 @@ public class BukkitTree implements Tree {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean plant(Location l, Random r) {
|
public boolean plant(Location l, Random r) {
|
||||||
|
try(ProfileFrame ignore = main.getProfiler().profile("bukkit_tree:" + delegate.toString().toLowerCase(Locale.ROOT))) {
|
||||||
return ((BukkitWorld) l.getWorld()).getHandle().generateTree(BukkitAdapter.adapt(l), delegate);
|
return ((BukkitWorld) l.getWorld()).getHandle().generateTree(BukkitAdapter.adapt(l), delegate);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MaterialSet getSpawnable() {
|
public MaterialSet getSpawnable() {
|
||||||
|
|||||||
@@ -6,11 +6,13 @@ import com.dfsek.terra.api.util.collections.MaterialSet;
|
|||||||
import com.dfsek.terra.fabric.TerraFabricPlugin;
|
import com.dfsek.terra.fabric.TerraFabricPlugin;
|
||||||
import com.dfsek.terra.fabric.world.generator.FabricChunkGenerator;
|
import com.dfsek.terra.fabric.world.generator.FabricChunkGenerator;
|
||||||
import com.dfsek.terra.fabric.world.handles.world.FabricWorldAccess;
|
import com.dfsek.terra.fabric.world.handles.world.FabricWorldAccess;
|
||||||
|
import com.dfsek.terra.profiler.ProfileFrame;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.StructureWorldAccess;
|
import net.minecraft.world.StructureWorldAccess;
|
||||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class FabricTree implements Tree {
|
public class FabricTree implements Tree {
|
||||||
@@ -22,10 +24,12 @@ public class FabricTree implements Tree {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean plant(Location l, Random r) {
|
public boolean plant(Location l, Random r) {
|
||||||
|
try(ProfileFrame ignore = TerraFabricPlugin.getInstance().getProfiler().profile("fabric_tree:" + delegate.toString().toLowerCase(Locale.ROOT))) {
|
||||||
FabricWorldAccess fabricWorldAccess = ((FabricWorldAccess) l.getWorld());
|
FabricWorldAccess fabricWorldAccess = ((FabricWorldAccess) l.getWorld());
|
||||||
ChunkGenerator generatorWrapper = ((FabricChunkGenerator) fabricWorldAccess.getGenerator()).getHandle();
|
ChunkGenerator generatorWrapper = ((FabricChunkGenerator) fabricWorldAccess.getGenerator()).getHandle();
|
||||||
return delegate.generate((StructureWorldAccess) fabricWorldAccess.getHandle(), generatorWrapper, r, new BlockPos(l.getBlockX(), l.getBlockY(), l.getBlockZ()));
|
return delegate.generate((StructureWorldAccess) fabricWorldAccess.getHandle(), generatorWrapper, r, new BlockPos(l.getBlockX(), l.getBlockY(), l.getBlockZ()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MaterialSet getSpawnable() {
|
public MaterialSet getSpawnable() {
|
||||||
|
|||||||
Reference in New Issue
Block a user