mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 22:31:52 +00:00
clean up chunkgenerator stuff
This commit is contained in:
+8
-3
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.addons.chunkgenerator;
|
package com.dfsek.terra.addons.chunkgenerator;
|
||||||
|
|
||||||
|
import com.dfsek.terra.addons.chunkgenerator.config.NoiseChunkGeneratorPackConfigTemplate;
|
||||||
import com.dfsek.terra.addons.chunkgenerator.generation.generators.NoiseChunkGenerator3D;
|
import com.dfsek.terra.addons.chunkgenerator.generation.generators.NoiseChunkGenerator3D;
|
||||||
import com.dfsek.terra.addons.chunkgenerator.palette.PaletteHolder;
|
import com.dfsek.terra.addons.chunkgenerator.palette.PaletteHolder;
|
||||||
import com.dfsek.terra.addons.chunkgenerator.palette.PaletteHolderLoader;
|
import com.dfsek.terra.addons.chunkgenerator.palette.PaletteHolderLoader;
|
||||||
@@ -36,12 +37,16 @@ public class NoiseChunkGenerator3DAddon implements AddonInitializer {
|
|||||||
.getHandler(FunctionalEventHandler.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
.register(addon, ConfigPackPreLoadEvent.class)
|
.register(addon, ConfigPackPreLoadEvent.class)
|
||||||
.then(event -> {
|
.then(event -> {
|
||||||
event.getPack().getOrCreateRegistry(ChunkGeneratorProvider.class).register("NOISE_3D",
|
NoiseChunkGeneratorPackConfigTemplate config = event.loadTemplate(new NoiseChunkGeneratorPackConfigTemplate());
|
||||||
pack -> new NoiseChunkGenerator3D(pack,
|
|
||||||
platform));
|
event.getPack()
|
||||||
|
.getOrCreateRegistry(ChunkGeneratorProvider.class)
|
||||||
|
.register("NOISE_3D",
|
||||||
|
pack -> new NoiseChunkGenerator3D(pack, platform, config.getElevationBlend()));
|
||||||
event.getPack()
|
event.getPack()
|
||||||
.applyLoader(SlantHolder.class, new SlantHolderLoader())
|
.applyLoader(SlantHolder.class, new SlantHolderLoader())
|
||||||
.applyLoader(PaletteHolder.class, new PaletteHolderLoader());
|
.applyLoader(PaletteHolder.class, new PaletteHolderLoader());
|
||||||
|
|
||||||
})
|
})
|
||||||
.failThrough();
|
.failThrough();
|
||||||
|
|
||||||
|
|||||||
+9
-2
@@ -11,6 +11,8 @@ import com.dfsek.terra.api.world.ServerWorld;
|
|||||||
import com.dfsek.terra.api.world.World;
|
import com.dfsek.terra.api.world.World;
|
||||||
import com.dfsek.terra.api.world.WritableWorld;
|
import com.dfsek.terra.api.world.WritableWorld;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.world.chunk.generation.util.math.SamplerProvider;
|
||||||
|
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -39,12 +41,17 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
|||||||
private final Platform platform;
|
private final Platform platform;
|
||||||
private final List<GenerationStage> generationStages = new ArrayList<>();
|
private final List<GenerationStage> generationStages = new ArrayList<>();
|
||||||
|
|
||||||
|
private final int elevationBlend;
|
||||||
|
|
||||||
|
private final SamplerProvider samplerCache;
|
||||||
|
|
||||||
private final BlockState air;
|
private final BlockState air;
|
||||||
|
|
||||||
public NoiseChunkGenerator3D(ConfigPack c, Platform platform) {
|
public NoiseChunkGenerator3D(ConfigPack c, Platform platform, int elevationBlend) {
|
||||||
this.configPack = c;
|
this.configPack = c;
|
||||||
this.platform = platform;
|
this.platform = platform;
|
||||||
this.air = platform.getWorldHandle().air();
|
this.air = platform.getWorldHandle().air();
|
||||||
|
this.elevationBlend = elevationBlend;
|
||||||
c.getStages().forEach(stage -> generationStages.add(stage.newInstance(c)));
|
c.getStages().forEach(stage -> generationStages.add(stage.newInstance(c)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +66,7 @@ public class NoiseChunkGenerator3D implements ChunkGenerator {
|
|||||||
int xOrig = (chunkX << 4);
|
int xOrig = (chunkX << 4);
|
||||||
int zOrig = (chunkZ << 4);
|
int zOrig = (chunkZ << 4);
|
||||||
|
|
||||||
Sampler sampler = world.getConfig().getSamplerCache().getChunk(chunkX, chunkZ);
|
Sampler sampler = samplerCache.getChunk(chunkX, chunkZ);
|
||||||
|
|
||||||
long seed = world.getSeed();
|
long seed = world.getSeed();
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@
|
|||||||
* along with Terra. If not, see <https://www.gnu.org/licenses/>.
|
* along with Terra. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.dfsek.terra.world;
|
package com.dfsek.terra.addons.chunkgenerator.generation.math.samplers;
|
||||||
|
|
||||||
import com.dfsek.terra.api.world.ServerWorld;
|
import com.dfsek.terra.api.world.ServerWorld;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.util.math.SamplerProvider;
|
import com.dfsek.terra.api.world.chunk.generation.util.math.SamplerProvider;
|
||||||
+1
-2
@@ -109,8 +109,7 @@ public class NoiseAddon implements AddonInitializer {
|
|||||||
noiseRegistry.register("EXPRESSION", () -> new ExpressionFunctionTemplate(packSamplers, packFunctions));
|
noiseRegistry.register("EXPRESSION", () -> new ExpressionFunctionTemplate(packSamplers, packFunctions));
|
||||||
|
|
||||||
|
|
||||||
NoiseConfigPackTemplate template = new NoiseConfigPackTemplate();
|
NoiseConfigPackTemplate template = event.loadTemplate(new NoiseConfigPackTemplate());
|
||||||
event.loadTemplate(template);
|
|
||||||
packSamplers.putAll(template.getSamplers());
|
packSamplers.putAll(template.getSamplers());
|
||||||
packFunctions.putAll(template.getFunctions());
|
packFunctions.putAll(template.getFunctions());
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -13,18 +13,13 @@ import com.dfsek.terra.api.registry.Registry;
|
|||||||
import com.dfsek.terra.api.util.StringIdentifiable;
|
import com.dfsek.terra.api.util.StringIdentifiable;
|
||||||
import com.dfsek.terra.api.world.ServerWorld;
|
import com.dfsek.terra.api.world.ServerWorld;
|
||||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.util.math.SamplerProvider;
|
|
||||||
|
|
||||||
|
|
||||||
public interface WorldConfig extends StringIdentifiable {
|
public interface WorldConfig extends StringIdentifiable {
|
||||||
int elevationBlend();
|
|
||||||
|
|
||||||
<T> Registry<T> getRegistry(Class<T> clazz);
|
<T> Registry<T> getRegistry(Class<T> clazz);
|
||||||
|
|
||||||
ServerWorld getWorld();
|
ServerWorld getWorld();
|
||||||
|
|
||||||
SamplerProvider getSamplerCache();
|
|
||||||
|
|
||||||
BiomeProvider getProvider();
|
BiomeProvider getProvider();
|
||||||
|
|
||||||
ConfigPack getPack();
|
ConfigPack getPack();
|
||||||
|
|||||||
+2
-1
@@ -32,8 +32,9 @@ public abstract class ConfigPackLoadEvent implements PackEvent, FailThroughEvent
|
|||||||
*
|
*
|
||||||
* @param template Template to register.
|
* @param template Template to register.
|
||||||
*/
|
*/
|
||||||
public void loadTemplate(ConfigTemplate template) throws ConfigException {
|
public <T extends ConfigTemplate> T loadTemplate(T template) throws ConfigException {
|
||||||
configLoader.accept(template);
|
configLoader.accept(template);
|
||||||
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.dfsek.terra.api.world;
|
package com.dfsek.terra.api.world;
|
||||||
|
|
||||||
import com.dfsek.terra.api.Handle;
|
import com.dfsek.terra.api.Handle;
|
||||||
import com.dfsek.terra.api.config.WorldConfig;
|
|
||||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
||||||
|
|
||||||
@@ -16,6 +15,4 @@ public interface World extends Handle {
|
|||||||
ChunkGenerator getGenerator();
|
ChunkGenerator getGenerator();
|
||||||
|
|
||||||
BiomeProvider getBiomeProvider();
|
BiomeProvider getBiomeProvider();
|
||||||
|
|
||||||
WorldConfig getConfig();
|
|
||||||
}
|
}
|
||||||
|
|||||||
-3
@@ -166,7 +166,6 @@ public class ConfigPackImpl implements ConfigPack {
|
|||||||
logger.error("Failed to load config pack from folder \"{}\"", folder.getAbsolutePath(), e);
|
logger.error("Failed to load config pack from folder \"{}\"", folder.getAbsolutePath(), e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
toWorldConfig(new DummyServerWorld()); // Build now to catch any errors immediately.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigPackImpl(ZipFile file, Platform platform) throws ConfigException {
|
public ConfigPackImpl(ZipFile file, Platform platform) throws ConfigException {
|
||||||
@@ -219,8 +218,6 @@ public class ConfigPackImpl implements ConfigPack {
|
|||||||
logger.error("Failed to load config pack from ZIP archive \"{}\"", file.getName());
|
logger.error("Failed to load config pack from ZIP archive \"{}\"", file.getName());
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
toWorldConfig(new DummyServerWorld()); // Build now to catch any errors immediately.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
-14
@@ -27,14 +27,11 @@ import com.dfsek.terra.api.config.WorldConfig;
|
|||||||
import com.dfsek.terra.api.registry.Registry;
|
import com.dfsek.terra.api.registry.Registry;
|
||||||
import com.dfsek.terra.api.world.ServerWorld;
|
import com.dfsek.terra.api.world.ServerWorld;
|
||||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.util.math.SamplerProvider;
|
|
||||||
import com.dfsek.terra.registry.LockedRegistryImpl;
|
import com.dfsek.terra.registry.LockedRegistryImpl;
|
||||||
import com.dfsek.terra.world.SamplerProviderImpl;
|
import com.dfsek.terra.world.SamplerProviderImpl;
|
||||||
|
|
||||||
|
|
||||||
public class WorldConfigImpl implements WorldConfig {
|
public class WorldConfigImpl implements WorldConfig {
|
||||||
private final SamplerProvider samplerProvider;
|
|
||||||
|
|
||||||
private final BiomeProvider provider;
|
private final BiomeProvider provider;
|
||||||
|
|
||||||
private final ServerWorld world;
|
private final ServerWorld world;
|
||||||
@@ -45,18 +42,12 @@ public class WorldConfigImpl implements WorldConfig {
|
|||||||
public WorldConfigImpl(ServerWorld world, ConfigPackImpl pack, Platform platform) {
|
public WorldConfigImpl(ServerWorld world, ConfigPackImpl pack, Platform platform) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.pack = pack;
|
this.pack = pack;
|
||||||
this.samplerProvider = new SamplerProviderImpl(platform, world);
|
|
||||||
|
|
||||||
pack.getRegistryMap().forEach((clazz, pair) -> registryMap.put(clazz, new LockedRegistryImpl<>(pair.getLeft())));
|
pack.getRegistryMap().forEach((clazz, pair) -> registryMap.put(clazz, new LockedRegistryImpl<>(pair.getLeft())));
|
||||||
|
|
||||||
this.provider = pack.getBiomeProvider();
|
this.provider = pack.getBiomeProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int elevationBlend() {
|
|
||||||
return pack.getTemplate().getElevationBlend();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T> Registry<T> getRegistry(Class<T> clazz) {
|
public <T> Registry<T> getRegistry(Class<T> clazz) {
|
||||||
@@ -68,11 +59,6 @@ public class WorldConfigImpl implements WorldConfig {
|
|||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public SamplerProvider getSamplerCache() {
|
|
||||||
return samplerProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BiomeProvider getProvider() {
|
public BiomeProvider getProvider() {
|
||||||
return provider;
|
return provider;
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ import com.dfsek.terra.commands.TerraCommandManager;
|
|||||||
public class TerraBukkitPlugin extends JavaPlugin {
|
public class TerraBukkitPlugin extends JavaPlugin {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(TerraBukkitPlugin.class);
|
private static final Logger logger = LoggerFactory.getLogger(TerraBukkitPlugin.class);
|
||||||
|
|
||||||
private final PlatformImpl terraPlugin = new PlatformImpl(this);
|
private final PlatformImpl platform = new PlatformImpl(this);
|
||||||
private final Map<String, com.dfsek.terra.api.world.chunk.generation.ChunkGenerator> generatorMap = new HashMap<>();
|
private final Map<String, com.dfsek.terra.api.world.chunk.generation.ChunkGenerator> generatorMap = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -58,13 +58,13 @@ public class TerraBukkitPlugin extends JavaPlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
terraPlugin.getEventManager().callEvent(new PlatformInitializationEvent());
|
platform.getEventManager().callEvent(new PlatformInitializationEvent());
|
||||||
|
|
||||||
new Metrics(this, 9017); // Set up bStats.
|
new Metrics(this, 9017); // Set up bStats.
|
||||||
|
|
||||||
PluginCommand cmd = Objects.requireNonNull(getCommand("terra"));
|
PluginCommand cmd = Objects.requireNonNull(getCommand("terra"));
|
||||||
|
|
||||||
CommandManager manager = new TerraCommandManager(terraPlugin);
|
CommandManager manager = new TerraCommandManager(platform);
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -91,7 +91,7 @@ public class TerraBukkitPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Class.forName("io.papermc.paper.event.world.StructureLocateEvent"); // Check if user is on Paper version with event.
|
Class.forName("io.papermc.paper.event.world.StructureLocateEvent"); // Check if user is on Paper version with event.
|
||||||
Bukkit.getPluginManager().registerEvents(new PaperListener(terraPlugin), this); // Register Paper events.
|
Bukkit.getPluginManager().registerEvents(new PaperListener(platform), this); // Register Paper events.
|
||||||
} catch(ClassNotFoundException e) {
|
} catch(ClassNotFoundException e) {
|
||||||
/*
|
/*
|
||||||
The command
|
The command
|
||||||
@@ -130,7 +130,7 @@ public class TerraBukkitPlugin extends JavaPlugin {
|
|||||||
|------------------------------------------------------------------------------|
|
|------------------------------------------------------------------------------|
|
||||||
""".strip(), e);
|
""".strip(), e);
|
||||||
|
|
||||||
Bukkit.getPluginManager().registerEvents(new SpigotListener(terraPlugin), this); // Register Spigot event listener
|
Bukkit.getPluginManager().registerEvents(new SpigotListener(platform), this); // Register Spigot event listener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -207,8 +207,8 @@ public class TerraBukkitPlugin extends JavaPlugin {
|
|||||||
public @Nullable
|
public @Nullable
|
||||||
ChunkGenerator getDefaultWorldGenerator(@NotNull String worldName, String id) {
|
ChunkGenerator getDefaultWorldGenerator(@NotNull String worldName, String id) {
|
||||||
return new BukkitChunkGeneratorWrapper(generatorMap.computeIfAbsent(worldName, name -> {
|
return new BukkitChunkGeneratorWrapper(generatorMap.computeIfAbsent(worldName, name -> {
|
||||||
ConfigPack pack = terraPlugin.getConfigRegistry().get(id).orElseThrow(() -> new IllegalArgumentException("No such config pack \"" + id + "\""));
|
ConfigPack pack = platform.getConfigRegistry().get(id).orElseThrow(() -> new IllegalArgumentException("No such config pack \"" + id + "\""));
|
||||||
return pack.getGeneratorProvider().newInstance(pack);
|
return pack.getGeneratorProvider().newInstance(pack);
|
||||||
}), terraPlugin.getRawConfigRegistry().get(id).orElseThrow());
|
}), platform.getRawConfigRegistry().get(id).orElseThrow(), platform);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+22
-9
@@ -17,10 +17,16 @@
|
|||||||
|
|
||||||
package com.dfsek.terra.bukkit.generator;
|
package com.dfsek.terra.bukkit.generator;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.Platform;
|
||||||
import com.dfsek.terra.api.config.ConfigPack;
|
import com.dfsek.terra.api.config.ConfigPack;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.world.ServerWorld;
|
||||||
import com.dfsek.terra.bukkit.world.BukkitProtoWorld;
|
import com.dfsek.terra.bukkit.world.BukkitProtoWorld;
|
||||||
|
|
||||||
|
import com.dfsek.terra.bukkit.world.BukkitServerWorld;
|
||||||
|
|
||||||
|
import com.dfsek.terra.world.SamplerProviderImpl;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.generator.BiomeProvider;
|
import org.bukkit.generator.BiomeProvider;
|
||||||
@@ -34,22 +40,23 @@ import java.util.List;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.dfsek.terra.api.config.WorldConfig;
|
|
||||||
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.util.GeneratorWrapper;
|
import com.dfsek.terra.api.world.chunk.generation.util.GeneratorWrapper;
|
||||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
|
||||||
|
|
||||||
|
|
||||||
public class BukkitChunkGeneratorWrapper extends org.bukkit.generator.ChunkGenerator implements GeneratorWrapper {
|
public class BukkitChunkGeneratorWrapper extends org.bukkit.generator.ChunkGenerator implements GeneratorWrapper {
|
||||||
private final ChunkGenerator delegate;
|
private final ChunkGenerator delegate;
|
||||||
|
|
||||||
private WorldConfig worldConfig;
|
private World world;
|
||||||
|
private ServerWorld terraWorld;
|
||||||
|
|
||||||
private final ConfigPack pack;
|
private final ConfigPack pack;
|
||||||
|
private final Platform platform;
|
||||||
|
|
||||||
public BukkitChunkGeneratorWrapper(ChunkGenerator delegate, ConfigPack pack) {
|
public BukkitChunkGeneratorWrapper(ChunkGenerator delegate, ConfigPack pack, Platform platform) {
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
this.pack = pack;
|
this.pack = pack;
|
||||||
|
this.platform = platform;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -59,10 +66,11 @@ public class BukkitChunkGeneratorWrapper extends org.bukkit.generator.ChunkGener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateNoise(@NotNull WorldInfo worldInfo, @NotNull Random random, int x, int z, @NotNull ChunkData chunkData) {
|
public void generateNoise(@NotNull WorldInfo worldInfo, @NotNull Random random, int x, int z, @NotNull ChunkData chunkData) {
|
||||||
if(this.worldConfig == null) {
|
if(this.world == null) {
|
||||||
this.worldConfig = pack.toWorldConfig(BukkitAdapter.adapt(Bukkit.getWorld(worldInfo.getUID())));
|
this.world = Bukkit.getWorld(worldInfo.getUID());
|
||||||
|
this.terraWorld = new BukkitServerWorld(world);
|
||||||
}
|
}
|
||||||
delegate.generateChunkData(new BukkitProtoChunk(chunkData), worldConfig.getWorld(), z, x);
|
delegate.generateChunkData(new BukkitProtoChunk(chunkData), terraWorld, z, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -95,8 +103,13 @@ public class BukkitChunkGeneratorWrapper extends org.bukkit.generator.ChunkGener
|
|||||||
return pack.vanillaStructures();
|
return pack.vanillaStructures();
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorldConfig getWorldConfig() {
|
|
||||||
return worldConfig;
|
public World getWorld() {
|
||||||
|
return world;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigPack getPack() {
|
||||||
|
return pack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,26 +1,22 @@
|
|||||||
package com.dfsek.terra.bukkit.world;
|
package com.dfsek.terra.bukkit.world;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.generator.LimitedRegion;
|
||||||
|
|
||||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||||
import com.dfsek.terra.api.block.state.BlockState;
|
import com.dfsek.terra.api.block.state.BlockState;
|
||||||
import com.dfsek.terra.api.config.WorldConfig;
|
|
||||||
import com.dfsek.terra.api.entity.Entity;
|
import com.dfsek.terra.api.entity.Entity;
|
||||||
import com.dfsek.terra.api.entity.EntityType;
|
import com.dfsek.terra.api.entity.EntityType;
|
||||||
import com.dfsek.terra.api.world.ServerWorld;
|
import com.dfsek.terra.api.world.ServerWorld;
|
||||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.ProtoWorld;
|
import com.dfsek.terra.api.world.chunk.generation.ProtoWorld;
|
||||||
|
|
||||||
import com.dfsek.terra.bukkit.BukkitEntity;
|
import com.dfsek.terra.bukkit.BukkitEntity;
|
||||||
import com.dfsek.terra.bukkit.generator.BukkitChunkGeneratorWrapper;
|
import com.dfsek.terra.bukkit.generator.BukkitChunkGeneratorWrapper;
|
||||||
import com.dfsek.terra.bukkit.world.block.data.BukkitBlockState;
|
import com.dfsek.terra.bukkit.world.block.data.BukkitBlockState;
|
||||||
|
|
||||||
import com.dfsek.terra.bukkit.world.block.state.BukkitBlockEntity;
|
import com.dfsek.terra.bukkit.world.block.state.BukkitBlockEntity;
|
||||||
|
|
||||||
import com.dfsek.terra.bukkit.world.entity.BukkitEntityType;
|
import com.dfsek.terra.bukkit.world.entity.BukkitEntityType;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.generator.LimitedRegion;
|
|
||||||
|
|
||||||
|
|
||||||
public class BukkitProtoWorld implements ProtoWorld {
|
public class BukkitProtoWorld implements ProtoWorld {
|
||||||
private final LimitedRegion delegate;
|
private final LimitedRegion delegate;
|
||||||
@@ -79,12 +75,7 @@ public class BukkitProtoWorld implements ProtoWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BiomeProvider getBiomeProvider() {
|
public BiomeProvider getBiomeProvider() {
|
||||||
return ((BukkitChunkGeneratorWrapper) delegate.getWorld().getGenerator()).getWorldConfig().getProvider();
|
return ((BukkitChunkGeneratorWrapper) delegate.getWorld().getGenerator()).getPack().getBiomeProvider();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public WorldConfig getConfig() {
|
|
||||||
return ((BukkitChunkGeneratorWrapper) delegate.getWorld().getGenerator()).getWorldConfig();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -59,13 +59,12 @@ public final class FabricAddon implements BaseAddon {
|
|||||||
.getHandler(FunctionalEventHandler.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
.register(this, ConfigPackPreLoadEvent.class)
|
.register(this, ConfigPackPreLoadEvent.class)
|
||||||
.then(event -> {
|
.then(event -> {
|
||||||
PreLoadCompatibilityOptions template = new PreLoadCompatibilityOptions();
|
|
||||||
try {
|
try {
|
||||||
event.loadTemplate(template);
|
PreLoadCompatibilityOptions template = event.loadTemplate(new PreLoadCompatibilityOptions());
|
||||||
|
templates.put(event.getPack(), Mutable.of(template, null));
|
||||||
} catch(ConfigException e) {
|
} catch(ConfigException e) {
|
||||||
logger.error("Error loading config template", e);
|
logger.error("Error loading config template", e);
|
||||||
}
|
}
|
||||||
templates.put(event.getPack(), Mutable.of(template, null));
|
|
||||||
})
|
})
|
||||||
.global();
|
.global();
|
||||||
|
|
||||||
@@ -73,15 +72,11 @@ public final class FabricAddon implements BaseAddon {
|
|||||||
.getHandler(FunctionalEventHandler.class)
|
.getHandler(FunctionalEventHandler.class)
|
||||||
.register(this, ConfigPackPostLoadEvent.class)
|
.register(this, ConfigPackPostLoadEvent.class)
|
||||||
.then(event -> {
|
.then(event -> {
|
||||||
PostLoadCompatibilityOptions template = new PostLoadCompatibilityOptions();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
event.loadTemplate(template);
|
templates.get(event.getPack()).setRight(event.loadTemplate(new PostLoadCompatibilityOptions()));
|
||||||
} catch(ConfigException e) {
|
} catch(ConfigException e) {
|
||||||
logger.error("Error loading config template", e);
|
logger.error("Error loading config template", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
templates.get(event.getPack()).setRight(template);
|
|
||||||
})
|
})
|
||||||
.priority(100)
|
.priority(100)
|
||||||
.global();
|
.global();
|
||||||
|
|||||||
Reference in New Issue
Block a user