build chunk generator addon

This commit is contained in:
dfsek
2021-07-07 10:54:25 -07:00
parent 66a5cce399
commit 99d64fec36
20 changed files with 64 additions and 83 deletions

View File

@@ -10,7 +10,6 @@ import com.dfsek.terra.api.addon.annotations.Author;
import com.dfsek.terra.api.addon.annotations.Version;
import com.dfsek.terra.api.block.state.BlockState;
import com.dfsek.terra.api.command.CommandManager;
import com.dfsek.terra.commands.TerraCommandManager;
import com.dfsek.terra.api.command.exception.MalformedCommandException;
import com.dfsek.terra.api.config.ConfigPack;
import com.dfsek.terra.api.config.PluginConfig;
@@ -42,6 +41,7 @@ import com.dfsek.terra.bukkit.util.PaperUtil;
import com.dfsek.terra.bukkit.world.BukkitBiome;
import com.dfsek.terra.bukkit.world.BukkitWorld;
import com.dfsek.terra.commands.CommandUtil;
import com.dfsek.terra.commands.TerraCommandManager;
import com.dfsek.terra.config.GenericLoaders;
import com.dfsek.terra.config.PluginConfigImpl;
import com.dfsek.terra.config.lang.LangUtil;
@@ -51,7 +51,6 @@ import com.dfsek.terra.registry.LockedRegistryImpl;
import com.dfsek.terra.registry.master.AddonRegistry;
import com.dfsek.terra.registry.master.ConfigRegistry;
import com.dfsek.terra.world.TerraWorldImpl;
import com.dfsek.terra.world.generation.generators.DefaultChunkGenerator3D;
import io.papermc.lib.PaperLib;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
@@ -69,7 +68,7 @@ import java.util.Objects;
public class TerraBukkitPlugin extends JavaPlugin implements TerraPlugin {
private final Map<String, DefaultChunkGenerator3D> generatorMap = new HashMap<>();
private final Map<String, com.dfsek.terra.api.world.generator.TerraChunkGenerator> generatorMap = new HashMap<>();
private final Map<World, TerraWorld> worldMap = new HashMap<>();
private final Map<String, ConfigPack> worlds = new HashMap<>();
@@ -127,16 +126,6 @@ public class TerraBukkitPlugin extends JavaPlugin implements TerraPlugin {
return "Bukkit";
}
public void setHandle(WorldHandle handle) {
getLogger().warning("|-------------------------------------------------------|");
getLogger().warning("A third-party com.dfsek.terra.addon has injected a custom WorldHandle!");
getLogger().warning("If you encounter issues, try *without* the com.dfsek.terra.addon before");
getLogger().warning("reporting to Terra. Report issues with the com.dfsek.terra.addon to the");
getLogger().warning("com.dfsek.terra.addon's maintainers!");
getLogger().warning("|-------------------------------------------------------|");
this.handle = handle;
}
@Override
public DebugLogger getDebugLogger() {
return debugLogger;
@@ -258,7 +247,7 @@ public class TerraBukkitPlugin extends JavaPlugin implements TerraPlugin {
if(!registry.contains(id)) throw new IllegalArgumentException("No such config pack \"" + id + "\"");
ConfigPack pack = registry.get(id);
worlds.put(worldName, pack);
return new DefaultChunkGenerator3D(registry.get(id), this);
return pack.getGeneratorProvider().newInstance(pack);
}));
}

View File

@@ -11,7 +11,6 @@ import com.dfsek.terra.api.world.generator.TerraChunkGenerator;
import com.dfsek.terra.fabric.TerraFabricPlugin;
import com.dfsek.terra.fabric.block.FabricBlockState;
import com.dfsek.terra.fabric.mixin.StructureAccessorAccessor;
import com.dfsek.terra.world.generation.generators.DefaultChunkGenerator3D;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.block.BlockState;
@@ -62,7 +61,7 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
);
private final long seed;
private final DefaultChunkGenerator3D delegate;
private final TerraChunkGenerator delegate;
private final TerraBiomeSource biomeSource;
private final ConfigPack pack;
@@ -72,7 +71,7 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
super(biomeSource, new StructuresConfig(false));
this.pack = configPack;
this.delegate = new DefaultChunkGenerator3D(pack, TerraFabricPlugin.getInstance());
this.delegate = pack.getGeneratorProvider().newInstance(pack);
delegate.getMain().logger().info("Loading world with config pack " + pack.getID());
this.biomeSource = biomeSource;

View File

@@ -1,12 +1,12 @@
package com.dfsek.terra.platform;
import com.dfsek.terra.api.world.generator.ChunkGenerator;
import com.dfsek.terra.world.generation.generators.DefaultChunkGenerator3D;
import com.dfsek.terra.api.world.generator.TerraChunkGenerator;
public class GenWrapper implements ChunkGenerator {
private final DefaultChunkGenerator3D generator;
private final TerraChunkGenerator generator;
public GenWrapper(DefaultChunkGenerator3D generator) {
public GenWrapper(TerraChunkGenerator generator) {
this.generator = generator;
}

View File

@@ -1,10 +1,10 @@
package com.dfsek.terra.region;
import com.dfsek.terra.StandalonePlugin;
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.generation.generators.DefaultChunkGenerator3D;
import com.dfsek.terra.world.population.FloraPopulator;
import com.dfsek.terra.world.population.OrePopulator;
import com.dfsek.terra.world.population.StructurePopulator;
@@ -22,7 +22,7 @@ public class Generator {
StructurePopulator structurePopulator;
TreePopulator treePopulator;
OrePopulator orePopulator;
DefaultChunkGenerator3D generator;
TerraChunkGenerator generator;
public Generator(long seed, StandalonePlugin plugin) {
plugin.load();
@@ -30,7 +30,7 @@ public class Generator {
structurePopulator = new StructurePopulator(plugin);
treePopulator = new TreePopulator(plugin);
orePopulator = new OrePopulator(plugin);
generator = new DefaultChunkGenerator3D(plugin.getConfigRegistry().get("DEFAULT"), plugin);
//generator = new DefaultChunkGenerator3D(plugin.getConfigRegistry().get("DEFAULT"), plugin);
this.seed = seed;
}