Skip to content

Commit

Permalink
Merge branch 'EngineHub:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Yomamaeatstoes authored Jul 12, 2024
2 parents 451c79c + 856d120 commit 0f96784
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import com.sk89q.worldedit.extent.reorder.MultiStageReorder;
import com.sk89q.worldedit.extent.validation.BlockChangeLimiter;
import com.sk89q.worldedit.extent.validation.DataValidatorExtent;
import com.sk89q.worldedit.extent.world.BiomeQuirkExtent;
import com.sk89q.worldedit.extent.world.ChunkLoadingExtent;
import com.sk89q.worldedit.extent.world.SideEffectExtent;
import com.sk89q.worldedit.extent.world.SurvivalModeExtent;
Expand Down Expand Up @@ -261,7 +260,6 @@ public String getDisplayName() {
watchdogExtents.add(watchdogExtent);
}
extent = traceIfNeeded(survivalExtent = new SurvivalModeExtent(extent, world));
extent = traceIfNeeded(new BiomeQuirkExtent(extent));
extent = traceIfNeeded(new ChunkLoadingExtent(extent, world));
extent = traceIfNeeded(new LastAccessExtentCache(extent));
extent = traceIfNeeded(blockBagExtent = new BlockBagExtent(extent, blockBag));
Expand Down Expand Up @@ -682,11 +680,6 @@ public int getBlockChangeCount() {
return changeSet.size();
}

@Override
public boolean fullySupports3DBiomes() {
return bypassNone.fullySupports3DBiomes();
}

@Override
public BiomeType getBiome(BlockVector3 position) {
return bypassNone.getBiome(position);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.sk89q.worldedit.extension.factory.parser.mask.BlockCategoryMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.BlockStateMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.BlocksMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.ClipboardMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.ExistingMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.ExposedMaskParser;
import com.sk89q.worldedit.extension.factory.parser.mask.ExpressionMaskParser;
Expand Down Expand Up @@ -65,6 +66,7 @@ public final class MaskFactory extends AbstractFactory<Mask> {
public MaskFactory(WorldEdit worldEdit) {
super(worldEdit, new BlocksMaskParser(worldEdit));

register(new ClipboardMaskParser(worldEdit));
register(new ExistingMaskParser(worldEdit));
register(new AirMaskParser(worldEdit));
register(new ExposedMaskParser(worldEdit));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* 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.sk89q.worldedit.EmptyClipboardException;
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.Mask;
import com.sk89q.worldedit.function.mask.MatchMask;
import com.sk89q.worldedit.internal.registry.SimpleInputParser;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;

import java.util.List;

public class ClipboardMaskParser extends SimpleInputParser<Mask> {

private static final List<String> aliases = List.of("#clipboard", "#copy");

public ClipboardMaskParser(WorldEdit worldEdit) {
super(worldEdit);
}

@Override
public List<String> getMatchedAliases() {
return aliases;
}

@Override
public Mask parseFromSimpleInput(String input, ParserContext context) throws InputParseException {
try {
return new MatchMask(context.requireExtent(), context.requireSession().getClipboard().getClipboard());
} catch (EmptyClipboardException e) {
throw new InputParseException(TranslatableComponent.of("worldedit.error.empty-clipboard"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@ public List<? extends Entity> getEntities(Region region) {
return extent.getEntities(region);
}

@Override
public boolean fullySupports3DBiomes() {
return extent.fullySupports3DBiomes();
}

@Override
public BiomeType getBiome(BlockVector3 position) {
return extent.getBiome(position);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B
return false;
}

@Override
public boolean fullySupports3DBiomes() {
return false;
}

@Override
public boolean setBiome(BlockVector3 position, BiomeType biome) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ public interface OutputExtent {
* </p>
*
* @return if the extent fully supports 3D biomes
* @deprecated All supported platforms now support this, the check is no longer necessary
*/
@Deprecated
default boolean fullySupports3DBiomes() {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@

/**
* Handles quirks when placing biomes.
*
* @deprecated This extent currently performs no functions.
*/
@Deprecated
public class BiomeQuirkExtent extends AbstractDelegateExtent {

/**
Expand All @@ -40,11 +43,6 @@ public BiomeQuirkExtent(Extent extent) {

@Override
public boolean setBiome(BlockVector3 position, BiomeType biome) {
boolean success = false;
if (!fullySupports3DBiomes()) {
// Also place at Y = 0 for proper handling
success = super.setBiome(position.withY(0), biome);
}
return super.setBiome(position, biome) || success;
return super.setBiome(position, biome);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* 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.function.mask;

import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;

/**
* A mask that returns true if the two given extents have the same block at the given position, with offset support.
*/
public final class MatchMask extends AbstractMask {

private final Extent extent;
private final Extent matchExtent;
private final BlockVector3 offset;

/**
* Create a new match mask.
*
* <p>
* This will assume an offset of zero. To specify an offset, use {@link #MatchMask(Extent, Extent, BlockVector3)}.
* </p>
*
* @param extent The base extent
* @param matchExtent The match extent
*/
public MatchMask(Extent extent, Extent matchExtent) {
this(extent, matchExtent, BlockVector3.ZERO);
}

/**
* Create a new match mask.
*
* @param extent The base extent
* @param matchExtent The match extent
* @param offset The offset of comparisons applied to the match extent
*/
public MatchMask(Extent extent, Extent matchExtent, BlockVector3 offset) {
this.extent = extent;
this.matchExtent = matchExtent;
this.offset = offset;
}

@Override
public boolean test(BlockVector3 vector) {
return extent.getBlock(vector).equals(matchExtent.getBlock(vector.add(offset)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@ public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T
return getExtent().setBlock(position, block);
}

@Override
public boolean fullySupports3DBiomes() {
return getExtent().fullySupports3DBiomes();
}

@Override
public boolean setBiome(BlockVector3 position, BiomeType biome) {
return getExtent().setBiome(position, biome);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ public boolean clearContainerBlockContents(BlockVector3 position) {
return false;
}

@Override
public boolean fullySupports3DBiomes() {
return false;
}

@Override
public BiomeType getBiome(BlockVector3 position) {
return BiomeTypes.THE_VOID;
Expand Down

0 comments on commit 0f96784

Please sign in to comment.