mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-17 14:03:55 +00:00
More file moving.
This commit is contained in:
81
src/main/java/com/sk89q/worldedit/tools/AreaPickaxe.java
Normal file
81
src/main/java/com/sk89q/worldedit/tools/AreaPickaxe.java
Normal file
@ -0,0 +1,81 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.tools;
|
||||
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
|
||||
/**
|
||||
* A super pickaxe mode that will remove blocks in an area.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class AreaPickaxe implements BlockTool {
|
||||
private static final BaseBlock air = new BaseBlock(0);
|
||||
private int range;
|
||||
|
||||
public AreaPickaxe(int range) {
|
||||
this.range = range;
|
||||
}
|
||||
|
||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||
LocalWorld world = clicked.getWorld();
|
||||
int ox = clicked.getBlockX();
|
||||
int oy = clicked.getBlockY();
|
||||
int oz = clicked.getBlockZ();
|
||||
int initialType = world.getBlockType(clicked);
|
||||
|
||||
if (initialType == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (initialType == BlockID.BEDROCK && !player.canDestroyBedrock()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
EditSession editSession =
|
||||
new EditSession(world, session.getBlockChangeLimit());
|
||||
|
||||
try {
|
||||
for (int x = ox - range; x <= ox + range; x++) {
|
||||
for (int y = oy - range; y <= oy + range; y++) {
|
||||
for (int z = oz - range; z <= oz + range; z++) {
|
||||
Vector pos = new Vector(x, y, z);
|
||||
if (world.getBlockType(pos) == initialType) {
|
||||
if (config.superPickaxeManyDrop) {
|
||||
world.simulateBlockMine(pos);
|
||||
}
|
||||
|
||||
editSession.setBlock(pos, air);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.printError("Max blocks change limit reached.");
|
||||
} finally {
|
||||
session.remember(editSession);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
157
src/main/java/com/sk89q/worldedit/tools/BlockDataCyler.java
Normal file
157
src/main/java/com/sk89q/worldedit/tools/BlockDataCyler.java
Normal file
@ -0,0 +1,157 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.tools;
|
||||
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
|
||||
/**
|
||||
* A mode that cycles the data values of supported blocks.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class BlockDataCyler implements DoubleActionBlockTool {
|
||||
|
||||
private boolean handleCycle(ServerInterface server, LocalConfiguration config,
|
||||
LocalPlayer player, LocalSession session, WorldVector clicked, boolean forward) {
|
||||
|
||||
LocalWorld world = clicked.getWorld();
|
||||
|
||||
int type = world.getBlockType(clicked);
|
||||
int data = world.getBlockData(clicked);
|
||||
|
||||
if (config.allowedDataCycleBlocks.size() > 0
|
||||
&& !player.hasPermission("worldedit.override.data-cycler")
|
||||
&& !config.allowedDataCycleBlocks.contains(type)) {
|
||||
player.printError("You are not permitted to cycle the data value of that block.");
|
||||
return true;
|
||||
}
|
||||
|
||||
int increment = forward ? 1 : -1;
|
||||
|
||||
if (type == BlockID.LOG) {
|
||||
data = (data + increment) % 3;
|
||||
} else if (type == BlockID.LEAVES) {
|
||||
data = (data + increment) % 3;
|
||||
} else if (type == BlockID.SAPLING) {
|
||||
int saplingType = data & 0x03;
|
||||
int age = data & 0x0c;
|
||||
data = (saplingType + increment) % 4 | age;
|
||||
} else if (type == BlockID.CACTUS) {
|
||||
data = (data + increment) % 16;
|
||||
} else if (type == BlockID.SOIL) {
|
||||
data = (data + increment) % 9;
|
||||
} else if (type == BlockID.CROPS) {
|
||||
data = (data + increment) % 6;
|
||||
} else if (type == BlockID.MINECART_TRACKS) {
|
||||
if (data >= 6 && data <= 9) {
|
||||
data = (data + increment) % 4 + 6;
|
||||
} else {
|
||||
player.printError("This minecart track orientation is not supported.");
|
||||
return true;
|
||||
}
|
||||
} else if (type == BlockID.WOODEN_STAIRS || type == BlockID.COBBLESTONE_STAIRS) {
|
||||
data = (data + increment) % 4;
|
||||
} else if (type == BlockID.SIGN_POST) {
|
||||
data = (data + increment) % 16;
|
||||
} else if (type == BlockID.WALL_SIGN) {
|
||||
data = ((data + increment) - 2) % 4 + 2;
|
||||
} else if (type == BlockID.STEP) {
|
||||
data = (data + increment) % 3;
|
||||
} else if (type == BlockID.DOUBLE_STEP) {
|
||||
data = (data + increment) % 3;
|
||||
} else if (type == BlockID.FURNACE || type == BlockID.BURNING_FURNACE
|
||||
|| type == BlockID.DISPENSER) {
|
||||
data = (data + increment) % 4 + 2;
|
||||
} else if (type == BlockID.PUMPKIN || type == BlockID.JACKOLANTERN) {
|
||||
data = (data + increment) % 4;
|
||||
} else if (type == BlockID.CLOTH) {
|
||||
if (forward) {
|
||||
data = nextClothColor(data);
|
||||
} else {
|
||||
data = prevClothColor(data);
|
||||
}
|
||||
} else {
|
||||
player.printError("That block's data cannot be cycled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
world.setBlockData(clicked, data);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||
return handleCycle(server, config, player, session, clicked, true);
|
||||
}
|
||||
|
||||
public boolean actSecondary(ServerInterface server,
|
||||
LocalConfiguration config, LocalPlayer player,
|
||||
LocalSession session, WorldVector clicked) {
|
||||
return handleCycle(server, config, player, session, clicked, false);
|
||||
}
|
||||
|
||||
private static int nextClothColor(int data) {
|
||||
switch (data) {
|
||||
case 0: return 8;
|
||||
case 8: return 7;
|
||||
case 7: return 15;
|
||||
case 15: return 12;
|
||||
case 12: return 14;
|
||||
case 14: return 1;
|
||||
case 1: return 4;
|
||||
case 4: return 5;
|
||||
case 5: return 13;
|
||||
case 13: return 9;
|
||||
case 9: return 3;
|
||||
case 3: return 11;
|
||||
case 11: return 10;
|
||||
case 10: return 2;
|
||||
case 2: return 6;
|
||||
case 6: return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int prevClothColor(int data) {
|
||||
switch (data) {
|
||||
case 8: return 0;
|
||||
case 7: return 8;
|
||||
case 15: return 7;
|
||||
case 12: return 15;
|
||||
case 14: return 12;
|
||||
case 1: return 14;
|
||||
case 4: return 1;
|
||||
case 5: return 4;
|
||||
case 13: return 5;
|
||||
case 9: return 13;
|
||||
case 3: return 9;
|
||||
case 11: return 3;
|
||||
case 10: return 11;
|
||||
case 2: return 10;
|
||||
case 6: return 2;
|
||||
case 0: return 6;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
75
src/main/java/com/sk89q/worldedit/tools/BlockReplacer.java
Normal file
75
src/main/java/com/sk89q/worldedit/tools/BlockReplacer.java
Normal file
@ -0,0 +1,75 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.tools;
|
||||
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.bags.BlockBag;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockType;
|
||||
|
||||
/**
|
||||
* A mode that replaces one block.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class BlockReplacer implements DoubleActionBlockTool {
|
||||
private BaseBlock targetBlock;
|
||||
|
||||
public BlockReplacer(BaseBlock targetBlock) {
|
||||
this.targetBlock = targetBlock;
|
||||
}
|
||||
|
||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||
|
||||
BlockBag bag = session.getBlockBag(player);
|
||||
|
||||
LocalWorld world = clicked.getWorld();
|
||||
EditSession editSession = new EditSession(world, -1, bag);
|
||||
|
||||
try {
|
||||
editSession.setBlock(clicked, targetBlock);
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
} finally {
|
||||
if (bag != null) {
|
||||
bag.flushChanges();
|
||||
}
|
||||
session.remember(editSession);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean actSecondary(ServerInterface server,
|
||||
LocalConfiguration config, LocalPlayer player,
|
||||
LocalSession session, WorldVector clicked) {
|
||||
|
||||
LocalWorld world = clicked.getWorld();
|
||||
targetBlock = (new EditSession(world, -1)).getBlock(clicked);
|
||||
BlockType type = BlockType.fromID(targetBlock.getType());
|
||||
|
||||
if (type != null) {
|
||||
player.print("Replacer tool switched to: " + type.getName());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
43
src/main/java/com/sk89q/worldedit/tools/BlockTool.java
Normal file
43
src/main/java/com/sk89q/worldedit/tools/BlockTool.java
Normal file
@ -0,0 +1,43 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.tools;
|
||||
|
||||
import com.sk89q.worldedit.*;
|
||||
|
||||
/**
|
||||
* Represents a tool that uses a block..
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public interface BlockTool extends Tool {
|
||||
/**
|
||||
* Perform the action. Should return true to deny the default
|
||||
* action.
|
||||
*
|
||||
* @param server
|
||||
* @param config
|
||||
* @param player
|
||||
* @param session
|
||||
* @param clicked
|
||||
* @return true to deny
|
||||
*/
|
||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||
LocalPlayer player, LocalSession session, WorldVector clicked);
|
||||
}
|
158
src/main/java/com/sk89q/worldedit/tools/BrushTool.java
Normal file
158
src/main/java/com/sk89q/worldedit/tools/BrushTool.java
Normal file
@ -0,0 +1,158 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.tools;
|
||||
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.bags.BlockBag;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.masks.Mask;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
import com.sk89q.worldedit.patterns.SingleBlockPattern;
|
||||
import com.sk89q.worldedit.tools.brushes.Brush;
|
||||
import com.sk89q.worldedit.tools.brushes.SphereBrush;
|
||||
|
||||
/**
|
||||
* Builds a shape at the place being looked at.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class BrushTool implements TraceTool {
|
||||
private Mask mask = null;
|
||||
private Brush brush = new SphereBrush();
|
||||
private Pattern material = new SingleBlockPattern(new BaseBlock(BlockID.COBBLESTONE));
|
||||
private int size = 1;
|
||||
|
||||
/**
|
||||
* Get the filter.
|
||||
*
|
||||
* @return the filter
|
||||
*/
|
||||
public Mask getMask() {
|
||||
return mask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the block filter used for identifying blocks to replace.
|
||||
*
|
||||
* @param filter the filter to set
|
||||
*/
|
||||
public void setMask(Mask filter) {
|
||||
this.mask = filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the brush.
|
||||
*
|
||||
* @param brush
|
||||
*/
|
||||
public void setBrush(Brush brush) {
|
||||
this.brush = brush;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current brush.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Brush getBrush() {
|
||||
return brush;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the material.
|
||||
*
|
||||
* @param material
|
||||
*/
|
||||
public void setFill(Pattern material) {
|
||||
this.material = material;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the material.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Pattern getMaterial() {
|
||||
return material;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the set brush size.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the set brush size.
|
||||
*
|
||||
* @param size
|
||||
*/
|
||||
public void setSize(int size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform the action. Should return true to deny the default
|
||||
* action.
|
||||
*
|
||||
* @param player
|
||||
* @param session
|
||||
* @return true to deny
|
||||
*/
|
||||
public boolean act(ServerInterface server, LocalConfiguration config,
|
||||
LocalPlayer player, LocalSession session) {
|
||||
WorldVector target = player.getBlockTrace(500);
|
||||
|
||||
if (target == null) {
|
||||
player.printError("No block in sight!");
|
||||
return true;
|
||||
}
|
||||
|
||||
BlockBag bag = session.getBlockBag(player);
|
||||
|
||||
EditSession editSession;
|
||||
|
||||
if (mask == null) {
|
||||
editSession = new EditSession(target.getWorld(),
|
||||
session.getBlockChangeLimit(), bag);
|
||||
} else {
|
||||
editSession = new ReplacingEditSession(target.getWorld(),
|
||||
session.getBlockChangeLimit(), bag, mask);
|
||||
}
|
||||
|
||||
try {
|
||||
brush.build(editSession, target, material, size);
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.printError("Max blocks change limit reached.");
|
||||
} finally {
|
||||
if (bag != null) {
|
||||
bag.flushChanges();
|
||||
}
|
||||
session.remember(editSession);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.tools;
|
||||
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.ServerInterface;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
|
||||
/**
|
||||
* Represents a block tool that also has a secondary/primary function.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public interface DoubleActionBlockTool extends BlockTool {
|
||||
/**
|
||||
* Perform the secondary action. Should return true to deny the default
|
||||
* action.
|
||||
*
|
||||
* @param server
|
||||
* @param config
|
||||
* @param player
|
||||
* @param session
|
||||
* @param clicked
|
||||
* @return true to deny
|
||||
*/
|
||||
public boolean actSecondary(ServerInterface server, LocalConfiguration config,
|
||||
LocalPlayer player, LocalSession session, WorldVector clicked);
|
||||
}
|
59
src/main/java/com/sk89q/worldedit/tools/QueryTool.java
Normal file
59
src/main/java/com/sk89q/worldedit/tools/QueryTool.java
Normal file
@ -0,0 +1,59 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.tools;
|
||||
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.*;
|
||||
|
||||
/**
|
||||
* Plants a tree.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class QueryTool implements BlockTool {
|
||||
|
||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||
|
||||
LocalWorld world = clicked.getWorld();
|
||||
BaseBlock block = (new EditSession(world, 0)).rawGetBlock(clicked);
|
||||
|
||||
player.print("\u00A79@" + clicked + ": " + "\u00A7e"
|
||||
+ "#" + block.getType() + "\u00A77" + " ("
|
||||
+ BlockType.fromID(block.getType()).getName() + ") "
|
||||
+ "\u00A7f"
|
||||
+ "[" + block.getData() + "]" + " (" + world.getBlockLightLevel(clicked) + "/" + world.getBlockLightLevel(clicked.add(0, 1, 0)) + ")");
|
||||
|
||||
if (block instanceof MobSpawnerBlock) {
|
||||
player.printRaw("\u00A7e" + "Mob Type: "
|
||||
+ ((MobSpawnerBlock)block).getMobType());
|
||||
} else if (block instanceof NoteBlock) {
|
||||
player.printRaw("\u00A7e" + "Note block: "
|
||||
+ ((NoteBlock)block).getNote());
|
||||
} else if (block.getType() == BlockID.CLOTH) {
|
||||
// Should never be null
|
||||
player.printRaw("\u00A7e" + "Color: "
|
||||
+ ClothColor.fromID(block.getData()).getName());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
119
src/main/java/com/sk89q/worldedit/tools/RecursivePickaxe.java
Normal file
119
src/main/java/com/sk89q/worldedit/tools/RecursivePickaxe.java
Normal file
@ -0,0 +1,119 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.tools;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
|
||||
/**
|
||||
* A pickaxe mode that recursively finds adjacent blocks within range of
|
||||
* an initial block and of the same type.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class RecursivePickaxe implements BlockTool {
|
||||
private static final BaseBlock air = new BaseBlock(0);
|
||||
private int range;
|
||||
|
||||
public RecursivePickaxe(int range) {
|
||||
this.range = range;
|
||||
}
|
||||
|
||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||
LocalWorld world = clicked.getWorld();
|
||||
|
||||
int initialType = world.getBlockType(clicked);
|
||||
|
||||
if (initialType == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (initialType == BlockID.BEDROCK && !player.canDestroyBedrock()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
EditSession editSession =
|
||||
new EditSession(world, session.getBlockChangeLimit());
|
||||
|
||||
try {
|
||||
recurse(server, editSession, world, clicked.toBlockVector(),
|
||||
clicked, range, initialType, new HashSet<BlockVector>(),
|
||||
config.superPickaxeManyDrop);
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.printError("Max blocks change limit reached.");
|
||||
} finally {
|
||||
session.remember(editSession);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method.
|
||||
*
|
||||
* @param server
|
||||
* @param superPickaxeManyDrop
|
||||
* @param world
|
||||
* @param pos
|
||||
* @param origin
|
||||
* @param size
|
||||
* @param initialType
|
||||
* @param visited
|
||||
*/
|
||||
private void recurse(ServerInterface server, EditSession editSession,
|
||||
LocalWorld world, BlockVector pos,
|
||||
Vector origin, int size, int initialType,
|
||||
Set<BlockVector> visited, boolean drop)
|
||||
throws MaxChangedBlocksException {
|
||||
|
||||
if (origin.distance(pos) > size || visited.contains(pos)) {
|
||||
return;
|
||||
}
|
||||
|
||||
visited.add(pos);
|
||||
|
||||
if (editSession.getBlock(pos).getType() == initialType) {
|
||||
if (drop) {
|
||||
world.simulateBlockMine(pos);
|
||||
}
|
||||
editSession.setBlock(pos, air);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
recurse(server, editSession, world, pos.add(1, 0, 0).toBlockVector(),
|
||||
origin, size, initialType, visited, drop);
|
||||
recurse(server, editSession, world, pos.add(-1, 0, 0).toBlockVector(),
|
||||
origin, size, initialType, visited, drop);
|
||||
recurse(server, editSession, world, pos.add(0, 0, 1).toBlockVector(),
|
||||
origin, size, initialType, visited, drop);
|
||||
recurse(server, editSession, world, pos.add(0, 0, -1).toBlockVector(),
|
||||
origin, size, initialType, visited, drop);
|
||||
recurse(server, editSession, world, pos.add(0, 1, 0).toBlockVector(),
|
||||
origin, size, initialType, visited, drop);
|
||||
recurse(server, editSession, world, pos.add(0, -1, 0).toBlockVector(),
|
||||
origin, size, initialType, visited, drop);
|
||||
}
|
||||
|
||||
}
|
52
src/main/java/com/sk89q/worldedit/tools/SinglePickaxe.java
Normal file
52
src/main/java/com/sk89q/worldedit/tools/SinglePickaxe.java
Normal file
@ -0,0 +1,52 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.tools;
|
||||
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
|
||||
/**
|
||||
* A super pickaxe mode that removes one block.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class SinglePickaxe implements BlockTool {
|
||||
|
||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||
LocalWorld world = clicked.getWorld();
|
||||
|
||||
if (world.getBlockType(clicked) == BlockID.BEDROCK
|
||||
&& !player.canDestroyBedrock()) {
|
||||
return true;
|
||||
} else if (world.getBlockType(clicked) == BlockID.TNT) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (config.superPickaxeDrop) {
|
||||
world.simulateBlockMine(clicked);
|
||||
}
|
||||
|
||||
world.setBlockType(clicked, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
29
src/main/java/com/sk89q/worldedit/tools/Tool.java
Normal file
29
src/main/java/com/sk89q/worldedit/tools/Tool.java
Normal file
@ -0,0 +1,29 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.tools;
|
||||
|
||||
/**
|
||||
* Represents a tool. This interface alone defines nothing. A tool also
|
||||
* has to implement <code>BlockTool</code> or <code>TraceTool</code>.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public abstract interface Tool {
|
||||
}
|
45
src/main/java/com/sk89q/worldedit/tools/TraceTool.java
Normal file
45
src/main/java/com/sk89q/worldedit/tools/TraceTool.java
Normal file
@ -0,0 +1,45 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.tools;
|
||||
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.ServerInterface;
|
||||
|
||||
/**
|
||||
* Represents a tool that does not require a block.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public interface TraceTool extends Tool {
|
||||
/**
|
||||
* Perform the action. Should return true to deny the default
|
||||
* action.
|
||||
*
|
||||
* @param server
|
||||
* @param config
|
||||
* @param player
|
||||
* @param session
|
||||
* @return true to deny
|
||||
*/
|
||||
public boolean act(ServerInterface server, LocalConfiguration config,
|
||||
LocalPlayer player, LocalSession session);
|
||||
}
|
57
src/main/java/com/sk89q/worldedit/tools/TreePlanter.java
Normal file
57
src/main/java/com/sk89q/worldedit/tools/TreePlanter.java
Normal file
@ -0,0 +1,57 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.tools;
|
||||
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
|
||||
/**
|
||||
* Plants a tree.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class TreePlanter implements BlockTool {
|
||||
private TreeGenerator gen;
|
||||
|
||||
public TreePlanter(TreeGenerator gen) {
|
||||
this.gen = gen;
|
||||
}
|
||||
|
||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||
|
||||
LocalWorld world = clicked.getWorld();
|
||||
EditSession editSession =
|
||||
new EditSession(world, session.getBlockChangeLimit());
|
||||
|
||||
try {
|
||||
if (!gen.generate(editSession, clicked.add(0, 1, 0))) {
|
||||
player.printError("A tree can't go there.");
|
||||
}
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
player.printError("Max. blocks changed reached.");
|
||||
} finally {
|
||||
session.remember(editSession);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
44
src/main/java/com/sk89q/worldedit/tools/brushes/Brush.java
Normal file
44
src/main/java/com/sk89q/worldedit/tools/brushes/Brush.java
Normal file
@ -0,0 +1,44 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.tools.brushes;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
|
||||
/**
|
||||
* Represents a brush.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public interface Brush {
|
||||
/**
|
||||
* Build the object.
|
||||
*
|
||||
* @param editSession
|
||||
* @param pos
|
||||
* @param mat
|
||||
* @param size
|
||||
* @throws MaxChangedBlocksException
|
||||
*/
|
||||
public void build(EditSession editSession, Vector pos, Pattern mat, int size)
|
||||
throws MaxChangedBlocksException;
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.tools.brushes;
|
||||
|
||||
import com.sk89q.worldedit.CuboidClipboard;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
|
||||
public class ClipboardBrush implements Brush {
|
||||
private CuboidClipboard clipboard;
|
||||
private boolean noAir;
|
||||
|
||||
public ClipboardBrush(CuboidClipboard clipboard, boolean noAir) {
|
||||
this.clipboard = clipboard;
|
||||
this.noAir = noAir;
|
||||
}
|
||||
|
||||
public void build(EditSession editSession, Vector pos, Pattern mat, int size)
|
||||
throws MaxChangedBlocksException {
|
||||
clipboard.place(editSession,
|
||||
pos.subtract(clipboard.getSize().divide(2)), noAir);
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.tools.brushes;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
|
||||
public class CylinderBrush implements Brush {
|
||||
private int height;
|
||||
|
||||
public CylinderBrush(int height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public void build(EditSession editSession, Vector pos, Pattern mat, int size)
|
||||
throws MaxChangedBlocksException {
|
||||
editSession.makeCylinder(pos, mat, size, height);
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.tools.brushes;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
|
||||
public class HollowCylinderBrush implements Brush {
|
||||
private int height;
|
||||
|
||||
public HollowCylinderBrush(int height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public void build(EditSession editSession, Vector pos, Pattern mat, int size)
|
||||
throws MaxChangedBlocksException {
|
||||
editSession.makeHollowCylinder(pos, mat, size, height);
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.tools.brushes;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
|
||||
public class HollowSphereBrush implements Brush {
|
||||
public HollowSphereBrush() {
|
||||
}
|
||||
|
||||
public void build(EditSession editSession, Vector pos, Pattern mat, int size)
|
||||
throws MaxChangedBlocksException {
|
||||
editSession.makeSphere(pos, mat, size, false);
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.tools.brushes;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.HeightMap;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.filtering.GaussianKernel;
|
||||
import com.sk89q.worldedit.filtering.HeightMapFilter;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
public class SmoothBrush implements Brush {
|
||||
private int iterations;
|
||||
|
||||
public SmoothBrush(int iterations) {
|
||||
this.iterations = iterations;
|
||||
}
|
||||
|
||||
public void build(EditSession editSession, Vector pos, Pattern mat, int size)
|
||||
throws MaxChangedBlocksException {
|
||||
int rad = size;
|
||||
Vector min = pos.subtract(rad, rad, rad);
|
||||
Vector max = pos.add(rad, rad + 10, rad);
|
||||
Region region = new CuboidRegion(min, max);
|
||||
HeightMap heightMap = new HeightMap(editSession, region);
|
||||
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
|
||||
heightMap.applyFilter(filter, iterations);
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.tools.brushes;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
|
||||
public class SphereBrush implements Brush {
|
||||
public SphereBrush() {
|
||||
}
|
||||
|
||||
public void build(EditSession editSession, Vector pos, Pattern mat, int size)
|
||||
throws MaxChangedBlocksException {
|
||||
editSession.makeSphere(pos, mat, size, true);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user