Bunch of changes to help masks

Dieser Commit ist enthalten in:
dordsor21 2020-07-02 22:09:12 +01:00
Ursprung 18c9da372c
Commit f1d4104480
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
7 geänderte Dateien mit 51 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -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 {

Datei anzeigen

@ -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 {

Datei anzeigen

@ -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 {

Datei anzeigen

@ -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;

Datei anzeigen

@ -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

Datei anzeigen

@ -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