mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-04 00:45:57 +00:00
remove ore addon from main repo
This commit is contained in:
parent
76f6184640
commit
097d33a056
@ -1,3 +0,0 @@
|
|||||||
# config-ore
|
|
||||||
|
|
||||||
Registers the default configuration for Terra Ores, `ORE`.
|
|
@ -1,2 +0,0 @@
|
|||||||
dependencies {
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
package com.dfsek.terra.addons.ore;
|
|
||||||
|
|
||||||
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.pack.ConfigPackPreLoadEvent;
|
|
||||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
|
||||||
import com.dfsek.terra.api.inject.annotations.Inject;
|
|
||||||
import com.dfsek.terra.api.world.generator.GenerationStageProvider;
|
|
||||||
|
|
||||||
|
|
||||||
@Addon("config-ore")
|
|
||||||
@Author("Terra")
|
|
||||||
@Version("1.0.0")
|
|
||||||
public class OreAddon extends TerraAddon {
|
|
||||||
@Inject
|
|
||||||
private Platform platform;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initialize() {
|
|
||||||
platform.getEventManager()
|
|
||||||
.getHandler(FunctionalEventHandler.class)
|
|
||||||
.register(this, ConfigPackPreLoadEvent.class)
|
|
||||||
.then(event -> {
|
|
||||||
event.getPack().registerConfigType(new OreConfigType(), "ORE", 1);
|
|
||||||
event.getPack().getOrCreateRegistry(GenerationStageProvider.class).register("ORE", pack -> new OrePopulator(platform));
|
|
||||||
})
|
|
||||||
.failThrough();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
package com.dfsek.terra.addons.ore;
|
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import com.dfsek.terra.addons.ore.ores.Ore;
|
|
||||||
import com.dfsek.terra.api.Platform;
|
|
||||||
import com.dfsek.terra.api.config.ConfigFactory;
|
|
||||||
import com.dfsek.terra.api.config.ConfigPack;
|
|
||||||
import com.dfsek.terra.api.config.ConfigType;
|
|
||||||
import com.dfsek.terra.api.registry.OpenRegistry;
|
|
||||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
|
||||||
|
|
||||||
|
|
||||||
public class OreConfigType implements ConfigType<OreTemplate, Ore> {
|
|
||||||
public static final TypeKey<Ore> ORE_TYPE_TOKEN = new TypeKey<>() {
|
|
||||||
};
|
|
||||||
private final OreFactory factory = new OreFactory();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Supplier<OpenRegistry<Ore>> registrySupplier(ConfigPack pack) {
|
|
||||||
return pack.getRegistryFactory()::create;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public OreTemplate getTemplate(ConfigPack pack, Platform platform) {
|
|
||||||
return new OreTemplate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ConfigFactory<OreTemplate, Ore> getFactory() {
|
|
||||||
return factory;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TypeKey<Ore> getTypeKey() {
|
|
||||||
return ORE_TYPE_TOKEN;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
package com.dfsek.terra.addons.ore;
|
|
||||||
|
|
||||||
import com.dfsek.terra.addons.ore.ores.Ore;
|
|
||||||
import com.dfsek.terra.addons.ore.ores.VanillaOre;
|
|
||||||
import com.dfsek.terra.api.Platform;
|
|
||||||
import com.dfsek.terra.api.block.state.BlockState;
|
|
||||||
import com.dfsek.terra.api.config.ConfigFactory;
|
|
||||||
|
|
||||||
|
|
||||||
public class OreFactory implements ConfigFactory<OreTemplate, Ore> {
|
|
||||||
@Override
|
|
||||||
public Ore build(OreTemplate config, Platform platform) {
|
|
||||||
BlockState m = config.getMaterial();
|
|
||||||
return new VanillaOre(m, config.getReplaceable(), config.doPhysics(), config.getSize(), platform, config.getMaterialOverrides());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
package com.dfsek.terra.addons.ore;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.Platform;
|
|
||||||
import com.dfsek.terra.api.profiler.ProfileFrame;
|
|
||||||
import com.dfsek.terra.api.util.PopulationUtil;
|
|
||||||
import com.dfsek.terra.api.world.Chunk;
|
|
||||||
import com.dfsek.terra.api.world.World;
|
|
||||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
|
||||||
import com.dfsek.terra.api.world.generator.GenerationStage;
|
|
||||||
|
|
||||||
|
|
||||||
public class OrePopulator implements GenerationStage {
|
|
||||||
private final Platform platform;
|
|
||||||
|
|
||||||
public OrePopulator(Platform platform) {
|
|
||||||
this.platform = platform;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("try")
|
|
||||||
@Override
|
|
||||||
public void populate(@NotNull World world, @NotNull Chunk chunk) {
|
|
||||||
try(ProfileFrame ignore = platform.getProfiler().profile("ore")) {
|
|
||||||
if(world.getConfig().disableOres()) return;
|
|
||||||
|
|
||||||
for(int cx = -1; cx <= 1; cx++) {
|
|
||||||
for(int cz = -1; cz <= 1; cz++) {
|
|
||||||
Random random = new Random(PopulationUtil.getCarverChunkSeed(chunk.getX() + cx, chunk.getZ() + cz, world.getSeed()));
|
|
||||||
int originX = ((chunk.getX() + cx) << 4);
|
|
||||||
int originZ = ((chunk.getZ() + cz) << 4);
|
|
||||||
TerraBiome b = world.getBiomeProvider().getBiome(originX + 8, originZ + 8, world.getSeed());
|
|
||||||
/*
|
|
||||||
BiomeTemplate config = ((UserDefinedBiome) b).getConfig();
|
|
||||||
int finalCx = cx;
|
|
||||||
int finalCz = cz;
|
|
||||||
config.getOreHolder().forEach((id, orePair) -> {
|
|
||||||
try(ProfileFrame ignored = main.getProfiler().profile("ore:" + id)) {
|
|
||||||
int amount = orePair.getRight().getAmount().get(random);
|
|
||||||
for(int i = 0; i < amount; i++) {
|
|
||||||
Vector3 location = new Vector3(random.nextInt(16) + 16 * finalCx, orePair.getRight().getHeight().get
|
|
||||||
(random), random.nextInt(16) + 16 * finalCz);
|
|
||||||
orePair.getLeft().generate(location, chunk, random);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
package com.dfsek.terra.addons.ore;
|
|
||||||
|
|
||||||
import com.dfsek.tectonic.annotations.Default;
|
|
||||||
import com.dfsek.tectonic.annotations.Final;
|
|
||||||
import com.dfsek.tectonic.annotations.Value;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.block.BlockType;
|
|
||||||
import com.dfsek.terra.api.block.state.BlockState;
|
|
||||||
import com.dfsek.terra.api.config.AbstractableTemplate;
|
|
||||||
import com.dfsek.terra.api.config.meta.Meta;
|
|
||||||
import com.dfsek.terra.api.util.Range;
|
|
||||||
import com.dfsek.terra.api.util.collection.MaterialSet;
|
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings({ "unused", "FieldMayBeFinal" })
|
|
||||||
public class OreTemplate implements AbstractableTemplate {
|
|
||||||
@Value("id")
|
|
||||||
@Final
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
@Value("material")
|
|
||||||
private @Meta BlockState material;
|
|
||||||
|
|
||||||
@Value("material-overrides")
|
|
||||||
@Default
|
|
||||||
private @Meta Map<@Meta BlockType, @Meta BlockState> materials = new HashMap<>();
|
|
||||||
|
|
||||||
@Value("replace")
|
|
||||||
private @Meta MaterialSet replaceable;
|
|
||||||
|
|
||||||
@Value("physics")
|
|
||||||
@Default
|
|
||||||
private @Meta boolean physics = false;
|
|
||||||
|
|
||||||
@Value("size")
|
|
||||||
private @Meta Range size;
|
|
||||||
|
|
||||||
@Value("deform")
|
|
||||||
@Default
|
|
||||||
private @Meta double deform = 0.75D;
|
|
||||||
|
|
||||||
@Value("deform-frequency")
|
|
||||||
@Default
|
|
||||||
private @Meta double deformFrequency = 0.1D;
|
|
||||||
|
|
||||||
public boolean doPhysics() {
|
|
||||||
return physics;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getDeform() {
|
|
||||||
return deform;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getDeformFrequency() {
|
|
||||||
return deformFrequency;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Range getSize() {
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockState getMaterial() {
|
|
||||||
return material;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MaterialSet getReplaceable() {
|
|
||||||
return replaceable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getID() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<BlockType, BlockState> getMaterialOverrides() {
|
|
||||||
return materials;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
package com.dfsek.terra.addons.ore.ores;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.Platform;
|
|
||||||
import com.dfsek.terra.api.block.BlockType;
|
|
||||||
import com.dfsek.terra.api.block.state.BlockState;
|
|
||||||
import com.dfsek.terra.api.util.collection.MaterialSet;
|
|
||||||
import com.dfsek.terra.api.util.vector.Vector3;
|
|
||||||
import com.dfsek.terra.api.world.Chunk;
|
|
||||||
|
|
||||||
|
|
||||||
public abstract class Ore {
|
|
||||||
|
|
||||||
private final BlockState material;
|
|
||||||
private final MaterialSet replaceable;
|
|
||||||
private final boolean applyGravity;
|
|
||||||
private final Map<BlockType, BlockState> materials;
|
|
||||||
protected Platform platform;
|
|
||||||
|
|
||||||
public Ore(BlockState material, MaterialSet replaceable, boolean applyGravity, Platform platform, Map<BlockType, BlockState> materials) {
|
|
||||||
this.material = material;
|
|
||||||
this.replaceable = replaceable;
|
|
||||||
this.applyGravity = applyGravity;
|
|
||||||
this.platform = platform;
|
|
||||||
this.materials = materials;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void generate(Vector3 origin, Chunk c, Random r);
|
|
||||||
|
|
||||||
public BlockState getMaterial(BlockType replace) {
|
|
||||||
return materials.getOrDefault(replace, material);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MaterialSet getReplaceable() {
|
|
||||||
return replaceable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isApplyGravity() {
|
|
||||||
return applyGravity;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package com.dfsek.terra.addons.ore.ores;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.util.Range;
|
|
||||||
|
|
||||||
|
|
||||||
public class OreConfig {
|
|
||||||
private final Range amount;
|
|
||||||
private final Range height;
|
|
||||||
|
|
||||||
public OreConfig(Range amount, Range height) {
|
|
||||||
this.amount = amount;
|
|
||||||
this.height = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Range getAmount() {
|
|
||||||
return amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Range getHeight() {
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
package com.dfsek.terra.addons.ore.ores;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.util.generic.pair.ImmutablePair;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Holds ordered list of ores mapped to their configs.
|
|
||||||
*/
|
|
||||||
public class OreHolder {
|
|
||||||
private final List<Entry> entries = new ArrayList<>();
|
|
||||||
|
|
||||||
public void forEach(BiConsumer<String, ImmutablePair<Ore, OreConfig>> consumer) {
|
|
||||||
entries.forEach(entry -> consumer.accept(entry.getId(), ImmutablePair.of(entry.getOre(), entry.getConfig())));
|
|
||||||
}
|
|
||||||
|
|
||||||
public OreHolder add(Ore ore, OreConfig config, String id) {
|
|
||||||
entries.add(new Entry(ore, config, id));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final class Entry {
|
|
||||||
private final Ore ore;
|
|
||||||
private final OreConfig config;
|
|
||||||
private final String id;
|
|
||||||
|
|
||||||
private Entry(Ore ore, OreConfig config, String id) {
|
|
||||||
this.ore = ore;
|
|
||||||
this.config = config;
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OreConfig getConfig() {
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Ore getOre() {
|
|
||||||
return ore;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,85 +0,0 @@
|
|||||||
package com.dfsek.terra.addons.ore.ores;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.Platform;
|
|
||||||
|
|
||||||
import net.jafama.FastMath;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.block.BlockType;
|
|
||||||
import com.dfsek.terra.api.block.state.BlockState;
|
|
||||||
import com.dfsek.terra.api.util.Range;
|
|
||||||
import com.dfsek.terra.api.util.collection.MaterialSet;
|
|
||||||
import com.dfsek.terra.api.util.vector.Vector3;
|
|
||||||
import com.dfsek.terra.api.world.Chunk;
|
|
||||||
|
|
||||||
|
|
||||||
public class VanillaOre extends Ore {
|
|
||||||
private final Range sizeRange;
|
|
||||||
|
|
||||||
public VanillaOre(BlockState material, MaterialSet replaceable, boolean applyGravity, Range size, Platform platform,
|
|
||||||
Map<BlockType, BlockState> materials) {
|
|
||||||
super(material, replaceable, applyGravity, platform, materials);
|
|
||||||
this.sizeRange = size;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generate(Vector3 location, Chunk chunk, Random random) {
|
|
||||||
double size = sizeRange.get(random);
|
|
||||||
|
|
||||||
int centerX = location.getBlockX();
|
|
||||||
int centerZ = location.getBlockZ();
|
|
||||||
int centerY = location.getBlockY();
|
|
||||||
|
|
||||||
|
|
||||||
double f = random.nextFloat() * Math.PI;
|
|
||||||
|
|
||||||
double fS = FastMath.sin(f) * size / 8.0F;
|
|
||||||
double fC = FastMath.cos(f) * size / 8.0F;
|
|
||||||
|
|
||||||
double d1 = centerX + 8 + fS;
|
|
||||||
double d2 = centerX + 8 - fS;
|
|
||||||
double d3 = centerZ + 8 + fC;
|
|
||||||
double d4 = centerZ + 8 - fC;
|
|
||||||
|
|
||||||
double d5 = centerY + random.nextInt(3) - 2D;
|
|
||||||
double d6 = centerY + random.nextInt(3) - 2D;
|
|
||||||
|
|
||||||
for(int i = 0; i < size; i++) {
|
|
||||||
double iFactor = i / size;
|
|
||||||
|
|
||||||
double d10 = random.nextDouble() * size / 16.0D;
|
|
||||||
double d11 = (FastMath.sin(Math.PI * iFactor) + 1.0) * d10 + 1.0;
|
|
||||||
|
|
||||||
int xStart = FastMath.roundToInt(FastMath.floor(d1 + (d2 - d1) * iFactor - d11 / 2.0D));
|
|
||||||
int yStart = FastMath.roundToInt(FastMath.floor(d5 + (d6 - d5) * iFactor - d11 / 2.0D));
|
|
||||||
int zStart = FastMath.roundToInt(FastMath.floor(d3 + (d4 - d3) * iFactor - d11 / 2.0D));
|
|
||||||
|
|
||||||
int xEnd = FastMath.roundToInt(FastMath.floor(d1 + (d2 - d1) * iFactor + d11 / 2.0D));
|
|
||||||
int yEnd = FastMath.roundToInt(FastMath.floor(d5 + (d6 - d5) * iFactor + d11 / 2.0D));
|
|
||||||
int zEnd = FastMath.roundToInt(FastMath.floor(d3 + (d4 - d3) * iFactor + d11 / 2.0D));
|
|
||||||
|
|
||||||
for(int x = xStart; x <= xEnd; x++) {
|
|
||||||
double d13 = (x + 0.5D - (d1 + (d2 - d1) * iFactor)) / (d11 / 2.0D);
|
|
||||||
|
|
||||||
if(d13 * d13 < 1.0D) {
|
|
||||||
for(int y = yStart; y <= yEnd; y++) {
|
|
||||||
double d14 = (y + 0.5D - (d5 + (d6 - d5) * iFactor)) / (d11 / 2.0D);
|
|
||||||
if(d13 * d13 + d14 * d14 < 1.0D) {
|
|
||||||
for(int z = zStart; z <= zEnd; z++) {
|
|
||||||
double d15 = (z + 0.5D - (d3 + (d4 - d3) * iFactor)) / (d11 / 2.0D);
|
|
||||||
if(x > 15 || z > 15 || y > 255 || x < 0 || z < 0 || y < 0) continue;
|
|
||||||
|
|
||||||
BlockType type = chunk.getBlock(x, y, z).getBlockType();
|
|
||||||
if((d13 * d13 + d14 * d14 + d15 * d15 < 1.0D) && getReplaceable().contains(type)) {
|
|
||||||
chunk.setBlock(x, y, z, getMaterial(type), isApplyGravity());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user