3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-09 13:00:05 +01:00

Add some more __internal__ <-> air logi

Fixes #831
Dieser Commit ist enthalten in:
dordsor21 2021-01-06 16:40:28 +00:00
Ursprung 336b90be15
Commit e40e86df5f
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
9 geänderte Dateien mit 56 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -16,4 +16,9 @@ public class AirMask extends BlockMask {
return new AirMask(getExtent()); return new AirMask(getExtent());
} }
@Override
public boolean replacesAir() {
return true;
}
} }

Datei anzeigen

@ -37,4 +37,9 @@ public class IdDataMask extends AbstractExtentMask implements ResettableMask {
return new IdDataMask(getExtent()); return new IdDataMask(getExtent());
} }
@Override
public boolean replacesAir() {
return true;
}
} }

Datei anzeigen

@ -38,4 +38,9 @@ public class IdMask extends AbstractExtentMask implements ResettableMask {
return new IdMask(getExtent()); return new IdMask(getExtent());
} }
@Override
public boolean replacesAir() {
return true;
}
} }

Datei anzeigen

@ -22,6 +22,7 @@ package com.sk89q.worldedit.function.mask;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockCategory; import com.sk89q.worldedit.world.block.BlockCategory;
import com.sk89q.worldedit.world.block.BlockTypes;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -61,4 +62,9 @@ public class BlockCategoryMask extends AbstractExtentMask {
public Mask copy() { public Mask copy() {
return new BlockCategoryMask(getExtent(), category); return new BlockCategoryMask(getExtent(), category);
} }
@Override
public boolean replacesAir() {
return category.contains(BlockTypes.AIR);
}
} }

Datei anzeigen

@ -29,12 +29,12 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.block.BlockTypesCache; import com.sk89q.worldedit.world.block.BlockTypesCache;
import com.sk89q.worldedit.world.block.ImmutableBaseBlock; import com.sk89q.worldedit.world.block.ImmutableBaseBlock;
import javax.annotation.Nullable;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.function.Predicate; import java.util.function.Predicate;
import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
@ -185,7 +185,7 @@ public class BlockMask extends ABlockMask {
@Override @Override
public boolean test(BlockState state) { public boolean test(BlockState state) {
return ordinals[state.getOrdinal()] || replacesAir() && state.getOrdinal() <= 3; return ordinals[state.getOrdinal()] || replacesAir() && state.getOrdinal() == 0;
} }
@Override @Override
@ -259,19 +259,16 @@ public class BlockMask extends ABlockMask {
int setTypes = 0; int setTypes = 0;
BlockType setType = null; BlockType setType = null;
BlockType unsetType = null;
int totalTypes = 0; int totalTypes = 0;
for (BlockType type : BlockTypesCache.values) { for (BlockType type : BlockTypesCache.values) {
if (type != null) { if (type != null) {
totalTypes++; totalTypes++;
boolean hasAll = true; boolean hasAll = true;
boolean hasAny = false;
List<BlockState> all = type.getAllStates(); List<BlockState> all = type.getAllStates();
for (BlockState state : all) { for (BlockState state : all) {
totalStates++; totalStates++;
hasAll &= test(state); hasAll &= test(state);
hasAny = true;
} }
if (hasAll) { if (hasAll) {
setTypes++; setTypes++;
@ -326,6 +323,7 @@ public class BlockMask extends ABlockMask {
cloned[BlockTypes.AIR.getDefaultState().getOrdinal()] = false; cloned[BlockTypes.AIR.getDefaultState().getOrdinal()] = false;
cloned[BlockTypes.CAVE_AIR.getDefaultState().getOrdinal()] = false; cloned[BlockTypes.CAVE_AIR.getDefaultState().getOrdinal()] = false;
cloned[BlockTypes.VOID_AIR.getDefaultState().getOrdinal()] = false; cloned[BlockTypes.VOID_AIR.getDefaultState().getOrdinal()] = false;
cloned[0] = false;
} }
return new BlockMask(getExtent(), cloned); return new BlockMask(getExtent(), cloned);
} }

Datei anzeigen

@ -36,4 +36,9 @@ public class InverseMask extends AbstractMask {
public Mask copy() { public Mask copy() {
return new InverseMask(mask.copy()); return new InverseMask(mask.copy());
} }
@Override
public boolean replacesAir() {
return mask.replacesAir();
}
} }

Datei anzeigen

@ -8,10 +8,12 @@ import com.sk89q.worldedit.world.block.BlockTypesCache;
public class InverseSingleBlockTypeMask extends ABlockMask { public class InverseSingleBlockTypeMask extends ABlockMask {
private final int internalId; private final int internalId;
private final boolean replacesAir;
public InverseSingleBlockTypeMask(Extent extent, BlockType type) { public InverseSingleBlockTypeMask(Extent extent, BlockType type) {
super(extent); super(extent);
this.internalId = type.getInternalId(); this.internalId = type.getInternalId();
this.replacesAir = type.getMaterial().isAir();
} }
@Override @Override
@ -33,4 +35,9 @@ public class InverseSingleBlockTypeMask extends ABlockMask {
// The mask is not mutable. There is no need to clone it. // The mask is not mutable. There is no need to clone it.
return this; return this;
} }
@Override
public boolean replacesAir() {
return replacesAir;
}
} }

Datei anzeigen

@ -275,4 +275,14 @@ public class MaskIntersection extends AbstractMask {
return new MaskIntersection(masks); return new MaskIntersection(masks);
} }
@Override
public boolean replacesAir() {
for (Mask mask : masksArray) {
if (mask.replacesAir()) {
return true;
}
}
return false;
}
} }

Datei anzeigen

@ -118,4 +118,14 @@ public class MaskUnion extends MaskIntersection {
Set<Mask> masksCopy = masks.stream().map(Mask::copy).collect(Collectors.toSet()); Set<Mask> masksCopy = masks.stream().map(Mask::copy).collect(Collectors.toSet());
return new MaskUnion(masksCopy); return new MaskUnion(masksCopy);
} }
@Override
public boolean replacesAir() {
for (Mask mask : getMasksArray()) {
if (mask.replacesAir()) {
return true;
}
}
return false;
}
} }