From 6ef4f7b7cccc80f3e22b1b86b438367157819fcb Mon Sep 17 00:00:00 2001 From: sk89q Date: Tue, 8 Jul 2014 20:08:43 -0700 Subject: [PATCH] Moved legacy block classes to the legacy source root. --- .../sk89q/worldedit/blocks/ChestBlock.java | 0 .../worldedit/blocks/ContainerBlock.java | 284 ++++++------- .../worldedit/blocks/DispenserBlock.java | 218 +++++----- .../sk89q/worldedit/blocks/FurnaceBlock.java | 334 +++++++-------- .../com/sk89q/worldedit/blocks/LazyBlock.java | 0 .../worldedit/blocks/MobSpawnerBlock.java | 0 .../com/sk89q/worldedit/blocks/NoteBlock.java | 246 +++++------ .../com/sk89q/worldedit/blocks/SignBlock.java | 0 .../sk89q/worldedit/blocks/SkullBlock.java | 388 +++++++++--------- 9 files changed, 735 insertions(+), 735 deletions(-) rename src/{main => legacy}/java/com/sk89q/worldedit/blocks/ChestBlock.java (100%) rename src/{main => legacy}/java/com/sk89q/worldedit/blocks/ContainerBlock.java (97%) rename src/{main => legacy}/java/com/sk89q/worldedit/blocks/DispenserBlock.java (96%) rename src/{main => legacy}/java/com/sk89q/worldedit/blocks/FurnaceBlock.java (96%) rename src/{main => legacy}/java/com/sk89q/worldedit/blocks/LazyBlock.java (100%) rename src/{main => legacy}/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java (100%) rename src/{main => legacy}/java/com/sk89q/worldedit/blocks/NoteBlock.java (96%) rename src/{main => legacy}/java/com/sk89q/worldedit/blocks/SignBlock.java (100%) rename src/{main => legacy}/java/com/sk89q/worldedit/blocks/SkullBlock.java (96%) diff --git a/src/main/java/com/sk89q/worldedit/blocks/ChestBlock.java b/src/legacy/java/com/sk89q/worldedit/blocks/ChestBlock.java similarity index 100% rename from src/main/java/com/sk89q/worldedit/blocks/ChestBlock.java rename to src/legacy/java/com/sk89q/worldedit/blocks/ChestBlock.java diff --git a/src/main/java/com/sk89q/worldedit/blocks/ContainerBlock.java b/src/legacy/java/com/sk89q/worldedit/blocks/ContainerBlock.java similarity index 97% rename from src/main/java/com/sk89q/worldedit/blocks/ContainerBlock.java rename to src/legacy/java/com/sk89q/worldedit/blocks/ContainerBlock.java index 9e0d69fb1..aae973c44 100644 --- a/src/main/java/com/sk89q/worldedit/blocks/ContainerBlock.java +++ b/src/legacy/java/com/sk89q/worldedit/blocks/ContainerBlock.java @@ -1,142 +1,142 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * 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 . - */ - -package com.sk89q.worldedit.blocks; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -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; - -/** - * Represents a block that stores items. - * - * @author sk89q - */ -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 - */ - public BaseItemStack[] getItems() { - return this.items; - } - - /** - * Set the list of items. - * - * @param items - */ - public void setItems(BaseItemStack[] items) { - this.items = items; - } - - @Override - public boolean hasNbtData() { - return true; - } - - public Map serializeItem(BaseItemStack item) { - Map data = new HashMap(); - data.put("id", new ShortTag("id", (short) item.getType())); - data.put("Damage", new ShortTag("Damage", item.getData())); - data.put("Count", new ByteTag("Count", (byte) item.getAmount())); - if (item.getEnchantments().size() > 0) { - List enchantmentList = new ArrayList(); - for(Map.Entry entry : item.getEnchantments().entrySet()) { - Map enchantment = new HashMap(); - enchantment.put("id", new ShortTag("id", entry.getKey().shortValue())); - enchantment.put("lvl", new ShortTag("lvl", entry.getValue().shortValue())); - enchantmentList.add(new CompoundTag(null, enchantment)); - } - - Map auxData = new HashMap(); - auxData.put("ench", new ListTag("ench", CompoundTag.class, enchantmentList)); - data.put("tag", new CompoundTag("tag", auxData)); - } - return data; - } - - public BaseItemStack deserializeItem(Map 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 auxData = NBTUtils.getChildTag(data, "tag", CompoundTag.class).getValue(); - ListTag ench = (ListTag)auxData.get("ench"); - for(Tag e : ench.getValue()) { - Map 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 items) throws DataException { - BaseItemStack[] stacks = new BaseItemStack[items.size()]; - for (CompoundTag tag : items) { - Map 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 serializeInventory(BaseItemStack[] items) { - List tags = new ArrayList(); - for (int i = 0; i < items.length; ++i) { - if (items[i] != null) { - Map tagData = serializeItem(items[i]); - tagData.put("Slot", new ByteTag("Slot", (byte) i)); - tags.add(new CompoundTag("", tagData)); - } - } - return tags; - } -} +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * 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 . + */ + +package com.sk89q.worldedit.blocks; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +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; + +/** + * Represents a block that stores items. + * + * @author sk89q + */ +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 + */ + public BaseItemStack[] getItems() { + return this.items; + } + + /** + * Set the list of items. + * + * @param items + */ + public void setItems(BaseItemStack[] items) { + this.items = items; + } + + @Override + public boolean hasNbtData() { + return true; + } + + public Map serializeItem(BaseItemStack item) { + Map data = new HashMap(); + data.put("id", new ShortTag("id", (short) item.getType())); + data.put("Damage", new ShortTag("Damage", item.getData())); + data.put("Count", new ByteTag("Count", (byte) item.getAmount())); + if (item.getEnchantments().size() > 0) { + List enchantmentList = new ArrayList(); + for(Map.Entry entry : item.getEnchantments().entrySet()) { + Map enchantment = new HashMap(); + enchantment.put("id", new ShortTag("id", entry.getKey().shortValue())); + enchantment.put("lvl", new ShortTag("lvl", entry.getValue().shortValue())); + enchantmentList.add(new CompoundTag(null, enchantment)); + } + + Map auxData = new HashMap(); + auxData.put("ench", new ListTag("ench", CompoundTag.class, enchantmentList)); + data.put("tag", new CompoundTag("tag", auxData)); + } + return data; + } + + public BaseItemStack deserializeItem(Map 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 auxData = NBTUtils.getChildTag(data, "tag", CompoundTag.class).getValue(); + ListTag ench = (ListTag)auxData.get("ench"); + for(Tag e : ench.getValue()) { + Map 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 items) throws DataException { + BaseItemStack[] stacks = new BaseItemStack[items.size()]; + for (CompoundTag tag : items) { + Map 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 serializeInventory(BaseItemStack[] items) { + List tags = new ArrayList(); + for (int i = 0; i < items.length; ++i) { + if (items[i] != null) { + Map tagData = serializeItem(items[i]); + tagData.put("Slot", new ByteTag("Slot", (byte) i)); + tags.add(new CompoundTag("", tagData)); + } + } + return tags; + } +} diff --git a/src/main/java/com/sk89q/worldedit/blocks/DispenserBlock.java b/src/legacy/java/com/sk89q/worldedit/blocks/DispenserBlock.java similarity index 96% rename from src/main/java/com/sk89q/worldedit/blocks/DispenserBlock.java rename to src/legacy/java/com/sk89q/worldedit/blocks/DispenserBlock.java index ea1392924..c13c7f163 100644 --- a/src/main/java/com/sk89q/worldedit/blocks/DispenserBlock.java +++ b/src/legacy/java/com/sk89q/worldedit/blocks/DispenserBlock.java @@ -1,109 +1,109 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * 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 . - */ - -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. - * - * @author sk89q - */ -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 values = new HashMap(); - values.put("Items", new ListTag("Items", CompoundTag.class, - serializeInventory(getItems()))); - return new CompoundTag(getNbtId(), values); - } - - @Override - public void setNbtData(CompoundTag rootTag) { - try { - if (rootTag == null) { - return; - } - - Map 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 items = new ArrayList(); - 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); - } - } -} +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * 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 . + */ + +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. + * + * @author sk89q + */ +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 values = new HashMap(); + values.put("Items", new ListTag("Items", CompoundTag.class, + serializeInventory(getItems()))); + return new CompoundTag(getNbtId(), values); + } + + @Override + public void setNbtData(CompoundTag rootTag) { + try { + if (rootTag == null) { + return; + } + + Map 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 items = new ArrayList(); + 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); + } + } +} diff --git a/src/main/java/com/sk89q/worldedit/blocks/FurnaceBlock.java b/src/legacy/java/com/sk89q/worldedit/blocks/FurnaceBlock.java similarity index 96% rename from src/main/java/com/sk89q/worldedit/blocks/FurnaceBlock.java rename to src/legacy/java/com/sk89q/worldedit/blocks/FurnaceBlock.java index 24e241dbd..07b38c78b 100644 --- a/src/main/java/com/sk89q/worldedit/blocks/FurnaceBlock.java +++ b/src/legacy/java/com/sk89q/worldedit/blocks/FurnaceBlock.java @@ -1,167 +1,167 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * 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 . - */ - -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. - * - * @author sk89q - */ -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 values = new HashMap(); - values.put("Items", new ListTag("Items", CompoundTag.class, - serializeInventory(getItems()))); - values.put("BurnTime", new ShortTag("BurnTime", burnTime)); - values.put("CookTime", new ShortTag("CookTime", cookTime)); - return new CompoundTag(getNbtId(), values); - } - - @Override - public void setNbtData(CompoundTag rootTag) { - if (rootTag == null) { - return; - } - - try { - Map 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 compound = new ArrayList(); - - 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); - } - } -} +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * 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 . + */ + +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. + * + * @author sk89q + */ +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 values = new HashMap(); + values.put("Items", new ListTag("Items", CompoundTag.class, + serializeInventory(getItems()))); + values.put("BurnTime", new ShortTag("BurnTime", burnTime)); + values.put("CookTime", new ShortTag("CookTime", cookTime)); + return new CompoundTag(getNbtId(), values); + } + + @Override + public void setNbtData(CompoundTag rootTag) { + if (rootTag == null) { + return; + } + + try { + Map 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 compound = new ArrayList(); + + 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); + } + } +} diff --git a/src/main/java/com/sk89q/worldedit/blocks/LazyBlock.java b/src/legacy/java/com/sk89q/worldedit/blocks/LazyBlock.java similarity index 100% rename from src/main/java/com/sk89q/worldedit/blocks/LazyBlock.java rename to src/legacy/java/com/sk89q/worldedit/blocks/LazyBlock.java diff --git a/src/main/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java b/src/legacy/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java similarity index 100% rename from src/main/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java rename to src/legacy/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java diff --git a/src/main/java/com/sk89q/worldedit/blocks/NoteBlock.java b/src/legacy/java/com/sk89q/worldedit/blocks/NoteBlock.java similarity index 96% rename from src/main/java/com/sk89q/worldedit/blocks/NoteBlock.java rename to src/legacy/java/com/sk89q/worldedit/blocks/NoteBlock.java index 32e1cdb18..0f5c819e3 100644 --- a/src/main/java/com/sk89q/worldedit/blocks/NoteBlock.java +++ b/src/legacy/java/com/sk89q/worldedit/blocks/NoteBlock.java @@ -1,123 +1,123 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * 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 . - */ - -package com.sk89q.worldedit.blocks; - -import com.sk89q.jnbt.ByteTag; -import com.sk89q.jnbt.CompoundTag; -import com.sk89q.jnbt.StringTag; -import com.sk89q.jnbt.Tag; - -import java.util.HashMap; -import java.util.Map; - -/** - * A note block. - * - * @author sk89q - */ -public class NoteBlock extends BaseBlock implements TileEntityBlock { - - private byte note; - - /** - * Construct the note block with a data value of 0. - */ - public NoteBlock() { - super(BlockID.NOTE_BLOCK); - this.note = 0; - } - - /** - * Construct the note block with a given data value. - * - * @param data data value - */ - public NoteBlock(int data) { - super(BlockID.NOTE_BLOCK, data); - this.note = 0; - } - - /** - * Construct the note block with a given data value and note. - * - * @param data data value - * @param note note - */ - public NoteBlock(int data, byte note) { - super(BlockID.NOTE_BLOCK, data); - this.note = note; - } - - /** - * Get the note. - * - * @return the note - */ - public byte getNote() { - return note; - } - - /** - * Set the note. - * - * @param note the note to set - */ - public void setNote(byte note) { - this.note = note; - } - - @Override - public boolean hasNbtData() { - return true; - } - - @Override - public String getNbtId() { - return "Music"; - } - - @Override - public CompoundTag getNbtData() { - Map values = new HashMap(); - values.put("note", new ByteTag("note", note)); - return new CompoundTag(getNbtId(), values); - } - - @Override - public void setNbtData(CompoundTag rootTag) { - if (rootTag == null) { - return; - } - - Map values = rootTag.getValue(); - - Tag t; - - t = values.get("id"); - if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Music")) { - throw new RuntimeException("'Music' tile entity expected"); - } - - t = values.get("note"); - if (t instanceof ByteTag) { - note = ((ByteTag) t).getValue(); - } - } -} +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * 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 . + */ + +package com.sk89q.worldedit.blocks; + +import com.sk89q.jnbt.ByteTag; +import com.sk89q.jnbt.CompoundTag; +import com.sk89q.jnbt.StringTag; +import com.sk89q.jnbt.Tag; + +import java.util.HashMap; +import java.util.Map; + +/** + * A note block. + * + * @author sk89q + */ +public class NoteBlock extends BaseBlock implements TileEntityBlock { + + private byte note; + + /** + * Construct the note block with a data value of 0. + */ + public NoteBlock() { + super(BlockID.NOTE_BLOCK); + this.note = 0; + } + + /** + * Construct the note block with a given data value. + * + * @param data data value + */ + public NoteBlock(int data) { + super(BlockID.NOTE_BLOCK, data); + this.note = 0; + } + + /** + * Construct the note block with a given data value and note. + * + * @param data data value + * @param note note + */ + public NoteBlock(int data, byte note) { + super(BlockID.NOTE_BLOCK, data); + this.note = note; + } + + /** + * Get the note. + * + * @return the note + */ + public byte getNote() { + return note; + } + + /** + * Set the note. + * + * @param note the note to set + */ + public void setNote(byte note) { + this.note = note; + } + + @Override + public boolean hasNbtData() { + return true; + } + + @Override + public String getNbtId() { + return "Music"; + } + + @Override + public CompoundTag getNbtData() { + Map values = new HashMap(); + values.put("note", new ByteTag("note", note)); + return new CompoundTag(getNbtId(), values); + } + + @Override + public void setNbtData(CompoundTag rootTag) { + if (rootTag == null) { + return; + } + + Map values = rootTag.getValue(); + + Tag t; + + t = values.get("id"); + if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Music")) { + throw new RuntimeException("'Music' tile entity expected"); + } + + t = values.get("note"); + if (t instanceof ByteTag) { + note = ((ByteTag) t).getValue(); + } + } +} diff --git a/src/main/java/com/sk89q/worldedit/blocks/SignBlock.java b/src/legacy/java/com/sk89q/worldedit/blocks/SignBlock.java similarity index 100% rename from src/main/java/com/sk89q/worldedit/blocks/SignBlock.java rename to src/legacy/java/com/sk89q/worldedit/blocks/SignBlock.java diff --git a/src/main/java/com/sk89q/worldedit/blocks/SkullBlock.java b/src/legacy/java/com/sk89q/worldedit/blocks/SkullBlock.java similarity index 96% rename from src/main/java/com/sk89q/worldedit/blocks/SkullBlock.java rename to src/legacy/java/com/sk89q/worldedit/blocks/SkullBlock.java index 981a339ec..ac62da26c 100644 --- a/src/main/java/com/sk89q/worldedit/blocks/SkullBlock.java +++ b/src/legacy/java/com/sk89q/worldedit/blocks/SkullBlock.java @@ -1,194 +1,194 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * 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 . - */ - -package com.sk89q.worldedit.blocks; - -import com.sk89q.jnbt.ByteTag; -import com.sk89q.jnbt.CompoundTag; -import com.sk89q.jnbt.StringTag; -import com.sk89q.jnbt.Tag; - -import java.util.HashMap; -import java.util.Map; - -/** - * A skull block. - */ -public class SkullBlock extends BaseBlock implements TileEntityBlock { - - private String owner = ""; // notchian - private byte skullType; // stored here for block, in damage value for item - private byte rot; // only matters if block data == 0x1 (on floor) - - /** - * Construct the skull block with a default type of skelton. - * @param data data value to set, controls placement - */ - public SkullBlock(int data) { - this(data, (byte) 0); - } - - /** - * Construct the skull block with a given type. - * 0 - skeleton - * 1 - wither skelly - * 2 - zombie - * 3 - human - * 4 - creeper - * @param data data value to set, controls placement - * @param type type of skull - */ - public SkullBlock(int data, byte type) { - this(data, type, (byte) 0); - } - - /** - * Construct the skull block with a given type and rotation. - * @param data data value to set, controls placement - * @param type type of skull - * @param rot rotation (if on floor) - */ - public SkullBlock(int data, byte type, byte rot) { - super(BlockID.HEAD, data); - if (type < (byte) 0 || type > (byte) 4) { - this.skullType = (byte) 0; - } else { - this.skullType = type; - } - this.rot = rot; - this.owner = ""; - } - - /** - * Construct the skull block with a given rotation and owner. - * The type is assumed to be player unless owner is null or empty. - * @param data data value to set, controls placement - * @param rot rotation of skull - * @param owner name of player - */ - public SkullBlock(int data, byte rot, String owner) { - super(BlockID.HEAD, data); - this.rot = rot; - this.setOwner(owner); - if (owner == null || owner.isEmpty()) this.skullType = (byte) 0; - } - - /** - * Set the skull's owner. Automatically sets type to player if not empty or null. - * @param owner player name to set the skull to - */ - public void setOwner(String owner) { - if (owner == null) { - this.owner = ""; - } else { - if (owner.length() > 16 || owner.isEmpty()) this.owner = ""; - else this.owner = owner; - } - if (this.owner != null && !this.owner.isEmpty()) this.skullType = (byte) 3; - } - - /** - * Get the skull's owner. Returns null if unset. - * @return player name or null - */ - public String getOwner() { - return owner; - } - - /** - * Get the type of skull. - * @return the skullType - */ - public byte getSkullType() { - return skullType; - } - - /** - * Set the type of skull; - * @param skullType the skullType to set - */ - public void setSkullType(byte skullType) { - this.skullType = skullType; - } - - /** - * Get rotation of skull. This only means anything if the block data is 1. - * @return the rotation - */ - public byte getRot() { - return rot; - } - - /** - * Set the rotation of skull. - * @param rot the rotation to set - */ - public void setRot(byte rot) { - this.rot = rot; - } - - @Override - public boolean hasNbtData() { - return true; - } - - @Override - public String getNbtId() { - return "Skull"; - } - - @Override - public CompoundTag getNbtData() { - Map values = new HashMap(); - values.put("SkullType", new ByteTag("SkullType", skullType)); - if (owner == null) owner = ""; - values.put("ExtraType", new StringTag("ExtraType", owner)); - values.put("Rot", new ByteTag("Rot", rot)); - return new CompoundTag(getNbtId(), values); - } - - @Override - public void setNbtData(CompoundTag rootTag) { - if (rootTag == null) { - return; - } - - Map values = rootTag.getValue(); - - Tag t; - - t = values.get("id"); - if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Skull")) { - throw new RuntimeException("'Skull' tile entity expected"); - } - - t = values.get("SkullType"); - if (t instanceof ByteTag) { - skullType = ((ByteTag) t).getValue(); - } - t = values.get("ExtraType"); - if (t != null && t instanceof StringTag) { - owner = ((StringTag) t).getValue(); - } - t = values.get("Rot"); - if (t instanceof ByteTag) { - rot = ((ByteTag) t).getValue(); - } - } -} +/* + * WorldEdit, a Minecraft world manipulation toolkit + * Copyright (C) sk89q + * 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 . + */ + +package com.sk89q.worldedit.blocks; + +import com.sk89q.jnbt.ByteTag; +import com.sk89q.jnbt.CompoundTag; +import com.sk89q.jnbt.StringTag; +import com.sk89q.jnbt.Tag; + +import java.util.HashMap; +import java.util.Map; + +/** + * A skull block. + */ +public class SkullBlock extends BaseBlock implements TileEntityBlock { + + private String owner = ""; // notchian + private byte skullType; // stored here for block, in damage value for item + private byte rot; // only matters if block data == 0x1 (on floor) + + /** + * Construct the skull block with a default type of skelton. + * @param data data value to set, controls placement + */ + public SkullBlock(int data) { + this(data, (byte) 0); + } + + /** + * Construct the skull block with a given type. + * 0 - skeleton + * 1 - wither skelly + * 2 - zombie + * 3 - human + * 4 - creeper + * @param data data value to set, controls placement + * @param type type of skull + */ + public SkullBlock(int data, byte type) { + this(data, type, (byte) 0); + } + + /** + * Construct the skull block with a given type and rotation. + * @param data data value to set, controls placement + * @param type type of skull + * @param rot rotation (if on floor) + */ + public SkullBlock(int data, byte type, byte rot) { + super(BlockID.HEAD, data); + if (type < (byte) 0 || type > (byte) 4) { + this.skullType = (byte) 0; + } else { + this.skullType = type; + } + this.rot = rot; + this.owner = ""; + } + + /** + * Construct the skull block with a given rotation and owner. + * The type is assumed to be player unless owner is null or empty. + * @param data data value to set, controls placement + * @param rot rotation of skull + * @param owner name of player + */ + public SkullBlock(int data, byte rot, String owner) { + super(BlockID.HEAD, data); + this.rot = rot; + this.setOwner(owner); + if (owner == null || owner.isEmpty()) this.skullType = (byte) 0; + } + + /** + * Set the skull's owner. Automatically sets type to player if not empty or null. + * @param owner player name to set the skull to + */ + public void setOwner(String owner) { + if (owner == null) { + this.owner = ""; + } else { + if (owner.length() > 16 || owner.isEmpty()) this.owner = ""; + else this.owner = owner; + } + if (this.owner != null && !this.owner.isEmpty()) this.skullType = (byte) 3; + } + + /** + * Get the skull's owner. Returns null if unset. + * @return player name or null + */ + public String getOwner() { + return owner; + } + + /** + * Get the type of skull. + * @return the skullType + */ + public byte getSkullType() { + return skullType; + } + + /** + * Set the type of skull; + * @param skullType the skullType to set + */ + public void setSkullType(byte skullType) { + this.skullType = skullType; + } + + /** + * Get rotation of skull. This only means anything if the block data is 1. + * @return the rotation + */ + public byte getRot() { + return rot; + } + + /** + * Set the rotation of skull. + * @param rot the rotation to set + */ + public void setRot(byte rot) { + this.rot = rot; + } + + @Override + public boolean hasNbtData() { + return true; + } + + @Override + public String getNbtId() { + return "Skull"; + } + + @Override + public CompoundTag getNbtData() { + Map values = new HashMap(); + values.put("SkullType", new ByteTag("SkullType", skullType)); + if (owner == null) owner = ""; + values.put("ExtraType", new StringTag("ExtraType", owner)); + values.put("Rot", new ByteTag("Rot", rot)); + return new CompoundTag(getNbtId(), values); + } + + @Override + public void setNbtData(CompoundTag rootTag) { + if (rootTag == null) { + return; + } + + Map values = rootTag.getValue(); + + Tag t; + + t = values.get("id"); + if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Skull")) { + throw new RuntimeException("'Skull' tile entity expected"); + } + + t = values.get("SkullType"); + if (t instanceof ByteTag) { + skullType = ((ByteTag) t).getValue(); + } + t = values.get("ExtraType"); + if (t != null && t instanceof StringTag) { + owner = ((StringTag) t).getValue(); + } + t = values.get("Rot"); + if (t instanceof ByteTag) { + rot = ((ByteTag) t).getValue(); + } + } +}