Bunch of changes to help masks

This commit is contained in:
dordsor21
2020-07-02 22:09:12 +01:00
parent 18c9da372c
commit f1d4104480
7 changed files with 51 additions and 6 deletions

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