geforkt von Mirrors/FastAsyncWorldEdit
Rename section index to position as it's a more suitable name
(cherry picked from commit 74f1d21f6e
)
Dieser Commit ist enthalten in:
Ursprung
d9a8c047a2
Commit
d60d178513
@ -8,6 +8,8 @@ import com.sk89q.worldedit.world.block.BlockState;
|
|||||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public abstract class CharBlocks implements IBlocks {
|
public abstract class CharBlocks implements IBlocks {
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManagerCompat.getLogger();
|
private static final Logger LOGGER = LogManagerCompat.getLogger();
|
||||||
@ -65,17 +67,17 @@ public abstract class CharBlocks implements IBlocks {
|
|||||||
};
|
};
|
||||||
public char[][] blocks;
|
public char[][] blocks;
|
||||||
public Section[] sections;
|
public Section[] sections;
|
||||||
protected int minSectionIndex;
|
protected int minSectionPosition;
|
||||||
protected int maxSectionIndex;
|
protected int maxSectionPosition;
|
||||||
protected int sectionCount;
|
protected int sectionCount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* New instance given initial min/max section indices. Can be negative.
|
* New instance given initial min/max section indices. Can be negative.
|
||||||
*/
|
*/
|
||||||
public CharBlocks(int minSectionIndex, int maxSectionIndex) {
|
public CharBlocks(int minSectionPosition, int maxSectionPosition) {
|
||||||
this.minSectionIndex = minSectionIndex;
|
this.minSectionPosition = minSectionPosition;
|
||||||
this.maxSectionIndex = maxSectionIndex;
|
this.maxSectionPosition = maxSectionPosition;
|
||||||
this.sectionCount = maxSectionIndex - minSectionIndex + 1;
|
this.sectionCount = maxSectionPosition - minSectionPosition + 1;
|
||||||
blocks = new char[sectionCount][];
|
blocks = new char[sectionCount][];
|
||||||
sections = new Section[sectionCount];
|
sections = new Section[sectionCount];
|
||||||
for (int i = 0; i < sectionCount; i++) {
|
for (int i = 0; i < sectionCount; i++) {
|
||||||
@ -116,7 +118,7 @@ public abstract class CharBlocks implements IBlocks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void reset(int layer) {
|
public synchronized void reset(int layer) {
|
||||||
layer -= minSectionIndex;
|
layer -= minSectionPosition;
|
||||||
sections[layer] = empty;
|
sections[layer] = empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,13 +135,13 @@ public abstract class CharBlocks implements IBlocks {
|
|||||||
// Not synchronized as any subsequent methods called from this class will be, or the section shouldn't appear as loaded anyway.
|
// Not synchronized as any subsequent methods called from this class will be, or the section shouldn't appear as loaded anyway.
|
||||||
@Override
|
@Override
|
||||||
public boolean hasSection(int layer) {
|
public boolean hasSection(int layer) {
|
||||||
layer -= minSectionIndex;
|
layer -= minSectionPosition;
|
||||||
return layer >= 0 && layer < sections.length && sections[layer].isFull();
|
return layer >= 0 && layer < sections.length && sections[layer].isFull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public char[] load(int layer) {
|
public char[] load(int layer) {
|
||||||
layer -= minSectionIndex;
|
layer -= minSectionPosition;
|
||||||
synchronized (sections[layer]) {
|
synchronized (sections[layer]) {
|
||||||
return sections[layer].get(this, layer);
|
return sections[layer].get(this, layer);
|
||||||
}
|
}
|
||||||
@ -153,7 +155,7 @@ public abstract class CharBlocks implements IBlocks {
|
|||||||
public char get(int x, int y, int z) {
|
public char get(int x, int y, int z) {
|
||||||
int layer = y >> 4;
|
int layer = y >> 4;
|
||||||
final int index = (y & 15) << 8 | z << 4 | x;
|
final int index = (y & 15) << 8 | z << 4 | x;
|
||||||
if (layer > maxSectionIndex || layer < minSectionIndex) {
|
if (layer > maxSectionPosition || layer < minSectionPosition) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return get(layer, index);
|
return get(layer, index);
|
||||||
@ -177,13 +179,13 @@ public abstract class CharBlocks implements IBlocks {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public final char get(int layer, int index) {
|
public final char get(int layer, int index) {
|
||||||
layer -= minSectionIndex;
|
layer -= minSectionPosition;
|
||||||
return sections[layer].get(this, layer, index);
|
return sections[layer].get(this, layer, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized final void set(int layer, int index, char value) throws
|
public synchronized final void set(int layer, int index, char value) throws
|
||||||
ArrayIndexOutOfBoundsException {
|
ArrayIndexOutOfBoundsException {
|
||||||
layer -= minSectionIndex;
|
layer -= minSectionPosition;
|
||||||
sections[layer].set(this, layer, index, value);
|
sections[layer].set(this, layer, index, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren