mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-09 09:16:34 +00:00
remove feature gen addon from main repo
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
dependencies {
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package com.dfsek.terra.addons.generation.feature;
|
||||
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
import com.dfsek.terra.api.structure.feature.BinaryColumn;
|
||||
import com.dfsek.terra.api.world.Column;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
|
||||
import java.util.function.IntConsumer;
|
||||
|
||||
|
||||
public class ColumnImpl implements Column {
|
||||
private final int x;
|
||||
private final int z;
|
||||
private final World world;
|
||||
|
||||
public ColumnImpl(int x, int z, World world) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(int y) {
|
||||
return world.getBlockData(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinY() {
|
||||
return world.getMinHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxY() {
|
||||
return world.getMaxHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(IntConsumer function) {
|
||||
for(int y = world.getMinHeight(); y < world.getMaxHeight(); y++) {
|
||||
function.accept(y);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BinaryColumn newBinaryColumn() {
|
||||
return new BinaryColumn(getMinY(), getMaxY());
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.dfsek.terra.addons.generation.feature;
|
||||
|
||||
import com.dfsek.terra.addons.generation.feature.config.BiomeFeaturesTemplate;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
import com.dfsek.terra.api.addon.annotations.Version;
|
||||
import com.dfsek.terra.api.event.events.config.ConfigurationLoadEvent;
|
||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||
import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
import com.dfsek.terra.api.world.generator.GenerationStageProvider;
|
||||
|
||||
|
||||
@Addon("generation-stage-feature")
|
||||
@Version("1.0.0")
|
||||
@Author("Terra")
|
||||
public class FeatureGenerationAddon extends TerraAddon {
|
||||
@Inject
|
||||
private Platform platform;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigPackPreLoadEvent.class)
|
||||
.then(event -> event.getPack()
|
||||
.getOrCreateRegistry(GenerationStageProvider.class)
|
||||
.register("FEATURE", pack -> new FeatureGenerationStage(platform)))
|
||||
.failThrough();
|
||||
|
||||
platform.getEventManager()
|
||||
.getHandler(FunctionalEventHandler.class)
|
||||
.register(this, ConfigurationLoadEvent.class)
|
||||
.then(event -> {
|
||||
if(event.is(TerraBiome.class)) {
|
||||
event.getLoadedObject(TerraBiome.class).getContext().put(event.load(new BiomeFeaturesTemplate()).get());
|
||||
}
|
||||
})
|
||||
.failThrough();
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.dfsek.terra.addons.generation.feature;
|
||||
|
||||
import com.dfsek.terra.addons.generation.feature.config.BiomeFeatures;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.profiler.ProfileFrame;
|
||||
import com.dfsek.terra.api.structure.rotation.Rotation;
|
||||
import com.dfsek.terra.api.util.PopulationUtil;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
import com.dfsek.terra.api.world.Chunk;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.world.generator.GenerationStage;
|
||||
|
||||
|
||||
public class FeatureGenerationStage implements GenerationStage {
|
||||
private final Platform platform;
|
||||
|
||||
public FeatureGenerationStage(Platform platform) {
|
||||
this.platform = platform;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("try")
|
||||
public void populate(World world, Chunk chunk) {
|
||||
try(ProfileFrame ignore = platform.getProfiler().profile("feature")) {
|
||||
int cx = chunk.getX() << 4;
|
||||
int cz = chunk.getZ() << 4;
|
||||
long seed = world.getSeed();
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
int tx = cx + x;
|
||||
int tz = cz + z;
|
||||
ColumnImpl column = new ColumnImpl(tx, tz, world);
|
||||
world.getBiomeProvider().getBiome(tx, tz, seed).getContext().get(BiomeFeatures.class).getFeatures().forEach(feature -> {
|
||||
if(feature.getDistributor().matches(tx, tz, seed)) {
|
||||
feature.getLocator()
|
||||
.getSuitableCoordinates(column)
|
||||
.forEach(y ->
|
||||
feature.getStructure(world, tx, y, tz)
|
||||
.generate(new Vector3(tx, y, tz), world, PopulationUtil.getRandom(chunk),
|
||||
Rotation.NONE)
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.dfsek.terra.addons.generation.feature.config;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.dfsek.terra.api.properties.Properties;
|
||||
import com.dfsek.terra.api.structure.feature.Feature;
|
||||
|
||||
|
||||
public class BiomeFeatures implements Properties {
|
||||
private final List<Feature> features;
|
||||
|
||||
public BiomeFeatures(List<Feature> features) {
|
||||
this.features = features;
|
||||
}
|
||||
|
||||
public List<Feature> getFeatures() {
|
||||
return features;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.dfsek.terra.addons.generation.feature.config;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Default;
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.structure.feature.Feature;
|
||||
|
||||
|
||||
public class BiomeFeaturesTemplate implements ObjectTemplate<BiomeFeatures> {
|
||||
@Value("features")
|
||||
@Default
|
||||
private @Meta List<@Meta Feature> features = Collections.emptyList();
|
||||
|
||||
@Override
|
||||
public BiomeFeatures get() {
|
||||
return new BiomeFeatures(features);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user