geforkt von Mirrors/FastAsyncWorldEdit
Fix fixLiquid
Dieser Commit ist enthalten in:
Ursprung
093542c337
Commit
652f27c853
@ -2196,18 +2196,24 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
* @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(final BlockVector3 origin, final double radius, Mask liquidMask, Pattern pattern) {
|
public int fixLiquid(final BlockVector3 origin, final double radius, BlockType fluid) {
|
||||||
checkNotNull(origin);
|
checkNotNull(origin);
|
||||||
checkArgument(radius >= 0, "radius >= 0 required");
|
checkArgument(radius >= 0, "radius >= 0 required");
|
||||||
|
|
||||||
|
// Our origins can only be liquids
|
||||||
|
Mask liquidMask = new BlockTypeMask(this, fluid);
|
||||||
|
|
||||||
|
// But we will also visit air blocks
|
||||||
|
MaskIntersection blockMask = new MaskUnion(liquidMask, Masks.negate(new ExistingBlockMask(this)));
|
||||||
|
|
||||||
// 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(), getMaximumPoint().getBlockY())),
|
new BoundedHeightMask(0, Math.min(origin.getBlockY(), getWorld().getMaxY())),
|
||||||
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
|
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
|
||||||
liquidMask);
|
blockMask);
|
||||||
|
|
||||||
BlockReplace replace = new BlockReplace(this, pattern);
|
BlockReplace replace = new BlockReplace(this, new BlockPattern(fluid.getDefaultState()));
|
||||||
NonRisingVisitor visitor = new NonRisingVisitor(mask, replace, (int) (radius * 2 + 1), this);
|
NonRisingVisitor visitor = new NonRisingVisitor(mask, replace);
|
||||||
|
|
||||||
// Around the origin in a 3x3 block
|
// Around the origin in a 3x3 block
|
||||||
for (BlockVector3 position : CuboidRegion.fromCenter(origin, 1)) {
|
for (BlockVector3 position : CuboidRegion.fromCenter(origin, 1)) {
|
||||||
@ -2216,8 +2222,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Operations.completeBlindly(visitor);
|
Operations.completeLegacy(visitor);
|
||||||
return getBlockChangeCount();
|
return visitor.getAffected();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -317,10 +317,11 @@ public class UtilityCommands extends MethodCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.fixlava")
|
@CommandPermissions("worldedit.fixlava")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
public void fixLava(Player player, LocalSession session, EditSession editSession, double radius) throws WorldEditException {
|
public void fixLava(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||||
|
double radius = Math.max(0, args.getDouble(0));
|
||||||
worldEdit.checkMaxRadius(radius);
|
worldEdit.checkMaxRadius(radius);
|
||||||
int affected = editSession.fixLiquid(
|
int affected = editSession.fixLiquid(
|
||||||
session.getPlacementPosition(player), radius, BlockTypes.LAVA.toMask(editSession), BlockTypes.LAVA.getDefaultState());
|
session.getPlacementPosition(player), radius, BlockTypes.LAVA);
|
||||||
player.print(BBC.getPrefix() + affected + " block(s) have been changed.");
|
player.print(BBC.getPrefix() + affected + " block(s) have been changed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,10 +334,11 @@ public class UtilityCommands extends MethodCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.fixwater")
|
@CommandPermissions("worldedit.fixwater")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
public void fixWater(Player player, LocalSession session, EditSession editSession, double radius) throws WorldEditException {
|
public void fixWater(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||||
|
double radius = Math.max(0, args.getDouble(0));
|
||||||
worldEdit.checkMaxRadius(radius);
|
worldEdit.checkMaxRadius(radius);
|
||||||
int affected = editSession.fixLiquid(
|
int affected = editSession.fixLiquid(
|
||||||
session.getPlacementPosition(player), radius, BlockTypes.WATER.toMask(editSession), BlockTypes.WATER.getDefaultState());
|
session.getPlacementPosition(player), radius, BlockTypes.WATER);
|
||||||
BBC.VISITOR_BLOCK.send(player, affected);
|
BBC.VISITOR_BLOCK.send(player, affected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren