mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-03 14:26:27 +00:00
remove most references to ConfigPack from API
This commit is contained in:
@@ -18,7 +18,6 @@ import com.dfsek.terra.addons.manifest.api.MonadAddonInitializer;
|
||||
import com.dfsek.terra.addons.manifest.api.monad.Do;
|
||||
import com.dfsek.terra.addons.manifest.api.monad.Get;
|
||||
import com.dfsek.terra.addons.manifest.api.monad.Init;
|
||||
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.properties.Context;
|
||||
@@ -26,7 +25,6 @@ import com.dfsek.terra.api.properties.PropertyKey;
|
||||
import com.dfsek.terra.api.util.function.monad.Monad;
|
||||
import com.dfsek.terra.api.util.generic.Construct;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.provider.ChunkGeneratorProvider;
|
||||
|
||||
|
||||
public class NoiseChunkGenerator3DAddon implements MonadAddonInitializer {
|
||||
|
||||
@@ -25,7 +25,6 @@ import com.dfsek.terra.addons.manifest.api.monad.Do;
|
||||
import com.dfsek.terra.addons.manifest.api.monad.Get;
|
||||
import com.dfsek.terra.addons.manifest.api.monad.Init;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
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.properties.Context;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class FeatureGenerationStage implements GenerationStage, StringIdentifiab
|
||||
for(int chunkZ = 0; chunkZ < 16; chunkZ += resolution) {
|
||||
int tx = cx + chunkX;
|
||||
int tz = cz + chunkZ;
|
||||
world.getBiomeProvider()
|
||||
world.biomeProvider()
|
||||
.getColumn(tx, tz, world)
|
||||
.forRanges(resolution, (min, max, biome) -> {
|
||||
for(int subChunkX = 0; subChunkX < resolution; subChunkX++) {
|
||||
|
||||
@@ -5,13 +5,11 @@ import com.dfsek.terra.addons.manifest.api.MonadAddonInitializer;
|
||||
import com.dfsek.terra.addons.manifest.api.monad.Do;
|
||||
import com.dfsek.terra.addons.manifest.api.monad.Get;
|
||||
import com.dfsek.terra.addons.manifest.api.monad.Init;
|
||||
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.util.function.monad.Monad;
|
||||
import com.dfsek.terra.api.util.generic.Construct;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.provider.GenerationStageProvider;
|
||||
|
||||
|
||||
public class StructureGenerationAddon implements MonadAddonInitializer {
|
||||
|
||||
@@ -19,11 +19,7 @@ import com.dfsek.terra.api.util.function.monad.Monad;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
import com.dfsek.terra.api.event.events.config.ConfigurationDiscoveryEvent;
|
||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||
import com.dfsek.terra.api.inject.annotations.Inject;
|
||||
|
||||
|
||||
public class YamlAddon implements MonadAddonInitializer {
|
||||
|
||||
@@ -43,7 +43,7 @@ public class BiomeFunction implements Function<String> {
|
||||
arguments.getRotation());
|
||||
|
||||
|
||||
BiomeProvider grid = arguments.getWorld().getBiomeProvider();
|
||||
BiomeProvider grid = arguments.getWorld().biomeProvider();
|
||||
|
||||
return grid.getBiome(arguments.getOrigin()
|
||||
.toVector3()
|
||||
|
||||
@@ -18,7 +18,6 @@ import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
import com.dfsek.terra.api.event.events.world.generation.EntitySpawnEvent;
|
||||
import com.dfsek.terra.api.util.RotationUtil;
|
||||
import com.dfsek.terra.api.util.vector.Vector2;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.block.entity.BlockEntity;
|
||||
import com.dfsek.terra.api.block.entity.Container;
|
||||
import com.dfsek.terra.api.event.events.world.generation.LootPopulateEvent;
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.registry.key.RegistryKey;
|
||||
import com.dfsek.terra.api.structure.LootTable;
|
||||
|
||||
@@ -68,7 +68,7 @@ public class CheckFunction implements Function<String> {
|
||||
private String apply(Vector3 vector, WritableWorld world) {
|
||||
int y = vector.getBlockY();
|
||||
if(y >= world.getMaxHeight() || y < 0) return "AIR";
|
||||
SamplerProvider cache = ((NoiseChunkGenerator3D) world.getGenerator()).samplerProvider();
|
||||
SamplerProvider cache = ((NoiseChunkGenerator3D) world.generator()).samplerProvider();
|
||||
double comp = sample(vector.getX(), vector.getY(), vector.getZ(), cache, world);
|
||||
|
||||
if(comp > 0) return "LAND"; // If noise val is greater than zero, location will always be land.
|
||||
@@ -84,6 +84,6 @@ public class CheckFunction implements Function<String> {
|
||||
private double sample(double x, double y, double z, SamplerProvider cache, World world) {
|
||||
int cx = FastMath.floorDiv((int) x, 16);
|
||||
int cz = FastMath.floorDiv((int) z, 16);
|
||||
return cache.getChunk(cx, cz, world, world.getBiomeProvider()).sample(x - (cx << 4), y, z - (cz << 4));
|
||||
return cache.getChunk(cx, cz, world, world.biomeProvider()).sample(x - (cx << 4), y, z - (cz << 4));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,11 +133,7 @@ public class RegistryArgument<T, R> extends CommandArgument<T, R> {
|
||||
try {
|
||||
result = registry.get(RegistryKey.parse(input));
|
||||
} catch(IllegalArgumentException e) {
|
||||
try {
|
||||
result = registry.getByID(input);
|
||||
} catch(IllegalArgumentException e1) {
|
||||
return ArgumentParseResult.failure(e1);
|
||||
}
|
||||
return ArgumentParseResult.failure(e);
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Polyhedral Development
|
||||
*
|
||||
* The Terra API is licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in the common/api directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.api.event.events;
|
||||
|
||||
|
||||
/**
|
||||
* An event with functionality directly linked to a {@link ConfigPack}.
|
||||
* <p>
|
||||
* PackEvents are only invoked when the pack specifies the addon in its
|
||||
* {@code addon} key (or when the listener is global).
|
||||
*/
|
||||
@SuppressWarnings("InterfaceMayBeAnnotatedFunctional")
|
||||
public interface PackEvent extends Event {
|
||||
/**
|
||||
* Get the {@link ConfigPack} associated with this event.
|
||||
*
|
||||
* @return ConfigPack associated with the event.
|
||||
*/
|
||||
ConfigPack getPack();
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Polyhedral Development
|
||||
*
|
||||
* The Terra API is licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in the common/api directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.api.event.events.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.Configuration;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import com.dfsek.terra.api.event.events.FailThroughEvent;
|
||||
import com.dfsek.terra.api.event.events.PackEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Fired when a pack is searched for {@link Configuration}s.
|
||||
* <p>
|
||||
* Addons should listen to this event if they wish to add
|
||||
* another configuration format.
|
||||
*/
|
||||
public class ConfigurationDiscoveryEvent implements PackEvent, FailThroughEvent {
|
||||
private final ConfigPack pack;
|
||||
private final Loader loader;
|
||||
|
||||
private final BiConsumer<String, Configuration> consumer;
|
||||
|
||||
public ConfigurationDiscoveryEvent(ConfigPack pack, Loader loader, BiConsumer<String, Configuration> consumer) {
|
||||
this.pack = pack;
|
||||
this.loader = loader;
|
||||
this.consumer = consumer;
|
||||
}
|
||||
|
||||
public void register(String identifier, Configuration config) {
|
||||
consumer.accept(identifier, config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigPack getPack() {
|
||||
return pack;
|
||||
}
|
||||
|
||||
public Loader getLoader() {
|
||||
return loader;
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Polyhedral Development
|
||||
*
|
||||
* The Terra API is licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in the common/api directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.api.event.events.config;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
||||
import com.dfsek.tectonic.impl.abstraction.AbstractConfiguration;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.dfsek.terra.api.event.events.FailThroughEvent;
|
||||
import com.dfsek.terra.api.event.events.PackEvent;
|
||||
import com.dfsek.terra.api.util.reflection.ReflectionUtil;
|
||||
|
||||
|
||||
/**
|
||||
* Fired when each individual configuration is loaded.
|
||||
* <p>
|
||||
* Addons should listen to this event if they wish to add
|
||||
* config values to existing {@link ConfigType}s.
|
||||
*/
|
||||
public class ConfigurationLoadEvent implements PackEvent, FailThroughEvent {
|
||||
private final ConfigPack pack;
|
||||
private final AbstractConfiguration configuration;
|
||||
private final Consumer<ConfigTemplate> loader;
|
||||
private final ConfigType<?, ?> type;
|
||||
|
||||
private final Object loaded;
|
||||
|
||||
public ConfigurationLoadEvent(ConfigPack pack, AbstractConfiguration configuration, Consumer<ConfigTemplate> loader,
|
||||
ConfigType<?, ?> type, Object loaded) {
|
||||
this.pack = pack;
|
||||
this.configuration = configuration;
|
||||
this.loader = loader;
|
||||
this.type = type;
|
||||
this.loaded = loaded;
|
||||
}
|
||||
|
||||
public <T extends ConfigTemplate> T load(T template) {
|
||||
loader.accept(template);
|
||||
return template;
|
||||
}
|
||||
|
||||
public boolean is(Class<?> clazz) {
|
||||
return clazz.isAssignableFrom(type.getTypeKey().getRawType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigPack getPack() {
|
||||
return pack;
|
||||
}
|
||||
|
||||
public AbstractConfiguration getConfiguration() {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
public ConfigType<?, ?> getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getLoadedObject(Class<T> clazz) {
|
||||
if(!clazz.isAssignableFrom(type.getTypeKey().getRawType()))
|
||||
throw new ClassCastException(
|
||||
"Cannot assign object from loader of type " + ReflectionUtil.typeToString(type.getTypeKey().getType()) + " to class " +
|
||||
clazz.getCanonicalName());
|
||||
return (T) loaded;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getLoadedObject() {
|
||||
return (T) loaded;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Polyhedral Development
|
||||
*
|
||||
* The Terra API is licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in the common/api directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.api.event.events.config.pack;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
||||
import com.dfsek.tectonic.api.exception.ConfigException;
|
||||
|
||||
import com.dfsek.terra.api.event.events.FailThroughEvent;
|
||||
import com.dfsek.terra.api.event.events.PackEvent;
|
||||
|
||||
|
||||
/**
|
||||
* An event related to the loading process of config packs.
|
||||
*/
|
||||
public abstract class ConfigPackLoadEvent implements PackEvent, FailThroughEvent {
|
||||
private final ConfigPack pack;
|
||||
private final ExceptionalConsumer<ConfigTemplate> configLoader;
|
||||
|
||||
public ConfigPackLoadEvent(ConfigPack pack, ExceptionalConsumer<ConfigTemplate> configLoader) {
|
||||
this.pack = pack;
|
||||
this.configLoader = configLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a custom {@link ConfigTemplate} using the pack manifest.
|
||||
*
|
||||
* @param template Template to register.
|
||||
*/
|
||||
public <T extends ConfigTemplate> T loadTemplate(T template) throws ConfigException {
|
||||
configLoader.accept(template);
|
||||
return template;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigPack getPack() {
|
||||
return pack;
|
||||
}
|
||||
|
||||
public interface ExceptionalConsumer<T extends ConfigTemplate> {
|
||||
void accept(T value) throws ConfigException;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Polyhedral Development
|
||||
*
|
||||
* The Terra API is licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in the common/api directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.api.event.events.config.pack;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
||||
|
||||
|
||||
/**
|
||||
* Called when a config pack has finished loading.
|
||||
*/
|
||||
public class ConfigPackPostLoadEvent extends ConfigPackLoadEvent {
|
||||
public ConfigPackPostLoadEvent(ConfigPack pack, ExceptionalConsumer<ConfigTemplate> loader) {
|
||||
super(pack, loader);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Polyhedral Development
|
||||
*
|
||||
* The Terra API is licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in the common/api directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.api.event.events.config.pack;
|
||||
|
||||
import com.dfsek.tectonic.api.config.template.ConfigTemplate;
|
||||
|
||||
|
||||
/**
|
||||
* Called before a config pack's registries are filled.
|
||||
*/
|
||||
public class ConfigPackPreLoadEvent extends ConfigPackLoadEvent {
|
||||
public ConfigPackPreLoadEvent(ConfigPack pack, ExceptionalConsumer<ConfigTemplate> configLoader) {
|
||||
super(pack, configLoader);
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Polyhedral Development
|
||||
*
|
||||
* The Terra API is licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in the common/api directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.api.event.events.config.type;
|
||||
|
||||
import com.dfsek.terra.api.event.events.FailThroughEvent;
|
||||
import com.dfsek.terra.api.event.events.PackEvent;
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.util.reflection.ReflectionUtil;
|
||||
|
||||
|
||||
public abstract class ConfigTypeLoadEvent implements PackEvent, FailThroughEvent {
|
||||
private final ConfigType<?, ?> type;
|
||||
private final Registry<?> registry;
|
||||
|
||||
private final ConfigPack pack;
|
||||
|
||||
public ConfigTypeLoadEvent(ConfigType<?, ?> type, Registry<?> registry, ConfigPack pack) {
|
||||
this.type = type;
|
||||
this.registry = registry;
|
||||
this.pack = pack;
|
||||
}
|
||||
|
||||
public boolean is(Class<?> clazz) {
|
||||
return clazz.isAssignableFrom(type.getTypeKey().getRawType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigPack getPack() {
|
||||
return pack;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> Registry<T> getRegistry(Class<T> clazz) {
|
||||
if(!clazz.isAssignableFrom(type.getTypeKey().getRawType()))
|
||||
throw new ClassCastException(
|
||||
"Cannot assign object from loader of type " + ReflectionUtil.typeToString(type.getTypeKey().getType()) + " to class " +
|
||||
clazz.getCanonicalName());
|
||||
return (Registry<T>) registry;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Polyhedral Development
|
||||
*
|
||||
* The Terra API is licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in the common/api directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.api.event.events.config.type;
|
||||
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
|
||||
|
||||
public class ConfigTypePostLoadEvent extends ConfigTypeLoadEvent {
|
||||
public ConfigTypePostLoadEvent(ConfigType<?, ?> type, Registry<?> registry, ConfigPack pack) {
|
||||
super(type, registry, pack);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Polyhedral Development
|
||||
*
|
||||
* The Terra API is licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in the common/api directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.api.event.events.config.type;
|
||||
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
|
||||
|
||||
public class ConfigTypePreLoadEvent extends ConfigTypeLoadEvent {
|
||||
public ConfigTypePreLoadEvent(ConfigType<?, ?> type, Registry<?> registry, ConfigPack pack) {
|
||||
super(type, registry, pack);
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Polyhedral Development
|
||||
*
|
||||
* The Terra API is licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in the common/api directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.api.event.events.world.generation;
|
||||
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.event.events.PackEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Called when an entity is spawned.
|
||||
*/
|
||||
public class EntitySpawnEvent implements PackEvent {
|
||||
private final ConfigPack pack;
|
||||
private final Entity entity;
|
||||
|
||||
public EntitySpawnEvent(ConfigPack pack, Entity entity) {
|
||||
this.pack = pack;
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigPack getPack() {
|
||||
return pack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entity that triggered the event.
|
||||
*
|
||||
* @return The entity.
|
||||
*/
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Polyhedral Development
|
||||
*
|
||||
* The Terra API is licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in the common/api directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.api.event.events.world.generation;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.dfsek.terra.api.block.entity.Container;
|
||||
import com.dfsek.terra.api.event.events.AbstractCancellable;
|
||||
import com.dfsek.terra.api.event.events.PackEvent;
|
||||
import com.dfsek.terra.api.structure.LootTable;
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
import com.dfsek.terra.api.util.vector.Vector3;
|
||||
|
||||
|
||||
/**
|
||||
* Called when loot is populated.
|
||||
*/
|
||||
public class LootPopulateEvent extends AbstractCancellable implements PackEvent {
|
||||
private final Container container;
|
||||
private final ConfigPack pack;
|
||||
private final Structure structure;
|
||||
private LootTable table;
|
||||
|
||||
public LootPopulateEvent(Container container, LootTable table, ConfigPack pack, Structure structure) {
|
||||
this.container = container;
|
||||
this.table = table;
|
||||
this.pack = pack;
|
||||
this.structure = structure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigPack getPack() {
|
||||
return pack;
|
||||
}
|
||||
|
||||
public Vector3 getPosition() {
|
||||
return container.getPosition();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link Container} representing the inventory.
|
||||
*
|
||||
* @return Inventory recieving loot.
|
||||
*/
|
||||
public Container getContainer() {
|
||||
return container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the loot table to be populated.
|
||||
*
|
||||
* @return Loot table.
|
||||
*/
|
||||
public LootTable getTable() {
|
||||
return table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the loot table to be populated.
|
||||
*
|
||||
* @param table New loot table.
|
||||
*/
|
||||
public void setTable(@NotNull LootTable table) {
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the script used to generate the structure.
|
||||
*
|
||||
* @return Structure script.
|
||||
*/
|
||||
public Structure getStructure() {
|
||||
return structure;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,8 @@ import com.dfsek.terra.api.world.util.Interceptors;
|
||||
import com.dfsek.terra.api.world.util.ReadInterceptor;
|
||||
import com.dfsek.terra.api.world.util.WriteInterceptor;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
/**
|
||||
* A {@link WritableWorld} implementation which delegates read/write operations to
|
||||
@@ -71,18 +73,13 @@ public class BufferedWorld implements WritableWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkGenerator getGenerator() {
|
||||
return delegate.getGenerator();
|
||||
public @NotNull ChunkGenerator generator() {
|
||||
return delegate.generator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeProvider getBiomeProvider() {
|
||||
return delegate.getBiomeProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigPack getPack() {
|
||||
return delegate.getPack();
|
||||
public @NotNull BiomeProvider biomeProvider() {
|
||||
return delegate.biomeProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,6 +4,9 @@ import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
||||
import com.dfsek.terra.api.world.info.WorldProperties;
|
||||
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a world.
|
||||
@@ -14,19 +17,16 @@ public interface World extends WorldProperties {
|
||||
*
|
||||
* @return Chunk generator.
|
||||
*/
|
||||
ChunkGenerator getGenerator();
|
||||
@NotNull
|
||||
@Contract(pure = true)
|
||||
ChunkGenerator generator();
|
||||
|
||||
/**
|
||||
* Get the {@link BiomeProvider} this world uses.
|
||||
*
|
||||
* @return Biome provider.
|
||||
*/
|
||||
BiomeProvider getBiomeProvider();
|
||||
|
||||
/**
|
||||
* Get the {@link ConfigPack} this world uses.
|
||||
*
|
||||
* @return Config pack.
|
||||
*/
|
||||
ConfigPack getPack();
|
||||
@NotNull
|
||||
@Contract(pure = true)
|
||||
BiomeProvider biomeProvider();
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Polyhedral Development
|
||||
*
|
||||
* The Terra API is licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in the common/api directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.api.world.chunk.generation.util.provider;
|
||||
|
||||
import com.dfsek.terra.api.world.chunk.generation.ChunkGenerator;
|
||||
|
||||
|
||||
public interface ChunkGeneratorProvider {
|
||||
ChunkGenerator newInstance(ConfigPack pack);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Polyhedral Development
|
||||
*
|
||||
* The Terra API is licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in the common/api directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.api.world.chunk.generation.util.provider;
|
||||
|
||||
import com.dfsek.terra.api.world.chunk.generation.stage.GenerationStage;
|
||||
|
||||
|
||||
public interface GenerationStageProvider {
|
||||
GenerationStage newInstance(ConfigPack pack);
|
||||
}
|
||||
@@ -57,11 +57,8 @@ import java.util.zip.ZipFile;
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.event.events.config.ConfigurationDiscoveryEvent;
|
||||
import com.dfsek.terra.api.event.events.config.ConfigurationLoadEvent;
|
||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPostLoadEvent;
|
||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||
import com.dfsek.terra.api.event.events.config.type.ConfigTypePostLoadEvent;
|
||||
import com.dfsek.terra.api.properties.Context;
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.registry.key.RegistryKey;
|
||||
@@ -72,7 +69,6 @@ import com.dfsek.terra.api.util.reflection.ReflectionUtil;
|
||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.api.world.chunk.generation.stage.GenerationStage;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.provider.ChunkGeneratorProvider;
|
||||
import com.dfsek.terra.config.fileloaders.FolderLoader;
|
||||
import com.dfsek.terra.config.fileloaders.ZIPLoader;
|
||||
import com.dfsek.terra.config.loaders.GenericTemplateSupplierLoader;
|
||||
|
||||
@@ -27,7 +27,6 @@ import java.util.List;
|
||||
|
||||
import com.dfsek.terra.api.config.meta.Meta;
|
||||
import com.dfsek.terra.api.world.chunk.generation.stage.GenerationStage;
|
||||
import com.dfsek.terra.api.world.chunk.generation.util.provider.ChunkGeneratorProvider;
|
||||
|
||||
|
||||
@SuppressWarnings({ "unused", "FieldMayBeFinal" })
|
||||
|
||||
@@ -31,7 +31,6 @@ import java.util.Map;
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
import com.dfsek.terra.api.event.events.Event;
|
||||
import com.dfsek.terra.api.event.events.FailThroughEvent;
|
||||
import com.dfsek.terra.api.event.events.PackEvent;
|
||||
import com.dfsek.terra.api.event.functional.EventContext;
|
||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.dfsek.terra.bukkit.world;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.generator.LimitedRegion;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -86,12 +87,12 @@ public class BukkitProtoWorld implements ProtoWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkGenerator getGenerator() {
|
||||
public @NotNull ChunkGenerator generator() {
|
||||
return ((BukkitChunkGeneratorWrapper) delegate.getWorld().getGenerator()).getHandle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeProvider getBiomeProvider() {
|
||||
public @NotNull BiomeProvider biomeProvider() {
|
||||
return biomeProvider;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ import com.dfsek.terra.bukkit.generator.BukkitChunkGeneratorWrapper;
|
||||
import com.dfsek.terra.bukkit.world.block.state.BukkitBlockEntity;
|
||||
import com.dfsek.terra.bukkit.world.entity.BukkitEntityType;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
public class BukkitServerWorld implements ServerWorld {
|
||||
private final org.bukkit.World delegate;
|
||||
@@ -82,12 +84,12 @@ public class BukkitServerWorld implements ServerWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkGenerator getGenerator() {
|
||||
public @NotNull ChunkGenerator generator() {
|
||||
return ((BukkitChunkGeneratorWrapper) delegate.getGenerator()).getHandle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeProvider getBiomeProvider() {
|
||||
public @NotNull BiomeProvider biomeProvider() {
|
||||
return ((BukkitChunkGeneratorWrapper) delegate.getGenerator()).getPack().getBiomeProvider();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.dfsek.terra.bukkit.nms.v1_19_R1;
|
||||
|
||||
import com.dfsek.terra.api.event.events.config.ConfigurationLoadEvent;
|
||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||
import com.dfsek.terra.api.world.biome.Biome;
|
||||
import com.dfsek.terra.bukkit.BukkitAddon;
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.dfsek.terra.cli.world;
|
||||
import com.google.common.collect.Streams;
|
||||
import net.jafama.FastMath;
|
||||
import net.querz.mca.MCAFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -190,12 +191,12 @@ public class CLIWorld implements ServerWorld, NBTSerializable<Stream<Pair<Vector
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkGenerator getGenerator() {
|
||||
public @NotNull ChunkGenerator generator() {
|
||||
return chunkGenerator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeProvider getBiomeProvider() {
|
||||
public @NotNull BiomeProvider biomeProvider() {
|
||||
return biomeProvider;
|
||||
}
|
||||
|
||||
@@ -265,12 +266,12 @@ public class CLIWorld implements ServerWorld, NBTSerializable<Stream<Pair<Vector
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkGenerator getGenerator() {
|
||||
public @NotNull ChunkGenerator generator() {
|
||||
return delegate.chunkGenerator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeProvider getBiomeProvider() {
|
||||
public @NotNull BiomeProvider biomeProvider() {
|
||||
return biomeProvider;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.dfsek.terra.api.addon.BaseAddon;
|
||||
import com.dfsek.terra.api.event.events.config.ConfigurationLoadEvent;
|
||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPostLoadEvent;
|
||||
import com.dfsek.terra.api.event.events.config.pack.ConfigPackPreLoadEvent;
|
||||
import com.dfsek.terra.api.event.functional.FunctionalEventHandler;
|
||||
|
||||
Reference in New Issue
Block a user