Minor changes to match upstream more closely

This commit is contained in:
MattBDev 2019-10-23 14:29:37 -04:00
parent c050132737
commit 1b28dcda40
14 changed files with 82 additions and 172 deletions

View File

@ -29,13 +29,11 @@ import com.boydti.fawe.FaweCache;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.HistoryExtent;
import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.changeset.BlockBagChangeSet;
import com.boydti.fawe.object.changeset.FaweChangeSet;
import com.boydti.fawe.object.collection.LocalBlockVectorSet;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.extent.FaweRegionExtent;
import com.boydti.fawe.object.extent.NullExtent;
import com.boydti.fawe.object.extent.ProcessedWEExtent;
@ -49,8 +47,6 @@ import com.boydti.fawe.util.ExtentTraverser;
import com.boydti.fawe.util.MaskTraverser;
import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.event.extent.EditSessionEvent;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
@ -63,13 +59,10 @@ import com.sk89q.worldedit.extent.inventory.BlockBagExtent;
import com.sk89q.worldedit.extent.world.SurvivalModeExtent;
import com.sk89q.worldedit.function.GroundFunction;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.RegionMaskingFilter;
import com.sk89q.worldedit.function.block.BlockReplace;
import com.sk89q.worldedit.function.block.Counter;
import com.sk89q.worldedit.function.block.Naturalizer;
import com.sk89q.worldedit.function.generator.ForestGenerator;
import com.sk89q.worldedit.function.generator.GardenPatchGenerator;
import com.sk89q.worldedit.function.mask.BlockMask;
import com.sk89q.worldedit.function.mask.BlockTypeMask;
import com.sk89q.worldedit.function.mask.BoundedHeightMask;
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
@ -83,7 +76,6 @@ import com.sk89q.worldedit.function.mask.SingleBlockTypeMask;
import com.sk89q.worldedit.function.mask.SolidBlockMask;
import com.sk89q.worldedit.function.operation.ChangeSetExecutor;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.pattern.WaterloggedRemover;
@ -322,9 +314,9 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
}
/**
* Get the FawePlayer or null
* Get the Player or null
*
* @return
* @return the player
*/
@Nullable
public Player getPlayer() {
@ -751,11 +743,6 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
return this.changes;
}
@Override
public BiomeType getBiome(final BlockVector2 position) {
return this.getExtent().getBiome(position);
}
@Override
public boolean setBiome(BlockVector2 position, BiomeType biome) {
this.changes++;
@ -768,20 +755,6 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
return this.getExtent().setBiome(x, y, z, biome);
}
public BlockState getBlock(int x, int y, int z) {
return getExtent().getBlock(x, y, z);
}
@Override
public BlockState getBlock(BlockVector3 position) {
return getExtent().getBlock(position);
}
@Override
public BaseBlock getFullBlock(BlockVector3 position) {
return getExtent().getFullBlock(position);
}
/**
* Returns the highest solid 'terrain' block.
*
@ -941,12 +914,6 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
}
}
@Override
@Nullable
public Entity createEntity(com.sk89q.worldedit.util.Location location, BaseEntity entity) {
return getExtent().createEntity(location, entity);
}
/**
* Restores all blocks to their initial state.
*
@ -998,26 +965,6 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
this.changes = size;
}
@Override
public BlockVector3 getMinimumPoint() {
return getExtent().getMinimumPoint();
}
@Override
public BlockVector3 getMaximumPoint() {
return getExtent().getMaximumPoint();
}
@Override
public List<? extends Entity> getEntities(Region region) {
return getExtent().getEntities(region);
}
@Override
public List<? extends Entity> getEntities() {
return getExtent().getEntities();
}
/**
* Closing an EditSession {@linkplain #flushSession() flushes its buffers}.
*/
@ -1034,11 +981,6 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
flushQueue();
}
@Override
public @Nullable Operation commit() {
return getExtent().commit();
}
/**
* Finish off the queue.
*/
@ -1404,18 +1346,15 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
if (region instanceof CuboidRegion) {
return makeCuboidWalls(region, pattern);
} else {
replaceBlocks(region, new Mask() {
@Override
public boolean test(BlockVector3 position) {
int x = position.getBlockX();
int y = position.getBlockY();
int z = position.getBlockZ();
if (!region.contains(x, z + 1) || !region.contains(x, z - 1) || !region.contains(x + 1, z) || !region.contains(x - 1, z)) {
return true;
}
return false;
replaceBlocks(region, position -> {
int x = position.getBlockX();
int y = position.getBlockY();
int z = position.getBlockZ();
if (!region.contains(x, z + 1) || !region.contains(x, z - 1) || !region.contains(x + 1, z) || !region.contains(x - 1, z)) {
return true;
}
return false;
}, pattern);
}
return changes;
@ -1479,7 +1418,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
/**
* Stack a cuboid region. For compatibility, entities are copied but biomes are not.
* Use {@link #stackCuboidRegion(Region, BlockVector3, int, boolean, boolean, Mask)} to fine tune.
* Use {@link #stackCuboidRegion(Region, BlockVector3, int, boolean, boolean, boolean)} to fine tune.
*
* @param region the region to stack
* @param dir the direction to stack

View File

@ -476,10 +476,10 @@ public class RegionCommands {
boolean moveSelection,
@Switch(name = 'a', desc = "Ignore air blocks")
boolean ignoreAirBlocks,
@Switch(name = 'b', desc = "Copy Biomes")
boolean copyBiomes,
@Switch(name = 'e', desc = "Ignore entities")
boolean skipEntities,
@Switch(name = 'b', desc = "Also copy biomes")
boolean copyBiomes,
InjectedValueAccess context) throws WorldEditException {
checkCommandArgument(count >= 1, "Count must be >= 1");
actor.checkConfirmationRegion(() -> {
@ -534,12 +534,12 @@ public class RegionCommands {
BlockVector3 direction,
@Switch(name = 's', desc = "Shift the selection to the last stacked copy")
boolean moveSelection,
@Switch(name = 'b', desc = "Copy Biomes")
boolean copyBiomes,
@Switch(name = 'e', desc = "Skip entities")
boolean skipEntities,
@Switch(name = 'a', desc = "Ignore air blocks")
boolean ignoreAirBlocks,
@Switch(name = 'e', desc = "Skip entities")
boolean skipEntities,
@Switch(name = 'b', desc = "Also copy biomes")
boolean copyBiomes,
@ArgFlag(name = 'm', desc = "Source mask")
Mask sourceMask,
InjectedValueAccess context) throws WorldEditException {

View File

@ -62,12 +62,12 @@ public class BlockDataCyler implements DoubleActionBlockTool {
if (!config.allowedDataCycleBlocks.isEmpty()
&& !player.hasPermission("worldedit.override.data-cycler")
&& !config.allowedDataCycleBlocks.contains(block.getBlockType().getId())) {
BBC.BLOCK_CYCLER_NO_PERM.send(player);
player.printError(BBC.BLOCK_CYCLER_NO_PERM.s());
return true;
}
if (block.getStates().keySet().isEmpty()) {
BBC.BLOCK_CYCLER_CANNOT_CYCLE.send(player);
player.printError(BBC.BLOCK_CYCLER_CANNOT_CYCLE.s());
} else {
Property<?> currentProperty = selectedProperties.get(player.getUniqueId());
@ -91,7 +91,7 @@ public class BlockDataCyler implements DoubleActionBlockTool {
editSession.setBlock(blockPoint, newBlock);
player.print("Value of " + currentProperty.getName() + " is now " + currentProperty.getValues().get(index));
} catch (MaxChangedBlocksException e) {
BBC.BLOCK_CYCLER_LIMIT.send(player);
player.printError(BBC.BLOCK_CYCLER_LIMIT.s());
} finally {
session.remember(editSession);
}

View File

@ -283,6 +283,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
*
* @return the filter
*/
//TODO A better description is needed here to explain what makes a source-mask different from a regular mask.
public Mask getSourceMask() {
return getContext().getSourceMask();
}

View File

@ -74,15 +74,14 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
private Location getTarget(Player player) {
Location target;
Mask mask = getTraceMask();
int range = getRange();
if (range < MAX_RANGE) {
target = player.getBlockTrace(range, true, mask);
if (this.range < MAX_RANGE) {
target = player.getBlockTrace(getRange(), true, mask);
} else {
target = player.getBlockTrace(MAX_RANGE, false, mask);
}
if (target == null) {
BBC.NO_BLOCK.send(player);
player.printError(BBC.NO_BLOCK.s());
return null;
}

View File

@ -74,7 +74,7 @@ public class FloatingTreeRemover implements BlockTool {
final BlockState state = world.getBlock(clicked.toVector().toBlockPoint());
if (!isTreeBlock(state.getBlockType())) {
BBC.TOOL_DELTREE_ERROR.send(player);
player.printError(BBC.TOOL_DELTREE_ERROR.s());
return true;
}

View File

@ -100,7 +100,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
target = player.getBlockTrace(MAX_RANGE, false, mask);
}
if (target == null) {
BBC.NO_BLOCK.send(player);
player.printError(BBC.NO_BLOCK.s());
return null;
}

View File

@ -23,7 +23,7 @@ import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes;
public class GravityBrush implements Brush {
@ -43,7 +43,7 @@ public class GravityBrush implements Brush {
for (double z = position.getZ() + size; z > position.getZ() - size; --z) {
double freeSpot = startCheckY;
for (double y = startCheckY; y <= endY; y++) {
BlockStateHolder block = editSession.getBlock((int)x, (int)y, (int)z);
BlockState block = editSession.getBlock((int)x, (int)y, (int)z);
if (!block.getBlockType().getMaterial().isAir()) {
if (y != freeSpot) {
editSession.setBlock((int)x, (int)y, (int)z, BlockTypes.AIR.getDefaultState());

View File

@ -56,8 +56,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.Nullable;
import com.sk89q.worldedit.world.block.BlockType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -370,7 +368,7 @@ public class PlatformManager {
if (!(tool instanceof BrushTool)) {
blockTool = reset(blockTool);
}
((BlockTool) blockTool).actPrimary(queryCapability(Capability.WORLD_EDITING),
blockTool.actPrimary(queryCapability(Capability.WORLD_EDITING),
getConfiguration(), player, session, location);
}, false, true);
event.setCancelled(true);
@ -420,7 +418,7 @@ public class PlatformManager {
if (pos != null) {
player.findFreePosition(pos);
} else {
BBC.NO_BLOCK.send(player);
player.printError(BBC.NO_BLOCK.s());
}
event.setCancelled(true);
@ -444,7 +442,7 @@ public class PlatformManager {
}
if (!player.passThroughForwardWall(40)) {
BBC.NAVIGATION_WAND_ERROR.send(player);
player.printError(BBC.NAVIGATION_WAND_ERROR.s());
}
event.setCancelled(true);

View File

@ -30,15 +30,20 @@ import com.boydti.fawe.object.extent.LightingExtent;
import com.boydti.fawe.util.ExtentTraverser;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.buffer.ForgetfulExtentBuffer;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.OperationQueue;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.List;
import javax.annotation.Nullable;
/**
@ -69,7 +74,7 @@ public class AbstractDelegateExtent implements Extent, LightingExtent {
@Override
public BlockState getBlock(BlockVector3 position) {
return getBlock(position.getX(),position.getY(),position.getZ());
return extent.getBlock(position.getX(),position.getY(),position.getZ());
}
/*
@ -124,24 +129,37 @@ public class AbstractDelegateExtent implements Extent, LightingExtent {
}
}
/*
Bounds
*/
@Override
public int getMaxY() {
return extent.getMaxY();
}
/*
Input + Output
*/
@Override
public BlockState getBlock(int x, int y, int z) {
return extent.getBlock(x, y, z);
}
@Override
@Nullable
public Entity createEntity(Location location, BaseEntity entity) {
return extent.createEntity(location, entity);
}
@Override
public List<? extends Entity> getEntities() {
return extent.getEntities();
}
@Override
public List<? extends Entity> getEntities(Region region) {
return extent.getEntities(region);
}
@Override
public BiomeType getBiome(BlockVector2 position) {
return extent.getBiome(position);
}
@Override
public BaseBlock getFullBlock(int x, int y, int z) {
return extent.getFullBlock(x, y, z);

View File

@ -5,8 +5,6 @@ import com.boydti.fawe.object.changeset.FaweChangeSet;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.function.generator.GenBase;
import com.sk89q.worldedit.function.generator.Resource;
@ -18,19 +16,18 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.Countable;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import javax.annotation.Nullable;
public class PassthroughExtent extends AbstractDelegateExtent {
/**
* Create a new instance.
*
@ -40,32 +37,7 @@ public class PassthroughExtent extends AbstractDelegateExtent {
super(extent);
}
public BlockVector3 getMinimumPoint() {
return getExtent().getMinimumPoint();
}
public BlockVector3 getMaximumPoint() {
return getExtent().getMaximumPoint();
}
@Override
public List<? extends Entity> getEntities(Region region) {
return getExtent().getEntities(region);
}
@Override
public List<? extends Entity> getEntities() {
return getExtent().getEntities();
}
@Override
@Nullable
public Entity createEntity(Location location, BaseEntity entity) {
return getExtent().createEntity(location, entity);
}
@Override
@Nullable
public void removeEntity(int x, int y, int z, UUID uuid) {
getExtent().removeEntity(x, y, z, uuid);
}
@ -160,11 +132,6 @@ public class PassthroughExtent extends AbstractDelegateExtent {
return getExtent().getBlockDistributionWithData(region);
}
@Override
public int getMaxY() {
return getExtent().getMaxY();
}
@Override
public BlockArrayClipboard lazyCopy(Region region) {
return getExtent().lazyCopy(region);
@ -215,43 +182,22 @@ public class PassthroughExtent extends AbstractDelegateExtent {
return getExtent().setBlocks(vset, pattern);
}
@Override
public BlockState getBlock(BlockVector3 position) {
return getExtent().getBlock(position);
}
public BlockState getBlock(int x, int y, int z) {
return getExtent().getBlock(x, y, z);
}
@Override
public BaseBlock getFullBlock(BlockVector3 position) {
return getExtent().getFullBlock(position);
}
public BaseBlock getFullBlock(int x, int y, int z) {
return getExtent().getFullBlock(x, y, z);
}
@Override
public BiomeType getBiome(BlockVector2 position) {
return getExtent().getBiome(position);
}
public BiomeType getBiomeType(int x, int z) {
return getExtent().getBiomeType(x, z);
}
@Override
@Deprecated
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block) throws WorldEditException {
return getExtent().setBlock(position, block);
}
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
return getExtent().setBlock(x, y, z, block);
}
@Override
public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException {
return getExtent().setTile(x, y, z, tile);
@ -262,11 +208,6 @@ public class PassthroughExtent extends AbstractDelegateExtent {
return getExtent().setBiome(position, biome);
}
@Override
public boolean setBiome(int x, int y, int z, BiomeType biome) {
return getExtent().setBiome(x, y, z, biome);
}
// special
public Extent disableHistory() {
return super.disableHistory();

View File

@ -357,10 +357,6 @@ public class MCEditSchematicReader extends NBTSchematicReader {
private String convertBlockEntityId(String id) {
switch (id) {
case "Chest":
return "chest";
case "Sign":
return "sign";
case "Cauldron":
return "brewing_stand";
case "Control":
@ -388,6 +384,24 @@ public class MCEditSchematicReader extends NBTSchematicReader {
return "note_block";
case "Structure":
return "structure_block";
case "Chest":
return "chest";
case "Sign":
return "sign";
case "Banner":
return "banner";
case "Beacon":
return "beacon";
case "Comparator":
return "comparator";
case "Dropper":
return "dropper";
case "Furnace":
return "furnace";
case "Hopper":
return "hopper";
case "Skull":
return "skull";
default:
return id;
}

View File

@ -32,7 +32,7 @@ import com.sk89q.worldedit.util.Location;
*/
public class EntityCreate implements Change {
public final Location location;
private final Location location;
public final BaseEntity state;
private Entity entity;

View File

@ -32,7 +32,7 @@ import com.sk89q.worldedit.util.Location;
*/
public class EntityRemove implements Change {
public final Location location;
private final Location location;
public final BaseEntity state;
private Entity entity;