- use maven-publish plugin
- provide context with setup events
This commit is contained in:
parent
179965fc9c
commit
dfb3a4c7b2
@ -25,7 +25,7 @@
|
||||
|
||||
package com.terraforged.api.biome.modifier;
|
||||
|
||||
public interface BiomeModifierRegistrar {
|
||||
|
||||
public interface ModifierManager {
|
||||
|
||||
void register(BiomeModifier modifier);
|
||||
}
|
@ -35,8 +35,6 @@ import net.minecraft.world.chunk.IChunk;
|
||||
public interface ColumnDecorator {
|
||||
|
||||
FastSource variance = (FastSource) Source.perlin(0, 100, 1);
|
||||
ThreadLocal<BlockPos.Mutable> pos = ThreadLocal.withInitial(BlockPos.Mutable::new);
|
||||
ThreadLocal<BlockPos.Mutable> pos1 = ThreadLocal.withInitial(BlockPos.Mutable::new);
|
||||
|
||||
void decorate(IChunk chunk, ProcessorContext context, int x, int y, int z);
|
||||
|
||||
@ -44,9 +42,15 @@ public interface ColumnDecorator {
|
||||
decorate(buffer.getDelegate(), context, x, y, z);
|
||||
}
|
||||
|
||||
default void setState(IChunk chunk, int x, int y, int z, BlockState state, boolean moving) {
|
||||
chunk.setBlockState(new BlockPos(x, y, z), state, moving);
|
||||
}
|
||||
|
||||
default void fillDown(IChunk chunk, int x, int z, int from, int to, BlockState state) {
|
||||
for (int dy = from; dy > to; dy--) {
|
||||
chunk.setBlockState(pos.get().setPos(x, dy, z), state, false);
|
||||
try (BlockPos.PooledMutable pos = pos()) {
|
||||
for (int dy = from; dy > to; dy--) {
|
||||
chunk.setBlockState(pos.setPos(x, dy, z), state, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,4 +61,8 @@ public interface ColumnDecorator {
|
||||
static float getNoise(float x, float z, int seed, int scale, int bias) {
|
||||
return getNoise(x, z, seed, scale / 255F, bias / 255F);
|
||||
}
|
||||
|
||||
static BlockPos.PooledMutable pos() {
|
||||
return BlockPos.PooledMutable.retain();
|
||||
}
|
||||
}
|
||||
|
@ -33,18 +33,18 @@ import net.minecraft.world.chunk.IChunk;
|
||||
|
||||
public interface Surface {
|
||||
|
||||
BlockPos.Mutable pos = new BlockPos.Mutable();
|
||||
|
||||
void buildSurface(int x, int z, int height, SurfaceContext ctx);
|
||||
|
||||
default void fill(int x, int z, int start, int end, IChunk chunk, BlockState state) {
|
||||
if (start < end) {
|
||||
for (int y = start; y < end; y++) {
|
||||
chunk.setBlockState(pos.setPos(x, y, z), state, false);
|
||||
}
|
||||
} else if (start > end) {
|
||||
for (int y = start; y > end; y--) {
|
||||
chunk.setBlockState(pos.setPos(x, y, z), state, false);
|
||||
try (BlockPos.PooledMutable pos = BlockPos.PooledMutable.retain()) {
|
||||
if (start < end) {
|
||||
for (int y = start; y < end; y++) {
|
||||
chunk.setBlockState(pos.setPos(x, y, z), state, false);
|
||||
}
|
||||
} else if (start > end) {
|
||||
for (int y = start; y > end; y--) {
|
||||
chunk.setBlockState(pos.setPos(x, y, z), state, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,73 +25,97 @@
|
||||
|
||||
package com.terraforged.api.event;
|
||||
|
||||
import com.terraforged.api.biome.modifier.ModifierManager;
|
||||
import com.terraforged.api.chunk.column.DecoratorManager;
|
||||
import com.terraforged.api.chunk.surface.SurfaceManager;
|
||||
import com.terraforged.api.material.geology.GeologyManager;
|
||||
import com.terraforged.api.material.layer.LayerManager;
|
||||
import com.terraforged.core.world.GeneratorContext;
|
||||
import com.terraforged.core.world.terrain.provider.TerrainProvider;
|
||||
import com.terraforged.feature.modifier.FeatureModifiers;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
public abstract class TerraEvent<T> extends Event {
|
||||
public abstract class SetupEvent<T> extends Event {
|
||||
|
||||
private final T manager;
|
||||
private final GeneratorContext context;
|
||||
|
||||
public TerraEvent(T manager) {
|
||||
public SetupEvent(T manager, GeneratorContext context) {
|
||||
this.manager = manager;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Manager/Service being setup
|
||||
*/
|
||||
public T getManager() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the generator setup context
|
||||
*/
|
||||
public GeneratorContext getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to register custom biome Surface decorators
|
||||
*/
|
||||
public static class Surface extends TerraEvent<SurfaceManager> {
|
||||
public static class Surface extends SetupEvent<SurfaceManager> {
|
||||
|
||||
public Surface(SurfaceManager manager) {
|
||||
super(manager);
|
||||
public Surface(SurfaceManager manager, GeneratorContext context) {
|
||||
super(manager, context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register additional layer blocks (such as Snow Layers)
|
||||
*/
|
||||
public static class Layers extends TerraEvent<LayerManager> {
|
||||
public static class Layers extends SetupEvent<LayerManager> {
|
||||
|
||||
public Layers(LayerManager manager) {
|
||||
super(manager);
|
||||
public Layers(LayerManager manager, GeneratorContext context) {
|
||||
super(manager, context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register custom Strata and Geologies
|
||||
*/
|
||||
public static class Geology extends TerraEvent<GeologyManager> {
|
||||
public static class Geology extends SetupEvent<GeologyManager> {
|
||||
|
||||
public Geology(GeologyManager manager) {
|
||||
super(manager);
|
||||
public Geology(GeologyManager manager, GeneratorContext context) {
|
||||
super(manager, context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register custom BiomeModifiers
|
||||
*/
|
||||
public static class BiomeModifier extends SetupEvent<ModifierManager> {
|
||||
|
||||
public BiomeModifier(ModifierManager manager, GeneratorContext context) {
|
||||
super(manager, context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register custom FeatureModifiers
|
||||
*/
|
||||
public static class Features extends TerraEvent<FeatureModifiers> {
|
||||
public static class Features extends SetupEvent<FeatureModifiers> {
|
||||
|
||||
public Features(FeatureModifiers manager) {
|
||||
super(manager);
|
||||
public Features(FeatureModifiers manager, GeneratorContext context) {
|
||||
super(manager, context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register custom Terrain Populators
|
||||
*/
|
||||
public static class Terrain extends TerraEvent<TerrainProvider> {
|
||||
public static class Terrain extends SetupEvent<TerrainProvider> {
|
||||
|
||||
public Terrain(TerrainProvider provider) {
|
||||
super(provider);
|
||||
public Terrain(TerrainProvider provider, GeneratorContext context) {
|
||||
super(provider, context);
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,10 +124,10 @@ public abstract class TerraEvent<T> extends Event {
|
||||
* - base decorators process chunk columns early in the generation process (before biome surfaces etc)
|
||||
* - feature decorators process chunk columns late in the generation process (after all features have been placed)
|
||||
*/
|
||||
public static class Decorators extends TerraEvent<DecoratorManager> {
|
||||
public static class Decorators extends SetupEvent<DecoratorManager> {
|
||||
|
||||
public Decorators(DecoratorManager manager) {
|
||||
super(manager);
|
||||
public Decorators(DecoratorManager manager, GeneratorContext context) {
|
||||
super(manager, context);
|
||||
}
|
||||
}
|
||||
}
|
@ -32,7 +32,6 @@ import com.terraforged.core.world.heightmap.RegionConfig;
|
||||
import com.terraforged.core.world.terrain.LandForms;
|
||||
import com.terraforged.core.world.terrain.Terrain;
|
||||
import com.terraforged.core.world.terrain.TerrainPopulator;
|
||||
import com.terraforged.core.world.terrain.Terrains;
|
||||
import com.terraforged.core.world.terrain.VolcanoPopulator;
|
||||
import me.dags.noise.Module;
|
||||
import me.dags.noise.Source;
|
||||
@ -78,11 +77,6 @@ public class StandardTerrainProvider implements TerrainProvider {
|
||||
registerUnMixable(context.terrain.mountains, landForms.mountains3(context.seed));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Terrains getTerrain() {
|
||||
return context.terrain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerMixable(TerrainPopulator populator) {
|
||||
populators.putIfAbsent(populator.getType(), populator);
|
||||
|
@ -29,7 +29,6 @@ import com.terraforged.core.cell.Populator;
|
||||
import com.terraforged.core.world.terrain.LandForms;
|
||||
import com.terraforged.core.world.terrain.Terrain;
|
||||
import com.terraforged.core.world.terrain.TerrainPopulator;
|
||||
import com.terraforged.core.world.terrain.Terrains;
|
||||
import me.dags.noise.Module;
|
||||
|
||||
import java.util.List;
|
||||
@ -39,8 +38,6 @@ import java.util.List;
|
||||
*/
|
||||
public interface TerrainProvider {
|
||||
|
||||
Terrains getTerrain();
|
||||
|
||||
LandForms getLandforms();
|
||||
|
||||
/**
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit f7e27c70a2a2b30225a85137688d2014f9ad1b6f
|
||||
Subproject commit 0cd63563bdc0fad258d78c21dfed1b14c975bdfd
|
Loading…
Reference in New Issue
Block a user