mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
structure addon work
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package com.dfsek.terra.addons.structure;
|
||||
|
||||
import com.dfsek.terra.api.properties.Properties;
|
||||
import com.dfsek.terra.api.structure.ConfiguredStructure;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class BiomeStructures implements Properties {
|
||||
private final Set<ConfiguredStructure> structures;
|
||||
|
||||
public BiomeStructures(Set<ConfiguredStructure> structures) {
|
||||
this.structures = structures;
|
||||
}
|
||||
|
||||
public Set<ConfiguredStructure> getStructures() {
|
||||
return structures;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.dfsek.terra.addons.structure;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Default;
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
||||
import com.dfsek.terra.api.structure.ConfiguredStructure;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
public class BiomeStructuresTemplate implements ObjectTemplate<BiomeStructures> {
|
||||
@Value("structures")
|
||||
@Default
|
||||
private Set<ConfiguredStructure> structures = Collections.emptySet();
|
||||
|
||||
@Override
|
||||
public BiomeStructures get() {
|
||||
return new BiomeStructures(structures);
|
||||
}
|
||||
}
|
||||
@@ -39,8 +39,9 @@ public class StructurePopulator implements TerraGenerationStage, Chunkified {
|
||||
for(ConfiguredStructure conf : config.getRegistry(TerraStructure.class).entries()) {
|
||||
Vector3 spawn = conf.getSpawn().getNearestSpawn(cx + 8, cz + 8, world.getSeed());
|
||||
|
||||
//if(!((UserDefinedBiome) provider.getBiome(spawn)).getConfig().getStructures().contains(conf))
|
||||
// continue;
|
||||
if(!provider.getBiome(spawn).getContext().get(BiomeStructures.class).getStructures().contains(conf)) {
|
||||
continue;
|
||||
}
|
||||
Random random = new Random(PopulationUtil.getCarverChunkSeed(FastMath.floorDiv(spawn.getBlockX(), 16), FastMath.floorDiv(spawn.getBlockZ(), 16), world.getSeed()));
|
||||
conf.getStructure().get(random).generate(spawn.setY(conf.getSpawnStart().get(random)), world, chunk, random, Rotation.fromDegrees(90 * random.nextInt(4)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user