3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-25 02:20:07 +01:00

Added //regen to regenerate an area.

Dieser Commit ist enthalten in:
sk89q 2011-03-12 16:37:07 -08:00
Ursprung 0fa675cecc
Commit 1b670a1c98
6 geänderte Dateien mit 167 neuen und 66 gelöschten Zeilen

Datei anzeigen

@ -11,6 +11,9 @@ commands:
delchunks: delchunks:
description: Delete chunks that your selection includes description: Delete chunks that your selection includes
usage: /<command> usage: /<command>
clearclipboard:
description: Clear your clipboard
usage: /<command>
/load: /load:
description: Load a schematic into your clipboard description: Load a schematic into your clipboard
usage: /<command> <filename> usage: /<command> <filename>
@ -32,12 +35,6 @@ commands:
/paste: /paste:
description: Paste the clipboard's contents description: Paste the clipboard's contents
usage: /<command> [-ao] usage: /<command> [-ao]
clearclipboard:
description: Clear your clipboard
usage: /<command>
/limit:
description: Modify block change limit
usage: /<command> <limit>
we: we:
description: WorldEdit commands description: WorldEdit commands
usage: /<command> usage: /<command>
@ -49,6 +46,9 @@ commands:
description: Search for an item description: Search for an item
usage: /<command> [-bi] <query> usage: /<command> [-bi] <query>
aliases: ['/l', 'search'] aliases: ['/l', 'search']
/limit:
description: Modify block change limit
usage: /<command> <limit>
/hcyl: /hcyl:
description: Generate a hollow cylinder description: Generate a hollow cylinder
usage: /<command> <block> <radius> [height] usage: /<command> <block> <radius> [height]
@ -67,17 +67,17 @@ commands:
pumpkins: pumpkins:
description: Generate pumpkin patches description: Generate pumpkin patches
usage: /<command> [size] usage: /<command> [size]
/undo: clearhistory:
description: Undoes the last action description: Clear your history
usage: /<command> [times] usage: /<command>
aliases: ['undo']
/redo: /redo:
description: Redoes the last action (from history) description: Redoes the last action (from history)
usage: /<command> [times] usage: /<command> [times]
aliases: ['redo'] aliases: ['redo']
clearhistory: /undo:
description: Clear your history description: Undoes the last action
usage: /<command> usage: /<command> [times]
aliases: ['undo']
unstuck: unstuck:
description: Escape from being stuck inside a block description: Escape from being stuck inside a block
usage: /<command> usage: /<command>
@ -87,27 +87,18 @@ commands:
descend: descend:
description: Go down a floor description: Go down a floor
usage: /<command> usage: /<command>
ceil:
description: Go to the celing
usage: /<command> [clearance]
thru: thru:
description: Passthrough walls description: Passthrough walls
usage: /<command> usage: /<command>
jumpto: jumpto:
description: Teleport to a location description: Teleport to a location
usage: /<command> usage: /<command>
ceil:
description: Go to the celing
usage: /<command> [clearance]
up: up:
description: Go upwards some distance description: Go upwards some distance
usage: /<command> <block> usage: /<command> <block>
/replace:
description: Replace all blocks in the selection with another
usage: /<command> [from-block] <to-block>
/stack:
description: Repeat the contents of the selection
usage: /<command> [-a] [count] [direction]
/set:
description: Set all the blocks inside the selection to a block
usage: /<command> <block>
/overlay: /overlay:
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>
@ -121,24 +112,27 @@ commands:
/smooth: /smooth:
description: Smooth the elevation in the selection description: Smooth the elevation in the selection
usage: /<command> [iterations] usage: /<command> [iterations]
/regen:
description: Regenerates the contents of the selection
usage: /<command>
/replace:
description: Replace all blocks in the selection with another
usage: /<command> [from-block] <to-block>
/stack:
description: Repeat the contents of the selection
usage: /<command> [-a] [count] [direction]
/set:
description: Set all the blocks inside the selection to a block
usage: /<command> <block>
/move: /move:
description: Move the contents of the selection description: Move the contents of the selection
usage: /<command> [count] [direction] [leave-id] usage: /<command> [count] [direction] [leave-id]
cs:
description: Execute a CraftScript
usage: /<command> <filename> [args...]
.s: .s:
description: Execute last CraftScript description: Execute last CraftScript
usage: /<command> [args...] usage: /<command> [args...]
/count: cs:
description: Counts the number of a certain type of block description: Execute a CraftScript
usage: /<command> <block> usage: /<command> <filename> [args...]
/size:
description: Get information about the selection
usage: /<command>
/shift:
description: Shift the selection area
usage: /<command> <amount> [direction]
/chunk: /chunk:
description: Set the selection to your current chunk description: Set the selection to your current chunk
usage: /<command> usage: /<command>
@ -160,25 +154,34 @@ commands:
toggleeditwand: toggleeditwand:
description: Toggle functionality of the edit wand description: Toggle functionality of the edit wand
usage: /<command> usage: /<command>
/expand:
description: Expand the selection area
usage: /<command> <amount> [reverse-amount] <direction>
/contract: /contract:
description: Contract the selection area description: Contract the selection area
usage: /<command> <amount> [reverse-amount] [direction] usage: /<command> <amount> [reverse-amount] [direction]
/outset: /outset:
description: Outset the selection area description: Outset the selection area
usage: /<command> [-hv] <amount> usage: /<command> [-hv] <amount>
/inset:
description: Inset the selection area
usage: /<command> [-hv] <amount>
/distr: /distr:
description: Get the distribution of blocks in the selection description: Get the distribution of blocks in the selection
usage: /<command> [-c] usage: /<command> [-c]
/count:
description: Counts the number of a certain type of block
usage: /<command> <block>
/size:
description: Get information about the selection
usage: /<command>
/shift:
description: Shift the selection area
usage: /<command> <amount> [direction]
/expand:
description: Expand the selection area
usage: /<command> <amount> [reverse-amount] <direction>
/sel: /sel:
description: Choose a region selector description: Choose a region selector
usage: /<command> [type] usage: /<command> [type]
aliases: [','] aliases: [',']
/inset:
description: Inset the selection area
usage: /<command> [-hv] <amount>
snapshot: snapshot:
description: Snapshot commands description: Snapshot commands
usage: /<command> usage: /<command>
@ -187,12 +190,6 @@ commands:
description: Restore the selection from a snapshot description: Restore the selection from a snapshot
usage: /<command> [snapshot] usage: /<command> [snapshot]
aliases: ['/restore'] aliases: ['/restore']
size:
description: Set the brush size
usage: /<command> [pattern]
mask:
description: Set the brush mask
usage: /<command> [mask]
/: /:
description: Toggle the super pickaxe pickaxe function description: Toggle the super pickaxe pickaxe function
usage: /<command> usage: /<command>
@ -208,15 +205,15 @@ commands:
description: Set the brush material description: Set the brush material
usage: /<command> [pattern] usage: /<command> [pattern]
aliases: ['material', 'fill'] aliases: ['material', 'fill']
info: size:
description: Block information tool description: Set the brush size
usage: /<command> usage: /<command> [pattern]
mask:
description: Set the brush mask
usage: /<command> [mask]
none: none:
description: Turn off all superpickaxe alternate modes description: Turn off all superpickaxe alternate modes
usage: /<command> usage: /<command>
tree:
description: Tree generator tool
usage: /<command> [type]
repl: repl:
description: Block replacer tool description: Block replacer tool
usage: /<command> <block> usage: /<command> <block>
@ -227,19 +224,15 @@ commands:
description: Brush tool description: Brush tool
usage: /<command> usage: /<command>
aliases: ['br'] aliases: ['br']
remove: info:
description: Remove all entities of a type description: Block information tool
usage: /<command> <type> <radius> usage: /<command>
aliases: ['rem', 'rement'] tree:
/fill: description: Tree generator tool
description: Fill a hole usage: /<command> [type]
usage: /<command> <block> <radius> [depth]
/fillr: /fillr:
description: Fill a hole recursively description: Fill a hole recursively
usage: /<command> <block> <radius> [depth] usage: /<command> <block> <radius> [depth]
/drain:
description: Drain a pool
usage: /<command> <radius>
fixlava: fixlava:
description: Fix lava to be stationary description: Fix lava to be stationary
usage: /<command> <radius> usage: /<command> <radius>
@ -271,3 +264,13 @@ commands:
butcher: butcher:
description: Kill all or nearby mobs description: Kill all or nearby mobs
usage: /<command> [radius] usage: /<command> [radius]
remove:
description: Remove all entities of a type
usage: /<command> <type> <radius>
aliases: ['rem', 'rement']
/fill:
description: Fill a hole
usage: /<command> <block> <radius> [depth]
/drain:
description: Drain a pool
usage: /<command> <radius>

Datei anzeigen

@ -249,6 +249,20 @@ public class EditSession {
return smartSetBlock(pt, block); return smartSetBlock(pt, block);
} }
/**
* Insert a contrived block change into the history.
*
* @param pt
* @param existing
* @param block
*/
public void rememberChange(Vector pt, BaseBlock existing, BaseBlock block) {
BlockVector blockPt = pt.toBlockVector();
original.put(blockPt, existing);
current.put(pt.toBlockVector(), block);
}
/** /**
* Set a block with a pattern. * Set a block with a pattern.
* *
@ -286,7 +300,7 @@ public class EditSession {
* @param block * @param block
* @return * @return
*/ */
private boolean smartSetBlock(Vector pt, BaseBlock block) { public boolean smartSetBlock(Vector pt, BaseBlock block) {
if (queued) { if (queued) {
// Place torches, etc. last // Place torches, etc. last
if (BlockType.shouldPlaceLast(block.getType())) { if (BlockType.shouldPlaceLast(block.getType())) {

Datei anzeigen

@ -22,6 +22,7 @@ package com.sk89q.worldedit;
import java.util.Random; import java.util.Random;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.regions.Region;
/** /**
* Represents a world. * Represents a world.
@ -79,6 +80,15 @@ public abstract class LocalWorld {
*/ */
public abstract int getBlockData(Vector pt); public abstract int getBlockData(Vector pt);
/**
* Regenerate an area.
*
* @param region
* @param editSession
* @return
*/
public abstract boolean regenerate(Region region, EditSession editSession);
/** /**
* Attempts to accurately copy a BaseBlock's extra data to the world. * Attempts to accurately copy a BaseBlock's extra data to the world.
* *

Datei anzeigen

@ -43,7 +43,9 @@ import org.bukkit.World;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalWorld; import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.blocks.*; import com.sk89q.worldedit.blocks.*;
import com.sk89q.worldedit.regions.Region;
public class BukkitWorld extends LocalWorld { public class BukkitWorld extends LocalWorld {
private World world; private World world;
@ -111,6 +113,60 @@ public class BukkitWorld extends LocalWorld {
return world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getData(); return world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getData();
} }
/**
* Regenerate an area.
*
* @param region
* @param editSession
* @return
*/
@Override
public boolean regenerate(Region region, EditSession editSession) {
BaseBlock[] history = new BaseBlock[16 * 16 * 128];
for (Vector2D chunk : region.getChunks()) {
Vector min = new Vector(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
Vector max = min.add(15, 127, 15);
// First save all the blocks inside
for (int x = 0; x < 16; x++) {
for (int y = 0; y < 128; y++) {
for (int z = 0; z < 16; z++) {
Vector pt = min.add(x, y, z);
int index = y * 16 * 16 + z * 16 + x;
history[index] = editSession.getBlock(pt);
}
}
}
try {
world.regenerateChunk(chunk.getBlockX(), chunk.getBlockZ());
} catch (Throwable t) {
t.printStackTrace();
}
// Then restore
for (int x = 0; x < 16; x++) {
for (int y = 0; y < 128; y++) {
for (int z = 0; z < 16; z++) {
Vector pt = min.add(x, y, z);
int index = y * 16 * 16 + z * 16 + x;
// We have to restore the block if it was outside
if (!region.contains(pt)) {
editSession.smartSetBlock(pt, history[index]);
} else { // Otherwise fool with history
editSession.rememberChange(pt, history[index],
editSession.rawGetBlock(pt));
}
}
}
}
}
return true;
}
/** /**
* Attempts to accurately copy a BaseBlock's extra data to the world. * Attempts to accurately copy a BaseBlock's extra data to the world.
* *

Datei anzeigen

@ -26,6 +26,7 @@ import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.minecraft.util.commands.CommandPermissions; import com.sk89q.minecraft.util.commands.CommandPermissions;
import com.sk89q.worldedit.*; import com.sk89q.worldedit.*;
import com.sk89q.worldedit.data.LegacyChunkStore; import com.sk89q.worldedit.data.LegacyChunkStore;
import com.sk89q.worldedit.regions.Region;
/** /**
* Chunk tools. * Chunk tools.

Datei anzeigen

@ -230,4 +230,21 @@ public class RegionCommands {
dir, count, !args.hasFlag('a')); dir, count, !args.hasFlag('a'));
player.print(affected + " blocks changed. Undo with //undo"); player.print(affected + " blocks changed. Undo with //undo");
} }
@Command(
aliases = {"/regen"},
usage = "",
desc = "Regenerates the contents of the selection",
min = 0,
max = 0
)
@CommandPermissions({"worldedit.regen"})
public static void regenerateChunk(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException {
Region region = session.getSelection(player.getWorld());
player.getWorld().regenerate(region, editSession);
player.print("Region regenerated.");
}
} }