Removed more deprecated code

This commit is contained in:
Matthew Miller 2018-06-19 17:03:09 +10:00
parent 416480c16d
commit 66d70f00e7
19 changed files with 107 additions and 296 deletions

View File

@ -66,11 +66,6 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
this.userFile = userFile; this.userFile = userFile;
} }
@Deprecated
public static boolean filesExists() {
return (new File("perms_groups.txt")).exists() && (new File("perms_users.txt")).exists();
}
public Map<String, Set<String>> loadGroupPermissions() { public Map<String, Set<String>> loadGroupPermissions() {
Map<String, Set<String>> userGroupPermissions = new HashMap<String, Set<String>>(); Map<String, Set<String>> userGroupPermissions = new HashMap<String, Set<String>>();

View File

@ -35,12 +35,12 @@ import com.sk89q.worldedit.blocks.type.BlockType;
import com.sk89q.worldedit.blocks.type.BlockTypes; import com.sk89q.worldedit.blocks.type.BlockTypes;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.history.change.BlockChange;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.world.AbstractWorld; import com.sk89q.worldedit.world.AbstractWorld;
import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.biome.BaseBiome;
import com.sk89q.worldedit.world.registry.BundledBlockData; import com.sk89q.worldedit.world.registry.BundledBlockData;
import com.sk89q.worldedit.world.registry.Registries;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.TreeType; import org.bukkit.TreeType;
import org.bukkit.World; import org.bukkit.World;
@ -159,7 +159,7 @@ public class BukkitWorld extends AbstractWorld {
@Override @Override
public boolean regenerate(Region region, EditSession editSession) { public boolean regenerate(Region region, EditSession editSession) {
BaseBlock[] history = new BaseBlock[16 * 16 * (getMaxY() + 1)]; BlockStateHolder[] history = new BlockStateHolder[16 * 16 * (getMaxY() + 1)];
for (Vector2D chunk : region.getChunks()) { for (Vector2D chunk : region.getChunks()) {
Vector min = new Vector(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16); Vector min = new Vector(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
@ -192,8 +192,7 @@ public class BukkitWorld extends AbstractWorld {
if (!region.contains(pt)) { if (!region.contains(pt)) {
editSession.smartSetBlock(pt, history[index]); editSession.smartSetBlock(pt, history[index]);
} else { // Otherwise fool with history } else { // Otherwise fool with history
editSession.rememberChange(pt, history[index], editSession.getChangeSet().add(new BlockChange(pt.toBlockVector(), history[index], editSession.getFullBlock(pt)));
editSession.getFullBlock(pt));
} }
} }
} }

View File

@ -66,7 +66,6 @@ public class LazyBlock extends BaseBlock {
* @param extent the extent to later load the full block data from * @param extent the extent to later load the full block data from
* @param position the position to later load the full block data from * @param position the position to later load the full block data from
*/ */
@Deprecated
public LazyBlock(BlockState state, Extent extent, Vector position) { public LazyBlock(BlockState state, Extent extent, Vector position) {
super(state); super(state);
checkNotNull(extent); checkNotNull(extent);

View File

@ -1,122 +0,0 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser 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 Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit.blocks;
import com.sk89q.jnbt.ByteTag;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag;
import java.util.HashMap;
import java.util.Map;
/**
* A note block.
*/
public class NoteBlock extends BaseBlock implements TileEntityBlock {
private byte note;
/**
* Construct the note block with a data value of 0.
*/
public NoteBlock() {
super(BlockID.NOTE_BLOCK);
this.note = 0;
}
/**
* Construct the note block with a given data value.
*
* @param data data value
*/
public NoteBlock(int data) {
super(BlockID.NOTE_BLOCK, data);
this.note = 0;
}
/**
* Construct the note block with a given data value and note.
*
* @param data data value
* @param note note
*/
public NoteBlock(int data, byte note) {
super(BlockID.NOTE_BLOCK, data);
this.note = note;
}
/**
* Get the note.
*
* @return the note
*/
public byte getNote() {
return note;
}
/**
* Set the note.
*
* @param note the note to set
*/
public void setNote(byte note) {
this.note = note;
}
@Override
public boolean hasNbtData() {
return true;
}
@Override
public String getNbtId() {
return "Music";
}
@Override
public CompoundTag getNbtData() {
Map<String, Tag> values = new HashMap<String, Tag>();
values.put("note", new ByteTag(note));
return new CompoundTag(values);
}
@Override
public void setNbtData(CompoundTag rootTag) {
if (rootTag == null) {
return;
}
Map<String, Tag> values = rootTag.getValue();
Tag t;
t = values.get("id");
if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Music")) {
throw new RuntimeException("'Music' tile entity expected");
}
t = values.get("note");
if (t instanceof ByteTag) {
note = ((ByteTag) t).getValue();
}
}
}

View File

@ -19,8 +19,13 @@
package com.sk89q.worldedit; package com.sk89q.worldedit;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.blocks.BlockType; import com.sk89q.worldedit.blocks.BlockType;
import com.sk89q.worldedit.blocks.LazyBlock; import com.sk89q.worldedit.blocks.LazyBlock;
import com.sk89q.worldedit.blocks.type.BlockCategories; import com.sk89q.worldedit.blocks.type.BlockCategories;
@ -51,14 +56,30 @@ import com.sk89q.worldedit.function.block.BlockReplace;
import com.sk89q.worldedit.function.block.Counter; import com.sk89q.worldedit.function.block.Counter;
import com.sk89q.worldedit.function.block.Naturalizer; import com.sk89q.worldedit.function.block.Naturalizer;
import com.sk89q.worldedit.function.generator.GardenPatchGenerator; import com.sk89q.worldedit.function.generator.GardenPatchGenerator;
import com.sk89q.worldedit.function.mask.*; import com.sk89q.worldedit.function.mask.BlockMask;
import com.sk89q.worldedit.function.operation.*; import com.sk89q.worldedit.function.mask.BoundedHeightMask;
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
import com.sk89q.worldedit.function.mask.FuzzyBlockMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.MaskIntersection;
import com.sk89q.worldedit.function.mask.MaskUnion;
import com.sk89q.worldedit.function.mask.Masks;
import com.sk89q.worldedit.function.mask.NoiseFilter2D;
import com.sk89q.worldedit.function.mask.RegionMask;
import com.sk89q.worldedit.function.operation.ChangeSetExecutor;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.OperationQueue;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.pattern.BlockPattern; import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.util.RegionOffset; import com.sk89q.worldedit.function.util.RegionOffset;
import com.sk89q.worldedit.function.visitor.*; import com.sk89q.worldedit.function.visitor.DownwardVisitor;
import com.sk89q.worldedit.function.visitor.LayerVisitor;
import com.sk89q.worldedit.function.visitor.NonRisingVisitor;
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
import com.sk89q.worldedit.function.visitor.RegionVisitor;
import com.sk89q.worldedit.history.UndoContext; import com.sk89q.worldedit.history.UndoContext;
import com.sk89q.worldedit.history.change.BlockChange;
import com.sk89q.worldedit.history.changeset.BlockOptimizedHistory; import com.sk89q.worldedit.history.changeset.BlockOptimizedHistory;
import com.sk89q.worldedit.history.changeset.ChangeSet; import com.sk89q.worldedit.history.changeset.ChangeSet;
import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.Expression;
@ -70,26 +91,36 @@ import com.sk89q.worldedit.math.interpolation.KochanekBartelsInterpolation;
import com.sk89q.worldedit.math.interpolation.Node; import com.sk89q.worldedit.math.interpolation.Node;
import com.sk89q.worldedit.math.noise.RandomNoise; import com.sk89q.worldedit.math.noise.RandomNoise;
import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.regions.*; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.EllipsoidRegion;
import com.sk89q.worldedit.regions.FlatRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.Regions;
import com.sk89q.worldedit.regions.shape.ArbitraryBiomeShape; import com.sk89q.worldedit.regions.shape.ArbitraryBiomeShape;
import com.sk89q.worldedit.regions.shape.ArbitraryShape; import com.sk89q.worldedit.regions.shape.ArbitraryShape;
import com.sk89q.worldedit.regions.shape.RegionShape; import com.sk89q.worldedit.regions.shape.RegionShape;
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment; import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
import com.sk89q.worldedit.util.*; import com.sk89q.worldedit.util.Countable;
import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.util.collection.DoubleArrayList; import com.sk89q.worldedit.util.collection.DoubleArrayList;
import com.sk89q.worldedit.util.eventbus.EventBus; import com.sk89q.worldedit.util.eventbus.EventBus;
import com.sk89q.worldedit.world.NullWorld; import com.sk89q.worldedit.world.NullWorld;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.biome.BaseBiome;
import javax.annotation.Nullable; import java.util.ArrayList;
import java.util.*; import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import static com.google.common.base.Preconditions.checkArgument; import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.regions.Regions.*;
/** /**
* An {@link Extent} that handles history, {@link BlockBag}s, change limits, * An {@link Extent} that handles history, {@link BlockBag}s, change limits,
@ -518,19 +549,6 @@ public class EditSession implements Extent {
return bypassNone.createEntity(location, entity); return bypassNone.createEntity(location, entity);
} }
/**
* Insert a contrived block change into the history.
*
* @param position the position
* @param existing the previous block at that position
* @param block the new block
* @deprecated Get the change set with {@link #getChangeSet()} and add the change with that
*/
@Deprecated
public void rememberChange(Vector position, BaseBlock existing, BaseBlock block) {
changeSet.add(new BlockChange(position.toBlockVector(), existing, block));
}
/** /**
* Restores all blocks to their initial state. * Restores all blocks to their initial state.
* *
@ -1115,7 +1133,7 @@ public class EditSession implements Extent {
new RegionMask(new EllipsoidRegion(null, origin, new Vector(radius, radius, radius))), new RegionMask(new EllipsoidRegion(null, origin, new Vector(radius, radius, radius))),
getWorld().createLiquidMask()); getWorld().createLiquidMask());
BlockReplace replace = new BlockReplace(this, new BlockPattern(new BaseBlock(BlockID.AIR))); BlockReplace replace = new BlockReplace(this, new BlockPattern(BlockTypes.AIR.getDefaultState()));
RecursiveVisitor visitor = new RecursiveVisitor(mask, replace); RecursiveVisitor visitor = new RecursiveVisitor(mask, replace);
// Around the origin in a 3x3 block // Around the origin in a 3x3 block
@ -1553,7 +1571,7 @@ public class EditSession implements Extent {
final int oy = position.getBlockY(); final int oy = position.getBlockY();
final int oz = position.getBlockZ(); final int oz = position.getBlockZ();
final BaseBlock grass = new BaseBlock(BlockID.GRASS); final BlockState grass = BlockTypes.GRASS_BLOCK.getDefaultState();
final int ceilRadius = (int) Math.ceil(radius); final int ceilRadius = (int) Math.ceil(radius);
for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) { for (int x = ox - ceilRadius; x <= ox + ceilRadius; ++x) {
@ -1562,35 +1580,21 @@ public class EditSession implements Extent {
continue; continue;
} }
loop: for (int y = world.getMaxY(); y >= 1; --y) { for (int y = world.getMaxY(); y >= 1; --y) {
final Vector pt = new Vector(x, y, z); final Vector pt = new Vector(x, y, z);
final BaseBlock block = getLazyBlock(pt); final BlockState block = getBlock(pt);
final int id = block.getId(); final com.sk89q.worldedit.blocks.type.BlockType id = block.getBlockType();
final int data = block.getData();
switch (id) {
case BlockID.DIRT:
if (onlyNormalDirt && data != 0) {
break loop;
}
if (block.getBlockType() == BlockTypes.DIRT ||
(!onlyNormalDirt && block.getBlockType() == BlockTypes.COARSE_DIRT)) {
if (setBlock(pt, grass)) { if (setBlock(pt, grass)) {
++affected; ++affected;
} }
break loop; break;
} else if (block.getBlockType() == BlockTypes.WATER || block.getBlockType() == BlockTypes.LAVA) {
case BlockID.WATER: break;
case BlockID.STATIONARY_WATER: } else if (!BlockType.canPassThrough(id.getLegacyId())) {
case BlockID.LAVA: break;
case BlockID.STATIONARY_LAVA:
// break on liquids...
break loop;
default:
// ...and all non-passable blocks
if (!BlockType.canPassThrough(id, data)) {
break loop;
}
} }
} }
} }
@ -1632,11 +1636,11 @@ public class EditSession implements Extent {
* @param basePosition a position * @param basePosition a position
* @param size a size * @param size a size
* @param density between 0 and 1, inclusive * @param density between 0 and 1, inclusive
* @param treeGenerator the tree genreator * @param treeType the tree type
* @return number of trees created * @return number of trees created
* @throws MaxChangedBlocksException thrown if too many blocks are changed * @throws MaxChangedBlocksException thrown if too many blocks are changed
*/ */
public int makeForest(Vector basePosition, int size, double density, TreeGenerator treeGenerator) throws MaxChangedBlocksException { public int makeForest(Vector basePosition, int size, double density, TreeGenerator.TreeType treeType) throws MaxChangedBlocksException {
int affected = 0; int affected = 0;
for (int x = basePosition.getBlockX() - size; x <= basePosition.getBlockX() for (int x = basePosition.getBlockX() - size; x <= basePosition.getBlockX()
@ -1656,7 +1660,7 @@ public class EditSession implements Extent {
// Check if we hit the ground // Check if we hit the ground
com.sk89q.worldedit.blocks.type.BlockType t = getBlock(new Vector(x, y, z)).getBlockType(); com.sk89q.worldedit.blocks.type.BlockType t = getBlock(new Vector(x, y, z)).getBlockType();
if (t == BlockTypes.GRASS_BLOCK || t == BlockTypes.DIRT) { if (t == BlockTypes.GRASS_BLOCK || t == BlockTypes.DIRT) {
treeGenerator.generate(this, new Vector(x, y + 1, z)); treeType.generate(this, new Vector(x, y + 1, z));
++affected; ++affected;
break; break;
} else if (t == BlockTypes.SNOW) { } else if (t == BlockTypes.SNOW) {

View File

@ -22,7 +22,7 @@ package com.sk89q.worldedit.blocks;
/** /**
* List of block IDs. * List of block IDs.
* *
* {@Deprecated Please use {@link com.sk89q.worldedit.blocks.type.BlockTypes}} * {@deprecated Please use {@link com.sk89q.worldedit.blocks.type.BlockTypes}}
*/ */
@Deprecated @Deprecated
public final class BlockID { public final class BlockID {

View File

@ -37,7 +37,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Block types. * Block types.
* *
* {@Deprecated Please use {@link com.sk89q.worldedit.blocks.type.BlockType}} * {@deprecated Please use {@link com.sk89q.worldedit.blocks.type.BlockType}}
*/ */
@Deprecated @Deprecated
public enum BlockType { public enum BlockType {

View File

@ -22,7 +22,7 @@ package com.sk89q.worldedit.blocks;
/** /**
* List of item IDs. * List of item IDs.
* *
* {@Deprecated Please use {@link com.sk89q.worldedit.blocks.type.ItemTypes}} * {@deprecated Please use {@link com.sk89q.worldedit.blocks.type.ItemTypes}}
*/ */
@Deprecated @Deprecated
public final class ItemID { public final class ItemID {

View File

@ -197,7 +197,7 @@ public class GenerationCommands {
@Logging(POSITION) @Logging(POSITION)
public void forestGen(Player player, LocalSession session, EditSession editSession, @Optional("10") int size, @Optional("tree") TreeType type, @Optional("5") double density) throws WorldEditException { public void forestGen(Player player, LocalSession session, EditSession editSession, @Optional("10") int size, @Optional("tree") TreeType type, @Optional("5") double density) throws WorldEditException {
density = density / 100; density = density / 100;
int affected = editSession.makeForest(session.getPlacementPosition(player), size, density, new TreeGenerator(type)); int affected = editSession.makeForest(session.getPlacementPosition(player), size, density, type);
player.print(affected + " trees created."); player.print(affected + " trees created.");
} }

View File

@ -437,7 +437,7 @@ public class RegionCommands {
public void forest(Player player, EditSession editSession, @Selection Region region, @Optional("tree") TreeType type, public void forest(Player player, EditSession editSession, @Selection Region region, @Optional("tree") TreeType type,
@Optional("5") @Range(min = 0, max = 100) double density) throws WorldEditException { @Optional("5") @Range(min = 0, max = 100) double density) throws WorldEditException {
density = density / 100; density = density / 100;
ForestGenerator generator = new ForestGenerator(editSession, new TreeGenerator(type)); ForestGenerator generator = new ForestGenerator(editSession, type);
GroundFunction ground = new GroundFunction(new ExistingBlockMask(editSession), generator); GroundFunction ground = new GroundFunction(new ExistingBlockMask(editSession), generator);
LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground); LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground);
visitor.setMask(new NoiseFilter2D(new RandomNoise(), density)); visitor.setMask(new NoiseFilter2D(new RandomNoise(), density));

View File

@ -89,7 +89,7 @@ public class ToolCommands {
} }
BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND); BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND);
session.setTool(itemStack.getType(), new TreePlanter(new TreeGenerator(type))); session.setTool(itemStack.getType(), new TreePlanter(type));
player.print("Tree tool bound to " + itemStack.getType().getName() + "."); player.print("Tree tool bound to " + itemStack.getType().getName() + ".");
} }

View File

@ -94,7 +94,7 @@ public class TreeGeneratorParser implements CommandExecutor<Contextual<ForestGen
@Override @Override
public ForestGenerator createFromContext(EditContext input) { public ForestGenerator createFromContext(EditContext input) {
return new ForestGenerator((EditSession) input.getDestination(), new TreeGenerator(type)); return new ForestGenerator((EditSession) input.getDestination(), type);
} }
@Override @Override

View File

@ -24,8 +24,9 @@ import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BlockID; import com.sk89q.worldedit.blocks.type.BlockCategories;
import com.sk89q.worldedit.blocks.type.BlockState; import com.sk89q.worldedit.blocks.type.BlockState;
import com.sk89q.worldedit.blocks.type.BlockType;
import com.sk89q.worldedit.blocks.type.BlockTypes; import com.sk89q.worldedit.blocks.type.BlockTypes;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
@ -55,6 +56,15 @@ public class FloatingTreeRemover implements BlockTool {
return player.hasPermission("worldedit.tool.deltree"); return player.hasPermission("worldedit.tool.deltree");
} }
private boolean isTreeBlock(BlockType type) {
return BlockCategories.LEAVES.contains(type)
|| BlockCategories.LOGS.contains(type)
|| type == BlockTypes.RED_MUSHROOM_BLOCK
|| type == BlockTypes.BROWN_MUSHROOM_BLOCK
|| type == BlockTypes.MUSHROOM_STEM
|| type == BlockTypes.VINE;
}
@Override @Override
public boolean actPrimary(Platform server, LocalConfiguration config, public boolean actPrimary(Platform server, LocalConfiguration config,
Player player, LocalSession session, Location clicked) { Player player, LocalSession session, Location clicked) {
@ -62,17 +72,7 @@ public class FloatingTreeRemover implements BlockTool {
final World world = (World) clicked.getExtent(); final World world = (World) clicked.getExtent();
final BlockState state = world.getBlock(clicked.toVector()); final BlockState state = world.getBlock(clicked.toVector());
switch (world.getLazyBlock(clicked.toVector()).getId()) { if (!isTreeBlock(state.getBlockType())) {
case BlockID.LOG:
case BlockID.LOG2:
case BlockID.LEAVES:
case BlockID.LEAVES2:
case BlockID.BROWN_MUSHROOM_CAP:
case BlockID.RED_MUSHROOM_CAP:
case BlockID.VINE:
break;
default:
player.printError("That's not a tree."); player.printError("That's not a tree.");
return true; return true;
} }
@ -87,15 +87,8 @@ public class FloatingTreeRemover implements BlockTool {
} }
for (Vector blockVector : blockSet) { for (Vector blockVector : blockSet) {
final int typeId = editSession.getBlock(blockVector).getBlockType().getLegacyId(); final BlockState otherState = editSession.getBlock(blockVector);
switch (typeId) { if (isTreeBlock(otherState.getBlockType())) {
case BlockID.LOG:
case BlockID.LOG2:
case BlockID.LEAVES:
case BlockID.LEAVES2:
case BlockID.BROWN_MUSHROOM_CAP:
case BlockID.RED_MUSHROOM_CAP:
case BlockID.VINE:
editSession.setBlock(blockVector, AIR); editSession.setBlock(blockVector, AIR);
} }
} }
@ -141,39 +134,24 @@ public class FloatingTreeRemover implements BlockTool {
} }
if (visited.add(next)) { if (visited.add(next)) {
switch (world.getLazyBlock(next).getId()) { BlockState state = world.getBlock(next);
case BlockID.AIR: if (state.getBlockType() == BlockTypes.AIR || state.getBlockType() == BlockTypes.SNOW) {
case BlockID.SNOW:
// we hit air or snow => stop walking this route
continue; continue;
}
case BlockID.LOG: if (isTreeBlock(state.getBlockType())) {
case BlockID.LOG2:
case BlockID.LEAVES:
case BlockID.LEAVES2:
case BlockID.BROWN_MUSHROOM_CAP:
case BlockID.RED_MUSHROOM_CAP:
case BlockID.VINE:
// queue next point
queue.addLast(next); queue.addLast(next);
break; } else {
default:
// we hit something solid - evaluate where we came from // we hit something solid - evaluate where we came from
final int curId = world.getLazyBlock(current).getId(); final BlockType currentType = world.getBlock(current).getBlockType();
if (curId == BlockID.LEAVES || curId == BlockID.LEAVES2 if (!BlockCategories.LEAVES.contains(currentType) && currentType != BlockTypes.VINE) {
|| curId == BlockID.VINE) {
// leaves touching a wall/the ground => stop walking this route
continue;
} else {
// log/shroom touching a wall/the ground => this is not a floating tree, bail out // log/shroom touching a wall/the ground => this is not a floating tree, bail out
return null; return null;
} }
} // switch }
} // if }
} // for }
} // while }
return visited; return visited;
} // bfs }
} }

View File

@ -22,9 +22,7 @@ package com.sk89q.worldedit.command.tool;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.MobSpawnerBlock; import com.sk89q.worldedit.blocks.MobSpawnerBlock;
import com.sk89q.worldedit.blocks.NoteBlock;
import com.sk89q.worldedit.blocks.type.BlockStateHolder; import com.sk89q.worldedit.blocks.type.BlockStateHolder;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
@ -57,9 +55,6 @@ public class QueryTool implements BlockTool {
if (block instanceof MobSpawnerBlock) { if (block instanceof MobSpawnerBlock) {
player.printRaw("\u00A7e" + "Mob Type: " player.printRaw("\u00A7e" + "Mob Type: "
+ ((MobSpawnerBlock) block).getMobType()); + ((MobSpawnerBlock) block).getMobType());
} else if (block instanceof NoteBlock) {
player.printRaw("\u00A7e" + "Note block: "
+ ((NoteBlock) block).getNote());
} }
return true; return true;

View File

@ -30,10 +30,10 @@ import com.sk89q.worldedit.util.*;
*/ */
public class TreePlanter implements BlockTool { public class TreePlanter implements BlockTool {
private TreeGenerator gen; private TreeGenerator.TreeType treeType;
public TreePlanter(TreeGenerator gen) { public TreePlanter(TreeGenerator.TreeType treeType) {
this.gen = gen; this.treeType = treeType;
} }
@Override @Override
@ -50,7 +50,7 @@ public class TreePlanter implements BlockTool {
boolean successful = false; boolean successful = false;
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
if (gen.generate(editSession, clicked.toVector().add(0, 1, 0))) { if (treeType.generate(editSession, clicked.toVector().add(0, 1, 0))) {
successful = true; successful = true;
break; break;
} }

View File

@ -22,7 +22,6 @@ package com.sk89q.worldedit.function.generator;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.type.BlockStateHolder; import com.sk89q.worldedit.blocks.type.BlockStateHolder;
import com.sk89q.worldedit.blocks.type.BlockType; import com.sk89q.worldedit.blocks.type.BlockType;
import com.sk89q.worldedit.blocks.type.BlockTypes; import com.sk89q.worldedit.blocks.type.BlockTypes;
@ -35,18 +34,18 @@ import com.sk89q.worldedit.util.TreeGenerator;
*/ */
public class ForestGenerator implements RegionFunction { public class ForestGenerator implements RegionFunction {
private final TreeGenerator treeGenerator; private final TreeGenerator.TreeType treeType;
private final EditSession editSession; private final EditSession editSession;
/** /**
* Create a new instance. * Create a new instance.
* *
* @param editSession the edit session * @param editSession the edit session
* @param treeGenerator a tree generator * @param treeType a tree generator
*/ */
public ForestGenerator(EditSession editSession, TreeGenerator treeGenerator) { public ForestGenerator(EditSession editSession, TreeGenerator.TreeType treeType) {
this.editSession = editSession; this.editSession = editSession;
this.treeGenerator = treeGenerator; this.treeType = treeType;
} }
@Override @Override
@ -55,11 +54,11 @@ public class ForestGenerator implements RegionFunction {
BlockType t = block.getBlockType(); BlockType t = block.getBlockType();
if (t == BlockTypes.GRASS || t == BlockTypes.DIRT) { if (t == BlockTypes.GRASS || t == BlockTypes.DIRT) {
treeGenerator.generate(editSession, position.add(0, 1, 0)); treeType.generate(editSession, position.add(0, 1, 0));
return true; return true;
} else if (t == BlockTypes.TALL_GRASS || t == BlockTypes.DEAD_BUSH || t == BlockTypes.POPPY || t == BlockTypes.DANDELION) { // TODO: This list needs to be moved } else if (t == BlockTypes.TALL_GRASS || t == BlockTypes.DEAD_BUSH || t == BlockTypes.POPPY || t == BlockTypes.DANDELION) { // TODO: This list needs to be moved
editSession.setBlock(position, BlockTypes.AIR.getDefaultState()); editSession.setBlock(position, BlockTypes.AIR.getDefaultState());
treeGenerator.generate(editSession, position); treeType.generate(editSession, position);
return true; return true;
} else if (t == BlockTypes.SNOW) { } else if (t == BlockTypes.SNOW) {
editSession.setBlock(position, BlockTypes.AIR.getDefaultState()); editSession.setBlock(position, BlockTypes.AIR.getDefaultState());

View File

@ -107,16 +107,6 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
return center.toVector((maxY + minY) / 2); return center.toVector((maxY + minY) / 2);
} }
/**
* Sets the main center point of the region
*
* @deprecated replaced by {@link #setCenter(Vector2D)}
*/
@Deprecated
public void setCenter(Vector center) {
setCenter(center.toVector2D());
}
/** /**
* Sets the main center point of the region * Sets the main center point of the region
* *

View File

@ -171,11 +171,6 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
return minY; return minY;
} }
@Deprecated
public int getMininumY() {
return minY;
}
/** /**
* Set the minimum Y. * Set the minimum Y.
* *

View File

@ -164,32 +164,11 @@ public class TreeGenerator {
} }
} }
private TreeGenerator() {
}
private static final Random RANDOM = new Random(); private static final Random RANDOM = new Random();
private TreeType type;
/**
* Construct the tree generator with a tree type.
*
* @param type the tree type
*/
@Deprecated
public TreeGenerator(TreeType type) {
this.type = type;
}
/**
* Generate a tree.
*
* @param editSession the edit session
* @param position the position to generate the tree at
* @return true if generation was successful
* @throws MaxChangedBlocksException
*/
public boolean generate(EditSession editSession, Vector position) throws MaxChangedBlocksException {
return type.generate(editSession, position);
}
/** /**
* Makes a terrible looking pine tree. * Makes a terrible looking pine tree.
* *