Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added upstream OffsetsMask classes #2210

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.OffsetMask;
import com.sk89q.worldedit.function.mask.OffsetsMask;
import com.sk89q.worldedit.math.BlockVector3;

import javax.annotation.Nonnull;
Expand Down Expand Up @@ -43,7 +43,7 @@ protected Mask parseFromInput(@Nonnull String[] arguments, ParserContext context
int y = Integer.parseInt(arguments[1]);
int z = Integer.parseInt(arguments[2]);
Mask submask = worldEdit.getMaskFactory().parseFromInput(arguments[3], context);
return new OffsetMask(submask, BlockVector3.at(x, y, z), context.getMinY(), context.getMaxY());
return OffsetsMask.single(submask, BlockVector3.at(x, y, z), context.getMinY(), context.getMaxY());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
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.OffsetMask;
import com.sk89q.worldedit.function.mask.OffsetsMask;
import com.sk89q.worldedit.internal.registry.InputParser;
import com.sk89q.worldedit.math.BlockVector3;

Expand Down Expand Up @@ -69,7 +69,7 @@ public Mask parseFromInput(String input, ParserContext context) throws InputPars
submask = new ExistingBlockMask(context.requireExtent());
}
//FAWE start - OffsetMask > OffsetsMask
return new OffsetMask(submask, BlockVector3.at(0, firstChar == '>' ? -1 : 1, 0), context.getMinY(), context.getMaxY());
return OffsetsMask.single(submask, BlockVector3.at(0, firstChar == '>' ? -1 : 1, 0), context.getMinY(), context.getMaxY());
//FAWE end
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
/**
* Checks whether another mask tests true for a position that is offset
* a given vector.
*
* @deprecated Use {@link OffsetsMask#single}
*/
@Deprecated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it forRemoval as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a question for @me4502 to answer. Hopefully, she can clarify for us.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most likely, generally deprecations are for removal in the next major version

there’s not much point having two classes that do the same thing here

public class OffsetMask extends AbstractMask {

//FAWE start - ignore resultant position outside world height range
Expand Down Expand Up @@ -71,8 +74,8 @@ public OffsetMask(Mask mask, BlockVector3 offset, int minY, int maxY) {
this.offset = offset;
this.minY = minY;
this.maxY = maxY;
//FAWE end
}
//FAWE end

/**
* Get the mask.
Expand Down Expand Up @@ -128,7 +131,7 @@ public boolean test(BlockVector3 vector) {
public Mask2D toMask2D() {
Mask2D childMask = getMask().toMask2D();
if (childMask != null) {
return new OffsetMask2D(childMask, getOffset().toBlockVector2());
return OffsetsMask2D.single(childMask, getOffset().toBlockVector2());
} else {
return null;
}
Expand All @@ -137,7 +140,7 @@ public Mask2D toMask2D() {
//FAWE start
@Override
public Mask copy() {
return new OffsetMask(mask.copy(), offset.toImmutable(), minY, maxY);
return OffsetsMask.single(mask.copy(), offset.toImmutable(), minY, maxY);
}
//FAWE end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
/**
* Checks whether another mask tests true for a position that is offset
* a given vector.
*
* @deprecated Use {@link OffsetsMask2D#single}
*/
@Deprecated
public class OffsetMask2D extends AbstractMask2D {

private Mask2D mask;
Expand Down Expand Up @@ -95,7 +98,7 @@ public boolean test(BlockVector2 vector) {

@Override
public Mask2D copy2D() {
return new OffsetMask2D(mask.copy2D(), BlockVector2.at(offset.getX(), offset.getZ()));
return OffsetsMask2D.single(mask.copy2D(), BlockVector2.at(offset.getX(), offset.getZ()));
}
//FAWE end

Expand Down
Loading