mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 20:16:41 +00:00
More work on masks (#607)
* Add a #air mask, the opposite of #existing (#1511) (cherry picked from commit 84fa2bbbc63de7bece01f41c0d5cb7d85cf129e6) * Remove unused methods in Mask.java * Remove `test(Extent, BlockVector3)` from Masks. This was a poorly planned idea. This should save some memory too. Authored-by: Matthew Miller <mnmiller1@me.com>
This commit is contained in:
@ -53,6 +53,8 @@ import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
import com.sk89q.worldedit.internal.registry.AbstractFactory;
|
||||
import com.sk89q.worldedit.internal.registry.InputParser;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -76,6 +78,7 @@ public final class MaskFactory extends AbstractFactory<Mask> {
|
||||
super(worldEdit, new BlocksMaskParser(worldEdit));
|
||||
|
||||
register(new ExistingMaskParser(worldEdit));
|
||||
register(new AirMaskParser(worldEdit));
|
||||
register(new SolidMaskParser(worldEdit));
|
||||
register(new LazyRegionMaskParser(worldEdit));
|
||||
register(new RegionMaskParser(worldEdit));
|
||||
@ -84,11 +87,11 @@ public final class MaskFactory extends AbstractFactory<Mask> {
|
||||
register(new BlockStateMaskParser(worldEdit));
|
||||
register(new NegateMaskParser(worldEdit));
|
||||
register(new ExpressionMaskParser(worldEdit));
|
||||
|
||||
register(new BlockCategoryMaskParser(worldEdit));
|
||||
register(new BiomeMaskParser(worldEdit));
|
||||
// Mask Parsers from FAWE
|
||||
register(new AdjacentMaskParser(worldEdit));
|
||||
register(new AirMaskParser(worldEdit));
|
||||
register(new AngleMaskParser(worldEdit));
|
||||
register(new ExtremaMaskParser(worldEdit));
|
||||
register(new FalseMaskParser(worldEdit));
|
||||
@ -124,18 +127,23 @@ public final class MaskFactory extends AbstractFactory<Mask> {
|
||||
continue;
|
||||
}
|
||||
|
||||
Mask match = null;
|
||||
for (InputParser<Mask> parser : getParsers()) {
|
||||
Mask match = parser.parseFromInput(component, context);
|
||||
match = parser.parseFromInput(component, context);
|
||||
|
||||
if (match != null) {
|
||||
masks.add(match);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (match == null) {
|
||||
throw new NoMatchException(TranslatableComponent.of("worldedit.error.no-match", TextComponent.of(component)));
|
||||
}
|
||||
masks.add(match);
|
||||
}
|
||||
|
||||
switch (masks.size()) {
|
||||
case 0:
|
||||
throw new NoMatchException("No match for '" + input + "'");
|
||||
throw new NoMatchException(TranslatableComponent.of("worldedit.error.no-match", TextComponent.of(input)));
|
||||
case 1:
|
||||
return masks.get(0).optimize();
|
||||
default:
|
||||
|
@ -1,10 +1,31 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.extension.factory.parser.mask;
|
||||
|
||||
import com.boydti.fawe.function.mask.AirMask;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.internal.registry.SimpleInputParser;
|
||||
|
||||
import java.util.List;
|
||||
@ -23,7 +44,7 @@ public class AirMaskParser extends SimpleInputParser<Mask> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mask parseFromSimpleInput(String input, ParserContext context) {
|
||||
return new AirMask(context.getExtent());
|
||||
public Mask parseFromSimpleInput(String input, ParserContext context) throws InputParseException {
|
||||
return Masks.negate(new ExistingBlockMask(context.requireExtent()));
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,6 @@ public class ZAxisMaskParser extends SimpleInputParser<Mask> {
|
||||
|
||||
@Override
|
||||
public Mask parseFromSimpleInput(String input, ParserContext context) {
|
||||
return new ZAxisMask(context.getExtent());
|
||||
return new ZAxisMask();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user