geforkt von Mirrors/FastAsyncWorldEdit
Allow //replace to ignore from block damage values (and force them to not be ignored with the -f flag)
Dieser Commit ist enthalten in:
Ursprung
56fd654eed
Commit
a1cf6eb6da
@ -207,9 +207,9 @@ public class EditSession {
|
||||
|
||||
if (BlockType.usesData(type)) {
|
||||
if (fastMode) {
|
||||
result = world.setTypeIdAndDataFast(pt, type, block.getData());
|
||||
result = world.setTypeIdAndDataFast(pt, type, block.getData() > -1 ? block.getData() : 0);
|
||||
} else {
|
||||
result = world.setTypeIdAndData(pt, type, block.getData());
|
||||
result = world.setTypeIdAndData(pt, type, block.getData() > -1 ? block.getData() : 0);
|
||||
}
|
||||
} else {
|
||||
if (fastMode) {
|
||||
|
@ -246,6 +246,11 @@ public class WorldEdit {
|
||||
}
|
||||
}
|
||||
|
||||
public BaseBlock getBlock(LocalPlayer player, String arg, boolean allAllowed)
|
||||
throws UnknownItemException, DisallowedItemException {
|
||||
return getBlock(player, arg, allAllowed, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an item ID from an item name or an item ID number.
|
||||
*
|
||||
@ -256,7 +261,8 @@ public class WorldEdit {
|
||||
* @throws UnknownItemException
|
||||
* @throws DisallowedItemException
|
||||
*/
|
||||
public BaseBlock getBlock(LocalPlayer player, String arg, boolean allAllowed)
|
||||
public BaseBlock getBlock(LocalPlayer player, String arg,
|
||||
boolean allAllowed, boolean allowNoData)
|
||||
throws UnknownItemException, DisallowedItemException {
|
||||
BlockType blockType;
|
||||
arg = arg.replace("_", " ");
|
||||
@ -307,8 +313,8 @@ public class WorldEdit {
|
||||
if (data == -1) { // Block data not yet detected
|
||||
// Parse the block data (optional)
|
||||
try {
|
||||
data = args1.length > 1 ? Integer.parseInt(args1[1]) : 0;
|
||||
if (data > 15 || data < 0) {
|
||||
data = args1.length > 1 ? Integer.parseInt(args1[1]) : (allowNoData ? -1 : 0);
|
||||
if (data > 15 || (data < 0 && !(allAllowed && data == -1))) {
|
||||
data = 0;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
@ -344,6 +350,11 @@ public class WorldEdit {
|
||||
case COBBLESTONE:
|
||||
data = 3;
|
||||
break;
|
||||
case BRICK:
|
||||
data = 4;
|
||||
break;
|
||||
case STONE_BRICK:
|
||||
data = 5;
|
||||
|
||||
default:
|
||||
throw new InvalidItemException(arg, "Invalid step type '" + args1[1] + "'");
|
||||
@ -425,16 +436,22 @@ public class WorldEdit {
|
||||
return getBlock(player, id, false);
|
||||
}
|
||||
|
||||
public Set<BaseBlock> getBlocks (LocalPlayer player, String list, boolean allAllowed)
|
||||
public Set<BaseBlock> getBlocks (LocalPlayer player, String list,
|
||||
boolean allAllowed, boolean allowNoData)
|
||||
throws DisallowedItemException, UnknownItemException {
|
||||
String[] items = list.split(",");
|
||||
Set<BaseBlock> blocks = new HashSet<BaseBlock>();
|
||||
for (String id : items) {
|
||||
blocks.add(getBlock(player, id, allAllowed));
|
||||
blocks.add(getBlock(player, id, allAllowed, allowNoData));
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
|
||||
public Set<BaseBlock> getBlocks(LocalPlayer player, String list, boolean allAllowed)
|
||||
throws DisallowedItemException, UnknownItemException {
|
||||
return getBlocks(player, list, allAllowed);
|
||||
}
|
||||
|
||||
public Set<BaseBlock> getBlocks(LocalPlayer player, String list)
|
||||
throws DisallowedItemException, UnknownItemException {
|
||||
return getBlocks(player, list, false);
|
||||
|
@ -129,7 +129,8 @@ public class BaseBlock {
|
||||
if (!(o instanceof BaseBlock)) {
|
||||
return false;
|
||||
}
|
||||
return (type == ((BaseBlock)o).type) && (data == ((BaseBlock)o).data);
|
||||
return (type == ((BaseBlock)o).type)
|
||||
&& (data == ((BaseBlock)o).data || data == -1 || ((BaseBlock)o).data == -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,6 +73,7 @@ public class RegionCommands {
|
||||
aliases = {"/replace"},
|
||||
usage = "[from-block] <to-block>",
|
||||
desc = "Replace all blocks in the selection with another",
|
||||
flags = "f",
|
||||
min = 1,
|
||||
max = 2
|
||||
)
|
||||
@ -88,7 +89,7 @@ public class RegionCommands {
|
||||
from = null;
|
||||
to = we.getBlockPattern(player, args.getString(0));
|
||||
} else {
|
||||
from = we.getBlocks(player, args.getString(0), true);
|
||||
from = we.getBlocks(player, args.getString(0), true, !args.hasFlag('f'));
|
||||
to = we.getBlockPattern(player, args.getString(1));
|
||||
}
|
||||
|
||||
|
@ -228,6 +228,7 @@ public class UtilityCommands {
|
||||
aliases = {"/replacenear", "replacenear"},
|
||||
usage = "<size> <from-id> <to-id>",
|
||||
desc = "Replace nearby blocks",
|
||||
flags = "f",
|
||||
min = 3,
|
||||
max = 3
|
||||
)
|
||||
@ -245,7 +246,7 @@ public class UtilityCommands {
|
||||
from = null;
|
||||
to = we.getBlockPattern(player, args.getString(1));
|
||||
} else {
|
||||
from = we.getBlocks(player, args.getString(1), true);
|
||||
from = we.getBlocks(player, args.getString(1), true, !args.hasFlag('f'));
|
||||
to = we.getBlockPattern(player, args.getString(2));
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren