Bunch of changes to help masks

This commit is contained in:
dordsor21 2020-07-02 22:09:12 +01:00
parent 18c9da372c
commit f1d4104480
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
7 changed files with 51 additions and 6 deletions

View File

@ -609,6 +609,10 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
} else {
ordinal = adapter.adaptToChar(ibd);
}
// Don't read "empty".
if (ordinal == 0) {
ordinal = 1;
}
paletteToBlockChars[paletteVal] = ordinal;
}
data[i] = ordinal;
@ -636,10 +640,18 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
val = ordinal(palette.a(i), adapter);
paletteToOrdinal[i] = val;
}
// Don't read "empty".
if (val == 0) {
val = 1;
}
data[i] = val;
}
} else {
char ordinal = ordinal(palette.a(0), adapter);
// Don't read "empty".
if (ordinal == 0) {
ordinal = 1;
}
Arrays.fill(data, ordinal);
}
} finally {

View File

@ -629,6 +629,10 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
}
paletteToBlockChars[paletteVal] = ordinal;
}
// Don't read "empty".
if (ordinal == 0) {
ordinal = 1;
}
data[i] = ordinal;
}
} finally {
@ -654,10 +658,18 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
val = ordinal(palette.a(i), adapter);
paletteToOrdinal[i] = val;
}
// Don't read "empty".
if (val == 0) {
val = 1;
}
data[i] = val;
}
} else {
char ordinal = ordinal(palette.a(0), adapter);
// Don't read "empty".
if (ordinal == 0) {
ordinal = 1;
}
Arrays.fill(data, ordinal);
}
} finally {

View File

@ -600,6 +600,10 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
}
paletteToBlockChars[paletteVal] = ordinal;
}
// Don't read "empty".
if (ordinal == 0) {
ordinal = 1;
}
data[i] = ordinal;
}
} finally {
@ -625,10 +629,18 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
val = ordinal(palette.a(i), adapter);
paletteToOrdinal[i] = val;
}
// Don't read "empty".
if (val == 0) {
val = 1;
}
data[i] = val;
}
} else {
char ordinal = ordinal(palette.a(0), adapter);
// Don't read "empty".
if (ordinal == 0) {
ordinal = 1;
}
Arrays.fill(data, ordinal);
}
} finally {

View File

@ -27,7 +27,7 @@ public abstract class CharGetBlocks extends CharBlocks implements IChunkGet {
public char[] update(int layer, char[] data) {
if (data == null) {
return new char[4096];
data = new char[4096];
}
Arrays.fill(data, (char) 1);
return data;

View File

@ -184,7 +184,7 @@ public class BlockMask extends ABlockMask {
}
@Override
public boolean test(BlockState state) {
return ordinals[state.getOrdinal()];
return ordinals[state.getOrdinal()] || replacesAir() && state.getOrdinal() <= 3;
}
@Override

View File

@ -3,10 +3,10 @@ package com.sk89q.worldedit.function.mask;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
public class InverseSingleBlockStateMask extends ABlockMask {
private final char ordinal;
private final boolean isAir;
public BlockState getBlockState() {
return BlockState.getFromOrdinal(ordinal);
@ -14,17 +14,26 @@ public class InverseSingleBlockStateMask extends ABlockMask {
public InverseSingleBlockStateMask(Extent extent, BlockState state) {
super(extent);
isAir = state.isAir();
this.ordinal = state.getOrdinalChar();
}
@Override
public boolean test(Extent extent, BlockVector3 vector) {
return ordinal != vector.getOrdinal(extent);
int test = vector.getOrdinal(extent);
if (isAir && test == 0) {
return false;
}
return ordinal != test;
}
@Override
public final boolean test(BlockState state) {
return state.getOrdinalChar() != ordinal;
int test = state.getOrdinalChar();
if (isAir && test == 0) {
return false;
}
return test != ordinal;
}
@Override

View File

@ -13,7 +13,7 @@ public class SingleBlockTypeMask extends ABlockMask {
public SingleBlockTypeMask(Extent extent, BlockType type) {
super(extent);
isAir = type == BlockTypes.AIR || type == BlockTypes.CAVE_AIR || type == BlockTypes.VOID_AIR;
this.internalId = type.getInternalId();
this.internalId = type.getInternalId();
}
@Override