Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-09 21:10:05 +01:00
Added pyramid generation with /pyramid & /hpyramid
Dieser Commit ist enthalten in:
Ursprung
2068189cf5
Commit
2342acfae2
@ -16,7 +16,6 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit;
|
package com.sk89q.worldedit;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -47,16 +46,15 @@ import com.sk89q.worldedit.patterns.*;
|
|||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class EditSession {
|
public class EditSession {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Random number generator.
|
* Random number generator.
|
||||||
*/
|
*/
|
||||||
private static Random prng = new Random();
|
private static Random prng = new Random();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* World.
|
* World.
|
||||||
*/
|
*/
|
||||||
protected LocalWorld world;
|
protected LocalWorld world;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the original blocks before modification.
|
* Stores the original blocks before modification.
|
||||||
*/
|
*/
|
||||||
@ -1851,6 +1849,49 @@ public class EditSession {
|
|||||||
return affected;
|
return affected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes a pyramid.
|
||||||
|
*
|
||||||
|
* @param pos
|
||||||
|
* @param block
|
||||||
|
* @param size
|
||||||
|
* @param filled
|
||||||
|
* @return number of blocks changed
|
||||||
|
* @throws MaxChangedBlocksException
|
||||||
|
*/
|
||||||
|
public int makePyramid(Vector pos, Pattern block, int size,
|
||||||
|
boolean filled) throws MaxChangedBlocksException {
|
||||||
|
int affected = 0;
|
||||||
|
|
||||||
|
int height = size;
|
||||||
|
|
||||||
|
for (int y = 0; y <= height; ++y) {
|
||||||
|
size--;
|
||||||
|
for (int x = 0; x <= size; ++x) {
|
||||||
|
for (int z = 0; z <= size; ++z) {
|
||||||
|
|
||||||
|
if ((filled && z <= size && x <= size) || z == size || x == size) {
|
||||||
|
|
||||||
|
if (setBlock(pos.add(x, y, z), block)) {
|
||||||
|
++affected;
|
||||||
|
}
|
||||||
|
if (setBlock(pos.add(-x, y, z), block)) {
|
||||||
|
++affected;
|
||||||
|
}
|
||||||
|
if (setBlock(pos.add(x, y, -z), block)) {
|
||||||
|
++affected;
|
||||||
|
}
|
||||||
|
if (setBlock(pos.add(-x, y, -z), block)) {
|
||||||
|
++affected;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return affected;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thaw.
|
* Thaw.
|
||||||
*
|
*
|
||||||
@ -2270,7 +2311,6 @@ public class EditSession {
|
|||||||
* maximal height
|
* maximal height
|
||||||
* @return height of highest block found or 'minY'
|
* @return height of highest block found or 'minY'
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
|
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
|
||||||
for (int y = maxY; y >= minY; --y) {
|
for (int y = maxY; y >= minY; --y) {
|
||||||
Vector pt = new Vector(x, y, z);
|
Vector pt = new Vector(x, y, z);
|
||||||
|
@ -178,4 +178,48 @@ public class GenerationCommands {
|
|||||||
int affected = editSession.makePumpkinPatches(player.getPosition(), size);
|
int affected = editSession.makePumpkinPatches(player.getPosition(), size);
|
||||||
player.print(affected + " pumpkin patches created.");
|
player.print(affected + " pumpkin patches created.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = {"/pyramid"},
|
||||||
|
usage = "<block> <range>",
|
||||||
|
desc = "Generate a filled pyramid",
|
||||||
|
min = 2,
|
||||||
|
max = 2
|
||||||
|
)
|
||||||
|
@CommandPermissions({"worldedit.generation.pyramid"})
|
||||||
|
public static void pyramid(CommandContext args, WorldEdit we,
|
||||||
|
LocalSession session, LocalPlayer player, EditSession editSession)
|
||||||
|
throws WorldEditException {
|
||||||
|
|
||||||
|
Pattern block = we.getBlockPattern(player, args.getString(0));
|
||||||
|
int size = Math.max(1, args.getInteger(1));
|
||||||
|
Vector pos = session.getPlacementPosition(player);
|
||||||
|
|
||||||
|
int affected = editSession.makePyramid(pos, block, size, true);
|
||||||
|
|
||||||
|
player.findFreePosition();
|
||||||
|
player.print(affected + " block(s) have been created.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = {"/hpyramid"},
|
||||||
|
usage = "<block> <range>",
|
||||||
|
desc = "Generate a hollow pyramid",
|
||||||
|
min = 2,
|
||||||
|
max = 2
|
||||||
|
)
|
||||||
|
@CommandPermissions({"worldedit.generation.pyramid"})
|
||||||
|
public static void hpyramid(CommandContext args, WorldEdit we,
|
||||||
|
LocalSession session, LocalPlayer player, EditSession editSession)
|
||||||
|
throws WorldEditException {
|
||||||
|
|
||||||
|
Pattern block = we.getBlockPattern(player, args.getString(0));
|
||||||
|
int size = Math.max(1, args.getInteger(1));
|
||||||
|
Vector pos = session.getPlacementPosition(player);
|
||||||
|
|
||||||
|
int affected = editSession.makePyramid(pos, block, size, false);
|
||||||
|
|
||||||
|
player.findFreePosition();
|
||||||
|
player.print(affected + " block(s) have been created.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,10 +50,19 @@ commands:
|
|||||||
description: Modify block change limit
|
description: Modify block change limit
|
||||||
usage: /<command> <limit>
|
usage: /<command> <limit>
|
||||||
permissions: 'worldedit.limit'
|
permissions: 'worldedit.limit'
|
||||||
|
/gmask:
|
||||||
|
description: Set the global mask
|
||||||
|
usage: /<command> [mask]
|
||||||
|
aliases: ['gmask']
|
||||||
|
permissions: 'worldedit.global-mask'
|
||||||
we:
|
we:
|
||||||
description: WorldEdit commands
|
description: WorldEdit commands
|
||||||
usage: /<command>
|
usage: /<command>
|
||||||
aliases: ['worldedit']
|
aliases: ['worldedit']
|
||||||
|
/fast:
|
||||||
|
description: Toggle fast mode
|
||||||
|
usage: /<command>
|
||||||
|
permissions: 'worldedit.fast'
|
||||||
toggleplace:
|
toggleplace:
|
||||||
description:
|
description:
|
||||||
usage: /<command>
|
usage: /<command>
|
||||||
@ -85,6 +94,10 @@ commands:
|
|||||||
description: Generate pumpkin patches
|
description: Generate pumpkin patches
|
||||||
usage: /<command> [size]
|
usage: /<command> [size]
|
||||||
permissions: 'worldedit.generation.pumpkins'
|
permissions: 'worldedit.generation.pumpkins'
|
||||||
|
/pyramid:
|
||||||
|
description: Generate a filled pyramid
|
||||||
|
usage: /<command> <block> <range> <height> [inverted]
|
||||||
|
permissions: 'worldedit.generation.sphere'
|
||||||
/undo:
|
/undo:
|
||||||
description: Undoes the last action
|
description: Undoes the last action
|
||||||
usage: /<command> [times]
|
usage: /<command> [times]
|
||||||
@ -105,11 +118,11 @@ commands:
|
|||||||
permissions: 'worldedit.navigation.unstuck'
|
permissions: 'worldedit.navigation.unstuck'
|
||||||
ascend:
|
ascend:
|
||||||
description: Go up a floor
|
description: Go up a floor
|
||||||
usage: /<command>
|
usage: /<command> [# of levels]
|
||||||
permissions: 'worldedit.navigation.ascend'
|
permissions: 'worldedit.navigation.ascend'
|
||||||
descend:
|
descend:
|
||||||
description: Go down a floor
|
description: Go down a floor
|
||||||
usage: /<command>
|
usage: /<command> [# of floors]
|
||||||
permissions: 'worldedit.navigation.descend'
|
permissions: 'worldedit.navigation.descend'
|
||||||
ceil:
|
ceil:
|
||||||
description: Go to the celing
|
description: Go to the celing
|
||||||
@ -143,6 +156,10 @@ commands:
|
|||||||
description: Set a block on top of blocks in the region
|
description: Set a block on top of blocks in the region
|
||||||
usage: /<command> <block>
|
usage: /<command> <block>
|
||||||
permissions: 'worldedit.region.overlay'
|
permissions: 'worldedit.region.overlay'
|
||||||
|
/naturalize:
|
||||||
|
description: 3 layers of dirt on top then rock below
|
||||||
|
usage: /<command>
|
||||||
|
permissions: 'worldedit.region.naturalize'
|
||||||
/walls:
|
/walls:
|
||||||
description: Build the four sides of the selection
|
description: Build the four sides of the selection
|
||||||
usage: /<command> <block>
|
usage: /<command> <block>
|
||||||
@ -270,6 +287,10 @@ commands:
|
|||||||
usage: /<command> [pattern]
|
usage: /<command> [pattern]
|
||||||
aliases: ['material', 'fill']
|
aliases: ['material', 'fill']
|
||||||
permissions: 'worldedit.brush.options.material'
|
permissions: 'worldedit.brush.options.material'
|
||||||
|
range:
|
||||||
|
description: Set the brush range
|
||||||
|
usage: /<command> [pattern]
|
||||||
|
permissions: 'worldedit.brush.options.range'
|
||||||
info:
|
info:
|
||||||
description: Block information tool
|
description: Block information tool
|
||||||
usage: /<command>
|
usage: /<command>
|
||||||
@ -289,6 +310,11 @@ commands:
|
|||||||
description: Block data cycler tool
|
description: Block data cycler tool
|
||||||
usage: /<command>
|
usage: /<command>
|
||||||
permissions: 'worldedit.tool.data-cycler'
|
permissions: 'worldedit.tool.data-cycler'
|
||||||
|
floodfill:
|
||||||
|
description: Flood fill tool
|
||||||
|
usage: /<command>
|
||||||
|
aliases: ['flood']
|
||||||
|
permissions: 'worldedit.tool.flood-fill'
|
||||||
brush:
|
brush:
|
||||||
description: Brush tool
|
description: Brush tool
|
||||||
usage: /<command>
|
usage: /<command>
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren