mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-03 00:15:35 +00:00
Revert "use getUngeneratedBlock for trees"
This reverts commit ca8cc8bc
This commit is contained in:
parent
ca8cc8bc66
commit
56a0d5d15b
@ -45,11 +45,11 @@ public class GenericLoaders implements LoaderRegistrar {
|
||||
.registerLoader(GridSpawn.class, new GridSpawnLoader())
|
||||
.registerLoader(PaletteHolder.class, new PaletteHolderLoader())
|
||||
.registerLoader(PaletteLayer.class, new PaletteLayerLoader())
|
||||
.registerLoader(FloraLayer.class, new FloraLayerLoader(main))
|
||||
.registerLoader(FloraLayer.class, new FloraLayerLoader())
|
||||
.registerLoader(Ore.Type.class, (t, o, l) -> Ore.Type.valueOf(o.toString()))
|
||||
.registerLoader(OreConfig.class, new OreConfigLoader())
|
||||
.registerLoader(NoiseBuilder.class, new NoiseBuilderLoader())
|
||||
.registerLoader(TreeLayer.class, new TreeLayerLoader(main))
|
||||
.registerLoader(TreeLayer.class, new TreeLayerLoader())
|
||||
.registerLoader(MaterialSet.class, new MaterialSetLoader())
|
||||
.registerLoader(OreHolder.class, new OreHolderLoader())
|
||||
.registerLoader(TerraFlora.Search.class, (t, o, l) -> TerraFlora.Search.valueOf(o.toString()))
|
||||
|
@ -186,10 +186,6 @@ public class Vector2 implements Cloneable {
|
||||
return FastMath.floorToInt(z);
|
||||
}
|
||||
|
||||
public Vector3 toVector3(double y) {
|
||||
return new Vector3(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "(" + x + ", " + z + ")";
|
||||
|
@ -68,7 +68,7 @@ public class StructureScript {
|
||||
.registerFunction("loot", new LootFunctionBuilder(main, lootRegistry))
|
||||
.registerFunction("entity", new EntityFunctionBuilder(main))
|
||||
.registerFunction("getBiome", new BiomeFunctionBuilder(main))
|
||||
.registerFunction("getBlock", new CheckBlockFunctionBuilder(main))
|
||||
.registerFunction("getBlock", new CheckBlockFunctionBuilder())
|
||||
.registerFunction("state", new StateFunctionBuilder(main))
|
||||
.registerFunction("originX", new ZeroArgFunctionBuilder<Number>(arguments -> arguments.getBuffer().getOrigin().getX(), Returnable.ReturnType.NUMBER))
|
||||
.registerFunction("originY", new ZeroArgFunctionBuilder<Number>(arguments -> arguments.getBuffer().getOrigin().getY(), Returnable.ReturnType.NUMBER))
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.dfsek.terra.api.structures.script.builders;
|
||||
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.api.structures.parser.lang.Returnable;
|
||||
import com.dfsek.terra.api.structures.parser.lang.functions.FunctionBuilder;
|
||||
import com.dfsek.terra.api.structures.script.functions.CheckBlockFunction;
|
||||
@ -9,16 +8,10 @@ import com.dfsek.terra.api.structures.tokenizer.Position;
|
||||
import java.util.List;
|
||||
|
||||
public class CheckBlockFunctionBuilder implements FunctionBuilder<CheckBlockFunction> {
|
||||
private final TerraPlugin main;
|
||||
|
||||
public CheckBlockFunctionBuilder(TerraPlugin main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public CheckBlockFunction build(List<Returnable<?>> argumentList, Position position) {
|
||||
return new CheckBlockFunction((Returnable<Number>) argumentList.get(0), (Returnable<Number>) argumentList.get(1), (Returnable<Number>) argumentList.get(2), position, main);
|
||||
return new CheckBlockFunction((Returnable<Number>) argumentList.get(0), (Returnable<Number>) argumentList.get(1), (Returnable<Number>) argumentList.get(2), position);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,10 +1,7 @@
|
||||
package com.dfsek.terra.api.structures.script.functions;
|
||||
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.api.math.vector.Vector2;
|
||||
import com.dfsek.terra.api.math.vector.Vector3;
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.structures.parser.lang.ImplementationArguments;
|
||||
import com.dfsek.terra.api.structures.parser.lang.Returnable;
|
||||
import com.dfsek.terra.api.structures.parser.lang.functions.Function;
|
||||
@ -16,14 +13,12 @@ import net.jafama.FastMath;
|
||||
public class CheckBlockFunction implements Function<String> {
|
||||
private final Returnable<Number> x, y, z;
|
||||
private final Position position;
|
||||
private final TerraPlugin main;
|
||||
|
||||
public CheckBlockFunction(Returnable<Number> x, Returnable<Number> y, Returnable<Number> z, Position position, TerraPlugin main) {
|
||||
public CheckBlockFunction(Returnable<Number> x, Returnable<Number> y, Returnable<Number> z, Position position) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.position = position;
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
|
||||
@ -35,11 +30,7 @@ public class CheckBlockFunction implements Function<String> {
|
||||
|
||||
RotationUtil.rotateVector(xz, arguments.getRotation());
|
||||
|
||||
TerraWorld world = main.getWorld(arguments.getBuffer().getOrigin().getWorld());
|
||||
|
||||
BlockData blockData = world.getUngeneratedBlock(arguments.getBuffer().getOrigin().clone().add(new Vector3(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments).doubleValue(), FastMath.roundToInt(xz.getZ()))));
|
||||
|
||||
String data = blockData.getAsString();
|
||||
String data = arguments.getBuffer().getOrigin().clone().add(new Vector3(FastMath.roundToInt(xz.getX()), y.apply(implementationArguments).doubleValue(), FastMath.roundToInt(xz.getZ()))).getBlock().getBlockData().getAsString();
|
||||
if(data.contains("[")) return data.substring(0, data.indexOf('[')); // Strip properties
|
||||
else return data;
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ import com.dfsek.tectonic.loading.TypeLoader;
|
||||
import com.dfsek.terra.api.math.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.math.Range;
|
||||
import com.dfsek.terra.api.math.noise.samplers.FastNoiseLite;
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.api.world.flora.Flora;
|
||||
import com.dfsek.terra.config.loaders.Types;
|
||||
import com.dfsek.terra.generation.config.NoiseBuilder;
|
||||
@ -18,12 +17,6 @@ import java.util.Map;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class FloraLayerLoader implements TypeLoader<FloraLayer> {
|
||||
private final TerraPlugin main;
|
||||
|
||||
public FloraLayerLoader(TerraPlugin main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FloraLayer load(Type type, Object o, ConfigLoader configLoader) throws LoadException {
|
||||
Map<String, Object> map = (Map<String, Object>) o;
|
||||
@ -39,12 +32,12 @@ public class FloraLayerLoader implements TypeLoader<FloraLayer> {
|
||||
} catch(ConfigException e) {
|
||||
throw new LoadException("Unable to load noise", e);
|
||||
}
|
||||
return new FloraLayer(density, range, items, sampler.build(2403), main);
|
||||
return new FloraLayer(density, range, items, sampler.build(2403));
|
||||
}
|
||||
sampler = new NoiseBuilder();
|
||||
sampler.setType(FastNoiseLite.NoiseType.WhiteNoise);
|
||||
sampler.setDimensions(3);
|
||||
|
||||
return new FloraLayer(density, range, items, sampler.build(2403), main);
|
||||
return new FloraLayer(density, range, items, sampler.build(2403));
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import com.dfsek.tectonic.loading.TypeLoader;
|
||||
import com.dfsek.terra.api.math.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.math.Range;
|
||||
import com.dfsek.terra.api.math.noise.samplers.FastNoiseLite;
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.api.world.tree.Tree;
|
||||
import com.dfsek.terra.config.loaders.Types;
|
||||
import com.dfsek.terra.generation.config.NoiseBuilder;
|
||||
@ -19,12 +18,6 @@ import java.util.Map;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class TreeLayerLoader implements TypeLoader<TreeLayer> {
|
||||
private final TerraPlugin main;
|
||||
|
||||
public TreeLayerLoader(TerraPlugin main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TreeLayer load(Type type, Object o, ConfigLoader configLoader) throws LoadException {
|
||||
Map<String, Object> map = (Map<String, Object>) o;
|
||||
@ -40,12 +33,12 @@ public class TreeLayerLoader implements TypeLoader<TreeLayer> {
|
||||
} catch(ConfigException e) {
|
||||
throw new LoadException("Unable to load noise", e);
|
||||
}
|
||||
return new TreeLayer(density, range, items, sampler.build(2403), main);
|
||||
return new TreeLayer(density, range, items, sampler.build(2403));
|
||||
}
|
||||
|
||||
sampler.setType(FastNoiseLite.NoiseType.WhiteNoise);
|
||||
sampler.setDimensions(3);
|
||||
|
||||
return new TreeLayer(density, range, items, sampler.build(2403), main);
|
||||
return new TreeLayer(density, range, items, sampler.build(2403));
|
||||
}
|
||||
}
|
||||
|
@ -4,24 +4,25 @@ import com.dfsek.terra.api.math.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.math.Range;
|
||||
import com.dfsek.terra.api.math.noise.samplers.NoiseSampler;
|
||||
import com.dfsek.terra.api.math.vector.Vector2;
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.api.platform.world.Chunk;
|
||||
|
||||
public abstract class PlaceableLayer<T> {
|
||||
protected final double density;
|
||||
protected final Range level;
|
||||
protected final ProbabilityCollection<T> layer;
|
||||
protected final TerraPlugin main;
|
||||
protected final NoiseSampler noise;
|
||||
|
||||
public PlaceableLayer(double density, Range level, ProbabilityCollection<T> layer, NoiseSampler noise, TerraPlugin main) {
|
||||
public PlaceableLayer(double density, Range level, ProbabilityCollection<T> layer, NoiseSampler noise) {
|
||||
this.density = density;
|
||||
this.level = level;
|
||||
this.layer = layer;
|
||||
this.main = main;
|
||||
this.noise = noise;
|
||||
}
|
||||
|
||||
public NoiseSampler getNoise() {
|
||||
return noise;
|
||||
}
|
||||
|
||||
public double getDensity() {
|
||||
return density;
|
||||
}
|
||||
|
@ -4,15 +4,14 @@ import com.dfsek.terra.api.math.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.math.Range;
|
||||
import com.dfsek.terra.api.math.noise.samplers.NoiseSampler;
|
||||
import com.dfsek.terra.api.math.vector.Vector2;
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.api.platform.world.Chunk;
|
||||
import com.dfsek.terra.api.world.flora.Flora;
|
||||
import com.dfsek.terra.population.items.PlaceableLayer;
|
||||
|
||||
public class FloraLayer extends PlaceableLayer<Flora> {
|
||||
|
||||
public FloraLayer(double density, Range level, ProbabilityCollection<Flora> layer, NoiseSampler noise, TerraPlugin main) {
|
||||
super(density, level, layer, noise, main);
|
||||
public FloraLayer(double density, Range level, ProbabilityCollection<Flora> layer, NoiseSampler noise) {
|
||||
super(density, level, layer, noise);
|
||||
}
|
||||
|
||||
public double getDensity() {
|
||||
|
@ -1,12 +1,11 @@
|
||||
package com.dfsek.terra.population.items.tree;
|
||||
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.api.math.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.math.Range;
|
||||
import com.dfsek.terra.api.math.noise.samplers.NoiseSampler;
|
||||
import com.dfsek.terra.api.math.vector.Vector2;
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.platform.block.Block;
|
||||
import com.dfsek.terra.api.platform.block.BlockFace;
|
||||
import com.dfsek.terra.api.platform.world.Chunk;
|
||||
import com.dfsek.terra.api.world.tree.Tree;
|
||||
import com.dfsek.terra.population.items.PlaceableLayer;
|
||||
@ -14,21 +13,18 @@ import com.dfsek.terra.util.PopulationUtil;
|
||||
|
||||
public class TreeLayer extends PlaceableLayer<Tree> {
|
||||
|
||||
public TreeLayer(double density, Range level, ProbabilityCollection<Tree> layer, NoiseSampler noise, TerraPlugin main) {
|
||||
super(density, level, layer, noise, main);
|
||||
public TreeLayer(double density, Range level, ProbabilityCollection<Tree> layer, NoiseSampler noise) {
|
||||
super(density, level, layer, noise);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void place(Chunk chunk, Vector2 coords) {
|
||||
Tree item = layer.get(noise, coords.getX(), coords.getZ());
|
||||
TerraWorld terraWorld = main.getWorld(chunk.getWorld());
|
||||
int cx = chunk.getX() << 4;
|
||||
int cz = chunk.getZ() << 4;
|
||||
BlockData current;
|
||||
for(int y : level) {
|
||||
current = terraWorld.getUngeneratedBlock(coords.getBlockX() + cx, y, coords.getBlockZ() + cz);
|
||||
if(item.getSpawnable().contains(current.getMaterial())) {
|
||||
item.plant(coords.toVector3(y).add(cx, 1, cz).toLocation(chunk.getWorld()), PopulationUtil.getRandom(chunk));
|
||||
Block current = chunk.getBlock((int) coords.getX(), level.getMax(), (int) coords.getZ());
|
||||
for(int ignored : level) {
|
||||
current = current.getRelative(BlockFace.DOWN);
|
||||
if(item.getSpawnable().contains(current.getType())) {
|
||||
item.plant(current.getLocation().add(0, 1, 0), PopulationUtil.getRandom(chunk));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user