geforkt von Mirrors/FastAsyncWorldEdit
Fixed up data cycler command, and the fixwater & fixlava commands.
Dieser Commit ist enthalten in:
Ursprung
64e0d99696
Commit
db21f51a18
@ -27,11 +27,6 @@ import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.LazyBlock;
|
import com.sk89q.worldedit.blocks.LazyBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockCategories;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
||||||
@ -108,6 +103,11 @@ import com.sk89q.worldedit.util.eventbus.EventBus;
|
|||||||
import com.sk89q.worldedit.world.NullWorld;
|
import com.sk89q.worldedit.world.NullWorld;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockCategories;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -1137,35 +1137,28 @@ public class EditSession implements Extent {
|
|||||||
*
|
*
|
||||||
* @param origin the original position
|
* @param origin the original position
|
||||||
* @param radius the radius to fix
|
* @param radius the radius to fix
|
||||||
* @param moving the block ID of the moving liquid
|
* @param fluid the type of the fluid
|
||||||
* @param stationary the block ID of the stationary liquid
|
|
||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int fixLiquid(Vector origin, double radius, BlockType moving, BlockType stationary) throws MaxChangedBlocksException {
|
public int fixLiquid(Vector origin, double radius, BlockType fluid) throws MaxChangedBlocksException {
|
||||||
checkNotNull(origin);
|
checkNotNull(origin);
|
||||||
checkArgument(radius >= 0, "radius >= 0 required");
|
checkArgument(radius >= 0, "radius >= 0 required");
|
||||||
|
|
||||||
// Our origins can only be liquids
|
// Our origins can only be liquids
|
||||||
BlockMask liquidMask = new BlockMask(
|
BlockMask liquidMask = new BlockMask(this, new BlockState(fluid, new HashMap<>()));
|
||||||
this,
|
|
||||||
moving.getDefaultState(),
|
|
||||||
stationary.getDefaultState());
|
|
||||||
|
|
||||||
// But we will also visit air blocks
|
// But we will also visit air blocks
|
||||||
MaskIntersection blockMask =
|
MaskIntersection blockMask = new MaskUnion(liquidMask, new BlockMask(this, BlockTypes.AIR.getDefaultState()));
|
||||||
new MaskUnion(liquidMask,
|
|
||||||
new BlockMask(
|
|
||||||
this,
|
|
||||||
BlockTypes.AIR.getDefaultState()));
|
|
||||||
|
|
||||||
// There are boundaries that the routine needs to stay in
|
// There are boundaries that the routine needs to stay in
|
||||||
MaskIntersection mask = new MaskIntersection(
|
MaskIntersection mask = new MaskIntersection(
|
||||||
new BoundedHeightMask(0, Math.min(origin.getBlockY(), getWorld().getMaxY())),
|
new BoundedHeightMask(0, Math.min(origin.getBlockY(), getWorld().getMaxY())),
|
||||||
new RegionMask(new EllipsoidRegion(null, origin, new Vector(radius, radius, radius))),
|
new RegionMask(new EllipsoidRegion(null, origin, new Vector(radius, radius, radius))),
|
||||||
blockMask);
|
blockMask
|
||||||
|
);
|
||||||
|
|
||||||
BlockReplace replace = new BlockReplace(this, new BlockPattern(stationary.getDefaultState()));
|
BlockReplace replace = new BlockReplace(this, new BlockPattern(fluid.getDefaultState()));
|
||||||
NonRisingVisitor visitor = new NonRisingVisitor(mask, replace);
|
NonRisingVisitor visitor = new NonRisingVisitor(mask, replace);
|
||||||
|
|
||||||
// Around the origin in a 3x3 block
|
// Around the origin in a 3x3 block
|
||||||
|
@ -170,9 +170,7 @@ public class UtilityCommands {
|
|||||||
|
|
||||||
double radius = Math.max(0, args.getDouble(0));
|
double radius = Math.max(0, args.getDouble(0));
|
||||||
we.checkMaxRadius(radius);
|
we.checkMaxRadius(radius);
|
||||||
// TODO Investigate with a real build of 1.13
|
int affected = editSession.fixLiquid(session.getPlacementPosition(player), radius, BlockTypes.LAVA);
|
||||||
int affected = editSession.fixLiquid(
|
|
||||||
session.getPlacementPosition(player), radius, BlockTypes.LAVA, BlockTypes.LAVA);
|
|
||||||
player.print(affected + " block(s) have been changed.");
|
player.print(affected + " block(s) have been changed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,9 +187,7 @@ public class UtilityCommands {
|
|||||||
|
|
||||||
double radius = Math.max(0, args.getDouble(0));
|
double radius = Math.max(0, args.getDouble(0));
|
||||||
we.checkMaxRadius(radius);
|
we.checkMaxRadius(radius);
|
||||||
// TODO Investigate with a real build of 1.13
|
int affected = editSession.fixLiquid(session.getPlacementPosition(player), radius, BlockTypes.WATER);
|
||||||
int affected = editSession.fixLiquid(
|
|
||||||
session.getPlacementPosition(player), radius, BlockTypes.WATER, BlockTypes.WATER);
|
|
||||||
player.print(affected + " block(s) have been changed.");
|
player.print(affected + " block(s) have been changed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command.tool;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
@ -26,10 +27,16 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
|
|||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extension.platform.Platform;
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mode that cycles the data values of supported blocks.
|
* A mode that cycles the data values of supported blocks.
|
||||||
*/
|
*/
|
||||||
@ -40,6 +47,8 @@ public class BlockDataCyler implements DoubleActionBlockTool {
|
|||||||
return player.hasPermission("worldedit.tool.data-cycler");
|
return player.hasPermission("worldedit.tool.data-cycler");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<UUID, Property<?>> selectedProperties = new HashMap<>();
|
||||||
|
|
||||||
private boolean handleCycle(Platform server, LocalConfiguration config,
|
private boolean handleCycle(Platform server, LocalConfiguration config,
|
||||||
Player player, LocalSession session, Location clicked, boolean forward) {
|
Player player, LocalSession session, Location clicked, boolean forward) {
|
||||||
|
|
||||||
@ -57,20 +66,37 @@ public class BlockDataCyler implements DoubleActionBlockTool {
|
|||||||
if (block.getStates().keySet().isEmpty()) {
|
if (block.getStates().keySet().isEmpty()) {
|
||||||
player.printError("That block's data cannot be cycled!");
|
player.printError("That block's data cannot be cycled!");
|
||||||
} else {
|
} else {
|
||||||
BlockState newBlock = block;
|
Property currentProperty = selectedProperties.get(player.getUniqueId());
|
||||||
|
|
||||||
|
if (currentProperty == null || (forward && block.getState(currentProperty) == null)) {
|
||||||
|
currentProperty = block.getStates().keySet().stream().findFirst().get();
|
||||||
|
selectedProperties.put(player.getUniqueId(), currentProperty);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (forward) {
|
||||||
|
block.getState(currentProperty);
|
||||||
|
int index = currentProperty.getValues().indexOf(block.getState(currentProperty));
|
||||||
|
index = (index + 1) % currentProperty.getValues().size();
|
||||||
|
BlockState newBlock = block.with(currentProperty, currentProperty.getValues().get(index));
|
||||||
|
|
||||||
// TODO Forward = cycle value, Backward = Next property
|
|
||||||
// int increment = forward ? 1 : -1;
|
|
||||||
// BaseBlock newBlock = new BaseBlock(type, BlockData.cycle(type, data, increment));
|
|
||||||
EditSession editSession = session.createEditSession(player);
|
EditSession editSession = session.createEditSession(player);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
editSession.setBlock(clicked.toVector(), newBlock);
|
editSession.setBlock(clicked.toVector(), newBlock);
|
||||||
|
player.print("Value of " + currentProperty.getName() + " is now " + currentProperty.getValues().get(index).toString());
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
player.printError("Max blocks change limit reached.");
|
player.printError("Max blocks change limit reached.");
|
||||||
} finally {
|
} finally {
|
||||||
session.remember(editSession);
|
session.remember(editSession);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
List<Property<?>> properties = Lists.newArrayList(block.getStates().keySet());
|
||||||
|
int index = properties.indexOf(currentProperty);
|
||||||
|
index = (index + 1) % properties.size();
|
||||||
|
currentProperty = properties.get(index);
|
||||||
|
selectedProperties.put(player.getUniqueId(), currentProperty);
|
||||||
|
player.print("Now cycling " + currentProperty.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -26,19 +26,26 @@ import com.sk89q.worldedit.Vector;
|
|||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BlockType;
|
import com.sk89q.worldedit.blocks.BlockType;
|
||||||
import com.sk89q.worldedit.blocks.Blocks;
|
import com.sk89q.worldedit.blocks.Blocks;
|
||||||
import com.sk89q.worldedit.world.block.BlockCategories;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
|
||||||
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.operation.BlockMapEntryPlacer;
|
import com.sk89q.worldedit.function.operation.BlockMapEntryPlacer;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
import com.sk89q.worldedit.function.operation.OperationQueue;
|
import com.sk89q.worldedit.function.operation.OperationQueue;
|
||||||
import com.sk89q.worldedit.function.operation.RunContext;
|
import com.sk89q.worldedit.function.operation.RunContext;
|
||||||
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
import com.sk89q.worldedit.util.collection.TupleArrayList;
|
import com.sk89q.worldedit.util.collection.TupleArrayList;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockCategories;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.Deque;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Re-orders blocks into several stages.
|
* Re-orders blocks into several stages.
|
||||||
@ -151,16 +158,16 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
|
|||||||
assert (blockTypes.containsKey(current));
|
assert (blockTypes.containsKey(current));
|
||||||
|
|
||||||
final BlockStateHolder blockStateHolder = blockTypes.get(current);
|
final BlockStateHolder blockStateHolder = blockTypes.get(current);
|
||||||
// final int data = baseBlock.getData();
|
|
||||||
|
|
||||||
if (BlockCategories.DOORS.contains(blockStateHolder.getBlockType())) {
|
if (BlockCategories.DOORS.contains(blockStateHolder.getBlockType())) {
|
||||||
// TODO if ((data & 0x8) == 0) {
|
Property<Object> halfProperty = blockStateHolder.getBlockType().getProperty("half");
|
||||||
// // Deal with lower door halves being attached to the floor AND the upper half
|
if (blockStateHolder.getState(halfProperty).equals("lower")) {
|
||||||
// BlockVector upperBlock = current.add(0, 1, 0).toBlockVector();
|
// Deal with lower door halves being attached to the floor AND the upper half
|
||||||
// if (blocks.contains(upperBlock) && !walked.contains(upperBlock)) {
|
BlockVector upperBlock = current.add(0, 1, 0).toBlockVector();
|
||||||
// walked.addFirst(upperBlock);
|
if (blocks.contains(upperBlock) && !walked.contains(upperBlock)) {
|
||||||
// }
|
walked.addFirst(upperBlock);
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
} else if (BlockCategories.RAILS.contains(blockStateHolder.getBlockType())) {
|
} else if (BlockCategories.RAILS.contains(blockStateHolder.getBlockType())) {
|
||||||
BlockVector lowerBlock = current.add(0, -1, 0).toBlockVector();
|
BlockVector lowerBlock = current.add(0, -1, 0).toBlockVector();
|
||||||
if (blocks.contains(lowerBlock) && !walked.contains(lowerBlock)) {
|
if (blocks.contains(lowerBlock) && !walked.contains(lowerBlock)) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren