Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-09-07 00:22:51 +02:00
Remove a tonne of code from WorldEdit. This breaks backwards compatibility. More will be removed. Sorry :)
Dieser Commit ist enthalten in:
Ursprung
b292a39765
Commit
c537a2e948
@ -450,12 +450,4 @@ public class BukkitWorld extends LocalWorld {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #setBlock(Vector, BaseBlock, boolean)}
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean setBlock(Vector pt, com.sk89q.worldedit.foundation.Block block, boolean notifyAdjacent) throws WorldEditException {
|
||||
return setBlock(pt, (BaseBlock) block, notifyAdjacent);
|
||||
}
|
||||
}
|
||||
|
@ -1,202 +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.bags;
|
||||
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import com.sk89q.worldedit.blocks.*;
|
||||
|
||||
/**
|
||||
* @deprecated Block bags are currently not a supported feature of WorldEdit
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
|
||||
public abstract class BlockBag {
|
||||
|
||||
/**
|
||||
* Stores a block as if it was mined.
|
||||
*
|
||||
* @param id the ID of the block
|
||||
* @throws BlockBagException thrown on a error
|
||||
* @deprecated Use {@link BlockBag#storeDroppedBlock(int, int)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void storeDroppedBlock(int id) throws BlockBagException {
|
||||
storeDroppedBlock(id, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a block as if it was mined.
|
||||
*
|
||||
* @param id the ID of the block
|
||||
* @param data the data value of the block
|
||||
* @throws BlockBagException thrown on a error
|
||||
*/
|
||||
public void storeDroppedBlock(int id, int data) throws BlockBagException {
|
||||
BaseItem dropped = BlockType.getBlockBagItem(id, data);
|
||||
if (dropped == null) return;
|
||||
if (dropped.getType() == BlockID.AIR) return;
|
||||
|
||||
storeItem(dropped);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a block as if it was placed by hand.
|
||||
*
|
||||
* @param id the ID of the block
|
||||
* @throws BlockBagException
|
||||
* @deprecated Use {@link #fetchPlacedBlock(int,int)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void fetchPlacedBlock(int id) throws BlockBagException {
|
||||
fetchPlacedBlock(id, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a block as if it was placed by hand.
|
||||
*
|
||||
* @param id the ID of the block
|
||||
* @param data the data value of the block
|
||||
* @throws BlockBagException
|
||||
*/
|
||||
public void fetchPlacedBlock(int id, int data) throws BlockBagException {
|
||||
try {
|
||||
// Blocks that can't be fetched...
|
||||
switch (id) {
|
||||
case BlockID.BEDROCK:
|
||||
case BlockID.GOLD_ORE:
|
||||
case BlockID.IRON_ORE:
|
||||
case BlockID.COAL_ORE:
|
||||
case BlockID.DIAMOND_ORE:
|
||||
case BlockID.TNT:
|
||||
case BlockID.MOB_SPAWNER:
|
||||
case BlockID.CROPS:
|
||||
case BlockID.REDSTONE_ORE:
|
||||
case BlockID.GLOWING_REDSTONE_ORE:
|
||||
case BlockID.SNOW:
|
||||
case BlockID.LIGHTSTONE:
|
||||
case BlockID.PORTAL:
|
||||
throw new UnplaceableBlockException();
|
||||
|
||||
case BlockID.WATER:
|
||||
case BlockID.STATIONARY_WATER:
|
||||
case BlockID.LAVA:
|
||||
case BlockID.STATIONARY_LAVA:
|
||||
// Override liquids
|
||||
return;
|
||||
|
||||
default:
|
||||
fetchBlock(id);
|
||||
break;
|
||||
}
|
||||
|
||||
} catch (OutOfBlocksException e) {
|
||||
BaseItem placed = BlockType.getBlockBagItem(id, data);
|
||||
if (placed == null) throw e; // TODO: check
|
||||
if (placed.getType() == BlockID.AIR) throw e; // TODO: check
|
||||
|
||||
fetchItem(placed);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a block.
|
||||
*
|
||||
* Either this method or fetchItem needs to be overridden
|
||||
*
|
||||
* @param id the ID of the block
|
||||
* @throws BlockBagException
|
||||
*/
|
||||
public void fetchBlock(int id) throws BlockBagException {
|
||||
fetchItem(new BaseItem(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a block.
|
||||
*
|
||||
* Either this method or fetchBlock needs to be overridden
|
||||
*
|
||||
* @param item the item
|
||||
* @throws BlockBagException
|
||||
*/
|
||||
public void fetchItem(BaseItem item) throws BlockBagException {
|
||||
fetchBlock(item.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a block.
|
||||
*
|
||||
* Either this method or storeItem needs to be overridden
|
||||
*
|
||||
* @param id the ID of the block
|
||||
* @throws BlockBagException
|
||||
*/
|
||||
public void storeBlock(int id) throws BlockBagException {
|
||||
storeItem(new BaseItem(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a block.
|
||||
*
|
||||
* Either this method or storeBlock needs to be overridden
|
||||
*
|
||||
* @param item the item
|
||||
* @throws BlockBagException
|
||||
*/
|
||||
public void storeItem(BaseItem item) throws BlockBagException {
|
||||
storeBlock(item.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if a block exists without removing it.
|
||||
*
|
||||
* @param id the ID of the block
|
||||
* @return whether the block exists
|
||||
*/
|
||||
public boolean peekBlock(int id) {
|
||||
try {
|
||||
fetchBlock(id);
|
||||
storeBlock(id);
|
||||
return true;
|
||||
} catch (BlockBagException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush any changes. This is called at the end.
|
||||
*/
|
||||
public abstract void flushChanges();
|
||||
|
||||
/**
|
||||
* Adds a position to be used a source.
|
||||
*
|
||||
* @param position the position of the source
|
||||
*/
|
||||
public abstract void addSourcePosition(WorldVector position);
|
||||
|
||||
/**
|
||||
* Adds a position to be used a source.
|
||||
*
|
||||
* @param position the position of the source
|
||||
*/
|
||||
public abstract void addSingleSourcePosition(WorldVector position);
|
||||
|
||||
}
|
@ -1,29 +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.bags;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Block bags are currently not a supported feature of WorldEdit
|
||||
*/
|
||||
@Deprecated
|
||||
public class BlockBagException extends Exception {
|
||||
|
||||
}
|
@ -1,29 +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.bags;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Block bags are currently not a supported feature of WorldEdit
|
||||
*/
|
||||
@Deprecated
|
||||
public class OutOfBlocksException extends BlockBagException {
|
||||
|
||||
}
|
@ -1,46 +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.bags;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Block bags are currently not a supported feature of WorldEdit
|
||||
*/
|
||||
@Deprecated
|
||||
public class OutOfSpaceException extends BlockBagException {
|
||||
|
||||
private int id;
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param id the type ID
|
||||
*/
|
||||
public OutOfSpaceException(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public int getID() {
|
||||
return id;
|
||||
}
|
||||
}
|
@ -1,29 +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.bags;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Block bags are currently not a supported feature of WorldEdit
|
||||
*/
|
||||
@Deprecated
|
||||
public class UnplaceableBlockException extends BlockBagException {
|
||||
|
||||
}
|
@ -1,111 +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.CompoundTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.jnbt.NBTUtils;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.world.DataException;
|
||||
import com.sk89q.worldedit.world.storage.InvalidFormatException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents a chest block.
|
||||
*/
|
||||
public class ChestBlock extends ContainerBlock {
|
||||
|
||||
/**
|
||||
* Construct an empty chest block with the default orientation (data value).
|
||||
*/
|
||||
public ChestBlock() {
|
||||
super(BlockID.CHEST, 27);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an empty chest block with a custom data value.
|
||||
*
|
||||
* @param data data indicating the position of the chest
|
||||
*/
|
||||
public ChestBlock(int data) {
|
||||
super(BlockID.CHEST, data, 27);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the chest block with a custom data value and a list of items.
|
||||
*
|
||||
* @param data data indicating the position of the chest
|
||||
* @param items array of items
|
||||
*/
|
||||
public ChestBlock(int data, BaseItemStack[] items) {
|
||||
super(BlockID.CHEST, data, 27);
|
||||
setItems(items);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNbtId() {
|
||||
return "Chest";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag getNbtData() {
|
||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
||||
values.put("Items", new ListTag(CompoundTag.class, serializeInventory(getItems())));
|
||||
return new CompoundTag(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNbtData(CompoundTag rootTag) {
|
||||
if (rootTag == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, Tag> values = rootTag.getValue();
|
||||
|
||||
Tag t = values.get("id");
|
||||
if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Chest")) {
|
||||
throw new RuntimeException("'Chest' tile entity expected");
|
||||
}
|
||||
|
||||
List<CompoundTag> items = new ArrayList<CompoundTag>();
|
||||
|
||||
try {
|
||||
for (Tag tag : NBTUtils.getChildTag(values, "Items", ListTag.class).getValue()) {
|
||||
if (!(tag instanceof CompoundTag)) {
|
||||
throw new RuntimeException("CompoundTag expected as child tag of Chest's Items");
|
||||
}
|
||||
|
||||
items.add((CompoundTag) tag);
|
||||
}
|
||||
|
||||
setItems(deserializeInventory(items));
|
||||
} catch (InvalidFormatException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (DataException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,141 +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.ListTag;
|
||||
import com.sk89q.jnbt.NBTUtils;
|
||||
import com.sk89q.jnbt.ShortTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.world.DataException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents a block that stores items.
|
||||
*/
|
||||
public abstract class ContainerBlock extends BaseBlock implements TileEntityBlock {
|
||||
|
||||
private BaseItemStack[] items;
|
||||
|
||||
public ContainerBlock(int type, int inventorySize) {
|
||||
super(type);
|
||||
this.items = new BaseItemStack[inventorySize];
|
||||
}
|
||||
|
||||
public ContainerBlock(int type, int data, int inventorySize) {
|
||||
super(type, data);
|
||||
this.items = new BaseItemStack[inventorySize];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of items.
|
||||
*
|
||||
* @return an array of stored items
|
||||
*/
|
||||
public BaseItemStack[] getItems() {
|
||||
return this.items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the list of items.
|
||||
*
|
||||
* @param items an array of stored items
|
||||
*/
|
||||
public void setItems(BaseItemStack[] items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNbtData() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Map<String, Tag> serializeItem(BaseItemStack item) {
|
||||
Map<String, Tag> data = new HashMap<String, Tag>();
|
||||
data.put("id", new ShortTag((short) item.getType()));
|
||||
data.put("Damage", new ShortTag(item.getData()));
|
||||
data.put("Count", new ByteTag((byte) item.getAmount()));
|
||||
if (!item.getEnchantments().isEmpty()) {
|
||||
List<CompoundTag> enchantmentList = new ArrayList<CompoundTag>();
|
||||
for(Map.Entry<Integer, Integer> entry : item.getEnchantments().entrySet()) {
|
||||
Map<String, Tag> enchantment = new HashMap<String, Tag>();
|
||||
enchantment.put("id", new ShortTag(entry.getKey().shortValue()));
|
||||
enchantment.put("lvl", new ShortTag(entry.getValue().shortValue()));
|
||||
enchantmentList.add(new CompoundTag(enchantment));
|
||||
}
|
||||
|
||||
Map<String, Tag> auxData = new HashMap<String, Tag>();
|
||||
auxData.put("ench", new ListTag(CompoundTag.class, enchantmentList));
|
||||
data.put("tag", new CompoundTag(auxData));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public BaseItemStack deserializeItem(Map<String, Tag> data) throws DataException {
|
||||
short id = NBTUtils.getChildTag(data, "id", ShortTag.class).getValue();
|
||||
short damage = NBTUtils.getChildTag(data, "Damage", ShortTag.class).getValue();
|
||||
byte count = NBTUtils.getChildTag(data, "Count", ByteTag.class).getValue();
|
||||
|
||||
BaseItemStack stack = new BaseItemStack(id, count, damage);
|
||||
|
||||
if (data.containsKey("tag")) {
|
||||
Map<String, Tag> auxData = NBTUtils.getChildTag(data, "tag", CompoundTag.class).getValue();
|
||||
ListTag ench = (ListTag)auxData.get("ench");
|
||||
for(Tag e : ench.getValue()) {
|
||||
Map<String, Tag> vars = ((CompoundTag) e).getValue();
|
||||
short enchId = NBTUtils.getChildTag(vars, "id", ShortTag.class).getValue();
|
||||
short enchLevel = NBTUtils.getChildTag(vars, "lvl", ShortTag.class).getValue();
|
||||
stack.getEnchantments().put((int) enchId, (int) enchLevel);
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
public BaseItemStack[] deserializeInventory(List<CompoundTag> items) throws DataException {
|
||||
BaseItemStack[] stacks = new BaseItemStack[items.size()];
|
||||
for (CompoundTag tag : items) {
|
||||
Map<String, Tag> item = tag.getValue();
|
||||
BaseItemStack stack = deserializeItem(item);
|
||||
byte slot = NBTUtils.getChildTag(item, "Slot", ByteTag.class).getValue();
|
||||
if (slot >= 0 && slot < stacks.length) {
|
||||
stacks[slot] = stack;
|
||||
}
|
||||
}
|
||||
return stacks;
|
||||
}
|
||||
|
||||
public List<CompoundTag> serializeInventory(BaseItemStack[] items) {
|
||||
List<CompoundTag> tags = new ArrayList<CompoundTag>();
|
||||
for (int i = 0; i < items.length; ++i) {
|
||||
if (items[i] != null) {
|
||||
Map<String, Tag> tagData = serializeItem(items[i]);
|
||||
tagData.put("Slot", new ByteTag((byte) i));
|
||||
tags.add(new CompoundTag(tagData));
|
||||
}
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
||||
}
|
@ -1,107 +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.CompoundTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.jnbt.NBTUtils;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.world.DataException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents dispensers.
|
||||
*/
|
||||
public class DispenserBlock extends ContainerBlock {
|
||||
|
||||
/**
|
||||
* Construct an empty dispenser block.
|
||||
*/
|
||||
public DispenserBlock() {
|
||||
super(BlockID.DISPENSER, 9);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an empty dispenser block.
|
||||
*
|
||||
* @param data data value (orientation)
|
||||
*/
|
||||
public DispenserBlock(int data) {
|
||||
super(BlockID.DISPENSER, data, 9);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a dispenser block with the given orientation and inventory.
|
||||
*
|
||||
* @param data data value (orientation)
|
||||
* @param items array of items in the inventory
|
||||
*/
|
||||
public DispenserBlock(int data, BaseItemStack[] items) {
|
||||
super(BlockID.DISPENSER, data, 9);
|
||||
this.setItems(items);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNbtId() {
|
||||
return "Trap";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag getNbtData() {
|
||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
||||
values.put("Items", new ListTag(CompoundTag.class, serializeInventory(getItems())));
|
||||
return new CompoundTag(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNbtData(CompoundTag rootTag) {
|
||||
try {
|
||||
if (rootTag == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, Tag> values = rootTag.getValue();
|
||||
|
||||
Tag t = values.get("id");
|
||||
if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Trap")) {
|
||||
throw new DataException("'Trap' tile entity expected");
|
||||
}
|
||||
|
||||
List<CompoundTag> items = new ArrayList<CompoundTag>();
|
||||
for (Tag tag : NBTUtils.getChildTag(values, "Items", ListTag.class).getValue()) {
|
||||
if (!(tag instanceof CompoundTag)) {
|
||||
throw new DataException("CompoundTag expected as child tag of Trap Items");
|
||||
}
|
||||
|
||||
items.add((CompoundTag) tag);
|
||||
}
|
||||
|
||||
setItems(deserializeInventory(items));
|
||||
} catch (DataException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,165 +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.CompoundTag;
|
||||
import com.sk89q.jnbt.ListTag;
|
||||
import com.sk89q.jnbt.NBTUtils;
|
||||
import com.sk89q.jnbt.ShortTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.world.DataException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents a furnace block.
|
||||
*/
|
||||
public class FurnaceBlock extends ContainerBlock {
|
||||
|
||||
private short burnTime;
|
||||
private short cookTime;
|
||||
|
||||
/**
|
||||
* Construct an empty furnace block with the default orientation.
|
||||
*
|
||||
* @param type type ID
|
||||
*/
|
||||
public FurnaceBlock(int type) {
|
||||
super(type, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an empty furnace block with a given orientation.
|
||||
*
|
||||
* @param type type ID
|
||||
* @param data orientation
|
||||
*/
|
||||
public FurnaceBlock(int type, int data) {
|
||||
super(type, data, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an furnace block with a given orientation and inventory.
|
||||
*
|
||||
* @param type type ID
|
||||
* @param data orientation
|
||||
* @param items inventory items
|
||||
*/
|
||||
public FurnaceBlock(int type, int data, BaseItemStack[] items) {
|
||||
super(type, data, 2);
|
||||
setItems(items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the burn time.
|
||||
*
|
||||
* @return the burn time
|
||||
*/
|
||||
public short getBurnTime() {
|
||||
return burnTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the burn time.
|
||||
*
|
||||
* @param burnTime the burn time
|
||||
*/
|
||||
public void setBurnTime(short burnTime) {
|
||||
this.burnTime = burnTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cook time.
|
||||
*
|
||||
* @return the cook time
|
||||
*/
|
||||
public short getCookTime() {
|
||||
return cookTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the cook time.
|
||||
*
|
||||
* @param cookTime the cook time to set
|
||||
*/
|
||||
public void setCookTime(short cookTime) {
|
||||
this.cookTime = cookTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNbtId() {
|
||||
return "Furnace";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag getNbtData() {
|
||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
||||
values.put("Items", new ListTag(CompoundTag.class, serializeInventory(getItems())));
|
||||
values.put("BurnTime", new ShortTag(burnTime));
|
||||
values.put("CookTime", new ShortTag(cookTime));
|
||||
return new CompoundTag(values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNbtData(CompoundTag rootTag) {
|
||||
if (rootTag == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Map<String, Tag> values = rootTag.getValue();
|
||||
|
||||
Tag t = values.get("id");
|
||||
if (!(t instanceof StringTag)
|
||||
|| !((StringTag) t).getValue().equals("Furnace")) {
|
||||
throw new RuntimeException("'Furnace' tile entity expected");
|
||||
}
|
||||
|
||||
ListTag items = NBTUtils.getChildTag(values, "Items", ListTag.class);
|
||||
|
||||
List<CompoundTag> compound = new ArrayList<CompoundTag>();
|
||||
|
||||
for (Tag tag : items.getValue()) {
|
||||
if (!(tag instanceof CompoundTag)) {
|
||||
throw new RuntimeException("CompoundTag expected as child tag of Furnace Items");
|
||||
}
|
||||
compound.add((CompoundTag) tag);
|
||||
}
|
||||
setItems(deserializeInventory(compound));
|
||||
|
||||
t = values.get("BurnTime");
|
||||
if (t instanceof ShortTag) {
|
||||
burnTime = ((ShortTag) t).getValue();
|
||||
}
|
||||
|
||||
t = values.get("CookTime");
|
||||
if (t instanceof ShortTag) {
|
||||
cookTime = ((ShortTag) t).getValue();
|
||||
}
|
||||
} catch (DataException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,34 +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.data;
|
||||
|
||||
/**
|
||||
* @deprecated Switch to {@link com.sk89q.worldedit.world.DataException}
|
||||
*/
|
||||
@Deprecated
|
||||
public class DataException extends com.sk89q.worldedit.world.DataException {
|
||||
|
||||
public DataException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public DataException() {
|
||||
}
|
||||
}
|
@ -1,42 +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.foundation;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link BaseBlock}
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class Block {
|
||||
|
||||
public abstract int getId();
|
||||
|
||||
public abstract void setId(int id);
|
||||
|
||||
public abstract int getData();
|
||||
|
||||
public abstract void setData(int data);
|
||||
|
||||
public abstract void setIdAndData(int id, int data);
|
||||
|
||||
public abstract boolean hasWildcardData();
|
||||
|
||||
}
|
@ -1,35 +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.masks;
|
||||
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
|
||||
/**
|
||||
* @deprecated Switch to {@link com.sk89q.worldedit.function.mask.AbstractMask}
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class AbstractMask implements Mask {
|
||||
@Override
|
||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||
}
|
||||
|
||||
}
|
@ -1,73 +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.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link com.sk89q.worldedit.function.mask.BlockMask}
|
||||
*/
|
||||
@Deprecated
|
||||
public class BlockMask extends AbstractMask {
|
||||
|
||||
private final Set<BaseBlock> blocks;
|
||||
|
||||
public BlockMask() {
|
||||
blocks = new HashSet<BaseBlock>();
|
||||
}
|
||||
|
||||
public BlockMask(Set<BaseBlock> types) {
|
||||
this.blocks = types;
|
||||
}
|
||||
|
||||
public BlockMask(BaseBlock... block) {
|
||||
blocks = new HashSet<BaseBlock>();
|
||||
for (BaseBlock b : block) {
|
||||
add(b);
|
||||
}
|
||||
}
|
||||
|
||||
public BlockMask(BaseBlock block) {
|
||||
this();
|
||||
add(block);
|
||||
}
|
||||
|
||||
public void add(BaseBlock block) {
|
||||
blocks.add(block);
|
||||
}
|
||||
|
||||
public void addAll(Collection<BaseBlock> blocks) {
|
||||
blocks.addAll(blocks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector position) {
|
||||
BaseBlock block = editSession.getBlock(position);
|
||||
return blocks.contains(block)
|
||||
|| blocks.contains(new BaseBlock(block.getType()));
|
||||
}
|
||||
|
||||
}
|
@ -1,54 +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.masks;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A filter that matches blocks based on block types.
|
||||
*
|
||||
* @deprecated replaced by {@link #BlockMask}
|
||||
*/
|
||||
@Deprecated
|
||||
public class BlockTypeMask extends BlockMask {
|
||||
|
||||
public BlockTypeMask() {
|
||||
super();
|
||||
}
|
||||
|
||||
public BlockTypeMask(Set<Integer> types) {
|
||||
super();
|
||||
for (int type : types) {
|
||||
add(type);
|
||||
}
|
||||
}
|
||||
|
||||
public BlockTypeMask(int type) {
|
||||
this();
|
||||
add(type);
|
||||
}
|
||||
|
||||
public void add(int type) {
|
||||
add(new BaseBlock(type));
|
||||
}
|
||||
|
||||
}
|
@ -1,84 +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.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @deprecated See {@link MaskIntersection}
|
||||
*/
|
||||
@Deprecated
|
||||
public class CombinedMask extends AbstractMask {
|
||||
private final List<Mask> masks = new ArrayList<Mask>();
|
||||
|
||||
public CombinedMask() {
|
||||
}
|
||||
|
||||
public CombinedMask(Mask mask) {
|
||||
add(mask);
|
||||
}
|
||||
|
||||
public CombinedMask(Mask ...mask) {
|
||||
for (Mask m : mask) {
|
||||
add(m);
|
||||
}
|
||||
}
|
||||
|
||||
public CombinedMask(List<Mask> masks) {
|
||||
this.masks.addAll(masks);
|
||||
}
|
||||
|
||||
public void add(Mask mask) {
|
||||
masks.add(mask);
|
||||
}
|
||||
|
||||
public boolean remove(Mask mask) {
|
||||
return masks.remove(mask);
|
||||
}
|
||||
|
||||
public boolean has(Mask mask) {
|
||||
return masks.contains(mask);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||
for (Mask mask : masks) {
|
||||
mask.prepare(session, player, target);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector position) {
|
||||
for (Mask mask : masks) {
|
||||
if (!mask.matches(editSession, position)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,46 +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.masks;
|
||||
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.session.request.RequestSelection;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link RequestSelection} with {@link com.sk89q.worldedit.function.mask.RegionMask}
|
||||
*/
|
||||
@Deprecated
|
||||
public class DynamicRegionMask extends AbstractMask {
|
||||
private Region region;
|
||||
|
||||
@Override
|
||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||
try {
|
||||
region = session.getSelection(player.getWorld());
|
||||
} catch (IncompleteRegionException exc) {
|
||||
region = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector position) {
|
||||
return region == null || region.contains(position);
|
||||
}
|
||||
}
|
@ -1,35 +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.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
|
||||
/**
|
||||
* @deprecated See {@link com.sk89q.worldedit.function.mask.ExistingBlockMask}
|
||||
*/
|
||||
@Deprecated
|
||||
public class ExistingBlockMask extends AbstractMask {
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector position) {
|
||||
return editSession.getBlockType(position) != BlockID.AIR;
|
||||
}
|
||||
}
|
@ -1,64 +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.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.Blocks;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @deprecated See {@link com.sk89q.worldedit.function.mask.FuzzyBlockMask}
|
||||
*/
|
||||
@Deprecated
|
||||
public class FuzzyBlockMask extends AbstractMask {
|
||||
|
||||
private final Set<BaseBlock> filter;
|
||||
|
||||
/**
|
||||
* Create a new fuzzy block mask.
|
||||
*
|
||||
* @param filter a list of block types to match
|
||||
*/
|
||||
public FuzzyBlockMask(Set<BaseBlock> filter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new fuzzy block mask.
|
||||
*
|
||||
* @param block a list of block types to match
|
||||
*/
|
||||
public FuzzyBlockMask(BaseBlock... block) {
|
||||
Set<BaseBlock> filter = new HashSet<BaseBlock>();
|
||||
Collections.addAll(filter, block);
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector position) {
|
||||
BaseBlock compare = new BaseBlock(editSession.getBlockType(position), editSession.getBlockData(position));
|
||||
return Blocks.containsFuzzy(filter, compare);
|
||||
}
|
||||
}
|
@ -1,49 +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.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A block type mask that only matches blocks that are not in the list.
|
||||
*/
|
||||
@Deprecated
|
||||
public class InvertedBlockTypeMask extends BlockTypeMask {
|
||||
|
||||
public InvertedBlockTypeMask() {
|
||||
}
|
||||
|
||||
public InvertedBlockTypeMask(Set<Integer> types) {
|
||||
super(types);
|
||||
}
|
||||
|
||||
public InvertedBlockTypeMask(int type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector position) {
|
||||
return !super.matches(editSession, position);
|
||||
}
|
||||
|
||||
}
|
@ -1,52 +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.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
|
||||
/**
|
||||
* @deprecated See {@link Masks#negate(com.sk89q.worldedit.function.mask.Mask)}
|
||||
*/
|
||||
@Deprecated
|
||||
public class InvertedMask extends AbstractMask {
|
||||
private final Mask mask;
|
||||
|
||||
public InvertedMask(Mask mask) {
|
||||
this.mask = mask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||
mask.prepare(session, player, target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector position) {
|
||||
return !mask.matches(editSession, position);
|
||||
}
|
||||
|
||||
public Mask getInvertedMask() {
|
||||
return mask;
|
||||
}
|
||||
}
|
@ -1,54 +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.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link com.sk89q.worldedit.function.mask.Mask}
|
||||
*/
|
||||
@Deprecated
|
||||
public interface Mask {
|
||||
|
||||
/**
|
||||
* Called one time before each edit session.
|
||||
*
|
||||
* @param session a session
|
||||
* @param player a player
|
||||
* @param target target of the brush, null if not a brush mask
|
||||
*/
|
||||
void prepare(LocalSession session, LocalPlayer player, Vector target);
|
||||
|
||||
/**
|
||||
* Given a block position, this method returns true if the block at
|
||||
* that position matches the filter. Block information is not provided
|
||||
* as getting a BaseBlock has unneeded overhead in most block querying
|
||||
* situations (enumerating a chest's contents is a waste, for example).
|
||||
*
|
||||
* @param editSession an instance
|
||||
* @param position the position to check
|
||||
* @return true if it matches
|
||||
*/
|
||||
boolean matches(EditSession editSession, Vector position);
|
||||
|
||||
}
|
@ -1,41 +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.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.function.mask.NoiseFilter;
|
||||
|
||||
/**
|
||||
* @deprecated See {@link NoiseFilter}
|
||||
*/
|
||||
@Deprecated
|
||||
public class RandomMask extends AbstractMask {
|
||||
private final double ratio;
|
||||
|
||||
public RandomMask(double ratio) {
|
||||
this.ratio = ratio;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector position) {
|
||||
return Math.random() < ratio;
|
||||
}
|
||||
}
|
@ -1,41 +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.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
/**
|
||||
* @deprecated See {@link com.sk89q.worldedit.function.mask.RegionMask}
|
||||
*/
|
||||
@Deprecated
|
||||
public class RegionMask extends AbstractMask {
|
||||
private final Region region;
|
||||
|
||||
public RegionMask(Region region) {
|
||||
this.region = region.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector position) {
|
||||
return region.contains(position);
|
||||
}
|
||||
}
|
@ -1,35 +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.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BlockType;
|
||||
|
||||
/**
|
||||
* @deprecated See {@link com.sk89q.worldedit.function.mask.SolidBlockMask}
|
||||
*/
|
||||
@Deprecated
|
||||
public class SolidBlockMask extends AbstractMask {
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector position) {
|
||||
return !BlockType.canPassThrough(editSession.getBlockType(position), editSession.getBlockData(position));
|
||||
}
|
||||
}
|
@ -1,76 +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.masks;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.mask.OffsetMask;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link OffsetMask} with {@link MaskIntersection} and {@link Masks#negate(com.sk89q.worldedit.function.mask.Mask)}
|
||||
*/
|
||||
@Deprecated
|
||||
public class UnderOverlayMask extends AbstractMask {
|
||||
private final int yMod;
|
||||
private Mask mask;
|
||||
|
||||
@Deprecated
|
||||
public UnderOverlayMask(Set<Integer> ids, boolean overlay) {
|
||||
this(new BlockTypeMask(ids), overlay);
|
||||
}
|
||||
|
||||
public UnderOverlayMask(Mask mask, boolean overlay) {
|
||||
this.yMod = overlay ? -1 : 1;
|
||||
this.mask = mask;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void addAll(Set<Integer> ids) {
|
||||
if (mask instanceof BlockMask) {
|
||||
final BlockMask blockTypeMask = (BlockMask) mask;
|
||||
for (Integer id : ids) {
|
||||
blockTypeMask.add(new BaseBlock(id));
|
||||
}
|
||||
} else if (mask instanceof ExistingBlockMask) {
|
||||
final BlockMask blockMask = new BlockMask();
|
||||
for (int type : ids) {
|
||||
blockMask.add(new BaseBlock(type));
|
||||
}
|
||||
mask = blockMask;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
||||
mask.prepare(session, player, target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector position) {
|
||||
return !mask.matches(editSession, position) && mask.matches(editSession, position.add(0, yMod, 0));
|
||||
}
|
||||
}
|
@ -1,58 +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.patterns;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed in the future -- there is no replacement
|
||||
*/
|
||||
@Deprecated
|
||||
public class BlockChance {
|
||||
|
||||
private BaseBlock block;
|
||||
private double chance;
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param block the block
|
||||
* @param chance the probability of the block
|
||||
*/
|
||||
public BlockChance(BaseBlock block, double chance) {
|
||||
this.block = block;
|
||||
this.chance = chance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the block
|
||||
*/
|
||||
public BaseBlock getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the chance
|
||||
*/
|
||||
public double getChance() {
|
||||
return chance;
|
||||
}
|
||||
|
||||
}
|
@ -1,57 +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.patterns;
|
||||
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
|
||||
/**
|
||||
* Pattern that repeats the clipboard.
|
||||
*/
|
||||
public class ClipboardPattern implements Pattern {
|
||||
|
||||
private CuboidClipboard clipboard;
|
||||
private Vector size;
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param clipboard the clipboard
|
||||
*/
|
||||
public ClipboardPattern(CuboidClipboard clipboard) {
|
||||
this.clipboard = clipboard;
|
||||
this.size = clipboard.getSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock next(Vector position) {
|
||||
return next(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock next(int x, int y, int z) {
|
||||
int xp = Math.abs(x) % size.getBlockX();
|
||||
int yp = Math.abs(y) % size.getBlockY();
|
||||
int zp = Math.abs(z) % size.getBlockZ();
|
||||
|
||||
return clipboard.getPoint(new Vector(xp, yp, zp));
|
||||
}
|
||||
|
||||
}
|
@ -1,51 +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.patterns;
|
||||
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
|
||||
/**
|
||||
* @deprecated See {@link com.sk89q.worldedit.function.pattern.Pattern}
|
||||
*/
|
||||
@Deprecated
|
||||
public interface Pattern {
|
||||
|
||||
/**
|
||||
* Get a block for a position. This return value of this method does
|
||||
* not have to be consistent for the same position.
|
||||
*
|
||||
* @param position the position where a block is needed
|
||||
* @return a block
|
||||
*/
|
||||
public BaseBlock next(Vector position);
|
||||
|
||||
/**
|
||||
* Get a block for a position. This return value of this method does
|
||||
* not have to be consistent for the same position.
|
||||
*
|
||||
* @param x the X coordinate
|
||||
* @param y the Y coordinate
|
||||
* @param z the Z coordinate
|
||||
* @return a block
|
||||
*/
|
||||
public BaseBlock next(int x, int y, int z);
|
||||
|
||||
}
|
@ -1,82 +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.patterns;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @deprecated See {@link RandomPattern}
|
||||
*/
|
||||
@Deprecated
|
||||
public class RandomFillPattern implements Pattern {
|
||||
|
||||
private static final Random random = new Random();
|
||||
private List<BlockChance> blocks;
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param blocks a list of blocks
|
||||
*/
|
||||
public RandomFillPattern(List<BlockChance> blocks) {
|
||||
double max = 0;
|
||||
|
||||
for (BlockChance block : blocks) {
|
||||
max += block.getChance();
|
||||
}
|
||||
|
||||
List<BlockChance> finalBlocks = new ArrayList<BlockChance>();
|
||||
|
||||
double i = 0;
|
||||
|
||||
for (BlockChance block : blocks) {
|
||||
double v = block.getChance() / max;
|
||||
i += v;
|
||||
finalBlocks.add(new BlockChance(block.getBlock(), i));
|
||||
}
|
||||
|
||||
this.blocks = finalBlocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock next(Vector position) {
|
||||
double r = random.nextDouble();
|
||||
|
||||
for (BlockChance block : blocks) {
|
||||
if (r <= block.getChance()) {
|
||||
return block.getBlock();
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException("ProportionalFillPattern");
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock next(int x, int y, int z) {
|
||||
return next(null);
|
||||
}
|
||||
|
||||
}
|
@ -1,62 +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.patterns;
|
||||
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
|
||||
/**
|
||||
* @deprecated See {@link BlockPattern}
|
||||
*/
|
||||
@Deprecated
|
||||
public class SingleBlockPattern implements Pattern {
|
||||
|
||||
private BaseBlock block;
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param block the block
|
||||
*/
|
||||
public SingleBlockPattern(BaseBlock block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the block.
|
||||
*
|
||||
* @return the block
|
||||
*/
|
||||
public BaseBlock getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock next(Vector position) {
|
||||
return block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock next(int x, int y, int z) {
|
||||
return block;
|
||||
}
|
||||
|
||||
}
|
@ -1,44 +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.regions;
|
||||
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
|
||||
abstract class AbstractLegacyRegionSelector implements RegionSelector {
|
||||
|
||||
@Deprecated
|
||||
public final void explainPrimarySelection(LocalPlayer player, LocalSession session, Vector position) {
|
||||
explainPrimarySelection((Actor) player, session, position);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public final void explainSecondarySelection(LocalPlayer player, LocalSession session, Vector position) {
|
||||
explainSecondarySelection((Actor) player, session, position);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public final void explainRegionAdjust(LocalPlayer player, LocalSession session) {
|
||||
explainRegionAdjust((Actor) player, session);
|
||||
}
|
||||
|
||||
}
|
@ -1,29 +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.regions;
|
||||
|
||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||
|
||||
/**
|
||||
* @deprecated This class only exists as to not break binary compatibility
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class ConvexPolyhedralRegionSelector extends AbstractLegacyRegionSelector implements CUIRegion {
|
||||
}
|
@ -1,29 +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.regions;
|
||||
|
||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||
|
||||
/**
|
||||
* @deprecated This class only exists as to not break binary compatibility
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class CuboidRegionSelector extends AbstractLegacyRegionSelector implements CUIRegion {
|
||||
}
|
@ -1,29 +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.regions;
|
||||
|
||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||
|
||||
/**
|
||||
* @deprecated This class only exists as to not break binary compatibility
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class CylinderRegionSelector extends AbstractLegacyRegionSelector implements CUIRegion {
|
||||
}
|
@ -1,29 +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.regions;
|
||||
|
||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||
|
||||
/**
|
||||
* @deprecated This class only exists as to not break binary compatibility
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class EllipsoidRegionSelector extends AbstractLegacyRegionSelector implements CUIRegion {
|
||||
}
|
@ -1,29 +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.regions;
|
||||
|
||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||
|
||||
/**
|
||||
* @deprecated This class only exists as to not break binary compatibility
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class ExtendingCuboidRegionSelector extends AbstractLegacyRegionSelector implements CUIRegion {
|
||||
}
|
@ -1,37 +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.regions;
|
||||
|
||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||
|
||||
/**
|
||||
* @deprecated This class only exists as to not break binary compatibility
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class Polygonal2DRegionSelector extends AbstractLegacyRegionSelector implements CUIRegion {
|
||||
|
||||
/**
|
||||
* Get the number of points.
|
||||
*
|
||||
* @return the number of points
|
||||
*/
|
||||
public abstract int getPointCount();
|
||||
|
||||
}
|
@ -1,29 +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.regions;
|
||||
|
||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||
|
||||
/**
|
||||
* @deprecated This class only exists as to not break binary compatibility
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class SphereRegionSelector extends AbstractLegacyRegionSelector implements CUIRegion {
|
||||
}
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.BlockType;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
||||
@ -49,7 +50,7 @@ import com.sk89q.worldedit.function.generator.GardenPatchGenerator;
|
||||
import com.sk89q.worldedit.function.mask.*;
|
||||
import com.sk89q.worldedit.function.operation.*;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.util.RegionOffset;
|
||||
import com.sk89q.worldedit.function.visitor.*;
|
||||
import com.sk89q.worldedit.history.UndoContext;
|
||||
@ -65,8 +66,6 @@ import com.sk89q.worldedit.math.interpolation.KochanekBartelsInterpolation;
|
||||
import com.sk89q.worldedit.math.interpolation.Node;
|
||||
import com.sk89q.worldedit.math.noise.RandomNoise;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
import com.sk89q.worldedit.patterns.SingleBlockPattern;
|
||||
import com.sk89q.worldedit.regions.*;
|
||||
import com.sk89q.worldedit.regions.shape.ArbitraryBiomeShape;
|
||||
import com.sk89q.worldedit.regions.shape.ArbitraryShape;
|
||||
@ -96,7 +95,7 @@ import static com.sk89q.worldedit.regions.Regions.*;
|
||||
* {@link Extent}s that are chained together. For example, history is logged
|
||||
* using the {@link ChangeSetExtent}.</p>
|
||||
*/
|
||||
@SuppressWarnings({"FieldCanBeLocal", "deprecation"})
|
||||
@SuppressWarnings({"FieldCanBeLocal"})
|
||||
public class EditSession implements Extent {
|
||||
|
||||
private static final Logger log = Logger.getLogger(EditSession.class.getCanonicalName());
|
||||
@ -131,7 +130,6 @@ public class EditSession implements Extent {
|
||||
private final Extent bypassHistory;
|
||||
private final Extent bypassNone;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private Mask oldMask;
|
||||
|
||||
/**
|
||||
@ -141,7 +139,6 @@ public class EditSession implements Extent {
|
||||
* @param maxBlocks the maximum number of blocks that can be changed, or -1 to use no limit
|
||||
* @deprecated use {@link WorldEdit#getEditSessionFactory()} to create {@link EditSession}s
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
public EditSession(LocalWorld world, int maxBlocks) {
|
||||
this(world, maxBlocks, null);
|
||||
@ -308,21 +305,6 @@ public class EditSession implements Extent {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the mask.
|
||||
*
|
||||
* @param mask the mask
|
||||
* @deprecated Use {@link #setMask(Mask)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setMask(com.sk89q.worldedit.masks.Mask mask) {
|
||||
if (mask == null) {
|
||||
setMask((Mask) null);
|
||||
} else {
|
||||
setMask(Masks.wrap(mask));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link SurvivalModeExtent}.
|
||||
*
|
||||
@ -560,9 +542,8 @@ public class EditSession implements Extent {
|
||||
* @return Whether the block changed -- not entirely dependable
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean setBlock(Vector position, Pattern pattern) throws MaxChangedBlocksException {
|
||||
return setBlock(position, pattern.next(position));
|
||||
return setBlock(position, pattern.apply(position));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -574,7 +555,6 @@ public class EditSession implements Extent {
|
||||
* @return the number of changed blocks
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
private int setBlocks(Set<Vector> vset, Pattern pattern) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
for (Vector v : vset) {
|
||||
@ -593,7 +573,6 @@ public class EditSession implements Extent {
|
||||
* @return whether a block was changed
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean setChanceBlockIfAir(Vector position, BaseBlock block, double probability)
|
||||
throws MaxChangedBlocksException {
|
||||
return Math.random() <= probability && setBlockIfAir(position, block);
|
||||
@ -705,7 +684,7 @@ public class EditSession implements Extent {
|
||||
* @return the number of found blocks
|
||||
*/
|
||||
public int countBlock(Region region, Set<Integer> searchIDs) {
|
||||
Set<BaseBlock> passOn = new HashSet<BaseBlock>();
|
||||
Set<BaseBlock> passOn = new HashSet<>();
|
||||
for (Integer i : searchIDs) {
|
||||
passOn.add(new BaseBlock(i, -1));
|
||||
}
|
||||
@ -739,10 +718,8 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int fillXZ(Vector origin, BaseBlock block, double radius, int depth, boolean recursive)
|
||||
throws MaxChangedBlocksException {
|
||||
return fillXZ(origin, new SingleBlockPattern(block), radius, depth, recursive);
|
||||
public int fillXZ(Vector origin, BaseBlock block, double radius, int depth, boolean recursive) throws MaxChangedBlocksException {
|
||||
return fillXZ(origin, new BlockPattern(block), radius, depth, recursive);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -756,7 +733,6 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int fillXZ(Vector origin, Pattern pattern, double radius, int depth, boolean recursive) throws MaxChangedBlocksException {
|
||||
checkNotNull(origin);
|
||||
checkNotNull(pattern);
|
||||
@ -771,7 +747,7 @@ public class EditSession implements Extent {
|
||||
Masks.negate(new ExistingBlockMask(this)));
|
||||
|
||||
// Want to replace blocks
|
||||
BlockReplace replace = new BlockReplace(this, Patterns.wrap(pattern));
|
||||
BlockReplace replace = new BlockReplace(this, pattern);
|
||||
|
||||
// Pick how we're going to visit blocks
|
||||
RecursiveVisitor visitor;
|
||||
@ -799,7 +775,6 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int removeAbove(Vector position, int apothem, int height) throws MaxChangedBlocksException {
|
||||
checkNotNull(position);
|
||||
checkArgument(apothem >= 1, "apothem >= 1");
|
||||
@ -809,7 +784,7 @@ public class EditSession implements Extent {
|
||||
getWorld(), // Causes clamping of Y range
|
||||
position.add(-apothem + 1, 0, -apothem + 1),
|
||||
position.add(apothem - 1, height - 1, apothem - 1));
|
||||
Pattern pattern = new SingleBlockPattern(new BaseBlock(BlockID.AIR));
|
||||
Pattern pattern = new BlockPattern(new BaseBlock(BlockTypes.AIR));
|
||||
return setBlocks(region, pattern);
|
||||
}
|
||||
|
||||
@ -822,7 +797,6 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int removeBelow(Vector position, int apothem, int height) throws MaxChangedBlocksException {
|
||||
checkNotNull(position);
|
||||
checkArgument(apothem >= 1, "apothem >= 1");
|
||||
@ -832,7 +806,7 @@ public class EditSession implements Extent {
|
||||
getWorld(), // Causes clamping of Y range
|
||||
position.add(-apothem + 1, 0, -apothem + 1),
|
||||
position.add(apothem - 1, -height + 1, apothem - 1));
|
||||
Pattern pattern = new SingleBlockPattern(new BaseBlock(BlockID.AIR));
|
||||
Pattern pattern = new BlockPattern(new BaseBlock(BlockTypes.AIR));
|
||||
return setBlocks(region, pattern);
|
||||
}
|
||||
|
||||
@ -845,7 +819,6 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int removeNear(Vector position, int blockType, int apothem) throws MaxChangedBlocksException {
|
||||
checkNotNull(position);
|
||||
checkArgument(apothem >= 1, "apothem >= 1");
|
||||
@ -856,7 +829,7 @@ public class EditSession implements Extent {
|
||||
getWorld(), // Causes clamping of Y range
|
||||
position.add(adjustment.multiply(-1)),
|
||||
position.add(adjustment));
|
||||
Pattern pattern = new SingleBlockPattern(new BaseBlock(BlockID.AIR));
|
||||
Pattern pattern = new BlockPattern(new BaseBlock(BlockTypes.AIR));
|
||||
return replaceBlocks(region, mask, pattern);
|
||||
}
|
||||
|
||||
@ -868,9 +841,8 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int setBlocks(Region region, BaseBlock block) throws MaxChangedBlocksException {
|
||||
return setBlocks(region, new SingleBlockPattern(block));
|
||||
return setBlocks(region, new BlockPattern(block));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -881,12 +853,11 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||
checkNotNull(region);
|
||||
checkNotNull(pattern);
|
||||
|
||||
BlockReplace replace = new BlockReplace(this, Patterns.wrap(pattern));
|
||||
BlockReplace replace = new BlockReplace(this, pattern);
|
||||
RegionVisitor visitor = new RegionVisitor(region, replace);
|
||||
Operations.completeLegacy(visitor);
|
||||
return visitor.getAffected();
|
||||
@ -897,14 +868,13 @@ public class EditSession implements Extent {
|
||||
* returned by a given pattern.
|
||||
*
|
||||
* @param region the region to replace the blocks within
|
||||
* @param filter a list of block types to match, or null to use {@link com.sk89q.worldedit.masks.ExistingBlockMask}
|
||||
* @param filter a list of block types to match, or null to use {@link com.sk89q.worldedit.function.mask.ExistingBlockMask}
|
||||
* @param replacement the replacement block
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int replaceBlocks(Region region, Set<BaseBlock> filter, BaseBlock replacement) throws MaxChangedBlocksException {
|
||||
return replaceBlocks(region, filter, new SingleBlockPattern(replacement));
|
||||
return replaceBlocks(region, filter, new BlockPattern(replacement));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -912,12 +882,11 @@ public class EditSession implements Extent {
|
||||
* returned by a given pattern.
|
||||
*
|
||||
* @param region the region to replace the blocks within
|
||||
* @param filter a list of block types to match, or null to use {@link com.sk89q.worldedit.masks.ExistingBlockMask}
|
||||
* @param filter a list of block types to match, or null to use {@link com.sk89q.worldedit.function.mask.ExistingBlockMask}
|
||||
* @param pattern the pattern that provides the new blocks
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int replaceBlocks(Region region, Set<BaseBlock> filter, Pattern pattern) throws MaxChangedBlocksException {
|
||||
Mask mask = filter == null ? new ExistingBlockMask(this) : new FuzzyBlockMask(this, filter);
|
||||
return replaceBlocks(region, mask, pattern);
|
||||
@ -933,13 +902,12 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int replaceBlocks(Region region, Mask mask, Pattern pattern) throws MaxChangedBlocksException {
|
||||
checkNotNull(region);
|
||||
checkNotNull(mask);
|
||||
checkNotNull(pattern);
|
||||
|
||||
BlockReplace replace = new BlockReplace(this, Patterns.wrap(pattern));
|
||||
BlockReplace replace = new BlockReplace(this, pattern);
|
||||
RegionMaskingFilter filter = new RegionMaskingFilter(mask, replace);
|
||||
RegionVisitor visitor = new RegionVisitor(region, filter);
|
||||
Operations.completeLegacy(visitor);
|
||||
@ -956,7 +924,6 @@ public class EditSession implements Extent {
|
||||
* @return the number of blocks placed
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int center(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||
checkNotNull(region);
|
||||
checkNotNull(pattern);
|
||||
@ -978,9 +945,8 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int makeCuboidFaces(Region region, BaseBlock block) throws MaxChangedBlocksException {
|
||||
return makeCuboidFaces(region, new SingleBlockPattern(block));
|
||||
return makeCuboidFaces(region, new BlockPattern(block));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -991,7 +957,6 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int makeCuboidFaces(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||
checkNotNull(region);
|
||||
checkNotNull(pattern);
|
||||
@ -1011,7 +976,6 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int makeFaces(final Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||
checkNotNull(region);
|
||||
checkNotNull(pattern);
|
||||
@ -1033,9 +997,8 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int makeCuboidWalls(Region region, BaseBlock block) throws MaxChangedBlocksException {
|
||||
return makeCuboidWalls(region, new SingleBlockPattern(block));
|
||||
return makeCuboidWalls(region, new BlockPattern(block));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1047,7 +1010,6 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int makeCuboidWalls(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||
checkNotNull(region);
|
||||
checkNotNull(pattern);
|
||||
@ -1067,7 +1029,6 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int makeWalls(final Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||
checkNotNull(region);
|
||||
checkNotNull(pattern);
|
||||
@ -1101,11 +1062,10 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int overlayCuboidBlocks(Region region, BaseBlock block) throws MaxChangedBlocksException {
|
||||
checkNotNull(block);
|
||||
|
||||
return overlayCuboidBlocks(region, new SingleBlockPattern(block));
|
||||
return overlayCuboidBlocks(region, new BlockPattern(block));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1117,12 +1077,11 @@ public class EditSession implements Extent {
|
||||
* @return number of blocks affected
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public int overlayCuboidBlocks(Region region, Pattern pattern) throws MaxChangedBlocksException {
|
||||
checkNotNull(region);
|
||||
checkNotNull(pattern);
|
||||
|
||||
BlockReplace replace = new BlockReplace(this, Patterns.wrap(pattern));
|
||||
BlockReplace replace = new BlockReplace(this, pattern);
|
||||
RegionOffset offset = new RegionOffset(new Vector(0, 1, 0), replace);
|
||||
GroundFunction ground = new GroundFunction(new ExistingBlockMask(this), offset);
|
||||
LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground);
|
||||
@ -1835,8 +1794,8 @@ public class EditSession implements Extent {
|
||||
* @return the results
|
||||
*/
|
||||
public List<Countable<Integer>> getBlockDistribution(Region region) {
|
||||
List<Countable<Integer>> distribution = new ArrayList<Countable<Integer>>();
|
||||
Map<Integer, Countable<Integer>> map = new HashMap<Integer, Countable<Integer>>();
|
||||
List<Countable<Integer>> distribution = new ArrayList<>();
|
||||
Map<Integer, Countable<Integer>> map = new HashMap<>();
|
||||
|
||||
if (region instanceof CuboidRegion) {
|
||||
// Doing this for speed
|
||||
@ -1860,7 +1819,7 @@ public class EditSession implements Extent {
|
||||
if (map.containsKey(id)) {
|
||||
map.get(id).increment();
|
||||
} else {
|
||||
Countable<Integer> c = new Countable<Integer>(id, 1);
|
||||
Countable<Integer> c = new Countable<>(id, 1);
|
||||
map.put(id, c);
|
||||
distribution.add(c);
|
||||
}
|
||||
@ -1874,7 +1833,7 @@ public class EditSession implements Extent {
|
||||
if (map.containsKey(id)) {
|
||||
map.get(id).increment();
|
||||
} else {
|
||||
Countable<Integer> c = new Countable<Integer>(id, 1);
|
||||
Countable<Integer> c = new Countable<>(id, 1);
|
||||
map.put(id, c);
|
||||
}
|
||||
}
|
||||
@ -1894,8 +1853,8 @@ public class EditSession implements Extent {
|
||||
*/
|
||||
// TODO reduce code duplication - probably during ops-redux
|
||||
public List<Countable<BaseBlock>> getBlockDistributionWithData(Region region) {
|
||||
List<Countable<BaseBlock>> distribution = new ArrayList<Countable<BaseBlock>>();
|
||||
Map<BaseBlock, Countable<BaseBlock>> map = new HashMap<BaseBlock, Countable<BaseBlock>>();
|
||||
List<Countable<BaseBlock>> distribution = new ArrayList<>();
|
||||
Map<BaseBlock, Countable<BaseBlock>> map = new HashMap<>();
|
||||
|
||||
if (region instanceof CuboidRegion) {
|
||||
// Doing this for speed
|
||||
@ -1919,7 +1878,7 @@ public class EditSession implements Extent {
|
||||
if (map.containsKey(blk)) {
|
||||
map.get(blk).increment();
|
||||
} else {
|
||||
Countable<BaseBlock> c = new Countable<BaseBlock>(blk, 1);
|
||||
Countable<BaseBlock> c = new Countable<>(blk, 1);
|
||||
map.put(blk, c);
|
||||
distribution.add(c);
|
||||
}
|
||||
@ -1933,7 +1892,7 @@ public class EditSession implements Extent {
|
||||
if (map.containsKey(blk)) {
|
||||
map.get(blk).increment();
|
||||
} else {
|
||||
Countable<BaseBlock> c = new Countable<BaseBlock>(blk, 1);
|
||||
Countable<BaseBlock> c = new Countable<>(blk, 1);
|
||||
map.put(blk, c);
|
||||
}
|
||||
}
|
||||
@ -1989,7 +1948,7 @@ public class EditSession implements Extent {
|
||||
final WorldEditExpressionEnvironment environment = new WorldEditExpressionEnvironment(this, unit, zero);
|
||||
expression.setEnvironment(environment);
|
||||
|
||||
final DoubleArrayList<BlockVector, BaseBlock> queue = new DoubleArrayList<BlockVector, BaseBlock>(false);
|
||||
final DoubleArrayList<BlockVector, BaseBlock> queue = new DoubleArrayList<>(false);
|
||||
|
||||
for (BlockVector position : region) {
|
||||
// offset, scale
|
||||
@ -2035,7 +1994,7 @@ public class EditSession implements Extent {
|
||||
public int hollowOutRegion(Region region, int thickness, Pattern pattern) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
|
||||
final Set<BlockVector> outside = new HashSet<BlockVector>();
|
||||
final Set<BlockVector> outside = new HashSet<>();
|
||||
|
||||
final Vector min = region.getMinimumPoint();
|
||||
final Vector max = region.getMaximumPoint();
|
||||
@ -2069,7 +2028,7 @@ public class EditSession implements Extent {
|
||||
}
|
||||
|
||||
for (int i = 1; i < thickness; ++i) {
|
||||
final Set<BlockVector> newOutside = new HashSet<BlockVector>();
|
||||
final Set<BlockVector> newOutside = new HashSet<>();
|
||||
outer: for (BlockVector position : region) {
|
||||
for (Vector recurseDirection: recurseDirections) {
|
||||
BlockVector neighbor = position.add(recurseDirection).toBlockVector();
|
||||
@ -2093,7 +2052,7 @@ public class EditSession implements Extent {
|
||||
}
|
||||
}
|
||||
|
||||
if (setBlock(position, pattern.next(position))) {
|
||||
if (setBlock(position, pattern.apply(position))) {
|
||||
++affected;
|
||||
}
|
||||
}
|
||||
@ -2116,7 +2075,7 @@ public class EditSession implements Extent {
|
||||
public int drawLine(Pattern pattern, Vector pos1, Vector pos2, double radius, boolean filled)
|
||||
throws MaxChangedBlocksException {
|
||||
|
||||
Set<Vector> vset = new HashSet<Vector>();
|
||||
Set<Vector> vset = new HashSet<>();
|
||||
boolean notdrawn = true;
|
||||
|
||||
int x1 = pos1.getBlockX(), y1 = pos1.getBlockY(), z1 = pos1.getBlockZ();
|
||||
@ -2187,8 +2146,8 @@ public class EditSession implements Extent {
|
||||
public int drawSpline(Pattern pattern, List<Vector> nodevectors, double tension, double bias, double continuity, double quality, double radius, boolean filled)
|
||||
throws MaxChangedBlocksException {
|
||||
|
||||
Set<Vector> vset = new HashSet<Vector>();
|
||||
List<Node> nodes = new ArrayList<Node>(nodevectors.size());
|
||||
Set<Vector> vset = new HashSet<>();
|
||||
List<Node> nodes = new ArrayList<>(nodevectors.size());
|
||||
|
||||
Interpolation interpol = new KochanekBartelsInterpolation();
|
||||
|
||||
@ -2227,7 +2186,7 @@ public class EditSession implements Extent {
|
||||
}
|
||||
|
||||
private static Set<Vector> getBallooned(Set<Vector> vset, double radius) {
|
||||
Set<Vector> returnset = new HashSet<Vector>();
|
||||
Set<Vector> returnset = new HashSet<>();
|
||||
int ceilrad = (int) Math.ceil(radius);
|
||||
|
||||
for (Vector v : vset) {
|
||||
@ -2247,7 +2206,7 @@ public class EditSession implements Extent {
|
||||
}
|
||||
|
||||
private static Set<Vector> getHollowed(Set<Vector> vset) {
|
||||
Set<Vector> returnset = new HashSet<Vector>();
|
||||
Set<Vector> returnset = new HashSet<>();
|
||||
for (Vector v : vset) {
|
||||
double x = v.getX(), y = v.getY(), z = v.getZ();
|
||||
if (!(vset.contains(new Vector(x + 1, y, z)) &&
|
||||
@ -2263,7 +2222,7 @@ public class EditSession implements Extent {
|
||||
}
|
||||
|
||||
private void recurseHollow(Region region, BlockVector origin, Set<BlockVector> outside) {
|
||||
final LinkedList<BlockVector> queue = new LinkedList<BlockVector>();
|
||||
final LinkedList<BlockVector> queue = new LinkedList<>();
|
||||
queue.addLast(origin);
|
||||
|
||||
while (!queue.isEmpty()) {
|
||||
|
@ -917,14 +917,4 @@ public class LocalSession {
|
||||
this.mask = mask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a mask.
|
||||
*
|
||||
* @param mask mask or null
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setMask(com.sk89q.worldedit.masks.Mask mask) {
|
||||
setMask(mask != null ? Masks.wrap(mask) : null);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,10 +37,6 @@ import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformManager;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||
import com.sk89q.worldedit.masks.Mask;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
import com.sk89q.worldedit.scripting.CraftScriptContext;
|
||||
import com.sk89q.worldedit.scripting.CraftScriptEngine;
|
||||
import com.sk89q.worldedit.scripting.RhinoCraftScriptEngine;
|
||||
@ -313,32 +309,6 @@ public class WorldEdit {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #getPatternFactory()} and {@link BlockFactory#parseFromInput(String, ParserContext)}
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public Pattern getBlockPattern(Player player, String input) throws WorldEditException {
|
||||
ParserContext context = new ParserContext();
|
||||
context.setActor(player);
|
||||
context.setWorld(player.getWorld());
|
||||
context.setSession(getSession(player));
|
||||
return Patterns.wrap(getPatternFactory().parseFromInput(input, context));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #getMaskFactory()} ()} and {@link MaskFactory#parseFromInput(String, ParserContext)}
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public Mask getBlockMask(Player player, LocalSession session, String input) throws WorldEditException {
|
||||
ParserContext context = new ParserContext();
|
||||
context.setActor(player);
|
||||
context.setWorld(player.getWorld());
|
||||
context.setSession(session);
|
||||
return Masks.wrap(getMaskFactory().parseFromInput(input, context));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the path to a file. This method will check to see if the filename
|
||||
* has valid characters and has an extension. It also prevents directory
|
||||
|
@ -25,7 +25,6 @@ import com.sk89q.worldedit.world.World;
|
||||
/**
|
||||
* @deprecated Use {@link com.sk89q.worldedit.util.Location} wherever possible
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
public class WorldVector extends Vector {
|
||||
|
||||
@ -127,7 +126,7 @@ public class WorldVector extends Vector {
|
||||
|
||||
/**
|
||||
* Gets a BlockVector version.
|
||||
*
|
||||
*
|
||||
* @return BlockWorldVector
|
||||
*/
|
||||
public BlockWorldVector toWorldBlockVector() {
|
||||
|
@ -22,7 +22,6 @@ package com.sk89q.worldedit;
|
||||
/**
|
||||
* @deprecated Use {@link com.sk89q.worldedit.util.Location} wherever possible
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Deprecated
|
||||
public class WorldVectorFace extends WorldVector {
|
||||
|
||||
|
@ -25,7 +25,6 @@ import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.CuboidClipboard.FlipDirection;
|
||||
import com.sk89q.worldedit.blocks.type.BlockType;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.foundation.Block;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.world.registry.BundledBlockData;
|
||||
import com.sk89q.worldedit.world.registry.state.State;
|
||||
@ -54,8 +53,7 @@ import javax.annotation.Nullable;
|
||||
* as a "wildcard" block value, even though a {@link Mask} would be
|
||||
* more appropriate.</p>
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BaseBlock extends Block implements TileEntityBlock {
|
||||
public class BaseBlock implements TileEntityBlock {
|
||||
|
||||
// Instances of this class should be _as small as possible_ because there will
|
||||
// be millions of instances of this object.
|
||||
@ -158,7 +156,6 @@ public class BaseBlock extends Block implements TileEntityBlock {
|
||||
*
|
||||
* @return legacy numerical ID
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public int getId() {
|
||||
return this.blockType.getLegacyId();
|
||||
@ -182,7 +179,6 @@ public class BaseBlock extends Block implements TileEntityBlock {
|
||||
*
|
||||
* @param id block id
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setId(int id) {
|
||||
internalSetId(id);
|
||||
@ -210,7 +206,6 @@ public class BaseBlock extends Block implements TileEntityBlock {
|
||||
*
|
||||
* @return data value (0-15)
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public int getData() {
|
||||
return 0;
|
||||
@ -268,7 +263,6 @@ public class BaseBlock extends Block implements TileEntityBlock {
|
||||
*
|
||||
* @param data block data value
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setData(int data) {
|
||||
internalSetData(data);
|
||||
@ -282,7 +276,6 @@ public class BaseBlock extends Block implements TileEntityBlock {
|
||||
* @see #setId(int)
|
||||
* @see #setData(int)
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setIdAndData(int id, int data) {
|
||||
setId(id);
|
||||
@ -294,7 +287,6 @@ public class BaseBlock extends Block implements TileEntityBlock {
|
||||
*
|
||||
* @return true if there are no matched states
|
||||
*/
|
||||
@Override
|
||||
public boolean hasWildcardData() {
|
||||
return getStates().isEmpty();
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||
import com.sk89q.worldedit.internal.annotation.Selection;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
@ -117,7 +116,7 @@ public class GenerationCommands {
|
||||
worldEdit.checkMaxRadius(height);
|
||||
|
||||
Vector pos = session.getPlacementPosition(player);
|
||||
int affected = editSession.makeCylinder(pos, Patterns.wrap(pattern), radiusX, radiusZ, height, !hollow);
|
||||
int affected = editSession.makeCylinder(pos, pattern, radiusX, radiusZ, height, !hollow);
|
||||
player.print(affected + " block(s) have been created.");
|
||||
}
|
||||
|
||||
@ -182,7 +181,7 @@ public class GenerationCommands {
|
||||
pos = pos.add(0, radiusY, 0);
|
||||
}
|
||||
|
||||
int affected = editSession.makeSphere(pos, Patterns.wrap(pattern), radiusX, radiusY, radiusZ, !hollow);
|
||||
int affected = editSession.makeSphere(pos, pattern, radiusX, radiusY, radiusZ, !hollow);
|
||||
player.findFreePosition();
|
||||
player.print(affected + " block(s) have been created.");
|
||||
}
|
||||
@ -243,7 +242,7 @@ public class GenerationCommands {
|
||||
public void pyramid(Player player, LocalSession session, EditSession editSession, Pattern pattern, @Range(min = 1) int size, @Switch('h') boolean hollow) throws WorldEditException {
|
||||
Vector pos = session.getPlacementPosition(player);
|
||||
worldEdit.checkMaxRadius(size);
|
||||
int affected = editSession.makePyramid(pos, Patterns.wrap(pattern), size, !hollow);
|
||||
int affected = editSession.makePyramid(pos, pattern, size, !hollow);
|
||||
player.findFreePosition();
|
||||
player.print(affected + " block(s) have been created.");
|
||||
}
|
||||
@ -306,7 +305,7 @@ public class GenerationCommands {
|
||||
}
|
||||
|
||||
try {
|
||||
final int affected = editSession.makeShape(region, zero, unit, Patterns.wrap(pattern), expression, hollow);
|
||||
final int affected = editSession.makeShape(region, zero, unit, pattern, expression, hollow);
|
||||
player.findFreePosition();
|
||||
player.print(affected + " block(s) have been created.");
|
||||
} catch (ExpressionException e) {
|
||||
|
@ -33,7 +33,6 @@ import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.NoiseFilter2D;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||
import com.sk89q.worldedit.function.visitor.LayerVisitor;
|
||||
import com.sk89q.worldedit.internal.annotation.Direction;
|
||||
import com.sk89q.worldedit.internal.annotation.Selection;
|
||||
@ -106,7 +105,7 @@ public class RegionCommands {
|
||||
CuboidRegion cuboidregion = (CuboidRegion) region;
|
||||
Vector pos1 = cuboidregion.getPos1();
|
||||
Vector pos2 = cuboidregion.getPos2();
|
||||
int blocksChanged = editSession.drawLine(Patterns.wrap(pattern), pos1, pos2, thickness, !shell);
|
||||
int blocksChanged = editSession.drawLine(pattern, pos1, pos2, thickness, !shell);
|
||||
|
||||
player.print(blocksChanged + " block(s) have been changed.");
|
||||
}
|
||||
@ -137,9 +136,9 @@ public class RegionCommands {
|
||||
}
|
||||
|
||||
ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region;
|
||||
List<Vector> vectors = new ArrayList<Vector>(cpregion.getVertices());
|
||||
List<Vector> vectors = new ArrayList<>(cpregion.getVertices());
|
||||
|
||||
int blocksChanged = editSession.drawSpline(Patterns.wrap(pattern), vectors, 0, 0, 0, 10, thickness, !shell);
|
||||
int blocksChanged = editSession.drawSpline(pattern, vectors, 0, 0, 0, 10, thickness, !shell);
|
||||
|
||||
player.print(blocksChanged + " block(s) have been changed.");
|
||||
}
|
||||
@ -158,7 +157,7 @@ public class RegionCommands {
|
||||
if (from == null) {
|
||||
from = new ExistingBlockMask(editSession);
|
||||
}
|
||||
int affected = editSession.replaceBlocks(region, from, Patterns.wrap(to));
|
||||
int affected = editSession.replaceBlocks(region, from, to);
|
||||
player.print(affected + " block(s) have been replaced.");
|
||||
}
|
||||
|
||||
@ -172,7 +171,7 @@ public class RegionCommands {
|
||||
@CommandPermissions("worldedit.region.overlay")
|
||||
@Logging(REGION)
|
||||
public void overlay(Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException {
|
||||
int affected = editSession.overlayCuboidBlocks(region, Patterns.wrap(pattern));
|
||||
int affected = editSession.overlayCuboidBlocks(region, pattern);
|
||||
player.print(affected + " block(s) have been overlaid.");
|
||||
}
|
||||
|
||||
@ -186,7 +185,7 @@ public class RegionCommands {
|
||||
@Logging(REGION)
|
||||
@CommandPermissions("worldedit.region.center")
|
||||
public void center(Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException {
|
||||
int affected = editSession.center(region, Patterns.wrap(pattern));
|
||||
int affected = editSession.center(region, pattern);
|
||||
player.print("Center set ("+ affected + " blocks changed)");
|
||||
}
|
||||
|
||||
@ -214,7 +213,7 @@ public class RegionCommands {
|
||||
@CommandPermissions("worldedit.region.walls")
|
||||
@Logging(REGION)
|
||||
public void walls(Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException {
|
||||
int affected = editSession.makeCuboidWalls(region, Patterns.wrap(pattern));
|
||||
int affected = editSession.makeCuboidWalls(region, pattern);
|
||||
player.print(affected + " block(s) have been changed.");
|
||||
}
|
||||
|
||||
@ -228,7 +227,7 @@ public class RegionCommands {
|
||||
@CommandPermissions("worldedit.region.faces")
|
||||
@Logging(REGION)
|
||||
public void faces(Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException {
|
||||
int affected = editSession.makeCuboidFaces(region, Patterns.wrap(pattern));
|
||||
int affected = editSession.makeCuboidFaces(region, pattern);
|
||||
player.print(affected + " block(s) have been changed.");
|
||||
}
|
||||
|
||||
@ -422,7 +421,7 @@ public class RegionCommands {
|
||||
@Optional("0") @Range(min = 0) int thickness,
|
||||
@Optional("air") Pattern pattern) throws WorldEditException {
|
||||
|
||||
int affected = editSession.hollowOutRegion(region, thickness, Patterns.wrap(pattern));
|
||||
int affected = editSession.hollowOutRegion(region, thickness, pattern);
|
||||
player.print(affected + " block(s) have been changed.");
|
||||
}
|
||||
|
||||
|
@ -26,8 +26,9 @@ import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.ItemType;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.command.tool.*;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
|
||||
public class ToolCommands {
|
||||
@ -139,7 +140,12 @@ public class ToolCommands {
|
||||
return;
|
||||
}
|
||||
|
||||
Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
||||
ParserContext context = new ParserContext();
|
||||
context.setActor(player);
|
||||
context.setWorld(player.getWorld());
|
||||
context.setSession(session);
|
||||
Pattern pattern = we.getPatternFactory().parseFromInput(args.getString(0), context);
|
||||
|
||||
session.setTool(player.getItemInHand(), new FloodFillTool(range, pattern));
|
||||
player.print("Block flood fill tool bound to "
|
||||
+ ItemType.toHeldName(player.getItemInHand()) + ".");
|
||||
|
@ -36,17 +36,18 @@ import com.sk89q.worldedit.command.util.CreatureButcher;
|
||||
import com.sk89q.worldedit.command.util.EntityRemover;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extension.platform.CommandManager;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.visitor.EntityVisitor;
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
import com.sk89q.worldedit.patterns.SingleBlockPattern;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.CylinderRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
@ -92,17 +93,20 @@ public class UtilityCommands {
|
||||
@Logging(PLACEMENT)
|
||||
public void fill(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
||||
ParserContext context = new ParserContext();
|
||||
context.setActor(player);
|
||||
context.setWorld(player.getWorld());
|
||||
context.setSession(session);
|
||||
Pattern pattern = we.getPatternFactory().parseFromInput(args.getString(0), context);
|
||||
|
||||
double radius = Math.max(1, args.getDouble(1));
|
||||
we.checkMaxRadius(radius);
|
||||
int depth = args.argsLength() > 2 ? Math.max(1, args.getInteger(2)) : 1;
|
||||
|
||||
Vector pos = session.getPlacementPosition(player);
|
||||
int affected = 0;
|
||||
if (pattern instanceof SingleBlockPattern) {
|
||||
affected = editSession.fillXZ(pos,
|
||||
((SingleBlockPattern) pattern).getBlock(),
|
||||
radius, depth, false);
|
||||
int affected;
|
||||
if (pattern instanceof BlockPattern) {
|
||||
affected = editSession.fillXZ(pos, ((BlockPattern) pattern).getBlock(), radius, depth, false);
|
||||
} else {
|
||||
affected = editSession.fillXZ(pos, pattern, radius, depth, false);
|
||||
}
|
||||
@ -120,17 +124,20 @@ public class UtilityCommands {
|
||||
@Logging(PLACEMENT)
|
||||
public void fillr(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||
|
||||
Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
||||
ParserContext context = new ParserContext();
|
||||
context.setActor(player);
|
||||
context.setWorld(player.getWorld());
|
||||
context.setSession(session);
|
||||
Pattern pattern = we.getPatternFactory().parseFromInput(args.getString(0), context);
|
||||
|
||||
double radius = Math.max(1, args.getDouble(1));
|
||||
we.checkMaxRadius(radius);
|
||||
int depth = args.argsLength() > 2 ? Math.max(1, args.getInteger(2)) : Integer.MAX_VALUE;
|
||||
|
||||
Vector pos = session.getPlacementPosition(player);
|
||||
int affected = 0;
|
||||
if (pattern instanceof SingleBlockPattern) {
|
||||
affected = editSession.fillXZ(pos,
|
||||
((SingleBlockPattern) pattern).getBlock(),
|
||||
radius, depth, true);
|
||||
if (pattern instanceof BlockPattern) {
|
||||
affected = editSession.fillXZ(pos, ((BlockPattern) pattern).getBlock(), radius, depth, true);
|
||||
} else {
|
||||
affected = editSession.fillXZ(pos, pattern, radius, depth, true);
|
||||
}
|
||||
@ -267,12 +274,20 @@ public class UtilityCommands {
|
||||
int affected;
|
||||
Set<BaseBlock> from;
|
||||
Pattern to;
|
||||
|
||||
ParserContext context = new ParserContext();
|
||||
context.setActor(player);
|
||||
context.setWorld(player.getWorld());
|
||||
context.setSession(session);
|
||||
context.setRestricted(false);
|
||||
context.setPreferringWildcard(!args.hasFlag('f'));
|
||||
|
||||
if (args.argsLength() == 2) {
|
||||
from = null;
|
||||
to = we.getBlockPattern(player, args.getString(1));
|
||||
to = we.getPatternFactory().parseFromInput(args.getString(1), context);
|
||||
} else {
|
||||
from = we.getBlocks(player, args.getString(1), true, !args.hasFlag('f'));
|
||||
to = we.getBlockPattern(player, args.getString(2));
|
||||
from = we.getBlockFactory().parseFromListInput(args.getString(1), context);
|
||||
to = we.getPatternFactory().parseFromInput(args.getString(2), context);
|
||||
}
|
||||
|
||||
Vector base = session.getPlacementPosition(player);
|
||||
@ -280,8 +295,8 @@ public class UtilityCommands {
|
||||
Vector max = base.add(size, size, size);
|
||||
Region region = new CuboidRegion(player.getWorld(), min, max);
|
||||
|
||||
if (to instanceof SingleBlockPattern) {
|
||||
affected = editSession.replaceBlocks(region, from, ((SingleBlockPattern) to).getBlock());
|
||||
if (to instanceof BlockPattern) {
|
||||
affected = editSession.replaceBlocks(region, from, ((BlockPattern) to).getBlock());
|
||||
} else {
|
||||
affected = editSession.replaceBlocks(region, from, to);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
@ -87,7 +87,7 @@ public class FloodFillTool implements BlockTool {
|
||||
visited.add(pos);
|
||||
|
||||
if (editSession.getBlock(pos).getType().getLegacyId() == initialType) {
|
||||
editSession.setBlock(pos, pattern.next(pos));
|
||||
editSession.setBlock(pos, pattern.apply(pos));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
@ -23,11 +23,9 @@ import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||
|
||||
public class CylinderBrush implements Brush {
|
||||
|
||||
@ -42,7 +40,7 @@ public class CylinderBrush implements Brush {
|
||||
if (pattern == null) {
|
||||
pattern = new BlockPattern(new BaseBlock(BlockTypes.COBBLESTONE));
|
||||
}
|
||||
editSession.makeCylinder(position, Patterns.wrap(pattern), size, size, height, true);
|
||||
editSession.makeCylinder(position, pattern, size, size, height, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,11 +23,9 @@ import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||
|
||||
public class HollowCylinderBrush implements Brush {
|
||||
|
||||
@ -42,7 +40,7 @@ public class HollowCylinderBrush implements Brush {
|
||||
if (pattern == null) {
|
||||
pattern = new BlockPattern(new BaseBlock(BlockTypes.COBBLESTONE));
|
||||
}
|
||||
editSession.makeCylinder(position, Patterns.wrap(pattern), size, size, height, false);
|
||||
editSession.makeCylinder(position, pattern, size, size, height, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,11 +23,9 @@ import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||
|
||||
public class HollowSphereBrush implements Brush {
|
||||
|
||||
@ -36,6 +34,6 @@ public class HollowSphereBrush implements Brush {
|
||||
if (pattern == null) {
|
||||
pattern = new BlockPattern(new BaseBlock(BlockTypes.COBBLESTONE));
|
||||
}
|
||||
editSession.makeSphere(position, Patterns.wrap(pattern), size, size, size, false);
|
||||
editSession.makeSphere(position, pattern, size, size, size, false);
|
||||
}
|
||||
}
|
||||
|
@ -23,11 +23,9 @@ import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||
|
||||
public class SphereBrush implements Brush {
|
||||
|
||||
@ -36,6 +34,6 @@ public class SphereBrush implements Brush {
|
||||
if (pattern == null) {
|
||||
pattern = new BlockPattern(new BaseBlock(BlockTypes.COBBLESTONE));
|
||||
}
|
||||
editSession.makeSphere(position, Patterns.wrap(pattern), size, size, size, true);
|
||||
editSession.makeSphere(position, pattern, size, size, size, true);
|
||||
}
|
||||
}
|
||||
|
@ -19,14 +19,15 @@
|
||||
|
||||
package com.sk89q.worldedit.function.block;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.function.LayerFunction;
|
||||
import com.sk89q.worldedit.masks.BlockMask;
|
||||
import com.sk89q.worldedit.masks.Mask;
|
||||
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -37,11 +38,12 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*/
|
||||
public class Naturalizer implements LayerFunction {
|
||||
|
||||
private static final BaseBlock grass = new BaseBlock(BlockTypes.GRASS_BLOCK);
|
||||
private static final BaseBlock dirt = new BaseBlock(BlockTypes.DIRT);
|
||||
private static final BaseBlock stone = new BaseBlock(BlockTypes.STONE);
|
||||
|
||||
private final EditSession editSession;
|
||||
private final BaseBlock grass = new BaseBlock(BlockTypes.GRASS_BLOCK);
|
||||
private final BaseBlock dirt = new BaseBlock(BlockTypes.DIRT);
|
||||
private final BaseBlock stone = new BaseBlock(BlockTypes.STONE);
|
||||
private final Mask mask = new BlockMask(grass, dirt, stone);
|
||||
private final Mask mask;
|
||||
private int affected = 0;
|
||||
|
||||
/**
|
||||
@ -52,6 +54,7 @@ public class Naturalizer implements LayerFunction {
|
||||
public Naturalizer(EditSession editSession) {
|
||||
checkNotNull(editSession);
|
||||
this.editSession = editSession;
|
||||
this.mask = new BlockMask(editSession, Sets.newHashSet(grass, dirt, stone));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,12 +68,12 @@ public class Naturalizer implements LayerFunction {
|
||||
|
||||
@Override
|
||||
public boolean isGround(Vector position) {
|
||||
return mask.matches(editSession, position);
|
||||
return mask.test(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position, int depth) throws WorldEditException {
|
||||
if (mask.matches(editSession, position)) {
|
||||
if (mask.test(position)) {
|
||||
affected++;
|
||||
switch (depth) {
|
||||
case 0:
|
||||
|
@ -131,82 +131,6 @@ public final class Masks {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap an old-style mask and convert it to a new mask.
|
||||
*
|
||||
* <p>Note, however, that this is strongly not recommended because
|
||||
* {@link com.sk89q.worldedit.masks.Mask#prepare(LocalSession, LocalPlayer, Vector)}
|
||||
* is not called.</p>
|
||||
*
|
||||
* @param mask the old-style mask
|
||||
* @param editSession the edit session to bind to
|
||||
* @return a new-style mask
|
||||
* @deprecated Please avoid if possible
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Mask wrap(final com.sk89q.worldedit.masks.Mask mask, final EditSession editSession) {
|
||||
checkNotNull(mask);
|
||||
return new AbstractMask() {
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
return mask.matches(editSession, vector);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap an old-style mask and convert it to a new mask.
|
||||
*
|
||||
* <p>As an {@link EditSession} is not provided in this case, one will be
|
||||
* taken from the {@link Request}, if possible. If not possible, then the
|
||||
* mask will return false.</p>
|
||||
*
|
||||
* @param mask the old-style mask
|
||||
* @return a new-style mask
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Mask wrap(final com.sk89q.worldedit.masks.Mask mask) {
|
||||
checkNotNull(mask);
|
||||
return new AbstractMask() {
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
EditSession editSession = Request.request().getEditSession();
|
||||
return editSession != null && mask.matches(editSession, vector);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a new-style mask to an old-style mask.
|
||||
*
|
||||
* @param mask the new-style mask
|
||||
* @return an old-style mask
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static com.sk89q.worldedit.masks.Mask wrap(final Mask mask) {
|
||||
checkNotNull(mask);
|
||||
return new com.sk89q.worldedit.masks.AbstractMask() {
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector position) {
|
||||
Request.request().setEditSession(editSession);
|
||||
return mask.test(position);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static class AlwaysTrue implements Mask, Mask2D {
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
|
@ -1,72 +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.function.pattern;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Utility methods related to {@link Pattern}s.
|
||||
*/
|
||||
public final class Patterns {
|
||||
|
||||
private Patterns() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap an old-style pattern and return a new pattern.
|
||||
*
|
||||
* @param pattern the pattern
|
||||
* @return a new-style pattern
|
||||
*/
|
||||
public static Pattern wrap(final com.sk89q.worldedit.patterns.Pattern pattern) {
|
||||
checkNotNull(pattern);
|
||||
return new Pattern() {
|
||||
@Override
|
||||
public BaseBlock apply(Vector position) {
|
||||
return pattern.next(position);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap a new-style pattern and return an old-style pattern.
|
||||
*
|
||||
* @param pattern the pattern
|
||||
* @return an old-style pattern
|
||||
*/
|
||||
public static com.sk89q.worldedit.patterns.Pattern wrap(final Pattern pattern) {
|
||||
checkNotNull(pattern);
|
||||
return new com.sk89q.worldedit.patterns.Pattern() {
|
||||
@Override
|
||||
public BaseBlock next(Vector position) {
|
||||
return pattern.apply(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock next(int x, int y, int z) {
|
||||
return next(new Vector(x, y, z));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
@ -48,14 +48,6 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
this(null, pos1, pos2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated cast {@code world} to {@link World}
|
||||
*/
|
||||
@Deprecated
|
||||
public CuboidRegion(LocalWorld world, Vector pos1, Vector pos2) {
|
||||
this((World) world, pos1, pos2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new instance of this cuboid using two corners of the cuboid.
|
||||
*
|
||||
|
@ -48,7 +48,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
/**
|
||||
* Creates a {@code ConvexPolyhedralRegion} from a user's selections.
|
||||
*/
|
||||
public class ConvexPolyhedralRegionSelector extends com.sk89q.worldedit.regions.ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion {
|
||||
public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
private final transient ConvexPolyhedralRegion region;
|
||||
private transient BlockVector pos1;
|
||||
|
@ -38,7 +38,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
/**
|
||||
* Creates a {@code CuboidRegion} from a user's selections.
|
||||
*/
|
||||
public class CuboidRegionSelector extends com.sk89q.worldedit.regions.CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
protected transient BlockVector position1;
|
||||
protected transient BlockVector position2;
|
||||
|
@ -38,7 +38,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
/**
|
||||
* Creates a {@code CylinderRegionSelector} from a user's selections.
|
||||
*/
|
||||
public class CylinderRegionSelector extends com.sk89q.worldedit.regions.CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
protected static transient final NumberFormat NUMBER_FORMAT;
|
||||
protected transient CylinderRegion region;
|
||||
|
@ -39,7 +39,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
/**
|
||||
* Creates a {@code EllipsoidRegionSelector} from a user's selections.
|
||||
*/
|
||||
public class EllipsoidRegionSelector extends com.sk89q.worldedit.regions.EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
protected transient EllipsoidRegion region;
|
||||
protected transient boolean started = false;
|
||||
|
@ -41,7 +41,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
/**
|
||||
* Creates a {@code Polygonal2DRegion} from a user's selections.
|
||||
*/
|
||||
public class Polygonal2DRegionSelector extends com.sk89q.worldedit.regions.Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
private transient BlockVector pos1;
|
||||
private transient Polygonal2DRegion region;
|
||||
@ -248,7 +248,6 @@ public class Polygonal2DRegionSelector extends com.sk89q.worldedit.regions.Polyg
|
||||
*
|
||||
* @return the number of points
|
||||
*/
|
||||
@Override
|
||||
public int getPointCount() {
|
||||
return region.getPoints().size();
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
/**
|
||||
@ -92,7 +92,7 @@ public abstract class ArbitraryShape {
|
||||
switch (cacheEntry) {
|
||||
case 0:
|
||||
// unknown, fetch material
|
||||
final BaseBlock material = getMaterial(x, y, z, pattern.next(new BlockVector(x, y, z)));
|
||||
final BaseBlock material = getMaterial(x, y, z, pattern.apply(new BlockVector(x, y, z)));
|
||||
if (material == null) {
|
||||
// outside
|
||||
cache[index] = -1;
|
||||
@ -156,7 +156,7 @@ public abstract class ArbitraryShape {
|
||||
int z = position.getBlockZ();
|
||||
|
||||
if (!hollow) {
|
||||
final BaseBlock material = getMaterial(x, y, z, pattern.next(position));
|
||||
final BaseBlock material = getMaterial(x, y, z, pattern.apply(position));
|
||||
if (material != null && editSession.setBlock(position, material)) {
|
||||
++affected;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.CuboidClipboard;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.data.DataException;
|
||||
import com.sk89q.worldedit.world.DataException;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.File;
|
||||
@ -138,7 +138,7 @@ public class MCEditSchematicFormat extends SchematicFormat {
|
||||
List<Tag> tileEntities = getChildTag(schematic, "TileEntities", ListTag.class)
|
||||
.getValue();
|
||||
Map<BlockVector, Map<String, Tag>> tileEntitiesMap =
|
||||
new HashMap<BlockVector, Map<String, Tag>>();
|
||||
new HashMap<>();
|
||||
|
||||
for (Tag tag : tileEntities) {
|
||||
if (!(tag instanceof CompoundTag)) continue;
|
||||
@ -148,7 +148,7 @@ public class MCEditSchematicFormat extends SchematicFormat {
|
||||
int y = 0;
|
||||
int z = 0;
|
||||
|
||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
||||
Map<String, Tag> values = new HashMap<>();
|
||||
|
||||
for (Map.Entry<String, Tag> entry : t.getValue().entrySet()) {
|
||||
if (entry.getKey().equals("x")) {
|
||||
@ -216,7 +216,7 @@ public class MCEditSchematicFormat extends SchematicFormat {
|
||||
throw new DataException("Length of region too large for a .schematic");
|
||||
}
|
||||
|
||||
HashMap<String, Tag> schematic = new HashMap<String, Tag>();
|
||||
HashMap<String, Tag> schematic = new HashMap<>();
|
||||
schematic.put("Width", new ShortTag((short) width));
|
||||
schematic.put("Length", new ShortTag((short) length));
|
||||
schematic.put("Height", new ShortTag((short) height));
|
||||
@ -232,7 +232,7 @@ public class MCEditSchematicFormat extends SchematicFormat {
|
||||
byte[] blocks = new byte[width * height * length];
|
||||
byte[] addBlocks = null;
|
||||
byte[] blockData = new byte[width * height * length];
|
||||
ArrayList<Tag> tileEntities = new ArrayList<Tag>();
|
||||
ArrayList<Tag> tileEntities = new ArrayList<>();
|
||||
|
||||
for (int x = 0; x < width; ++x) {
|
||||
for (int y = 0; y < height; ++y) {
|
||||
@ -257,7 +257,7 @@ public class MCEditSchematicFormat extends SchematicFormat {
|
||||
// Get the list of key/values from the block
|
||||
CompoundTag rawTag = block.getNbtData();
|
||||
if (rawTag != null) {
|
||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
||||
Map<String, Tag> values = new HashMap<>();
|
||||
for (Entry<String, Tag> entry : rawTag.getValue().entrySet()) {
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
@ -21,7 +21,8 @@ package com.sk89q.worldedit.schematic;
|
||||
|
||||
import com.sk89q.worldedit.CuboidClipboard;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.data.DataException;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.world.DataException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -29,13 +30,13 @@ import java.util.*;
|
||||
|
||||
public abstract class SchematicFormat {
|
||||
|
||||
private static final Map<String, SchematicFormat> SCHEMATIC_FORMATS = new HashMap<String, SchematicFormat>();
|
||||
private static final Map<String, SchematicFormat> SCHEMATIC_FORMATS = new HashMap<>();
|
||||
|
||||
// Built-in schematic formats
|
||||
public static final SchematicFormat MCEDIT = new MCEditSchematicFormat();
|
||||
|
||||
public static Set<SchematicFormat> getFormats() {
|
||||
return Collections.unmodifiableSet(new HashSet<SchematicFormat>(SCHEMATIC_FORMATS.values()));
|
||||
return Collections.unmodifiableSet(new HashSet<>(SCHEMATIC_FORMATS.values()));
|
||||
}
|
||||
|
||||
public static SchematicFormat getFormat(String lookupName) {
|
||||
@ -60,7 +61,7 @@ public abstract class SchematicFormat {
|
||||
|
||||
protected SchematicFormat(String name, String... lookupNames) {
|
||||
this.name = name;
|
||||
List<String> registeredLookupNames = new ArrayList<String>(lookupNames.length);
|
||||
List<String> registeredLookupNames = new ArrayList<>(lookupNames.length);
|
||||
for (int i = 0; i < lookupNames.length; ++i) {
|
||||
if (i == 0 || !SCHEMATIC_FORMATS.containsKey(lookupNames[i].toLowerCase())) {
|
||||
SCHEMATIC_FORMATS.put(lookupNames[i].toLowerCase(), this);
|
||||
|
@ -23,8 +23,9 @@ import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.command.InsufficientArgumentsException;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.patterns.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.util.io.file.FilenameException;
|
||||
|
||||
import java.io.File;
|
||||
@ -36,10 +37,9 @@ import java.util.Set;
|
||||
/**
|
||||
* The context given to scripts.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class CraftScriptContext extends CraftScriptEnvironment {
|
||||
|
||||
private List<EditSession> editSessions = new ArrayList<EditSession>();
|
||||
private List<EditSession> editSessions = new ArrayList<>();
|
||||
private String[] args;
|
||||
|
||||
public CraftScriptContext(WorldEdit controller,
|
||||
@ -176,7 +176,11 @@ public class CraftScriptContext extends CraftScriptEnvironment {
|
||||
* @throws DisallowedItemException
|
||||
*/
|
||||
public Pattern getBlockPattern(String list) throws WorldEditException {
|
||||
return controller.getBlockPattern(player, list);
|
||||
ParserContext context = new ParserContext();
|
||||
context.setActor(player);
|
||||
context.setWorld(player.getWorld());
|
||||
context.setSession(session);
|
||||
return controller.getPatternFactory().parseFromInput(list, context);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren