more pos refactor stuff
This commit is contained in:
parent
c566614f66
commit
f17036097d
@ -36,9 +36,9 @@ public interface ColumnDecorator {
|
||||
|
||||
FastSource variance = (FastSource) Source.perlin(0, 100, 1);
|
||||
|
||||
void decorate(IChunk chunk, ProcessorContext context, int x, int y, int z);
|
||||
void decorate(IChunk chunk, DecoratorContext context, int x, int y, int z);
|
||||
|
||||
default void decorate(ChunkSurfaceBuffer buffer, ProcessorContext context, int x, int y, int z) {
|
||||
default void decorate(ChunkSurfaceBuffer buffer, DecoratorContext context, int x, int y, int z) {
|
||||
decorate(buffer.getDelegate(), context, x, y, z);
|
||||
}
|
||||
|
||||
@ -46,11 +46,9 @@ public interface ColumnDecorator {
|
||||
chunk.setBlockState(new BlockPos(x, y, z), state, moving);
|
||||
}
|
||||
|
||||
default void fillDown(IChunk chunk, int x, int z, int from, int to, BlockState state) {
|
||||
try (BlockPos.PooledMutable pos = ColumnDecorator.pos(x, from, z)) {
|
||||
for (int dy = from; dy > to; dy--) {
|
||||
chunk.setBlockState(pos.setPos(x, dy, z), state, false);
|
||||
}
|
||||
default void fillDown(DecoratorContext context, IChunk chunk, int x, int z, int from, int to, BlockState state) {
|
||||
for (int dy = from; dy > to; dy--) {
|
||||
chunk.setBlockState(context.pos.setPos(x, dy, z), state, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,8 +59,4 @@ 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(int x, int y, int z) {
|
||||
return BlockPos.PooledMutable.retain(x, y, z);
|
||||
}
|
||||
}
|
||||
|
@ -31,19 +31,21 @@ import com.terraforged.core.world.climate.Climate;
|
||||
import com.terraforged.core.world.heightmap.Levels;
|
||||
import com.terraforged.core.world.terrain.Terrain;
|
||||
import com.terraforged.core.world.terrain.Terrains;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.chunk.IChunk;
|
||||
|
||||
public class ProcessorContext extends ChunkContext {
|
||||
public class DecoratorContext extends ChunkContext {
|
||||
|
||||
public final Levels levels;
|
||||
public final Climate climate;
|
||||
public final Terrains terrains;
|
||||
public final BlockPos.Mutable pos = new BlockPos.Mutable();
|
||||
|
||||
public Biome biome;
|
||||
public Cell<Terrain> cell;
|
||||
|
||||
public ProcessorContext(IChunk chunk, Levels levels, Terrains terrain, Climate climate) {
|
||||
public DecoratorContext(IChunk chunk, Levels levels, Terrains terrain, Climate climate) {
|
||||
super(chunk);
|
||||
this.levels = levels;
|
||||
this.climate = climate;
|
@ -26,26 +26,22 @@
|
||||
package com.terraforged.api.chunk.surface;
|
||||
|
||||
|
||||
import com.terraforged.api.chunk.column.ColumnDecorator;
|
||||
import com.terraforged.api.chunk.surface.builder.Combiner;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.chunk.IChunk;
|
||||
|
||||
public interface Surface {
|
||||
|
||||
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) {
|
||||
try (BlockPos.PooledMutable pos = ColumnDecorator.pos(x, start, z)) {
|
||||
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);
|
||||
}
|
||||
default void fill(int x, int z, int start, int end, SurfaceContext ctx, IChunk chunk, BlockState state) {
|
||||
if (start < end) {
|
||||
for (int y = start; y < end; y++) {
|
||||
chunk.setBlockState(ctx.pos.setPos(x, y, z), state, false);
|
||||
}
|
||||
} else if (start > end) {
|
||||
for (int y = start; y > end; y--) {
|
||||
chunk.setBlockState(ctx.pos.setPos(x, y, z), state, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
package com.terraforged.api.chunk.surface;
|
||||
|
||||
import com.terraforged.api.chunk.column.ProcessorContext;
|
||||
import com.terraforged.api.chunk.column.DecoratorContext;
|
||||
import com.terraforged.core.world.climate.Climate;
|
||||
import com.terraforged.core.world.heightmap.Levels;
|
||||
import com.terraforged.core.world.terrain.Terrains;
|
||||
@ -33,7 +33,7 @@ import net.minecraft.block.BlockState;
|
||||
import net.minecraft.world.chunk.IChunk;
|
||||
import net.minecraft.world.gen.GenerationSettings;
|
||||
|
||||
public class SurfaceContext extends ProcessorContext {
|
||||
public class SurfaceContext extends DecoratorContext {
|
||||
|
||||
public final BlockState solid;
|
||||
public final BlockState fluid;
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 3717ff07d10d449d8a5c77ff75cf88f00e277429
|
||||
Subproject commit 8077a91476371a9d71567763a55982c5e05b4cdc
|
Loading…
Reference in New Issue
Block a user