Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 02:20:07 +01:00
Added block damage support to //replace and //replacenear
Dieser Commit ist enthalten in:
Ursprung
d83fed13fb
Commit
1562f17540
@ -999,7 +999,7 @@ public class EditSession {
|
|||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException
|
* @throws MaxChangedBlocksException
|
||||||
*/
|
*/
|
||||||
public int replaceBlocks(Region region, Set<Integer> fromBlockTypes,
|
public int replaceBlocks(Region region, Set<BaseBlock> fromBlockTypes,
|
||||||
BaseBlock toBlock) throws MaxChangedBlocksException {
|
BaseBlock toBlock) throws MaxChangedBlocksException {
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
|
|
||||||
@ -1019,11 +1019,10 @@ public class EditSession {
|
|||||||
for (int y = minY; y <= maxY; ++y) {
|
for (int y = minY; y <= maxY; ++y) {
|
||||||
for (int z = minZ; z <= maxZ; ++z) {
|
for (int z = minZ; z <= maxZ; ++z) {
|
||||||
Vector pt = new Vector(x, y, z);
|
Vector pt = new Vector(x, y, z);
|
||||||
int curBlockType = getBlockType(pt);
|
BaseBlock curBlockType = getBlock(pt);
|
||||||
|
|
||||||
if ((fromBlockTypes == null && curBlockType != 0)
|
if ((fromBlockTypes == null && !curBlockType.isAir())
|
||||||
|| (fromBlockTypes != null && fromBlockTypes
|
|| (fromBlockTypes != null && curBlockType.inIterable(fromBlockTypes))) {
|
||||||
.contains(curBlockType))) {
|
|
||||||
if (setBlock(pt, toBlock)) {
|
if (setBlock(pt, toBlock)) {
|
||||||
++affected;
|
++affected;
|
||||||
}
|
}
|
||||||
@ -1033,10 +1032,10 @@ public class EditSession {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (Vector pt : region) {
|
for (Vector pt : region) {
|
||||||
int curBlockType = getBlockType(pt);
|
BaseBlock curBlockType = getBlock(pt);
|
||||||
|
|
||||||
if (fromBlockTypes == null && curBlockType != 0
|
if (fromBlockTypes == null && !curBlockType.isAir()
|
||||||
|| fromBlockTypes.contains(curBlockType)) {
|
|| fromBlockTypes != null && curBlockType.inIterable(fromBlockTypes)) {
|
||||||
if (setBlock(pt, toBlock)) {
|
if (setBlock(pt, toBlock)) {
|
||||||
++affected;
|
++affected;
|
||||||
}
|
}
|
||||||
@ -1056,7 +1055,7 @@ public class EditSession {
|
|||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException
|
* @throws MaxChangedBlocksException
|
||||||
*/
|
*/
|
||||||
public int replaceBlocks(Region region, Set<Integer> fromBlockTypes,
|
public int replaceBlocks(Region region, Set<BaseBlock> fromBlockTypes,
|
||||||
Pattern pattern) throws MaxChangedBlocksException {
|
Pattern pattern) throws MaxChangedBlocksException {
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
|
|
||||||
@ -1076,11 +1075,10 @@ public class EditSession {
|
|||||||
for (int y = minY; y <= maxY; ++y) {
|
for (int y = minY; y <= maxY; ++y) {
|
||||||
for (int z = minZ; z <= maxZ; ++z) {
|
for (int z = minZ; z <= maxZ; ++z) {
|
||||||
Vector pt = new Vector(x, y, z);
|
Vector pt = new Vector(x, y, z);
|
||||||
int curBlockType = getBlockType(pt);
|
BaseBlock curBlockType = getBlock(pt);
|
||||||
|
|
||||||
if ((fromBlockTypes == null && curBlockType != 0)
|
if ((fromBlockTypes == null && !curBlockType.isAir())
|
||||||
|| (fromBlockTypes != null && fromBlockTypes
|
|| (fromBlockTypes != null && curBlockType.inIterable(fromBlockTypes))) {
|
||||||
.contains(curBlockType))) {
|
|
||||||
if (setBlock(pt, pattern.next(pt))) {
|
if (setBlock(pt, pattern.next(pt))) {
|
||||||
++affected;
|
++affected;
|
||||||
}
|
}
|
||||||
@ -1090,10 +1088,10 @@ public class EditSession {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (Vector pt : region) {
|
for (Vector pt : region) {
|
||||||
int curBlockType = getBlockType(pt);
|
BaseBlock curBlockType = getBlock(pt);
|
||||||
|
|
||||||
if (fromBlockTypes == null && curBlockType != 0
|
if (fromBlockTypes == null && !curBlockType.isAir()
|
||||||
|| fromBlockTypes.contains(curBlockType)) {
|
|| curBlockType.inIterable(fromBlockTypes)) {
|
||||||
if (setBlock(pt, pattern.next(pt))) {
|
if (setBlock(pt, pattern.next(pt))) {
|
||||||
++affected;
|
++affected;
|
||||||
}
|
}
|
||||||
|
@ -400,6 +400,21 @@ public class WorldEdit {
|
|||||||
return getBlock(player, id, false);
|
return getBlock(player, id, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<BaseBlock> getBlocks (LocalPlayer player, String list, boolean allAllowed)
|
||||||
|
throws DisallowedItemException, UnknownItemException {
|
||||||
|
String[] items = list.split(",");
|
||||||
|
Set<BaseBlock> blocks = new HashSet<BaseBlock>();
|
||||||
|
for (String id : items) {
|
||||||
|
blocks.add(getBlock(player, id, allAllowed));
|
||||||
|
}
|
||||||
|
return blocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<BaseBlock> getBlocks(LocalPlayer player, String list)
|
||||||
|
throws DisallowedItemException, UnknownItemException {
|
||||||
|
return getBlocks(player, list, false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of blocks as a set. This returns a Pattern.
|
* Get a list of blocks as a set. This returns a Pattern.
|
||||||
*
|
*
|
||||||
|
@ -115,4 +115,26 @@ public class BaseBlock {
|
|||||||
public void flip(FlipDirection direction) {
|
public void flip(FlipDirection direction) {
|
||||||
data = (char)BlockData.flip(type, data, direction);
|
data = (char)BlockData.flip(type, data, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (!(o instanceof BaseBlock)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return (type == ((BaseBlock)o).type) && (data == ((BaseBlock)o).data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "BaseBlock id: " + getType() + " with damage: " + getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean inIterable(Iterable<BaseBlock> iter) {
|
||||||
|
for (BaseBlock block : iter) {
|
||||||
|
if (block.equals(this)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,13 +81,13 @@ public class RegionCommands {
|
|||||||
LocalSession session, LocalPlayer player, EditSession editSession)
|
LocalSession session, LocalPlayer player, EditSession editSession)
|
||||||
throws WorldEditException {
|
throws WorldEditException {
|
||||||
|
|
||||||
Set<Integer> from;
|
Set<BaseBlock> from;
|
||||||
Pattern to;
|
Pattern to;
|
||||||
if (args.argsLength() == 1) {
|
if (args.argsLength() == 1) {
|
||||||
from = null;
|
from = null;
|
||||||
to = we.getBlockPattern(player, args.getString(0));
|
to = we.getBlockPattern(player, args.getString(0));
|
||||||
} else {
|
} else {
|
||||||
from = we.getBlockIDs(player, args.getString(0), true);
|
from = we.getBlocks(player, args.getString(0), true);
|
||||||
to = we.getBlockPattern(player, args.getString(1));
|
to = we.getBlockPattern(player, args.getString(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,13 +239,13 @@ public class UtilityCommands {
|
|||||||
|
|
||||||
int size = Math.max(1, args.getInteger(0));
|
int size = Math.max(1, args.getInteger(0));
|
||||||
int affected;
|
int affected;
|
||||||
Set<Integer> from;
|
Set<BaseBlock> from;
|
||||||
Pattern to;
|
Pattern to;
|
||||||
if (args.argsLength() == 2) {
|
if (args.argsLength() == 2) {
|
||||||
from = null;
|
from = null;
|
||||||
to = we.getBlockPattern(player, args.getString(1));
|
to = we.getBlockPattern(player, args.getString(1));
|
||||||
} else {
|
} else {
|
||||||
from = we.getBlockIDs(player, args.getString(1), true);
|
from = we.getBlocks(player, args.getString(1), true);
|
||||||
to = we.getBlockPattern(player, args.getString(2));
|
to = we.getBlockPattern(player, args.getString(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren