mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-04 23:06:05 +00:00
reimplement structure probability collections
This commit is contained in:
@@ -6,6 +6,7 @@ import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.tectonic.config.ValidatedConfigTemplate;
|
||||
import com.dfsek.tectonic.exception.ValidationException;
|
||||
import com.dfsek.terra.api.loot.LootTable;
|
||||
import com.dfsek.terra.api.math.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.math.Range;
|
||||
import com.dfsek.terra.api.structures.script.StructureScript;
|
||||
import com.dfsek.terra.api.util.GlueList;
|
||||
@@ -19,9 +20,9 @@ public class StructureTemplate extends AbstractableTemplate implements Validated
|
||||
@Value("id")
|
||||
private String id;
|
||||
|
||||
@Value("script")
|
||||
@Value("scripts")
|
||||
@Abstractable
|
||||
private StructureScript structure;
|
||||
private ProbabilityCollection<StructureScript> structure;
|
||||
|
||||
@Value("spawn.start")
|
||||
@Abstractable
|
||||
@@ -52,7 +53,7 @@ public class StructureTemplate extends AbstractableTemplate implements Validated
|
||||
return id;
|
||||
}
|
||||
|
||||
public StructureScript getStructures() {
|
||||
public ProbabilityCollection<StructureScript> getStructures() {
|
||||
return structure;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,14 +3,15 @@ package com.dfsek.terra.config.templates;
|
||||
import com.dfsek.tectonic.annotations.Abstractable;
|
||||
import com.dfsek.tectonic.annotations.Default;
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.terra.api.math.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.structures.script.StructureScript;
|
||||
import com.dfsek.terra.util.MaterialSet;
|
||||
|
||||
@SuppressWarnings({"unused", "FieldMayBeFinal"})
|
||||
public class TreeTemplate extends AbstractableTemplate {
|
||||
@Value("script")
|
||||
@Value("scripts")
|
||||
@Abstractable
|
||||
private StructureScript structure;
|
||||
private ProbabilityCollection<StructureScript> structure;
|
||||
|
||||
@Value("id")
|
||||
private String id;
|
||||
@@ -24,7 +25,7 @@ public class TreeTemplate extends AbstractableTemplate {
|
||||
@Abstractable
|
||||
private MaterialSet spawnable;
|
||||
|
||||
public StructureScript getStructures() {
|
||||
public ProbabilityCollection<StructureScript> getStructures() {
|
||||
return structure;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.dfsek.terra.generation.items;
|
||||
|
||||
import com.dfsek.terra.api.loot.LootTable;
|
||||
import com.dfsek.terra.api.math.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.math.Range;
|
||||
import com.dfsek.terra.api.structures.script.StructureScript;
|
||||
import com.dfsek.terra.config.templates.StructureTemplate;
|
||||
@@ -10,14 +11,14 @@ import java.util.Map;
|
||||
|
||||
// TODO: implementation
|
||||
public class TerraStructure {
|
||||
private final StructureScript structure;
|
||||
private final ProbabilityCollection<StructureScript> structure;
|
||||
private final Range bound;
|
||||
private final Range spawnStart;
|
||||
private final GridSpawn spawn;
|
||||
private final Map<Integer, LootTable> loot;
|
||||
private final StructureTemplate template;
|
||||
|
||||
public TerraStructure(StructureScript structures, Range bound, Range spawnStart, GridSpawn spawn, Map<Integer, LootTable> loot, StructureTemplate template) {
|
||||
public TerraStructure(ProbabilityCollection<StructureScript> structures, Range bound, Range spawnStart, GridSpawn spawn, Map<Integer, LootTable> loot, StructureTemplate template) {
|
||||
this.structure = structures;
|
||||
this.bound = bound;
|
||||
this.spawnStart = spawnStart;
|
||||
@@ -30,7 +31,7 @@ public class TerraStructure {
|
||||
return template;
|
||||
}
|
||||
|
||||
public StructureScript getStructure() {
|
||||
public ProbabilityCollection<StructureScript> getStructure() {
|
||||
return structure;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.dfsek.terra.generation.items.tree;
|
||||
|
||||
import com.dfsek.terra.api.math.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.math.vector.Location;
|
||||
import com.dfsek.terra.api.structures.script.StructureScript;
|
||||
import com.dfsek.terra.api.structures.structure.Rotation;
|
||||
@@ -11,9 +12,9 @@ import java.util.Random;
|
||||
public class TerraTree implements Tree {
|
||||
private final MaterialSet spawnable;
|
||||
private final int yOffset;
|
||||
private final StructureScript structure;
|
||||
private final ProbabilityCollection<StructureScript> structure;
|
||||
|
||||
public TerraTree(MaterialSet spawnable, int yOffset, StructureScript structure) {
|
||||
public TerraTree(MaterialSet spawnable, int yOffset, ProbabilityCollection<StructureScript> structure) {
|
||||
this.spawnable = spawnable;
|
||||
this.yOffset = yOffset;
|
||||
this.structure = structure;
|
||||
@@ -21,7 +22,7 @@ public class TerraTree implements Tree {
|
||||
|
||||
@Override
|
||||
public synchronized boolean plant(Location location, Random random) {
|
||||
structure.execute(location.clone().add(0, yOffset, 0), random, Rotation.fromDegrees(90 * random.nextInt(4)));
|
||||
structure.get(random).execute(location.clone().add(0, yOffset, 0), random, Rotation.fromDegrees(90 * random.nextInt(4)));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class StructurePopulator implements TerraBlockPopulator {
|
||||
if(!((UserDefinedBiome) grid.getBiome(spawn)).getConfig().getStructures().contains(conf))
|
||||
continue;
|
||||
Random random = new FastRandom(MathUtil.getCarverChunkSeed(FastMath.floorDiv(spawn.getBlockX(), 16), FastMath.floorDiv(spawn.getBlockZ(), 16), world.getSeed()));
|
||||
conf.getStructure().execute(spawn.setY(conf.getSpawnStart().get(random)), chunk, random, Rotation.fromDegrees(90 * random.nextInt(4)));
|
||||
conf.getStructure().get(random).execute(spawn.setY(conf.getSpawnStart().get(random)), chunk, random, Rotation.fromDegrees(90 * random.nextInt(4)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user