This commit is contained in:
dfsek 2021-07-15 13:24:05 -07:00
parent 34e78ab55e
commit 95e6479505
7 changed files with 73 additions and 18 deletions

View File

@ -2,6 +2,7 @@ package com.dfsek.terra.addons.biome;
import com.dfsek.terra.addons.biome.holder.PaletteHolder;
import com.dfsek.terra.addons.biome.holder.PaletteHolderLoader;
import com.dfsek.terra.addons.biome.slant.SlantHolder;
import com.dfsek.terra.api.TerraPlugin;
import com.dfsek.terra.api.addon.TerraAddon;
import com.dfsek.terra.api.addon.annotations.Addon;
@ -21,7 +22,8 @@ public class BiomeConfigAddon extends TerraAddon implements EventListener {
@Override
public void initialize() {
main.getEventManager().registerListener(this, this);
main.applyLoader(PaletteHolder.class, new PaletteHolderLoader());
main.applyLoader(PaletteHolder.class, new PaletteHolderLoader())
.applyLoader(SlantHolder.class, (t, o, l) -> null);
}
public void onPackLoad(ConfigPackPreLoadEvent event) {

View File

@ -0,0 +1,29 @@
package com.dfsek.terra.addons.structure;
import com.dfsek.terra.api.TerraPlugin;
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.EventListener;
import com.dfsek.terra.api.event.events.config.ConfigPackPreLoadEvent;
import com.dfsek.terra.api.injection.annotations.Inject;
import com.dfsek.terra.api.structure.ConfiguredStructure;
@Addon("config-structure")
@Version("1.0.0")
@Author("Terra")
public class StructureAddon extends TerraAddon implements EventListener {
@Inject
private TerraPlugin main;
@Override
public void initialize() {
main.getEventManager().registerListener(this, this);
main.applyLoader(ConfiguredStructure.class, (t, o, l) -> null);
}
public void onConfigLoad(ConfigPackPreLoadEvent event) {
}
}

View File

@ -36,8 +36,12 @@ public class OpenRegistryImpl<T> implements OpenRegistry<T> {
@Override
public T load(AnnotatedType type, Object o, ConfigLoader configLoader) throws LoadException {
T obj = get((String) o);
StringBuilder keys = new StringBuilder("[");
objects.keySet().forEach(key -> keys.append(key + ", "));
if(obj == null)
throw new LoadException("No such " + type.getType().getTypeName() + " matching \"" + o + "\" was found in this registry.");
throw new LoadException("No such " + type.getType().getTypeName() + " matching \"" + o + "\" was found in this registry. Registry contains items: " + keys.substring(0, keys.length()-2) + "]");
return obj;
}

View File

@ -1,6 +1,8 @@
package com.dfsek.terra;
import com.dfsek.tectonic.loading.TypeLoader;
import com.dfsek.tectonic.loading.TypeRegistry;
import com.dfsek.tectonic.loading.object.ObjectTemplate;
import com.dfsek.terra.api.TerraPlugin;
import com.dfsek.terra.api.addon.TerraAddon;
import com.dfsek.terra.api.block.state.BlockState;
@ -13,6 +15,7 @@ import com.dfsek.terra.api.lang.Language;
import com.dfsek.terra.api.profiler.Profiler;
import com.dfsek.terra.api.registry.CheckedRegistry;
import com.dfsek.terra.api.registry.Registry;
import com.dfsek.terra.api.tectonic.LoaderHolder;
import com.dfsek.terra.api.world.TerraWorld;
import com.dfsek.terra.api.world.World;
import com.dfsek.terra.api.world.biome.Biome;
@ -34,6 +37,8 @@ import com.dfsek.terra.world.TerraWorldImpl;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.function.Supplier;
import java.util.logging.Logger;
public class StandalonePlugin implements TerraPlugin {
@ -156,4 +161,14 @@ public class StandalonePlugin implements TerraPlugin {
public Profiler getProfiler() {
return profiler;
}
@Override
public <T> LoaderHolder applyLoader(Type type, TypeLoader<T> loader) {
return null;
}
@Override
public <T> LoaderHolder applyLoader(Type type, Supplier<ObjectTemplate<T>> loader) {
return null;
}
}

View File

@ -11,6 +11,11 @@ public class RawWorldHandle implements WorldHandle {
return new State(data);
}
@Override
public BlockState air() {
return null;
}
@Override
public EntityType getEntity(String id) {
return null;

View File

@ -2,6 +2,7 @@ package com.dfsek.terra.platform;
import com.dfsek.terra.api.block.BlockType;
import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.block.state.properties.Property;
import net.querz.nbt.tag.CompoundTag;
public class State implements BlockState, BlockType {
@ -57,6 +58,21 @@ public class State implements BlockState, BlockType {
return false;
}
@Override
public <T> boolean has(Property<T> property) {
return false;
}
@Override
public <T> T get(Property<T> property) {
return null;
}
@Override
public <T> BlockState set(Property<T> property, T value) {
return null;
}
@Override
public BlockState clone() {

View File

@ -5,10 +5,6 @@ import com.dfsek.terra.api.world.generator.TerraChunkGenerator;
import com.dfsek.terra.platform.DirectChunkData;
import com.dfsek.terra.platform.DirectWorld;
import com.dfsek.terra.platform.GenWrapper;
import com.dfsek.terra.world.population.FloraPopulator;
import com.dfsek.terra.world.population.OrePopulator;
import com.dfsek.terra.world.population.StructurePopulator;
import com.dfsek.terra.world.population.TreePopulator;
import net.querz.mca.MCAFile;
import net.querz.mca.MCAUtil;
@ -18,18 +14,10 @@ import java.util.Map;
public class Generator {
private final long seed;
FloraPopulator floraPopulator;
StructurePopulator structurePopulator;
TreePopulator treePopulator;
OrePopulator orePopulator;
TerraChunkGenerator generator;
public Generator(long seed, StandalonePlugin plugin) {
plugin.load();
floraPopulator = new FloraPopulator(plugin);
structurePopulator = new StructurePopulator(plugin);
treePopulator = new TreePopulator(plugin);
orePopulator = new OrePopulator(plugin);
//generator = new DefaultChunkGenerator3D(plugin.getConfigRegistry().get("DEFAULT"), plugin);
this.seed = seed;
}
@ -51,10 +39,6 @@ public class Generator {
DirectChunkData chunkData = (DirectChunkData) world.getChunkAt(cx, cz);
generator.generateChunkData(world, null, cx, cz, chunkData);
structurePopulator.populate(world, chunkData);
orePopulator.populate(world, chunkData);
floraPopulator.populate(world, chunkData);
treePopulator.populate(world, chunkData);
count++;
if(count % 200 == 0) {