consistency changes

This commit is contained in:
MattBDev
2020-01-26 13:01:16 -05:00
parent e0f6869573
commit 8078cf077a
32 changed files with 296 additions and 388 deletions

View File

@ -8,6 +8,7 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import org.jetbrains.annotations.Range;
public interface IChunkExtent<T extends IChunk> extends Extent {
/**
@ -20,7 +21,7 @@ public interface IChunkExtent<T extends IChunk> extends Extent {
T getOrCreateChunk(int chunkX, int chunkZ);
@Override
default <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B state) {
default <B extends BlockStateHolder<B>> boolean setBlock(int x, @Range(from = 0, to = 255) int y, int z, B state) {
final IChunk chunk = getOrCreateChunk(x >> 4, z >> 4);
return chunk.setBlock(x & 15, y, z & 15, state);
}

View File

@ -97,13 +97,13 @@ public abstract class CharBlocks implements IBlocks {
return BlockTypesCache.states[get(x, y, z)];
}
public char get(int x, int y, int z) {
public char get(int x, @Range(from = 0, to = 255) int y, int z) {
final int layer = y >> 4;
final int index = (y & 15) << 8 | z << 4 | x;
return sections[layer].get(this, layer, index);
}
public void set(int x, int y, int z, char value) {
public void set(int x, @Range(from = 0, to = 255) int y, int z, char value) {
final int layer = y >> 4;
final int index = (y & 15) << 8 | z << 4 | x;
try {
@ -130,13 +130,13 @@ public abstract class CharBlocks implements IBlocks {
public static abstract class Section {
public abstract char[] get(CharBlocks blocks, int layer);
public abstract char[] get(CharBlocks blocks, @Range(from = 0, to = 15) int layer);
public final char get(CharBlocks blocks, int layer, int index) {
public final char get(CharBlocks blocks, @Range(from = 0, to = 15) int layer, int index) {
return get(blocks, layer)[index];
}
public final void set(CharBlocks blocks, int layer, int index, char value) {
public final void set(CharBlocks blocks, @Range(from = 0, to = 15) int layer, int index, char value) {
get(blocks, layer)[index] = value;
}
}

View File

@ -22,6 +22,7 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.stream.IntStream;
import org.jetbrains.annotations.Range;
public class CharSetBlocks extends CharBlocks implements IChunkSet {
private static Pool<CharSetBlocks> POOL = FaweCache.INSTANCE.registerPool(CharSetBlocks.class, CharSetBlocks::new, Settings.IMP.QUEUE.POOL);
@ -82,7 +83,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T holder) {
public <T extends BlockStateHolder<T>> boolean setBlock(int x, @Range(from = 0, to = 255) int y, int z, T holder) {
set(x, y, z, holder.getOrdinalChar());
holder.applyTileEntity(this, x, y, z);
return true;

View File

@ -23,6 +23,7 @@ import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Future;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Range;
/**
* An abstract {@link IChunk} class that implements basic get/set blocks
@ -208,7 +209,7 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(ChunkHolder chunk, int x, int y, int z, T block) {
public <B extends BlockStateHolder<B>> boolean setBlock(ChunkHolder chunk, int x, @Range(from = 0, to = 255) int y, int z, B block) {
return chunk.chunkSet.setBlock(x, y, z, block);
}