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