mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-28 10:06:40 +00:00
More file moving.
This commit is contained in:
116
src/main/java/com/sk89q/worldedit/blocks/BaseBlock.java
Normal file
116
src/main/java/com/sk89q/worldedit/blocks/BaseBlock.java
Normal file
@ -0,0 +1,116 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
import com.sk89q.worldedit.data.BlockData;
|
||||
|
||||
/**
|
||||
* Represents a block.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class BaseBlock {
|
||||
/**
|
||||
* BaseBlock type.
|
||||
*/
|
||||
private short type = 0;
|
||||
/**
|
||||
* BaseBlock data.
|
||||
*/
|
||||
private char data = 0;
|
||||
|
||||
/**
|
||||
* Construct the block with its type.
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
public BaseBlock(int type) {
|
||||
this.type = (short)type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the block with its type and data.
|
||||
*
|
||||
* @param type
|
||||
* @param data
|
||||
*/
|
||||
public BaseBlock(int type, int data) {
|
||||
this.type = (short)type;
|
||||
this.data = (char)data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type
|
||||
*/
|
||||
public int getType() {
|
||||
return (int)type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param type the type to set
|
||||
*/
|
||||
public void setType(int type) {
|
||||
this.type = (short)type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the data
|
||||
*/
|
||||
public int getData() {
|
||||
return (int)data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param data the data to set
|
||||
*/
|
||||
public void setData(int data) {
|
||||
this.data = (char)data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if it's air.
|
||||
*
|
||||
* @return if air
|
||||
*/
|
||||
public boolean isAir() {
|
||||
return type == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate this block 90 degrees.
|
||||
*/
|
||||
public void rotate90() {
|
||||
data = (char)BlockData.rotate90(type, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate this block -90 degrees.
|
||||
*/
|
||||
public void rotate90Reverse() {
|
||||
data = (char)BlockData.rotate90Reverse(type, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flip this block.
|
||||
*/
|
||||
public void flip() {
|
||||
data = (char)BlockData.flip(type, data);
|
||||
}
|
||||
}
|
85
src/main/java/com/sk89q/worldedit/blocks/BaseItem.java
Normal file
85
src/main/java/com/sk89q/worldedit/blocks/BaseItem.java
Normal file
@ -0,0 +1,85 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
/**
|
||||
* Represents an item.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class BaseItem {
|
||||
/**
|
||||
* Item ID.
|
||||
*/
|
||||
private int id;
|
||||
/**
|
||||
* Item damage.
|
||||
*/
|
||||
private short damage;
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public BaseItem(int id) {
|
||||
this.id = id;
|
||||
this.damage = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param id
|
||||
* @param damage
|
||||
*/
|
||||
public BaseItem(int id, short damage) {
|
||||
this.id = id;
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public int getType() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setType(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the damage
|
||||
*/
|
||||
public short getDamage() {
|
||||
return damage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param damage the damage to set
|
||||
*/
|
||||
public void setDamage(short damage) {
|
||||
this.damage = damage;
|
||||
}
|
||||
}
|
78
src/main/java/com/sk89q/worldedit/blocks/BaseItemStack.java
Normal file
78
src/main/java/com/sk89q/worldedit/blocks/BaseItemStack.java
Normal file
@ -0,0 +1,78 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
/**
|
||||
* Represents a stack of BaseItems.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class BaseItemStack extends BaseItem {
|
||||
/**
|
||||
* Amount of an item.
|
||||
*/
|
||||
private int amount = 1;
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public BaseItemStack(int id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param id
|
||||
* @param amount
|
||||
*/
|
||||
public BaseItemStack(int id, int amount) {
|
||||
super(id);
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param id
|
||||
* @param amount
|
||||
* @param damage
|
||||
*/
|
||||
public BaseItemStack(int id, int amount, short damage) {
|
||||
super(id, damage);
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the amount
|
||||
*/
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param amount the amount to set
|
||||
*/
|
||||
public void setAmount(int amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
}
|
119
src/main/java/com/sk89q/worldedit/blocks/BlockID.java
Normal file
119
src/main/java/com/sk89q/worldedit/blocks/BlockID.java
Normal file
@ -0,0 +1,119 @@
|
||||
// $Id$
|
||||
/*
|
||||
* CraftBook
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
/**
|
||||
* List of block IDs.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public final class BlockID {
|
||||
public static final int AIR = 0;
|
||||
public static final int STONE = 1;
|
||||
public static final int GRASS = 2;
|
||||
public static final int DIRT = 3;
|
||||
public static final int COBBLESTONE = 4;
|
||||
public static final int WOOD = 5;
|
||||
public static final int SAPLING = 6;
|
||||
public static final int BEDROCK = 7;
|
||||
public static final int WATER = 8;
|
||||
public static final int STATIONARY_WATER = 9;
|
||||
public static final int LAVA = 10;
|
||||
public static final int STATIONARY_LAVA = 11;
|
||||
public static final int SAND = 12;
|
||||
public static final int GRAVEL = 13;
|
||||
public static final int GOLD_ORE = 14;
|
||||
public static final int IRON_ORE = 15;
|
||||
public static final int COAL_ORE = 16;
|
||||
public static final int LOG = 17;
|
||||
public static final int LEAVES = 18;
|
||||
public static final int SPONGE = 19;
|
||||
public static final int GLASS = 20;
|
||||
public static final int LAPIS_LAZULI_ORE = 21;
|
||||
public static final int LAPIS_LAZULI_BLOCK = 22;
|
||||
public static final int DISPENSER = 23;
|
||||
public static final int SANDSTONE = 24;
|
||||
public static final int NOTE_BLOCK = 25;
|
||||
public static final int BED = 26;
|
||||
public static final int POWERED_RAIL = 27;
|
||||
public static final int DETECTOR_RAIL = 28;
|
||||
public static final int WEB = 30;
|
||||
public static final int CLOTH = 35;
|
||||
public static final int YELLOW_FLOWER = 37;
|
||||
public static final int RED_FLOWER = 38;
|
||||
public static final int BROWN_MUSHROOM = 39;
|
||||
public static final int RED_MUSHROOM = 40;
|
||||
public static final int GOLD_BLOCK = 41;
|
||||
public static final int IRON_BLOCK = 42;
|
||||
public static final int DOUBLE_STEP = 43;
|
||||
public static final int STEP = 44;
|
||||
public static final int BRICK = 45;
|
||||
public static final int TNT = 46;
|
||||
public static final int BOOKCASE = 47;
|
||||
public static final int MOSSY_COBBLESTONE = 48;
|
||||
public static final int OBSIDIAN = 49;
|
||||
public static final int TORCH = 50;
|
||||
public static final int FIRE = 51;
|
||||
public static final int MOB_SPAWNER = 52;
|
||||
public static final int WOODEN_STAIRS = 53;
|
||||
public static final int CHEST = 54;
|
||||
public static final int REDSTONE_WIRE = 55;
|
||||
public static final int DIAMOND_ORE = 56;
|
||||
public static final int DIAMOND_BLOCK = 57;
|
||||
public static final int WORKBENCH = 58;
|
||||
public static final int CROPS = 59;
|
||||
public static final int SOIL = 60;
|
||||
public static final int FURNACE = 61;
|
||||
public static final int BURNING_FURNACE = 62;
|
||||
public static final int SIGN_POST = 63;
|
||||
public static final int WOODEN_DOOR = 64;
|
||||
public static final int LADDER = 65;
|
||||
public static final int MINECART_TRACKS = 66;
|
||||
public static final int COBBLESTONE_STAIRS = 67;
|
||||
public static final int WALL_SIGN = 68;
|
||||
public static final int LEVER = 69;
|
||||
public static final int STONE_PRESSURE_PLATE = 70;
|
||||
public static final int IRON_DOOR = 71;
|
||||
public static final int WOODEN_PRESSURE_PLATE = 72;
|
||||
public static final int REDSTONE_ORE = 73;
|
||||
public static final int GLOWING_REDSTONE_ORE = 74;
|
||||
public static final int REDSTONE_TORCH_OFF = 75;
|
||||
public static final int REDSTONE_TORCH_ON = 76;
|
||||
public static final int STONE_BUTTON = 77;
|
||||
public static final int SNOW = 78;
|
||||
public static final int ICE = 79;
|
||||
public static final int SNOW_BLOCK = 80;
|
||||
public static final int CACTUS = 81;
|
||||
public static final int CLAY = 82;
|
||||
public static final int REED = 83;
|
||||
public static final int JUKEBOX = 84;
|
||||
public static final int FENCE = 85;
|
||||
public static final int PUMPKIN = 86;
|
||||
public static final int NETHERSTONE = 87;
|
||||
public static final int NETHERRACK = 87;
|
||||
public static final int SLOW_SAND = 88;
|
||||
public static final int LIGHTSTONE = 89;
|
||||
public static final int PORTAL = 90;
|
||||
public static final int JACKOLANTERN = 91;
|
||||
public static final int CAKE_BLOCK = 92;
|
||||
public static final int REDSTONE_REPEATER_OFF = 93;
|
||||
public static final int REDSTONE_REPEATER_ON = 94;
|
||||
public static final int LOCKED_CHEST = 95;
|
||||
}
|
538
src/main/java/com/sk89q/worldedit/blocks/BlockType.java
Normal file
538
src/main/java/com/sk89q/worldedit/blocks/BlockType.java
Normal file
@ -0,0 +1,538 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.EnumSet;
|
||||
|
||||
/**
|
||||
* Block types.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public enum BlockType {
|
||||
AIR(0, "Air", "air"),
|
||||
STONE(1, "Stone", new String[] {"stone", "rock"}),
|
||||
GRASS(2, "Grass", "grass"),
|
||||
DIRT(3, "Dirt", "dirt"),
|
||||
COBBLESTONE(4, "Cobblestone", new String[] {"cobblestone", "cobble"}),
|
||||
WOOD(5, "Wood", new String[] {"wood", "woodplank", "plank", "woodplanks", "planks"}),
|
||||
SAPLING(6, "Sapling", "sapling"),
|
||||
BEDROCK(7, "Bedrock", new String[] {"adminium", "bedrock"}),
|
||||
WATER(8, "Water", new String[] {"watermoving", "movingwater"}),
|
||||
STATIONARY_WATER(9, "Water (stationary)",
|
||||
new String[] {"water", "waterstationary", "stationarywater", "stillwater"}),
|
||||
LAVA(10, "Lava", new String[] {"lavamoving", "movinglava"}),
|
||||
STATIONARY_LAVA(11, "Lava (stationary)",
|
||||
new String[] {"lava", "lavastationary", "stationarylava", "stilllava"}),
|
||||
SAND(12, "Sand", "sand"),
|
||||
GRAVEL(13, "Gravel", "gravel"),
|
||||
GOLD_ORE(14, "Gold ore", "goldore"),
|
||||
IRON_ORE(15, "Iron ore", "ironore"),
|
||||
COAL_ORE(16, "Coal ore", "coalore"),
|
||||
LOG(17, "Log", new String[] {"log", "tree", "pine", "oak", "birch", "redwood"}),
|
||||
LEAVES(18, "Leaves", new String[] {"leaves", "leaf"}),
|
||||
SPONGE(19, "Sponge", "sponge"),
|
||||
GLASS(20, "Glass", "glass"),
|
||||
LAPIS_LAZULI_ORE(21, "Lapis lazuli ore", new String[] {"lapislazuliore", "blueore", "lapisore"}),
|
||||
LAPIS_LAZULI(22, "Lapis lazuli", new String[] {"lapislazuli", "lapislazuliblock", "bluerock"}),
|
||||
DISPENSER(23, "Dispenser", "dispenser"),
|
||||
SANDSTONE(24, "Sandstone", "sandstone"),
|
||||
NOTE_BLOCK(25, "Note block", new String[] {"musicblock", "noteblock", "note", "music", "instrument"}),
|
||||
BED(26, "Bed", "bed"),
|
||||
POWERED_RAIL(27, "Powered Rail",
|
||||
new String[] {"poweredrail", "boosterrail", "poweredtrack", "boostertrack"}),
|
||||
DETECTOR_RAIL(28, "Detector Rail", "detectorrail"),
|
||||
WEB(30, "Web", new String[] {"web", "spiderweb"}),
|
||||
CLOTH(35, "Wool", new String[] {"cloth", "wool"}),
|
||||
YELLOW_FLOWER(37, "Yellow flower", new String[] {"yellowflower", "flower"}),
|
||||
RED_FLOWER(38, "Red rose", new String[] {"redflower", "redrose", "rose"}),
|
||||
BROWN_MUSHROOM(39, "Brown mushroom", new String[] {"brownmushroom", "mushroom"}),
|
||||
RED_MUSHROOM(40, "Red mushroom", "redmushroom"),
|
||||
GOLD_BLOCK(41, "Gold block", new String[] {"gold", "goldblock"}),
|
||||
IRON_BLOCK(42, "Iron block", new String[] {"iron", "ironblock"}),
|
||||
DOUBLE_STEP(43, "Double step", new String[] {"doubleslab", "doublestoneslab", "doublestep"}),
|
||||
STEP(44, "Step", new String[] {"slab", "stoneslab", "step", "halfstep"}),
|
||||
BRICK(45, "Brick", new String[] {"brick", "brickblock"}),
|
||||
TNT(46, "TNT", "tnt"),
|
||||
BOOKCASE(47, "Bookcase", new String[] {"bookshelf", "bookshelves"}),
|
||||
MOSSY_COBBLESTONE(48, "Cobblestone (mossy)",
|
||||
new String[] {"mossycobblestone", "mossstone", "mossystone",
|
||||
"mosscobble", "mossycobble", "moss", "mossy", "sossymobblecone"}),
|
||||
OBSIDIAN(49, "Obsidian", "obsidian"),
|
||||
TORCH(50, "Torch", "torch"),
|
||||
FIRE(51, "Fire", new String[] {"fire", "flame", "flames"}),
|
||||
MOB_SPAWNER(52, "Mob spawner", new String[] {"mobspawner", "spawner"}),
|
||||
WOODEN_STAIRS(53, "Wooden stairs",
|
||||
new String[] {"woodstair", "woodstairs", "woodenstair", "woodenstairs"}),
|
||||
CHEST(54, "Chest", new String[] {"chest", "storage"}),
|
||||
REDSTONE_WIRE(55, "Redstone wire", "redstone"),
|
||||
DIAMOND_ORE(56, "Diamond ore", "diamondore"),
|
||||
DIAMOND_BLOCK(57, "Diamond block", new String[] {"diamond", "diamondblock"}),
|
||||
WORKBENCH(58, "Workbench", new String[] {"workbench", "table", "craftingtable"}),
|
||||
CROPS(59, "Crops", new String[] {"crops", "crop", "plant", "plants"}),
|
||||
SOIL(60, "Soil", new String[] {"soil", "farmland"}),
|
||||
FURNACE(61, "Furnace", "furnace"),
|
||||
BURNING_FURNACE(62, "Furnace (burning)", new String[] {"burningfurnace", "litfurnace"}),
|
||||
SIGN_POST(63, "Sign post", new String[] {"sign", "signpost"}),
|
||||
WOODEN_DOOR(64, "Wooden door", new String[] {"wooddoor", "woodendoor", "door"}),
|
||||
LADDER(65, "Ladder", "ladder"),
|
||||
MINECART_TRACKS(66, "Minecart tracks",
|
||||
new String[] {"track", "tracks", "minecrattrack", "minecarttracks", "rails", "rail"}),
|
||||
COBBLESTONE_STAIRS(67, "Cobblestone stairs",
|
||||
new String[] {"cobblestonestair", "cobblestonestairs", "cobblestair", "cobblestairs"}),
|
||||
WALL_SIGN(68, "Wall sign", "wallsign"),
|
||||
LEVER(69, "Lever", new String[] {"lever", "switch", "stonelever", "stoneswitch"}),
|
||||
STONE_PRESSURE_PLATE(70, "Stone pressure plate",
|
||||
new String[] {"stonepressureplate", "stoneplate"}),
|
||||
IRON_DOOR(71, "Iron Door", "irondoor"),
|
||||
WOODEN_PRESSURE_PLATE(72, "Wooden pressure plate",
|
||||
new String[] {"woodpressureplate", "woodplate", "woodenpressureplate", "woodenplate"}),
|
||||
REDSTONE_ORE(73, "Redstone ore", "redstoneore"),
|
||||
GLOWING_REDSTONE_ORE(74, "Glowing redstone ore", "glowingredstoneore"),
|
||||
REDSTONE_TORCH_OFF(75, "Redstone torch (off)",
|
||||
new String[] {"redstonetorchoff", "rstorchoff"}),
|
||||
REDSTONE_TORCH_ON(76, "Redstone torch (on)",
|
||||
new String [] {"redstonetorch", "redstonetorchon", "rstorchon"}),
|
||||
STONE_BUTTON(77, "Stone Button", new String[] {"stonebutton", "button"}),
|
||||
SNOW(78, "Snow", "snow"),
|
||||
ICE(79, "Ice", "ice"),
|
||||
SNOW_BLOCK(80, "Snow block", "snowblock"),
|
||||
CACTUS(81, "Cactus", new String[] {"cactus", "cacti"}),
|
||||
CLAY(82, "Clay", "clay"),
|
||||
SUGAR_CANE(83, "Reed", new String[] {"reed", "cane", "sugarcane", "sugarcanes"}),
|
||||
JUKEBOX(84, "Jukebox", new String[] {"jukebox", "stereo", "recordplayer"}),
|
||||
FENCE(85, "Fence", "fence"),
|
||||
PUMPKIN(86, "Pumpkin", "pumpkin"),
|
||||
NETHERRACK(87, "Netherrack",
|
||||
new String[] {"redmossycobblestone", "redcobblestone", "redmosstone",
|
||||
"redcobble", "netherstone", "netherrack", "nether", "hellstone"}),
|
||||
SOUL_SAND(88, "Soul sand",
|
||||
new String[] {"slowmud", "mud", "soulsand", "hellmud"}),
|
||||
GLOWSTONE(89, "Glowstone",
|
||||
new String[] {"brittlegold", "glowstone", "lightstone", "brimstone", "australium"}),
|
||||
PORTAL(90, "Portal", "portal"),
|
||||
JACK_O_LANTERN(91, "Pumpkin (on)",
|
||||
new String[] {"pumpkinlighted", "pumpkinon", "litpumpkin", "jackolantern"}),
|
||||
CAKE(92, "Cake", new String[] {"cake", "cakeblock"}),
|
||||
REDSTONE_REPEATER_OFF(93, "Redstone repeater (off)", new String[] {"diodeoff", "redstonerepeater", "repeater", "delayer"}),
|
||||
REDSTONE_REPEATER_ON(94, "Redstone repeater (on)", new String[] {"diode", "diodeon", "redstonerepeateron", "repeateron", "delayeron"}),
|
||||
LOCKED_CHEST(95, "Locked chest", new String[] {"lockedchest", "steveco", "supplycrate", "valveneedstoworkonep3nottf2kthx"});
|
||||
|
||||
/**
|
||||
* Stores a list of dropped blocks for blocks.
|
||||
*/
|
||||
private static final Map<Integer,Integer> blockDrops = new HashMap<Integer,Integer>();
|
||||
|
||||
/**
|
||||
* Static constructor.
|
||||
*/
|
||||
static {
|
||||
blockDrops.put(1, 4);
|
||||
blockDrops.put(2, 3);
|
||||
blockDrops.put(3, 3);
|
||||
blockDrops.put(4, 4);
|
||||
blockDrops.put(5, 5);
|
||||
blockDrops.put(6, 6);
|
||||
blockDrops.put(7, -1);
|
||||
blockDrops.put(12, 12);
|
||||
blockDrops.put(13, 13);
|
||||
blockDrops.put(14, 14);
|
||||
blockDrops.put(15, 15);
|
||||
blockDrops.put(16, 16);
|
||||
blockDrops.put(17, 17);
|
||||
blockDrops.put(18, 18);
|
||||
blockDrops.put(19, 19);
|
||||
blockDrops.put(20, 20); // Have to drop glass for //undo
|
||||
blockDrops.put(21, 21); // Block damage drops not implemented
|
||||
blockDrops.put(22, 22);
|
||||
blockDrops.put(23, 23);
|
||||
blockDrops.put(24, 24);
|
||||
blockDrops.put(25, 25);
|
||||
blockDrops.put(26, 355);
|
||||
blockDrops.put(27, 27);
|
||||
blockDrops.put(28, 28);
|
||||
blockDrops.put(30, 30);
|
||||
blockDrops.put(35, 35);
|
||||
blockDrops.put(37, 37);
|
||||
blockDrops.put(38, 38);
|
||||
blockDrops.put(39, 39);
|
||||
blockDrops.put(40, 40);
|
||||
blockDrops.put(41, 41);
|
||||
blockDrops.put(42, 42);
|
||||
blockDrops.put(43, 43);
|
||||
blockDrops.put(44, 44);
|
||||
blockDrops.put(45, 45);
|
||||
blockDrops.put(47, 47);
|
||||
blockDrops.put(48, 48);
|
||||
blockDrops.put(49, 49);
|
||||
blockDrops.put(50, 50);
|
||||
blockDrops.put(53, 53);
|
||||
blockDrops.put(54, 54);
|
||||
blockDrops.put(55, 331);
|
||||
blockDrops.put(56, 264);
|
||||
blockDrops.put(57, 57);
|
||||
blockDrops.put(58, 58);
|
||||
blockDrops.put(59, 295);
|
||||
blockDrops.put(60, 60);
|
||||
blockDrops.put(61, 61);
|
||||
blockDrops.put(62, 61);
|
||||
blockDrops.put(63, 323);
|
||||
blockDrops.put(64, 324);
|
||||
blockDrops.put(65, 65);
|
||||
blockDrops.put(66, 66);
|
||||
blockDrops.put(67, 67);
|
||||
blockDrops.put(68, 323);
|
||||
blockDrops.put(69, 69);
|
||||
blockDrops.put(70, 70);
|
||||
blockDrops.put(71, 330);
|
||||
blockDrops.put(72, 72);
|
||||
blockDrops.put(73, 331);
|
||||
blockDrops.put(74, 331);
|
||||
blockDrops.put(75, 76);
|
||||
blockDrops.put(76, 76);
|
||||
blockDrops.put(77, 77);
|
||||
blockDrops.put(78, 332);
|
||||
blockDrops.put(80, 80);
|
||||
blockDrops.put(81, 81);
|
||||
blockDrops.put(82, 82);
|
||||
blockDrops.put(83, 338);
|
||||
blockDrops.put(84, 84);
|
||||
blockDrops.put(85, 85);
|
||||
blockDrops.put(86, 86);
|
||||
blockDrops.put(87, 87);
|
||||
blockDrops.put(88, 88);
|
||||
blockDrops.put(89, 348);
|
||||
blockDrops.put(91, 91);
|
||||
blockDrops.put(92, 354);
|
||||
blockDrops.put(93, 356);
|
||||
blockDrops.put(94, 356);
|
||||
blockDrops.put(95, 95);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a map of the IDs for fast access.
|
||||
*/
|
||||
private static final Map<Integer,BlockType> ids = new HashMap<Integer,BlockType>();
|
||||
/**
|
||||
* Stores a map of the names for fast access.
|
||||
*/
|
||||
private static final Map<String,BlockType> lookup = new HashMap<String,BlockType>();
|
||||
|
||||
private final int id;
|
||||
private final String name;
|
||||
private final String[] lookupKeys;
|
||||
|
||||
static {
|
||||
for(BlockType type : EnumSet.allOf(BlockType.class)) {
|
||||
ids.put(type.id, type);
|
||||
for (String key : type.lookupKeys) {
|
||||
lookup.put(key, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct the type.
|
||||
*
|
||||
* @param id
|
||||
* @param name
|
||||
*/
|
||||
BlockType(int id, String name, String lookupKey) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.lookupKeys = new String[]{lookupKey};
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the type.
|
||||
*
|
||||
* @param id
|
||||
* @param name
|
||||
*/
|
||||
BlockType(int id, String name, String[] lookupKeys) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.lookupKeys = lookupKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return type from ID. May return null.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static BlockType fromID(int id) {
|
||||
return ids.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return type from name. May return null.
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public static BlockType lookup(String name) {
|
||||
return lookup.get(name.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get block numeric ID.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user-friendly block name.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see whether a block should be placed last.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean shouldPlaceLast() {
|
||||
return shouldPlaceLast(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see whether a block should be placed last.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static boolean shouldPlaceLast(int id) {
|
||||
return id == 6 // Saplings
|
||||
|| id == 26 // Beds
|
||||
|| id == 27 // Powered rails
|
||||
|| id == 28 // Detector rails
|
||||
|| id == 37 // Yellow flower
|
||||
|| id == 38 // Red flower
|
||||
|| id == 39 // Brown mushroom
|
||||
|| id == 40 // Red mush room
|
||||
|| id == 50 // Torch
|
||||
|| id == 51 // Fire
|
||||
|| id == 55 // Redstone wire
|
||||
|| id == 59 // Crops
|
||||
|| id == 63 // Sign post
|
||||
|| id == 64 // Wooden door
|
||||
|| id == 65 // Ladder
|
||||
|| id == 66 // Minecart tracks
|
||||
|| id == 68 // Wall sign
|
||||
|| id == 69 // Lever
|
||||
|| id == 70 // Stone pressure plate
|
||||
|| id == 71 // Iron door
|
||||
|| id == 72 // Wooden pressure plate
|
||||
|| id == 75 // Redstone torch (off)
|
||||
|| id == 76 // Redstone torch (on)
|
||||
|| id == 77 // Stone button
|
||||
|| id == 78 // Snow
|
||||
|| id == 81 // Cactus
|
||||
|| id == 83 // Reed
|
||||
|| id == 90 // Portal
|
||||
|| id == 92 // Cake
|
||||
|| id == 93 // Repeater (off)
|
||||
|| id == 94; // Repeater (on)
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a block can be passed through.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static boolean canPassThrough(int id) {
|
||||
return id == 0 // Air
|
||||
|| id == 8 // Water
|
||||
|| id == 9 // Water
|
||||
|| id == 6 // Saplings
|
||||
|| id == 27 // Powered rails
|
||||
|| id == 28 // Detector rails
|
||||
|| id == 30 // Web <- someone will hate me for this
|
||||
|| id == 37 // Yellow flower
|
||||
|| id == 38 // Red flower
|
||||
|| id == 39 // Brown mushroom
|
||||
|| id == 40 // Red mush room
|
||||
|| id == 50 // Torch
|
||||
|| id == 51 // Fire
|
||||
|| id == 55 // Redstone wire
|
||||
|| id == 59 // Crops
|
||||
|| id == 63 // Sign post
|
||||
|| id == 65 // Ladder
|
||||
|| id == 66 // Minecart tracks
|
||||
|| id == 68 // Wall sign
|
||||
|| id == 69 // Lever
|
||||
|| id == 70 // Stone pressure plate
|
||||
|| id == 72 // Wooden pressure plate
|
||||
|| id == 75 // Redstone torch (off)
|
||||
|| id == 76 // Redstone torch (on)
|
||||
|| id == 77 // Stone button
|
||||
|| id == 78 // Snow
|
||||
|| id == 83 // Reed
|
||||
|| id == 90 // Portal
|
||||
|| id == 93 // Diode (off)
|
||||
|| id == 94; // Diode (on)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the block uses its data value.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static boolean usesData(int id) {
|
||||
return id == 6 // Saplings
|
||||
|| id == 8 // Water
|
||||
|| id == 9 // Water
|
||||
|| id == 10 // Lava
|
||||
|| id == 11 // Lava
|
||||
|| id == 17 // Wood
|
||||
|| id == 18 // Leaves
|
||||
|| id == 23 // Dispenser
|
||||
|| id == 25 // Note Block
|
||||
|| id == 26 // Bed
|
||||
|| id == 27 // Powered rails
|
||||
|| id == 28 // Detector rails
|
||||
|| id == 35 // Wool
|
||||
|| id == 43 // Double slab
|
||||
|| id == 44 // Slab
|
||||
|| id == 50 // Torch
|
||||
|| id == 53 // Wooden stairs
|
||||
|| id == 55 // Redstone wire
|
||||
|| id == 59 // Crops
|
||||
|| id == 60 // Soil
|
||||
|| id == 61 // Furnace
|
||||
|| id == 62 // Furnace
|
||||
|| id == 63 // Sign post
|
||||
|| id == 64 // Wooden door
|
||||
|| id == 65 // Ladder
|
||||
|| id == 66 // Minecart track
|
||||
|| id == 67 // Cobblestone stairs
|
||||
|| id == 68 // Wall sign
|
||||
|| id == 69 // Lever
|
||||
|| id == 70 // Stone pressure plate
|
||||
|| id == 71 // Iron door
|
||||
|| id == 72 // Wooden pressure plate
|
||||
|| id == 75 // Redstone torch (off)
|
||||
|| id == 76 // Redstone torch (on)
|
||||
|| id == 77 // Stone button
|
||||
|| id == 81 // Cactus
|
||||
|| id == 86 // Pumpkin
|
||||
|| id == 91 // Jack-o-lantern
|
||||
|| id == 92 // Cake
|
||||
|| id == 93 // Redstone repeater (off)
|
||||
|| id == 94; // Redstone repeater (on)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the block is a container block.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static boolean isContainerBlock(int id) {
|
||||
return id == 23 // Dispenser
|
||||
|| id == 61 // Furnace
|
||||
|| id == 62 // Furnace
|
||||
|| id == 54; // Chest
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a block uses redstone in some way.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static boolean isRedstoneBlock(int id) {
|
||||
return id == 27 // Powered rail
|
||||
|| id == 28 // Detector rail
|
||||
|| id == 69 // Lever
|
||||
|| id == 70 // Stone pressure plate
|
||||
|| id == 72 // Wood pressure plate
|
||||
|| id == 76 // Redstone torch
|
||||
|| id == 75 // Redstone torch
|
||||
|| id == 77 // Stone button
|
||||
|| id == 55 // Redstone wire
|
||||
|| id == 64 // Wooden door
|
||||
|| id == 71 // Iron door
|
||||
|| id == 46 // TNT
|
||||
|| id == 23 // Dispenser
|
||||
|| id == 25 // Note block
|
||||
|| id == 93 // Diode (off)
|
||||
|| id == 94; // Diode (on)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a block can transfer redstone.
|
||||
* Made this since isRedstoneBlock was getting big.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static boolean canTransferRedstone(int id) {
|
||||
return id == 75 // Redstone torch (off)
|
||||
|| id == 76 // Redstone torch (on)
|
||||
|| id == 55 // Redstone wire
|
||||
|| id == 93 // Diode (off)
|
||||
|| id == 94; // Diode (on)
|
||||
}
|
||||
|
||||
/**
|
||||
* Yay for convenience methods.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static boolean isRedstoneSource(int id) {
|
||||
return id == 28 // Detector rail
|
||||
|| id == 75 // Redstone torch (off)
|
||||
|| id == 76 // Redstone torch (on)
|
||||
|| id == 69 // Lever
|
||||
|| id == 70 // Stone plate
|
||||
|| id == 72 // Wood plate
|
||||
|| id == 77; // Button
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the block or item that would have been dropped. If nothing is
|
||||
* dropped, 0 will be returned. If the block should not be destroyed
|
||||
* (i.e. bedrock), -1 will be returned.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static int getDroppedBlock(int id) {
|
||||
Integer dropped = blockDrops.get(id);
|
||||
if (dropped == null) {
|
||||
return 0;
|
||||
}
|
||||
return dropped;
|
||||
}
|
||||
}
|
165
src/main/java/com/sk89q/worldedit/blocks/ChestBlock.java
Normal file
165
src/main/java/com/sk89q/worldedit/blocks/ChestBlock.java
Normal file
@ -0,0 +1,165 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
import com.sk89q.jnbt.*;
|
||||
import com.sk89q.worldedit.data.*;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Represents chests.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class ChestBlock extends BaseBlock implements TileEntityBlock, ContainerBlock {
|
||||
/**
|
||||
* Store the list of items.
|
||||
*/
|
||||
private BaseItemStack[] items;
|
||||
|
||||
/**
|
||||
* Construct the chest block.
|
||||
*/
|
||||
public ChestBlock() {
|
||||
super(54);
|
||||
items = new BaseItemStack[27];
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the chest block.
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
public ChestBlock(int data) {
|
||||
super(54, data);
|
||||
items = new BaseItemStack[27];
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the chest block.
|
||||
*
|
||||
* @param data
|
||||
* @param items
|
||||
*/
|
||||
public ChestBlock(int data, BaseItemStack[] items) {
|
||||
super(54, data);
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of items.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public BaseItemStack[] getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the list of items.
|
||||
*/
|
||||
public void setItems(BaseItemStack[] items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tile entity ID.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getTileEntityID() {
|
||||
return "Chest";
|
||||
}
|
||||
|
||||
/**
|
||||
* Store additional tile entity data. Returns true if the data is used.
|
||||
*
|
||||
* @return map of values
|
||||
* @throws DataException
|
||||
*/
|
||||
public Map<String,Tag> toTileEntityNBT()
|
||||
throws DataException {
|
||||
List<Tag> itemsList = new ArrayList<Tag>();
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
BaseItemStack item = items[i];
|
||||
if (item != null) {
|
||||
Map<String,Tag> data = new HashMap<String,Tag>();
|
||||
CompoundTag itemTag = new CompoundTag("Items", data);
|
||||
data.put("id", new ShortTag("id", (short)item.getType()));
|
||||
data.put("Damage", new ShortTag("Damage", item.getDamage()));
|
||||
data.put("Count", new ByteTag("Count", (byte)item.getAmount()));
|
||||
data.put("Slot", new ByteTag("Slot", (byte)i));
|
||||
itemsList.add(itemTag);
|
||||
}
|
||||
}
|
||||
Map<String,Tag> values = new HashMap<String,Tag>();
|
||||
values.put("Items", new ListTag("Items", CompoundTag.class, itemsList));
|
||||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get additional information from the title entity data.
|
||||
*
|
||||
* @param values
|
||||
* @throws DataException
|
||||
*/
|
||||
public void fromTileEntityNBT(Map<String,Tag> values)
|
||||
throws DataException {
|
||||
if (values == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Tag t = values.get("id");
|
||||
if (!(t instanceof StringTag) || !((StringTag)t).getValue().equals("Chest")) {
|
||||
throw new DataException("'Chest' tile entity expected");
|
||||
}
|
||||
|
||||
ListTag items = (ListTag)Chunk.getChildTag(values, "Items", ListTag.class);
|
||||
BaseItemStack[] newItems = new BaseItemStack[27];
|
||||
|
||||
for (Tag tag : items.getValue()) {
|
||||
if (!(tag instanceof CompoundTag)) {
|
||||
throw new DataException("CompoundTag expected as child tag of Chest's Items");
|
||||
}
|
||||
|
||||
CompoundTag item = (CompoundTag)tag;
|
||||
Map<String,Tag> itemValues = item.getValue();
|
||||
|
||||
short id = (Short)((ShortTag)Chunk.getChildTag(itemValues, "id", ShortTag.class))
|
||||
.getValue();
|
||||
short damage = (Short)((ShortTag)Chunk.getChildTag(itemValues, "Damage", ShortTag.class))
|
||||
.getValue();
|
||||
byte count = (Byte)((ByteTag)Chunk.getChildTag(itemValues, "Count", ByteTag.class))
|
||||
.getValue();
|
||||
byte slot = (Byte)((ByteTag)Chunk.getChildTag(itemValues, "Slot", ByteTag.class))
|
||||
.getValue();
|
||||
|
||||
if (slot >= 0 && slot <= 26) {
|
||||
newItems[slot] = new BaseItemStack(id, count, damage);
|
||||
}
|
||||
}
|
||||
|
||||
this.items = newItems;
|
||||
}
|
||||
}
|
133
src/main/java/com/sk89q/worldedit/blocks/ClothColor.java
Normal file
133
src/main/java/com/sk89q/worldedit/blocks/ClothColor.java
Normal file
@ -0,0 +1,133 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.EnumSet;
|
||||
|
||||
/**
|
||||
* Cloth colors.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public enum ClothColor {
|
||||
WHITE(0, "White", "white"),
|
||||
ORANGE(1, "Orange", "orange"),
|
||||
MAGENTA(2, "Magenta", "magenta"),
|
||||
LIGHT_BLUE(3, "Light blue", "lightblue"),
|
||||
YELLOW(4, "Yellow", "yellow"),
|
||||
LIGHT_GREEN(5, "Light green", "lightgreen"),
|
||||
PINK(6, "Pink", new String[] {"pink", "lightred"}),
|
||||
GRAY(7, "Gray", new String[] {"grey", "gray"}),
|
||||
LIGHT_GRAY(8, "Light gray", new String[] {"lightgrey", "lightgray"}),
|
||||
CYAN(9, "Cyan", new String[] {"cyan", "turquoise"}),
|
||||
PURPLE(10, "Purple", new String[] {"purple", "violet"}),
|
||||
BLUE(11, "Blue", "blue"),
|
||||
BROWN(12, "Brown", new String[] {"brown", "cocoa", "coffee"}),
|
||||
DARK_GREEN(13, "Dark green", new String[] {"green", "darkgreen", "cactusgreen", "cactigreen"}),
|
||||
RED(14, "Red", "red"),
|
||||
BLACK(15, "Black", "black");
|
||||
|
||||
/**
|
||||
* Stores a map of the IDs for fast access.
|
||||
*/
|
||||
private static final Map<Integer,ClothColor> ids = new HashMap<Integer,ClothColor>();
|
||||
/**
|
||||
* Stores a map of the names for fast access.
|
||||
*/
|
||||
private static final Map<String,ClothColor> lookup = new HashMap<String,ClothColor>();
|
||||
|
||||
private final int id;
|
||||
private final String name;
|
||||
private final String[] lookupKeys;
|
||||
|
||||
static {
|
||||
for (ClothColor type : EnumSet.allOf(ClothColor.class)) {
|
||||
ids.put(type.id, type);
|
||||
for (String key : type.lookupKeys) {
|
||||
lookup.put(key, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct the type.
|
||||
*
|
||||
* @param id
|
||||
* @param name
|
||||
*/
|
||||
ClothColor(int id, String name, String lookupKey) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.lookupKeys = new String[]{lookupKey};
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the type.
|
||||
*
|
||||
* @param id
|
||||
* @param name
|
||||
*/
|
||||
ClothColor(int id, String name, String[] lookupKeys) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.lookupKeys = lookupKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return type from ID. May return null.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static ClothColor fromID(int id) {
|
||||
return ids.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return type from name. May return null.
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public static ClothColor lookup(String name) {
|
||||
return lookup.get(name.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get item numeric ID.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user-friendly item name.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
41
src/main/java/com/sk89q/worldedit/blocks/ContainerBlock.java
Normal file
41
src/main/java/com/sk89q/worldedit/blocks/ContainerBlock.java
Normal file
@ -0,0 +1,41 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
/**
|
||||
* Represents a block that stores items.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public interface ContainerBlock {
|
||||
/**
|
||||
* Get the list of items.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public BaseItemStack[] getItems();
|
||||
|
||||
/**
|
||||
* Set the list of items.
|
||||
*
|
||||
* @param items
|
||||
*/
|
||||
public void setItems(BaseItemStack[] items);
|
||||
}
|
165
src/main/java/com/sk89q/worldedit/blocks/DispenserBlock.java
Normal file
165
src/main/java/com/sk89q/worldedit/blocks/DispenserBlock.java
Normal file
@ -0,0 +1,165 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
import com.sk89q.jnbt.*;
|
||||
import com.sk89q.worldedit.data.*;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Represents dispensers.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class DispenserBlock extends BaseBlock implements TileEntityBlock, ContainerBlock {
|
||||
/**
|
||||
* Store the list of items.
|
||||
*/
|
||||
private BaseItemStack[] items;
|
||||
|
||||
/**
|
||||
* Construct the chest block.
|
||||
*/
|
||||
public DispenserBlock() {
|
||||
super(54);
|
||||
items = new BaseItemStack[9];
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the chest block.
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
public DispenserBlock(int data) {
|
||||
super(23, data);
|
||||
items = new BaseItemStack[9];
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the chest block.
|
||||
*
|
||||
* @param data
|
||||
* @param items
|
||||
*/
|
||||
public DispenserBlock(int data, BaseItemStack[] items) {
|
||||
super(23, data);
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of items.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public BaseItemStack[] getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the list of items.
|
||||
*/
|
||||
public void setItems(BaseItemStack[] items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tile entity ID.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getTileEntityID() {
|
||||
return "Trap";
|
||||
}
|
||||
|
||||
/**
|
||||
* Store additional tile entity data. Returns true if the data is used.
|
||||
*
|
||||
* @return map of values
|
||||
* @throws DataException
|
||||
*/
|
||||
public Map<String,Tag> toTileEntityNBT()
|
||||
throws DataException {
|
||||
List<Tag> itemsList = new ArrayList<Tag>();
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
BaseItemStack item = items[i];
|
||||
if (item != null) {
|
||||
Map<String,Tag> data = new HashMap<String,Tag>();
|
||||
CompoundTag itemTag = new CompoundTag("Items", data);
|
||||
data.put("id", new ShortTag("id", (short)item.getType()));
|
||||
data.put("Damage", new ShortTag("Damage", item.getDamage()));
|
||||
data.put("Count", new ByteTag("Count", (byte)item.getAmount()));
|
||||
data.put("Slot", new ByteTag("Slot", (byte)i));
|
||||
itemsList.add(itemTag);
|
||||
}
|
||||
}
|
||||
Map<String,Tag> values = new HashMap<String,Tag>();
|
||||
values.put("Items", new ListTag("Items", CompoundTag.class, itemsList));
|
||||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get additional information from the title entity data.
|
||||
*
|
||||
* @param values
|
||||
* @throws DataException
|
||||
*/
|
||||
public void fromTileEntityNBT(Map<String,Tag> values)
|
||||
throws DataException {
|
||||
if (values == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Tag t = values.get("id");
|
||||
if (!(t instanceof StringTag) || !((StringTag)t).getValue().equals("Trap")) {
|
||||
throw new DataException("'Trap' tile entity expected");
|
||||
}
|
||||
|
||||
ListTag items = (ListTag)Chunk.getChildTag(values, "Items", ListTag.class);
|
||||
BaseItemStack[] newItems = new BaseItemStack[27];
|
||||
|
||||
for (Tag tag : items.getValue()) {
|
||||
if (!(tag instanceof CompoundTag)) {
|
||||
throw new DataException("CompoundTag expected as child tag of Trap Items");
|
||||
}
|
||||
|
||||
CompoundTag item = (CompoundTag)tag;
|
||||
Map<String,Tag> itemValues = item.getValue();
|
||||
|
||||
short id = (Short)((ShortTag)Chunk.getChildTag(itemValues, "id", ShortTag.class))
|
||||
.getValue();
|
||||
short damage = (Short)((ShortTag)Chunk.getChildTag(itemValues, "Damage", ShortTag.class))
|
||||
.getValue();
|
||||
byte count = (Byte)((ByteTag)Chunk.getChildTag(itemValues, "Count", ByteTag.class))
|
||||
.getValue();
|
||||
byte slot = (Byte)((ByteTag)Chunk.getChildTag(itemValues, "Slot", ByteTag.class))
|
||||
.getValue();
|
||||
|
||||
if (slot >= 0 && slot <= 26) {
|
||||
newItems[slot] = new BaseItemStack(id, count, damage);
|
||||
}
|
||||
}
|
||||
|
||||
this.items = newItems;
|
||||
}
|
||||
}
|
218
src/main/java/com/sk89q/worldedit/blocks/FurnaceBlock.java
Normal file
218
src/main/java/com/sk89q/worldedit/blocks/FurnaceBlock.java
Normal file
@ -0,0 +1,218 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
import com.sk89q.jnbt.*;
|
||||
import com.sk89q.worldedit.data.*;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Represents furnaces.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class FurnaceBlock extends BaseBlock implements TileEntityBlock, ContainerBlock {
|
||||
/**
|
||||
* Store the list of items.
|
||||
*/
|
||||
private BaseItemStack[] items;
|
||||
|
||||
/**
|
||||
* Fuel time.
|
||||
*/
|
||||
private short burnTime;
|
||||
|
||||
/**
|
||||
* Cook time.
|
||||
*/
|
||||
private short cookTime;
|
||||
|
||||
/**
|
||||
* Construct the chest block.
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
public FurnaceBlock(int type) {
|
||||
super(type);
|
||||
items = new BaseItemStack[2];
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the chest block.
|
||||
*
|
||||
* @param type
|
||||
* @param data
|
||||
*/
|
||||
public FurnaceBlock(int type, int data) {
|
||||
super(type, data);
|
||||
items = new BaseItemStack[2];
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the chest block.
|
||||
*
|
||||
* @param type
|
||||
* @param data
|
||||
* @param items
|
||||
*/
|
||||
public FurnaceBlock(int type, int data, BaseItemStack[] items) {
|
||||
super(type, data);
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of items.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public BaseItemStack[] getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the list of items.
|
||||
*/
|
||||
public void setItems(BaseItemStack[] items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the burnTime
|
||||
*/
|
||||
public short getBurnTime() {
|
||||
return burnTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param burnTime the burnTime to set
|
||||
*/
|
||||
public void setBurnTime(short burnTime) {
|
||||
this.burnTime = burnTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the cookTime
|
||||
*/
|
||||
public short getCookTime() {
|
||||
return cookTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cookTime the cookTime to set
|
||||
*/
|
||||
public void setCookTime(short cookTime) {
|
||||
this.cookTime = cookTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tile entity ID.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getTileEntityID() {
|
||||
return "Furnace";
|
||||
}
|
||||
|
||||
/**
|
||||
* Store additional tile entity data. Returns true if the data is used.
|
||||
*
|
||||
* @return map of values
|
||||
* @throws DataException
|
||||
*/
|
||||
public Map<String,Tag> toTileEntityNBT()
|
||||
throws DataException {
|
||||
List<Tag> itemsList = new ArrayList<Tag>();
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
BaseItemStack item = items[i];
|
||||
if (item != null) {
|
||||
Map<String,Tag> data = new HashMap<String,Tag>();
|
||||
CompoundTag itemTag = new CompoundTag("Items", data);
|
||||
data.put("id", new ShortTag("id", (short)item.getType()));
|
||||
data.put("Damage", new ShortTag("Damage", item.getDamage()));
|
||||
data.put("Count", new ByteTag("Count", (byte)item.getAmount()));
|
||||
data.put("Slot", new ByteTag("Slot", (byte)i));
|
||||
itemsList.add(itemTag);
|
||||
}
|
||||
}
|
||||
Map<String,Tag> values = new HashMap<String,Tag>();
|
||||
values.put("Items", new ListTag("Items", CompoundTag.class, itemsList));
|
||||
values.put("BurnTime", new ShortTag("BurnTime", burnTime));
|
||||
values.put("CookTime", new ShortTag("CookTime", cookTime));
|
||||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get additional information from the title entity data.
|
||||
*
|
||||
* @param values
|
||||
* @throws DataException
|
||||
*/
|
||||
public void fromTileEntityNBT(Map<String,Tag> values)
|
||||
throws DataException {
|
||||
if (values == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Tag t = values.get("id");
|
||||
if (!(t instanceof StringTag) || !((StringTag)t).getValue().equals("Furnace")) {
|
||||
throw new DataException("'Furnace' tile entity expected");
|
||||
}
|
||||
|
||||
ListTag items = (ListTag)Chunk.getChildTag(values, "Items", ListTag.class);
|
||||
BaseItemStack[] newItems = new BaseItemStack[27];
|
||||
|
||||
for (Tag tag : items.getValue()) {
|
||||
if (!(tag instanceof CompoundTag)) {
|
||||
throw new DataException("CompoundTag expected as child tag of Trap Items");
|
||||
}
|
||||
|
||||
CompoundTag item = (CompoundTag)tag;
|
||||
Map<String,Tag> itemValues = item.getValue();
|
||||
|
||||
short id = (Short)((ShortTag)Chunk.getChildTag(itemValues, "id", ShortTag.class))
|
||||
.getValue();
|
||||
short damage = (Short)((ShortTag)Chunk.getChildTag(itemValues, "Damage", ShortTag.class))
|
||||
.getValue();
|
||||
byte count = (Byte)((ByteTag)Chunk.getChildTag(itemValues, "Count", ByteTag.class))
|
||||
.getValue();
|
||||
byte slot = (Byte)((ByteTag)Chunk.getChildTag(itemValues, "Slot", ByteTag.class))
|
||||
.getValue();
|
||||
|
||||
if (slot >= 0 && slot <= 26) {
|
||||
newItems[slot] = new BaseItemStack(id, count, damage);
|
||||
}
|
||||
}
|
||||
|
||||
this.items = newItems;
|
||||
|
||||
t = values.get("BurnTime");
|
||||
if (t instanceof ShortTag) {
|
||||
burnTime = ((ShortTag)t).getValue();
|
||||
}
|
||||
|
||||
t = values.get("CookTime");
|
||||
if (t instanceof ShortTag) {
|
||||
cookTime = ((ShortTag)t).getValue();
|
||||
}
|
||||
}
|
||||
}
|
411
src/main/java/com/sk89q/worldedit/blocks/ItemType.java
Normal file
411
src/main/java/com/sk89q/worldedit/blocks/ItemType.java
Normal file
@ -0,0 +1,411 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.EnumSet;
|
||||
|
||||
/**
|
||||
* ItemType types.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public enum ItemType {
|
||||
// Blocks
|
||||
AIR(0, "Air", "air"),
|
||||
STONE(1, "Stone", new String[] {"stone", "rock"}),
|
||||
GRASS(2, "Grass", "grass"),
|
||||
DIRT(3, "Dirt", "dirt"),
|
||||
COBBLESTONE(4, "Cobblestone", new String[] {"cobblestone", "cobble"}),
|
||||
WOOD(5, "Wood", new String[] {"wood", "woodplank", "plank", "woodplanks", "planks"}),
|
||||
SAPLING(6, "Sapling", "sapling"),
|
||||
BEDROCK(7, "Bedrock", new String[] {"adminium", "bedrock"}),
|
||||
WATER(8, "Water", new String[] {"watermoving", "movingwater"}),
|
||||
STATIONARY_WATER(9, "Water (stationary)",
|
||||
new String[] {"water", "waterstationary", "stationarywater", "stillwater"}),
|
||||
LAVA(10, "Lava", new String[] {"lavamoving", "movinglava"}),
|
||||
STATIONARY_LAVA(11, "Lava (stationary)",
|
||||
new String[] {"lava", "lavastationary", "stationarylava", "stilllava"}),
|
||||
SAND(12, "Sand", "sand"),
|
||||
GRAVEL(13, "Gravel", "gravel"),
|
||||
GOLD_ORE(14, "Gold ore", "goldore"),
|
||||
IRON_ORE(15, "Iron ore", "ironore"),
|
||||
COAL_ORE(16, "Coal ore", "coalore"),
|
||||
LOG(17, "Log", new String[] {"log", "tree", "pine", "oak", "birch", "redwood"}),
|
||||
LEAVES(18, "Leaves", new String[] {"leaves", "leaf"}),
|
||||
SPONGE(19, "Sponge", "sponge"),
|
||||
GLASS(20, "Glass", "glass"),
|
||||
LAPIS_LAZULI_ORE(21, "Lapis lazuli ore", new String[] {"lapislazuliore", "blueore", "lapisore"}),
|
||||
LAPIS_LAZULI(22, "Lapis lazuli", new String[] {"lapislazuli", "lapislazuliblock", "bluerock"}),
|
||||
DISPENSER(23, "Dispenser", "dispenser"),
|
||||
SANDSTONE(24, "Sandstone", "sandstone"),
|
||||
NOTE_BLOCK(25, "Note block", new String[] {"musicblock", "noteblock", "note", "music", "instrument"}),
|
||||
BED(26, "Bed", "bed"),
|
||||
POWERED_RAIL(27, "Powered Rail",
|
||||
new String[] {"poweredrail", "boosterrail", "poweredtrack", "boostertrack"}),
|
||||
DETECTOR_RAIL(28, "Detector Rail", "detectorrail"),
|
||||
WEB(30, "Web", new String[] {"web", "spiderweb"}),
|
||||
CLOTH(35, "Wool", new String[] {"cloth", "wool"}),
|
||||
YELLOW_FLOWER(37, "Yellow flower", new String[] {"yellowflower", "flower"}),
|
||||
RED_FLOWER(38, "Red rose", new String[] {"redflower", "redrose", "rose"}),
|
||||
BROWN_MUSHROOM(39, "Brown mushroom", new String[] {"brownmushroom", "mushroom"}),
|
||||
RED_MUSHROOM(40, "Red mushroom", "redmushroom"),
|
||||
GOLD_BLOCK(41, "Gold block", new String[] {"gold", "goldblock"}),
|
||||
IRON_BLOCK(42, "Iron block", new String[] {"iron", "ironblock"}),
|
||||
DOUBLE_STEP(43, "Double step", new String[] {"doubleslab", "doublestoneslab", "doublestep"}),
|
||||
STEP(44, "Step", new String[] {"slab", "stoneslab", "step", "halfstep"}),
|
||||
BRICK(45, "Brick", new String[] {"brick", "brickblock"}),
|
||||
TNT(46, "TNT", "tnt"),
|
||||
BOOKCASE(47, "Bookcase", new String[] {"bookshelf", "bookshelves"}),
|
||||
MOSSY_COBBLESTONE(48, "Cobblestone (mossy)",
|
||||
new String[] {"mossycobblestone", "mossstone", "mossystone",
|
||||
"mosscobble", "mossycobble", "moss", "mossy", "sossymobblecone"}),
|
||||
OBSIDIAN(49, "Obsidian", "obsidian"),
|
||||
TORCH(50, "Torch", "torch"),
|
||||
FIRE(51, "Fire", new String[] {"fire", "flame", "flames"}),
|
||||
MOB_SPAWNER(52, "Mob spawner", new String[] {"mobspawner", "spawner"}),
|
||||
WOODEN_STAIRS(53, "Wooden stairs",
|
||||
new String[] {"woodstair", "woodstairs", "woodenstair", "woodenstairs"}),
|
||||
CHEST(54, "Chest", new String[] {"chest", "storage"}),
|
||||
REDSTONE_WIRE(55, "Redstone wire", "redstone"),
|
||||
DIAMOND_ORE(56, "Diamond ore", "diamondore"),
|
||||
DIAMOND_BLOCK(57, "Diamond block", new String[] {"diamond", "diamondblock"}),
|
||||
WORKBENCH(58, "Workbench", new String[] {"workbench", "table", "craftingtable"}),
|
||||
CROPS(59, "Crops", new String[] {"crops", "crop", "plant", "plants"}),
|
||||
SOIL(60, "Soil", new String[] {"soil", "farmland"}),
|
||||
FURNACE(61, "Furnace", "furnace"),
|
||||
BURNING_FURNACE(62, "Furnace (burning)", new String[] {"burningfurnace", "litfurnace"}),
|
||||
SIGN_POST(63, "Sign post", new String[] {"sign", "signpost"}),
|
||||
WOODEN_DOOR(64, "Wooden door", new String[] {"wooddoor", "woodendoor", "door"}),
|
||||
LADDER(65, "Ladder", "ladder"),
|
||||
MINECART_TRACKS(66, "Minecart tracks",
|
||||
new String[] {"track", "tracks", "minecrattrack", "minecarttracks", "rails", "rail"}),
|
||||
COBBLESTONE_STAIRS(67, "Cobblestone stairs",
|
||||
new String[] {"cobblestonestair", "cobblestonestairs", "cobblestair", "cobblestairs"}),
|
||||
WALL_SIGN(68, "Wall sign", "wallsign"),
|
||||
LEVER(69, "Lever", new String[] {"lever", "switch", "stonelever", "stoneswitch"}),
|
||||
STONE_PRESSURE_PLATE(70, "Stone pressure plate",
|
||||
new String[] {"stonepressureplate", "stoneplate"}),
|
||||
IRON_DOOR(71, "Iron Door", "irondoor"),
|
||||
WOODEN_PRESSURE_PLATE(72, "Wooden pressure plate",
|
||||
new String[] {"woodpressureplate", "woodplate", "woodenpressureplate", "woodenplate"}),
|
||||
REDSTONE_ORE(73, "Redstone ore", "redstoneore"),
|
||||
GLOWING_REDSTONE_ORE(74, "Glowing redstone ore", "glowingredstoneore"),
|
||||
REDSTONE_TORCH_OFF(75, "Redstone torch (off)",
|
||||
new String[] {"redstonetorchoff", "rstorchoff"}),
|
||||
REDSTONE_TORCH_ON(76, "Redstone torch (on)",
|
||||
new String [] {"redstonetorch", "redstonetorchon", "rstorchon"}),
|
||||
STONE_BUTTON(77, "Stone Button", new String[] {"stonebutton", "button"}),
|
||||
SNOW(78, "Snow", "snow"),
|
||||
ICE(79, "Ice", "ice"),
|
||||
SNOW_BLOCK(80, "Snow block", "snowblock"),
|
||||
CACTUS(81, "Cactus", new String[] {"cactus", "cacti"}),
|
||||
CLAY(82, "Clay", "clay"),
|
||||
SUGAR_CANE(83, "Reed", new String[] {"reed", "cane", "sugarcane", "sugarcanes"}),
|
||||
JUKEBOX(84, "Jukebox", new String[] {"jukebox", "stereo", "recordplayer"}),
|
||||
FENCE(85, "Fence", "fence"),
|
||||
PUMPKIN(86, "Pumpkin", "pumpkin"),
|
||||
NETHERRACK(87, "Netherrack",
|
||||
new String[] {"redmossycobblestone", "redcobblestone", "redmosstone",
|
||||
"redcobble", "netherstone", "netherrack", "nether", "hellstone"}),
|
||||
SOUL_SAND(88, "Soul sand",
|
||||
new String[] {"slowmud", "mud", "soulsand", "hellmud"}),
|
||||
GLOWSTONE(89, "Glowstone",
|
||||
new String[] {"brittlegold", "glowstone", "lightstone", "brimstone", "australium"}),
|
||||
PORTAL(90, "Portal", "portal"),
|
||||
JACK_O_LANTERN(91, "Pumpkin (on)",
|
||||
new String[] {"pumpkinlighted", "pumpkinon", "litpumpkin", "jackolantern"}),
|
||||
CAKE(92, "Cake", new String[] {"cake", "cakeblock"}),
|
||||
REDSTONE_REPEATER_OFF(93, "Redstone repeater (off)", new String[] {"diodeoff", "redstonerepeater", "repeater", "delayer"}),
|
||||
REDSTONE_REPEATER_ON(94, "Redstone repeater (on)", new String[] {"diode", "diodeon", "redstonerepeateron", "repeateron", "delayeron"}),
|
||||
LOCKED_CHEST(95, "Locked chest", new String[] {"lockedchest", "steveco", "supplycrate", "valveneedstoworkonep3nottf2kthx"}),
|
||||
|
||||
// Items
|
||||
IRON_SHOVEL(256, "Iron shovel", "ironshovel"),
|
||||
IRON_PICK(257, "Iron pick", new String[] {"ironpick", "ironpickaxe"}),
|
||||
IRON_AXE(258, "Iron axe", "ironaxe"),
|
||||
FLINT_AND_TINDER(259, "Flint and tinder",
|
||||
new String[] {"flintandtinder", "lighter", "flintandsteel", "flintsteel",
|
||||
"flintandiron", "flintnsteel", "flintniron", "flintntinder"}),
|
||||
RED_APPLE(260, "Red apple", new String[] {"redapple", "apple"}),
|
||||
BOW(261, "Bow", "bow"),
|
||||
ARROW(262, "Arrow", "arrow"),
|
||||
COAL(263, "Coal", "coal"),
|
||||
DIAMOND(264, "Diamond", "diamond"),
|
||||
IRON_BAR(265, "Iron bar", "ironbar"),
|
||||
GOLD_BAR(266, "Gold bar", "goldbar"),
|
||||
IRON_SWORD(267, "Iron sword", "ironsword"),
|
||||
WOOD_SWORD(268, "Wooden sword", "woodsword"),
|
||||
WOOD_SHOVEL(269, "Wooden shovel", "woodshovel"),
|
||||
WOOD_PICKAXE(270, "Wooden pickaxe", new String[] {"woodpick", "woodpickaxe"}),
|
||||
WOOD_AXE(271, "Wooden axe", "woodaxe"),
|
||||
STONE_SWORD(272, "Stone sword", "stonesword"),
|
||||
STONE_SHOVEL(273, "Stone shovel", "stoneshovel"),
|
||||
STONE_PICKAXE(274, "Stone pickaxe", new String[] {"stonepick", "stonepickaxe"}),
|
||||
STONE_AXE(275, "Stone pickaxe", "stoneaxe"),
|
||||
DIAMOND_SWORD(276, "Diamond sword", "diamondsword"),
|
||||
DIAMOND_SHOVEL(277, "Diamond shovel", "diamondshovel"),
|
||||
DIAMOND_PICKAXE(278, "Diamond pickaxe", new String[] {"diamondpick", "diamondpickaxe"}),
|
||||
DIAMOND_AXE(279, "Diamond axe", "diamondaxe"),
|
||||
STICK(280, "Stick", "stick"),
|
||||
BOWL(281, "Bowl", "bowl"),
|
||||
MUSHROOM_SOUP(282, "Mushroom soup", new String[] {"mushroomsoup", "soup", "brbsoup"}),
|
||||
GOLD_SWORD(283, "Golden sword", "goldsword"),
|
||||
GOLD_SHOVEL(284, "Golden shovel", "goldshovel"),
|
||||
GOLD_PICKAXE(285, "Golden pickaxe", new String[] {"goldpick", "goldpickaxe"}),
|
||||
GOLD_AXE(286, "Golden axe", "goldaxe"),
|
||||
STRING(287, "String", "string"),
|
||||
FEATHER(288, "Feather", "feather"),
|
||||
SULPHUR(289, "Sulphur", new String[] {"sulphur", "sulfur", "gunpowder"}),
|
||||
WOOD_HOE(290, "Wooden hoe", "woodhoe"),
|
||||
STONE_HOE(291, "Stone hoe", "stonehoe"),
|
||||
IRON_HOE(292, "Iron hoe", "ironhoe"),
|
||||
DIAMOND_HOE(293, "Diamond hoe", "diamondhoe"),
|
||||
GOLD_HOE(294, "Golden hoe", "goldhoe"),
|
||||
SEEDS(295, "Seeds", new String[] {"seeds", "seed"}),
|
||||
WHEAT(296, "Wheat", "wheat"),
|
||||
BREAD(297, "Bread", "bread"),
|
||||
LEATHER_HELMET(298, "Leather helmet", "leatherhelmet"),
|
||||
LEATHER_CHEST(299, "Leather chestplate", "leatherchest"),
|
||||
LEATHER_PANTS(300, "Leather pants", "leatherpants"),
|
||||
LEATHER_BOOTS(301, "Leather boots", "leatherboots"),
|
||||
CHAINMAIL_HELMET(302, "Chainmail helmet", "chainmailhelmet"),
|
||||
CHAINMAIL_CHEST(303, "Chainmail chestplate", "chainmailchest"),
|
||||
CHAINMAIL_PANTS(304, "Chainmail pants", "chainmailpants"),
|
||||
CHAINMAIL_BOOTS(305, "Chainmail boots", "chainmailboots"),
|
||||
IRON_HELMET(306, "Iron helmet", "ironhelmet"),
|
||||
IRON_CHEST(307, "Iron chestplate", "ironchest"),
|
||||
IRON_PANTS(308, "Iron pants", "ironpants"),
|
||||
IRON_BOOTS(309, "Iron boots", "ironboots"),
|
||||
DIAMOND_HELMET(310, "Diamond helmet", "diamondhelmet"),
|
||||
DIAMOND_CHEST(311, "Diamond chestplate", "diamondchest"),
|
||||
DIAMOND_PANTS(312, "Diamond pants", "diamondpants"),
|
||||
DIAMOND_BOOTS(313, "Diamond boots", "diamondboots"),
|
||||
GOLD_HELMET(314, "Gold helmet", "goldhelmet"),
|
||||
GOLD_CHEST(315, "Gold chestplate", "goldchest"),
|
||||
GOLD_PANTS(316, "Gold pants", "goldpants"),
|
||||
GOLD_BOOTS(317, "Gold boots", "goldboots"),
|
||||
FLINT(318, "Flint", "flint"),
|
||||
RAW_PORKCHOP(319, "Raw porkchop",
|
||||
new String[] {"rawpork", "rawporkchop", "rawbacon", "baconstrips", "rawmeat"}),
|
||||
COOKED_PORKCHOP(320, "Cooked porkchop",
|
||||
new String[] {"pork", "cookedpork", "cookedporkchop", "cookedbacon", "bacon", "meat"}),
|
||||
PAINTING(321, "Painting", "painting"),
|
||||
GOLD_APPLE(322, "Golden apple", new String[] {"goldapple", "goldenapple"}),
|
||||
SIGN(323, "Wooden sign", "sign"),
|
||||
WOODEN_DOOR_ITEM(324, "Wooden door", new String[] {"wooddoor", "door"}),
|
||||
BUCKET(325, "Bucket", new String[] {"bucket", "bukkit"}),
|
||||
WATER_BUCKET(326, "Water bucket", new String[] {"waterbucket", "waterbukkit"}),
|
||||
LAVA_BUCKET(327, "Lava bucket", new String[] {"lavabucket", "lavabukkit"}),
|
||||
MINECART(328, "Minecart", new String[] {"minecart", "cart"}),
|
||||
SADDLE(329, "Saddle", "saddle"),
|
||||
IRON_DOOR_ITEM(330, "Iron door", "irondoor"),
|
||||
REDSTONE_DUST(331, "Redstone dust", new String[] {"redstonedust", "reddust"}),
|
||||
SNOWBALL(332, "Snowball", "snowball"),
|
||||
WOOD_BOAT(333, "Wooden boat", new String[] {"woodboat", "woodenboat", "boat"}),
|
||||
LEATHER(334, "Leather", new String[] {"leather", "cowhide"}),
|
||||
MILK_BUCKET(335, "Milk bucket", new String[] {"milkbucket", "milk", "milkbukkit"}),
|
||||
BRICK_BAR(336, "Brick", "brick"),
|
||||
CLAY_BALL(337, "Clay", "clay"),
|
||||
SUGAR_CANE_ITEM(338, "Sugar cane", new String[] {"sugarcane", "reed", "reeds"}),
|
||||
PAPER(339, "Paper", "paper"),
|
||||
BOOK(340, "Book", "book"),
|
||||
SLIME_BALL(341, "Slime ball", new String[] {"slimeball", "slime"}),
|
||||
STORAGE_MINECART(342, "Storage minecart", new String[] {"storageminecart", "storagecart"}),
|
||||
POWERED_MINECART(343, "Powered minecart", new String[] {"poweredminecart", "poweredcart"}),
|
||||
EGG(344, "Egg", "egg"),
|
||||
COMPASS(345, "Compass", "compass"),
|
||||
FISHING_ROD(346, "Fishing rod", new String[] {"fishingrod", "fishingpole"}),
|
||||
WATCH(347, "Watch", new String[] {"watch", "clock", "timer" }),
|
||||
LIGHTSTONE_DUST(348, "Glowstone dust", new String[] {
|
||||
"lightstonedust", "glowstonedone", "brightstonedust",
|
||||
"brittlegolddust", "brimstonedust"}),
|
||||
RAW_FISH(349, "Raw fish", new String[] {"rawfish", "fish"}),
|
||||
COOKED_FISH(350, "Cooked fish", "cookedfish"),
|
||||
INK_SACK(351, "Ink sac", new String[] {"inksac", "ink", "dye", "inksack"}),
|
||||
BONE(352, "Bone", "bone"),
|
||||
SUGAR(353, "Sugar", "sugar"),
|
||||
CAKE_ITEM(354, "Cake", "cake"),
|
||||
BED_ITEM(355, "Bed", "bed"),
|
||||
REDSTONE_REPEATER(356, "Redstone repeater", new String[] {"redstonerepeater", "diode", "delayer"}),
|
||||
COOKIE(357, "Cookie", "cookie"),
|
||||
GOLD_RECORD(2256, "Gold Record", new String[] {"goldrecord", "golddisc"}),
|
||||
GREEN_RECORD(2257, "Green Record", new String[] {"greenrecord", "greenddisc"});
|
||||
|
||||
/**
|
||||
* Stores a map of the IDs for fast access.
|
||||
*/
|
||||
private static final Map<Integer,ItemType> ids = new HashMap<Integer,ItemType>();
|
||||
/**
|
||||
* Stores a map of the names for fast access.
|
||||
*/
|
||||
private static final Map<String,ItemType> lookup = new HashMap<String,ItemType>();
|
||||
|
||||
private final int id;
|
||||
private final String name;
|
||||
private final String[] lookupKeys;
|
||||
|
||||
static {
|
||||
for (ItemType type : EnumSet.allOf(ItemType.class)) {
|
||||
ids.put(type.id, type);
|
||||
for (String key : type.lookupKeys) {
|
||||
lookup.put(key, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct the type.
|
||||
*
|
||||
* @param id
|
||||
* @param name
|
||||
*/
|
||||
ItemType(int id, String name, String lookupKey) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.lookupKeys = new String[] {lookupKey};
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the type.
|
||||
*
|
||||
* @param id
|
||||
* @param name
|
||||
*/
|
||||
ItemType(int id, String name, String[] lookupKeys) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.lookupKeys = lookupKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return type from ID. May return null.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static ItemType fromID(int id) {
|
||||
return ids.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a name for the item.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static String toName(int id) {
|
||||
ItemType type = ids.get(id);
|
||||
if (type != null) {
|
||||
return type.getName();
|
||||
} else {
|
||||
return "#" + id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a name for a held item.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static String toHeldName(int id) {
|
||||
if (id == 0) {
|
||||
return "Hand";
|
||||
}
|
||||
ItemType type = ids.get(id);
|
||||
if (type != null) {
|
||||
return type.getName();
|
||||
} else {
|
||||
return "#" + id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return type from name. May return null.
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public static ItemType lookup(String name) {
|
||||
return lookup.get(name.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get item numeric ID.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user-friendly item name.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of aliases.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String[] getAliases() {
|
||||
return lookupKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if an item should not be stacked.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static boolean shouldNotStack(int id) {
|
||||
return (id >= 256 && id <= 259)
|
||||
|| id == 261
|
||||
|| (id >= 267 && id <= 279)
|
||||
|| (id >= 281 && id <= 286)
|
||||
|| (id >= 290 && id <= 294)
|
||||
|| (id >= 298 && id <= 317)
|
||||
|| (id >= 325 && id <= 327)
|
||||
|| id == 335
|
||||
|| id == 354
|
||||
|| id == 355
|
||||
|| id >= 2256;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if an item uses its damage value for something
|
||||
* other than damage.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static boolean usesDamageValue(int id) {
|
||||
return id == 35
|
||||
|| id == 351;
|
||||
}
|
||||
}
|
159
src/main/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java
Normal file
159
src/main/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java
Normal file
@ -0,0 +1,159 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
import com.sk89q.jnbt.*;
|
||||
import com.sk89q.worldedit.data.*;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Represents chests.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class MobSpawnerBlock extends BaseBlock implements TileEntityBlock {
|
||||
/**
|
||||
* Store mob spawn type.
|
||||
*/
|
||||
private String mobType;
|
||||
/**
|
||||
* Delay until next spawn.
|
||||
*/
|
||||
private short delay;
|
||||
|
||||
/**
|
||||
* Construct the mob spawner block.
|
||||
*
|
||||
*/
|
||||
public MobSpawnerBlock() {
|
||||
super(52);
|
||||
this.mobType = "Pig";
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the mob spawner block.
|
||||
*
|
||||
* @param mobType
|
||||
*/
|
||||
public MobSpawnerBlock(String mobType) {
|
||||
super(52);
|
||||
this.mobType = mobType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the mob spawner block.
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
public MobSpawnerBlock(int data) {
|
||||
super(52, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the mob spawner block.
|
||||
*
|
||||
* @param data
|
||||
* @param mobType
|
||||
*/
|
||||
public MobSpawnerBlock(int data, String mobType) {
|
||||
super(52, data);
|
||||
this.mobType = mobType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mob type.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getMobType() {
|
||||
return mobType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the mob type.
|
||||
*
|
||||
* @param mobType
|
||||
*/
|
||||
public void setMobType(String mobType) {
|
||||
this.mobType = mobType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the delay
|
||||
*/
|
||||
public short getDelay() {
|
||||
return delay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param delay the delay to set
|
||||
*/
|
||||
public void setDelay(short delay) {
|
||||
this.delay = delay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tile entity ID.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getTileEntityID() {
|
||||
return "MobSpawner";
|
||||
}
|
||||
|
||||
/**
|
||||
* Store additional tile entity data. Returns true if the data is used.
|
||||
*
|
||||
* @return map of values
|
||||
* @throws DataException
|
||||
*/
|
||||
public Map<String,Tag> toTileEntityNBT()
|
||||
throws DataException {
|
||||
Map<String,Tag> values = new HashMap<String,Tag>();
|
||||
values.put("EntityId", new StringTag("EntityId", mobType));
|
||||
values.put("Delay", new ShortTag("Delay", delay));
|
||||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get additional information from the title entity data.
|
||||
*
|
||||
* @param values
|
||||
* @throws DataException
|
||||
*/
|
||||
public void fromTileEntityNBT(Map<String,Tag> values)
|
||||
throws DataException {
|
||||
if (values == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Tag t = values.get("id");
|
||||
if (!(t instanceof StringTag) || !((StringTag)t).getValue().equals("MobSpawner")) {
|
||||
throw new DataException("'MobSpawner' tile entity expected");
|
||||
}
|
||||
|
||||
StringTag mobTypeTag = (StringTag)Chunk.getChildTag(values, "EntityId", StringTag.class);
|
||||
ShortTag delayTag = (ShortTag)Chunk.getChildTag(values, "Delay", ShortTag.class);
|
||||
|
||||
this.mobType = mobTypeTag.getValue();
|
||||
this.delay = delayTag.getValue();
|
||||
}
|
||||
}
|
126
src/main/java/com/sk89q/worldedit/blocks/NoteBlock.java
Normal file
126
src/main/java/com/sk89q/worldedit/blocks/NoteBlock.java
Normal file
@ -0,0 +1,126 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
import com.sk89q.jnbt.*;
|
||||
import com.sk89q.worldedit.data.*;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class NoteBlock extends BaseBlock implements TileEntityBlock {
|
||||
/**
|
||||
* Stores the pitch.
|
||||
*/
|
||||
private byte note;
|
||||
|
||||
/**
|
||||
* Construct the note block.
|
||||
*/
|
||||
public NoteBlock() {
|
||||
super(25);
|
||||
this.note = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the note block.
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
public NoteBlock(int data) {
|
||||
super(25, data);
|
||||
this.note = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the note block.
|
||||
*
|
||||
* @param data
|
||||
* @param note
|
||||
*/
|
||||
public NoteBlock(int data, byte note) {
|
||||
super(25, data);
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the note
|
||||
*/
|
||||
public byte getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param note the note to set
|
||||
*/
|
||||
public void setNote(byte note) {
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the title entity ID.
|
||||
*
|
||||
* @return title entity ID
|
||||
*/
|
||||
public String getTileEntityID() {
|
||||
return "Music";
|
||||
}
|
||||
|
||||
/**
|
||||
* Store additional tile entity data. Returns true if the data is used.
|
||||
*
|
||||
* @return map of values
|
||||
* @throws DataException
|
||||
*/
|
||||
public Map<String,Tag> toTileEntityNBT()
|
||||
throws DataException {
|
||||
Map<String,Tag> values = new HashMap<String,Tag>();
|
||||
values.put("note", new ByteTag("note", note));
|
||||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get additional information from the title entity data.
|
||||
*
|
||||
* @param values
|
||||
* @throws DataException
|
||||
*/
|
||||
public void fromTileEntityNBT(Map<String,Tag> values)
|
||||
throws DataException {
|
||||
if (values == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Tag t;
|
||||
|
||||
t = values.get("id");
|
||||
if (!(t instanceof StringTag) || !((StringTag)t).getValue().equals("Music")) {
|
||||
throw new DataException("'Music' tile entity expected");
|
||||
}
|
||||
|
||||
t = values.get("note");
|
||||
if (t instanceof ByteTag) {
|
||||
note = ((ByteTag)t).getValue();
|
||||
}
|
||||
}
|
||||
}
|
140
src/main/java/com/sk89q/worldedit/blocks/SignBlock.java
Normal file
140
src/main/java/com/sk89q/worldedit/blocks/SignBlock.java
Normal file
@ -0,0 +1,140 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
import com.sk89q.jnbt.*;
|
||||
import com.sk89q.worldedit.data.*;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class SignBlock extends BaseBlock implements TileEntityBlock {
|
||||
/**
|
||||
* Stores the sign's text.
|
||||
*/
|
||||
private String[] text;
|
||||
|
||||
/**
|
||||
* Construct the sign without text.
|
||||
*
|
||||
* @param type
|
||||
* @param data
|
||||
*/
|
||||
public SignBlock(int type, int data) {
|
||||
super(type, data);
|
||||
this.text = new String[]{ "", "", "", "" };
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the sign with text.
|
||||
*
|
||||
* @param type
|
||||
* @param data
|
||||
* @param text
|
||||
*/
|
||||
public SignBlock(int type, int data, String[] text) {
|
||||
super(type, data);
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the text
|
||||
*/
|
||||
public String[] getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param text the text to set
|
||||
*/
|
||||
public void setText(String[] text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of the title entity ID.
|
||||
*
|
||||
* @return title entity ID
|
||||
*/
|
||||
public String getTileEntityID() {
|
||||
return "Sign";
|
||||
}
|
||||
|
||||
/**
|
||||
* Store additional tile entity data. Returns true if the data is used.
|
||||
*
|
||||
* @return map of values
|
||||
* @throws DataException
|
||||
*/
|
||||
public Map<String,Tag> toTileEntityNBT()
|
||||
throws DataException {
|
||||
Map<String,Tag> values = new HashMap<String,Tag>();
|
||||
values.put("Text1", new StringTag("Text1", text[0]));
|
||||
values.put("Text2", new StringTag("Text2", text[1]));
|
||||
values.put("Text3", new StringTag("Text3", text[2]));
|
||||
values.put("Text4", new StringTag("Text4", text[3]));
|
||||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get additional information from the title entity data.
|
||||
*
|
||||
* @param values
|
||||
* @throws DataException
|
||||
*/
|
||||
public void fromTileEntityNBT(Map<String,Tag> values)
|
||||
throws DataException {
|
||||
if (values == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Tag t;
|
||||
|
||||
text = new String[]{ "", "", "", "" };
|
||||
|
||||
t = values.get("id");
|
||||
if (!(t instanceof StringTag) || !((StringTag)t).getValue().equals("Sign")) {
|
||||
throw new DataException("'Sign' tile entity expected");
|
||||
}
|
||||
|
||||
t = values.get("Text1");
|
||||
if (t instanceof StringTag) {
|
||||
text[0] = ((StringTag)t).getValue();
|
||||
}
|
||||
|
||||
t = values.get("Text2");
|
||||
if (t instanceof StringTag) {
|
||||
text[1] = ((StringTag)t).getValue();
|
||||
}
|
||||
|
||||
t = values.get("Text3");
|
||||
if (t instanceof StringTag) {
|
||||
text[2] = ((StringTag)t).getValue();
|
||||
}
|
||||
|
||||
t = values.get("Text4");
|
||||
if (t instanceof StringTag) {
|
||||
text[3] = ((StringTag)t).getValue();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.data.*;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A class implementing this interface has extra TileEntityBlock data to store.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public interface TileEntityBlock {
|
||||
/**
|
||||
* Return the name of the title entity ID.
|
||||
*
|
||||
* @return title entity ID
|
||||
*/
|
||||
public String getTileEntityID();
|
||||
/**
|
||||
* Store additional tile entity data.
|
||||
*
|
||||
* @return map of values
|
||||
* @throws DataException
|
||||
*/
|
||||
public Map<String,Tag> toTileEntityNBT()
|
||||
throws DataException;
|
||||
/**
|
||||
* Get additional information from the title entity data.
|
||||
*
|
||||
* @param values
|
||||
* @throws DataException
|
||||
*/
|
||||
public void fromTileEntityNBT(Map<String,Tag> values)
|
||||
throws DataException;
|
||||
}
|
Reference in New Issue
Block a user