mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Fix lack of handling of custom world heights in CharFilterBlock
This commit is contained in:
parent
7a9cbe5d77
commit
17a97f2f19
@ -31,6 +31,8 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
|||||||
private static final SetDelegate FULL = (block, value) -> block.setArr[block.index] = value;
|
private static final SetDelegate FULL = (block, value) -> block.setArr[block.index] = value;
|
||||||
private static final SetDelegate NULL = (block, value) -> block.initSet().set(block, value);
|
private static final SetDelegate NULL = (block, value) -> block.initSet().set(block, value);
|
||||||
|
|
||||||
|
private int maxLayer;
|
||||||
|
private int minLayer;
|
||||||
private CharGetBlocks get;
|
private CharGetBlocks get;
|
||||||
private IChunkSet set;
|
private IChunkSet set;
|
||||||
private char[] getArr;
|
private char[] getArr;
|
||||||
@ -65,6 +67,8 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
|||||||
@Override
|
@Override
|
||||||
public final ChunkFilterBlock initLayer(IBlocks iget, IChunkSet iset, int layer) {
|
public final ChunkFilterBlock initLayer(IBlocks iget, IChunkSet iset, int layer) {
|
||||||
this.get = (CharGetBlocks) iget;
|
this.get = (CharGetBlocks) iget;
|
||||||
|
minLayer = this.get.getMinSectionPosition();
|
||||||
|
maxLayer = this.get.getMaxSectionPosition();
|
||||||
this.layer = layer;
|
this.layer = layer;
|
||||||
if (!iget.hasSection(layer)) {
|
if (!iget.hasSection(layer)) {
|
||||||
getArr = FaweCache.IMP.EMPTY_CHAR_4096;
|
getArr = FaweCache.IMP.EMPTY_CHAR_4096;
|
||||||
@ -327,7 +331,7 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
|||||||
if (y > 0) {
|
if (y > 0) {
|
||||||
return states[getArr[index - 256]];
|
return states[getArr[index - 256]];
|
||||||
}
|
}
|
||||||
if (layer > 0) {
|
if (layer > minLayer) {
|
||||||
final int newLayer = layer - 1;
|
final int newLayer = layer - 1;
|
||||||
final CharGetBlocks chunk = this.get;
|
final CharGetBlocks chunk = this.get;
|
||||||
return states[chunk.sections[newLayer].get(chunk, newLayer, index + 3840)];
|
return states[chunk.sections[newLayer].get(chunk, newLayer, index + 3840)];
|
||||||
@ -340,7 +344,7 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
|||||||
if (y < 16) {
|
if (y < 16) {
|
||||||
return states[getArr[index + 256]];
|
return states[getArr[index + 256]];
|
||||||
}
|
}
|
||||||
if (layer < 16) {
|
if (layer < maxLayer) {
|
||||||
final int newLayer = layer + 1;
|
final int newLayer = layer + 1;
|
||||||
final CharGetBlocks chunk = this.get;
|
final CharGetBlocks chunk = this.get;
|
||||||
return states[chunk.sections[newLayer].get(chunk, newLayer, index - 3840)];
|
return states[chunk.sections[newLayer].get(chunk, newLayer, index - 3840)];
|
||||||
@ -352,53 +356,13 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
|||||||
public final BlockState getBlockRelativeY(int y) {
|
public final BlockState getBlockRelativeY(int y) {
|
||||||
final int newY = this.y + y;
|
final int newY = this.y + y;
|
||||||
final int layerAdd = newY >> 4;
|
final int layerAdd = newY >> 4;
|
||||||
switch (layerAdd) {
|
if (layerAdd == 0) {
|
||||||
case 0:
|
|
||||||
return states[getArr[this.index + (y << 8)]];
|
return states[getArr[this.index + (y << 8)]];
|
||||||
case 1:
|
} else if ((layerAdd > 0 && layerAdd < (maxLayer - layer)) || (layerAdd < 0 && layerAdd < (minLayer - layer))) {
|
||||||
case 2:
|
|
||||||
case 3:
|
|
||||||
case 4:
|
|
||||||
case 5:
|
|
||||||
case 6:
|
|
||||||
case 7:
|
|
||||||
case 8:
|
|
||||||
case 9:
|
|
||||||
case 10:
|
|
||||||
case 11:
|
|
||||||
case 12:
|
|
||||||
case 13:
|
|
||||||
case 14:
|
|
||||||
case 15: {
|
|
||||||
final int newLayer = layer + layerAdd;
|
final int newLayer = layer + layerAdd;
|
||||||
if (newLayer < 16) {
|
|
||||||
final int index = this.index + ((y & 15) << 8);
|
final int index = this.index + ((y & 15) << 8);
|
||||||
return states[get.sections[newLayer].get(get, newLayer, index)];
|
return states[get.sections[newLayer].get(get, newLayer, index)];
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
case -1:
|
|
||||||
case -2:
|
|
||||||
case -3:
|
|
||||||
case -4:
|
|
||||||
case -5:
|
|
||||||
case -6:
|
|
||||||
case -7:
|
|
||||||
case -8:
|
|
||||||
case -9:
|
|
||||||
case -10:
|
|
||||||
case -11:
|
|
||||||
case -12:
|
|
||||||
case -13:
|
|
||||||
case -14:
|
|
||||||
case -15:
|
|
||||||
final int newLayer = layer + layerAdd;
|
|
||||||
if (newLayer >= 0) {
|
|
||||||
final int index = this.index + ((y & 15) << 8);
|
|
||||||
return states[get.sections[newLayer].get(get, newLayer, index)];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return BlockTypes.__RESERVED__.getDefaultState();
|
return BlockTypes.__RESERVED__.getDefaultState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,34 +211,33 @@ public abstract class CharBlocks implements IBlocks {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public final char get(int layer, int index) {
|
public final char get(int layer, int index) {
|
||||||
layer -= minSectionPosition;
|
return sections[layer - minSectionPosition].get(this, layer, index);
|
||||||
return sections[layer].get(this, layer, index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void set(int layer, int index, char value) throws
|
public final void set(int layer, int index, char value) throws ArrayIndexOutOfBoundsException {
|
||||||
ArrayIndexOutOfBoundsException {
|
sections[layer - minSectionPosition].set(this, layer, index, value);
|
||||||
layer -= minSectionPosition;
|
|
||||||
sections[layer].set(this, layer, index, value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract static class Section {
|
public abstract static class Section {
|
||||||
|
|
||||||
public abstract char[] get(CharBlocks blocks, int layer);
|
abstract char[] get(CharBlocks blocks, int layer);
|
||||||
|
|
||||||
public abstract char[] get(CharBlocks blocks, int layer, boolean aggressive);
|
abstract char[] get(CharBlocks blocks, int layer, boolean aggressive);
|
||||||
|
|
||||||
public abstract boolean isFull();
|
public abstract boolean isFull();
|
||||||
|
|
||||||
public final char get(CharBlocks blocks, int layer, int index) {
|
public final char get(CharBlocks blocks, int layer, int index) {
|
||||||
char[] section = get(blocks, layer);
|
int normalized = layer - blocks.minSectionPosition;
|
||||||
|
char[] section = get(blocks, normalized);
|
||||||
if (section == null) {
|
if (section == null) {
|
||||||
blocks.reset(layer);
|
blocks.reset(layer);
|
||||||
section = blocks.empty.get(blocks, layer, false);
|
section = blocks.empty.get(blocks, normalized, false);
|
||||||
}
|
}
|
||||||
return section[index];
|
return section[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
public final synchronized void set(CharBlocks blocks, int layer, int index, char value) {
|
public final synchronized void set(CharBlocks blocks, int layer, int index, char value) {
|
||||||
|
layer -= blocks.minSectionPosition;
|
||||||
get(blocks, layer)[index] = value;
|
get(blocks, layer)[index] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user