mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-12 10:18:36 +00:00
merge
This commit is contained in:
@ -4,6 +4,26 @@ import com.boydti.fawe.beta.IBlocks;
|
||||
import com.boydti.fawe.beta.IChunkSet;
|
||||
|
||||
public class CharBlocks implements IBlocks {
|
||||
|
||||
public static final Section FULL = new Section() {
|
||||
@Override
|
||||
public final char[] get(CharBlocks blocks, int layer) {
|
||||
return blocks.blocks[layer];
|
||||
}
|
||||
};
|
||||
public static final Section EMPTY = new Section() {
|
||||
@Override
|
||||
public final char[] get(CharBlocks blocks, int layer) {
|
||||
blocks.sections[layer] = FULL;
|
||||
char[] arr = blocks.blocks[layer];
|
||||
if (arr == null) {
|
||||
arr = blocks.blocks[layer] = blocks.load(layer);
|
||||
} else {
|
||||
blocks.blocks[layer] = blocks.load(layer, arr);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
};
|
||||
public final char[][] blocks;
|
||||
public final Section[] sections;
|
||||
|
||||
@ -15,11 +35,13 @@ public class CharBlocks implements IBlocks {
|
||||
public CharBlocks() {
|
||||
blocks = new char[16][];
|
||||
sections = new Section[16];
|
||||
for (int i = 0; i < 16; i++) sections[i] = EMPTY;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
sections[i] = EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trim(final boolean aggressive) {
|
||||
public boolean trim(boolean aggressive) {
|
||||
boolean result = true;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if (sections[i] == EMPTY) {
|
||||
@ -33,82 +55,67 @@ public class CharBlocks implements IBlocks {
|
||||
|
||||
@Override
|
||||
public IChunkSet reset() {
|
||||
for (int i = 0; i < 16; i++) sections[i] = EMPTY;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
sections[i] = EMPTY;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void reset(final int layer) {
|
||||
public void reset(int layer) {
|
||||
sections[layer] = EMPTY;
|
||||
}
|
||||
|
||||
public char[] load(final int layer) {
|
||||
public char[] load(int layer) {
|
||||
return new char[4096];
|
||||
}
|
||||
|
||||
public char[] load(final int layer, final char[] data) {
|
||||
for (int i = 0; i < 4096; i++) data[i] = 0;
|
||||
public char[] load(int layer, char[] data) {
|
||||
for (int i = 0; i < 4096; i++) {
|
||||
data[i] = 0;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSection(final int layer) {
|
||||
public boolean hasSection(int layer) {
|
||||
return sections[layer] == FULL;
|
||||
}
|
||||
|
||||
public char get(final int x, final int y, final int z) {
|
||||
public char get(int x, int y, int z) {
|
||||
final int layer = y >> 4;
|
||||
final int index = ((y & 15) << 8) | (z << 4) | (x);
|
||||
final int index = (y & 15) << 8 | z << 4 | x;
|
||||
return sections[layer].get(this, layer, index);
|
||||
}
|
||||
|
||||
public void set(final int x, final int y, final int z, final char value) {
|
||||
public void set(int x, int y, int z, char value) {
|
||||
final int layer = y >> 4;
|
||||
final int index = ((y & 15) << 8) | (z << 4) | (x);
|
||||
final int index = (y & 15) << 8 | z << 4 | x;
|
||||
set(layer, index, value);
|
||||
}
|
||||
|
||||
public final char get(final int layer, final int index) {
|
||||
return sections[layer].get(this, layer, index);
|
||||
}
|
||||
|
||||
public final void set(final int layer, final int index, final char value) {
|
||||
sections[layer].set(this, layer, index, value);
|
||||
}
|
||||
|
||||
/*
|
||||
Section
|
||||
*/
|
||||
|
||||
public final char get(int layer, int index) {
|
||||
return sections[layer].get(this, layer, index);
|
||||
}
|
||||
|
||||
public final void set(int layer, int index, char value) {
|
||||
sections[layer].set(this, layer, index, value);
|
||||
}
|
||||
|
||||
public static abstract class Section {
|
||||
|
||||
public abstract char[] get(CharBlocks blocks, int layer);
|
||||
|
||||
public final char get(final CharBlocks blocks, final int layer, final int index) {
|
||||
public final char get(CharBlocks blocks, int layer, int index) {
|
||||
return get(blocks, layer)[index];
|
||||
}
|
||||
|
||||
public final void set(final CharBlocks blocks, final int layer, final int index, final char value) {
|
||||
public final void set(CharBlocks blocks, int layer, int index,
|
||||
char value) {
|
||||
get(blocks, layer)[index] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static final Section EMPTY = new Section() {
|
||||
@Override
|
||||
public final char[] get(final CharBlocks blocks, final int layer) {
|
||||
blocks.sections[layer] = FULL;
|
||||
char[] arr = blocks.blocks[layer];
|
||||
if (arr == null) {
|
||||
arr = blocks.blocks[layer] = blocks.load(layer);
|
||||
} else {
|
||||
blocks.blocks[layer] = blocks.load(layer, arr);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
};
|
||||
|
||||
public static final Section FULL = new Section() {
|
||||
@Override
|
||||
public final char[] get(final CharBlocks blocks, final int layer) {
|
||||
return blocks.blocks[layer];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user