mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-06-17 22:31:52 +00:00
move column impl to main api
This commit is contained in:
-70
@@ -1,70 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2020-2021 Polyhedral Development
|
|
||||||
*
|
|
||||||
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
|
|
||||||
* reference the LICENSE file in this module's root directory.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.dfsek.terra.addons.generation.feature;
|
|
||||||
|
|
||||||
import java.util.function.IntConsumer;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.block.state.BlockState;
|
|
||||||
import com.dfsek.terra.api.structure.feature.BinaryColumn;
|
|
||||||
import com.dfsek.terra.api.world.WritableWorld;
|
|
||||||
import com.dfsek.terra.api.world.chunk.generation.util.Column;
|
|
||||||
|
|
||||||
|
|
||||||
public class ColumnImpl<T extends WritableWorld> implements Column<T> {
|
|
||||||
private final int x;
|
|
||||||
private final int z;
|
|
||||||
private final T world;
|
|
||||||
|
|
||||||
public ColumnImpl(int x, int z, T world) {
|
|
||||||
this.x = x;
|
|
||||||
this.z = z;
|
|
||||||
this.world = world;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getX() {
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getZ() {
|
|
||||||
return z;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getBlock(int y) {
|
|
||||||
return world.getBlockState(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T getWorld() {
|
|
||||||
return world;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMinY() {
|
|
||||||
return world.getMinHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMaxY() {
|
|
||||||
return world.getMaxHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void forEach(IntConsumer function) {
|
|
||||||
for(int y = world.getMinHeight(); y < world.getMaxHeight(); y++) {
|
|
||||||
function.accept(y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BinaryColumn newBinaryColumn() {
|
|
||||||
return new BinaryColumn(getMinY(), getMaxY());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+42
-9
@@ -17,20 +17,53 @@ import com.dfsek.terra.api.world.WritableWorld;
|
|||||||
/**
|
/**
|
||||||
* A single vertical column of a world.
|
* A single vertical column of a world.
|
||||||
*/
|
*/
|
||||||
public interface Column<T extends WritableWorld> {
|
public class Column<T extends WritableWorld> {
|
||||||
int getX();
|
private final int x;
|
||||||
|
private final int z;
|
||||||
|
private final T world;
|
||||||
|
|
||||||
int getZ();
|
public Column(int x, int z, T world) {
|
||||||
|
this.x = x;
|
||||||
|
this.z = z;
|
||||||
|
this.world = world;
|
||||||
|
}
|
||||||
|
|
||||||
BlockState getBlock(int y);
|
public int getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
T getWorld();
|
public int getZ() {
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
int getMinY();
|
public BlockState getBlock(int y) {
|
||||||
|
return world.getBlockState(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
int getMaxY();
|
public T getWorld() {
|
||||||
|
return world;
|
||||||
|
}
|
||||||
|
|
||||||
void forEach(IntConsumer function);
|
public int getMinY() {
|
||||||
|
return world.getMinHeight();
|
||||||
|
}
|
||||||
|
|
||||||
BinaryColumn newBinaryColumn();
|
public int getMaxY() {
|
||||||
|
return world.getMaxHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void forEach(IntConsumer function) {
|
||||||
|
for(int y = world.getMinHeight(); y < world.getMaxHeight(); y++) {
|
||||||
|
function.accept(y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BinaryColumn newBinaryColumn() {
|
||||||
|
return new BinaryColumn(getMinY(), getMaxY());
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public Column<T> adjacent(int offsetX, int offsetZ) {
|
||||||
|
return (Column<T>) world.column(x + offsetX, z + offsetZ);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user