mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Moved legacy block classes to the legacy source root.
This commit is contained in:
parent
7463fdef79
commit
6ef4f7b7cc
@ -1,142 +1,142 @@
|
|||||||
/*
|
/*
|
||||||
* WorldEdit, a Minecraft world manipulation toolkit
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* 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
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
* for more details.
|
* for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.blocks;
|
package com.sk89q.worldedit.blocks;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.sk89q.jnbt.ByteTag;
|
import com.sk89q.jnbt.ByteTag;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.ListTag;
|
import com.sk89q.jnbt.ListTag;
|
||||||
import com.sk89q.jnbt.NBTUtils;
|
import com.sk89q.jnbt.NBTUtils;
|
||||||
import com.sk89q.jnbt.ShortTag;
|
import com.sk89q.jnbt.ShortTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.world.DataException;
|
import com.sk89q.worldedit.world.DataException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a block that stores items.
|
* Represents a block that stores items.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public abstract class ContainerBlock extends BaseBlock implements TileEntityBlock {
|
public abstract class ContainerBlock extends BaseBlock implements TileEntityBlock {
|
||||||
|
|
||||||
private BaseItemStack[] items;
|
private BaseItemStack[] items;
|
||||||
|
|
||||||
public ContainerBlock(int type, int inventorySize) {
|
public ContainerBlock(int type, int inventorySize) {
|
||||||
super(type);
|
super(type);
|
||||||
this.items = new BaseItemStack[inventorySize];
|
this.items = new BaseItemStack[inventorySize];
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContainerBlock(int type, int data, int inventorySize) {
|
public ContainerBlock(int type, int data, int inventorySize) {
|
||||||
super(type, data);
|
super(type, data);
|
||||||
this.items = new BaseItemStack[inventorySize];
|
this.items = new BaseItemStack[inventorySize];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the list of items.
|
* Get the list of items.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public BaseItemStack[] getItems() {
|
public BaseItemStack[] getItems() {
|
||||||
return this.items;
|
return this.items;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the list of items.
|
* Set the list of items.
|
||||||
*
|
*
|
||||||
* @param items
|
* @param items
|
||||||
*/
|
*/
|
||||||
public void setItems(BaseItemStack[] items) {
|
public void setItems(BaseItemStack[] items) {
|
||||||
this.items = items;
|
this.items = items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNbtData() {
|
public boolean hasNbtData() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Tag> serializeItem(BaseItemStack item) {
|
public Map<String, Tag> serializeItem(BaseItemStack item) {
|
||||||
Map<String, Tag> data = new HashMap<String, Tag>();
|
Map<String, Tag> data = new HashMap<String, Tag>();
|
||||||
data.put("id", new ShortTag("id", (short) item.getType()));
|
data.put("id", new ShortTag("id", (short) item.getType()));
|
||||||
data.put("Damage", new ShortTag("Damage", item.getData()));
|
data.put("Damage", new ShortTag("Damage", item.getData()));
|
||||||
data.put("Count", new ByteTag("Count", (byte) item.getAmount()));
|
data.put("Count", new ByteTag("Count", (byte) item.getAmount()));
|
||||||
if (item.getEnchantments().size() > 0) {
|
if (item.getEnchantments().size() > 0) {
|
||||||
List<CompoundTag> enchantmentList = new ArrayList<CompoundTag>();
|
List<CompoundTag> enchantmentList = new ArrayList<CompoundTag>();
|
||||||
for(Map.Entry<Integer, Integer> entry : item.getEnchantments().entrySet()) {
|
for(Map.Entry<Integer, Integer> entry : item.getEnchantments().entrySet()) {
|
||||||
Map<String, Tag> enchantment = new HashMap<String, Tag>();
|
Map<String, Tag> enchantment = new HashMap<String, Tag>();
|
||||||
enchantment.put("id", new ShortTag("id", entry.getKey().shortValue()));
|
enchantment.put("id", new ShortTag("id", entry.getKey().shortValue()));
|
||||||
enchantment.put("lvl", new ShortTag("lvl", entry.getValue().shortValue()));
|
enchantment.put("lvl", new ShortTag("lvl", entry.getValue().shortValue()));
|
||||||
enchantmentList.add(new CompoundTag(null, enchantment));
|
enchantmentList.add(new CompoundTag(null, enchantment));
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Tag> auxData = new HashMap<String, Tag>();
|
Map<String, Tag> auxData = new HashMap<String, Tag>();
|
||||||
auxData.put("ench", new ListTag("ench", CompoundTag.class, enchantmentList));
|
auxData.put("ench", new ListTag("ench", CompoundTag.class, enchantmentList));
|
||||||
data.put("tag", new CompoundTag("tag", auxData));
|
data.put("tag", new CompoundTag("tag", auxData));
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseItemStack deserializeItem(Map<String, Tag> data) throws DataException {
|
public BaseItemStack deserializeItem(Map<String, Tag> data) throws DataException {
|
||||||
short id = NBTUtils.getChildTag(data, "id", ShortTag.class).getValue();
|
short id = NBTUtils.getChildTag(data, "id", ShortTag.class).getValue();
|
||||||
short damage = NBTUtils.getChildTag(data, "Damage", ShortTag.class).getValue();
|
short damage = NBTUtils.getChildTag(data, "Damage", ShortTag.class).getValue();
|
||||||
byte count = NBTUtils.getChildTag(data, "Count", ByteTag.class).getValue();
|
byte count = NBTUtils.getChildTag(data, "Count", ByteTag.class).getValue();
|
||||||
|
|
||||||
BaseItemStack stack = new BaseItemStack(id, count, damage);
|
BaseItemStack stack = new BaseItemStack(id, count, damage);
|
||||||
|
|
||||||
if (data.containsKey("tag")) {
|
if (data.containsKey("tag")) {
|
||||||
Map<String, Tag> auxData = NBTUtils.getChildTag(data, "tag", CompoundTag.class).getValue();
|
Map<String, Tag> auxData = NBTUtils.getChildTag(data, "tag", CompoundTag.class).getValue();
|
||||||
ListTag ench = (ListTag)auxData.get("ench");
|
ListTag ench = (ListTag)auxData.get("ench");
|
||||||
for(Tag e : ench.getValue()) {
|
for(Tag e : ench.getValue()) {
|
||||||
Map<String, Tag> vars = ((CompoundTag) e).getValue();
|
Map<String, Tag> vars = ((CompoundTag) e).getValue();
|
||||||
short enchId = NBTUtils.getChildTag(vars, "id", ShortTag.class).getValue();
|
short enchId = NBTUtils.getChildTag(vars, "id", ShortTag.class).getValue();
|
||||||
short enchLevel = NBTUtils.getChildTag(vars, "lvl", ShortTag.class).getValue();
|
short enchLevel = NBTUtils.getChildTag(vars, "lvl", ShortTag.class).getValue();
|
||||||
stack.getEnchantments().put((int) enchId, (int) enchLevel);
|
stack.getEnchantments().put((int) enchId, (int) enchLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseItemStack[] deserializeInventory(List<CompoundTag> items) throws DataException {
|
public BaseItemStack[] deserializeInventory(List<CompoundTag> items) throws DataException {
|
||||||
BaseItemStack[] stacks = new BaseItemStack[items.size()];
|
BaseItemStack[] stacks = new BaseItemStack[items.size()];
|
||||||
for (CompoundTag tag : items) {
|
for (CompoundTag tag : items) {
|
||||||
Map<String, Tag> item = tag.getValue();
|
Map<String, Tag> item = tag.getValue();
|
||||||
BaseItemStack stack = deserializeItem(item);
|
BaseItemStack stack = deserializeItem(item);
|
||||||
byte slot = NBTUtils.getChildTag(item, "Slot", ByteTag.class).getValue();
|
byte slot = NBTUtils.getChildTag(item, "Slot", ByteTag.class).getValue();
|
||||||
if (slot >= 0 && slot < stacks.length) {
|
if (slot >= 0 && slot < stacks.length) {
|
||||||
stacks[slot] = stack;
|
stacks[slot] = stack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return stacks;
|
return stacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CompoundTag> serializeInventory(BaseItemStack[] items) {
|
public List<CompoundTag> serializeInventory(BaseItemStack[] items) {
|
||||||
List<CompoundTag> tags = new ArrayList<CompoundTag>();
|
List<CompoundTag> tags = new ArrayList<CompoundTag>();
|
||||||
for (int i = 0; i < items.length; ++i) {
|
for (int i = 0; i < items.length; ++i) {
|
||||||
if (items[i] != null) {
|
if (items[i] != null) {
|
||||||
Map<String, Tag> tagData = serializeItem(items[i]);
|
Map<String, Tag> tagData = serializeItem(items[i]);
|
||||||
tagData.put("Slot", new ByteTag("Slot", (byte) i));
|
tagData.put("Slot", new ByteTag("Slot", (byte) i));
|
||||||
tags.add(new CompoundTag("", tagData));
|
tags.add(new CompoundTag("", tagData));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,109 +1,109 @@
|
|||||||
/*
|
/*
|
||||||
* WorldEdit, a Minecraft world manipulation toolkit
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* 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
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
* for more details.
|
* for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.blocks;
|
package com.sk89q.worldedit.blocks;
|
||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.ListTag;
|
import com.sk89q.jnbt.ListTag;
|
||||||
import com.sk89q.jnbt.NBTUtils;
|
import com.sk89q.jnbt.NBTUtils;
|
||||||
import com.sk89q.jnbt.StringTag;
|
import com.sk89q.jnbt.StringTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.world.DataException;
|
import com.sk89q.worldedit.world.DataException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents dispensers.
|
* Represents dispensers.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class DispenserBlock extends ContainerBlock {
|
public class DispenserBlock extends ContainerBlock {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct an empty dispenser block.
|
* Construct an empty dispenser block.
|
||||||
*/
|
*/
|
||||||
public DispenserBlock() {
|
public DispenserBlock() {
|
||||||
super(BlockID.DISPENSER, 9);
|
super(BlockID.DISPENSER, 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct an empty dispenser block.
|
* Construct an empty dispenser block.
|
||||||
*
|
*
|
||||||
* @param data data value (orientation)
|
* @param data data value (orientation)
|
||||||
*/
|
*/
|
||||||
public DispenserBlock(int data) {
|
public DispenserBlock(int data) {
|
||||||
super(BlockID.DISPENSER, data, 9);
|
super(BlockID.DISPENSER, data, 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a dispenser block with the given orientation and inventory.
|
* Construct a dispenser block with the given orientation and inventory.
|
||||||
*
|
*
|
||||||
* @param data data value (orientation)
|
* @param data data value (orientation)
|
||||||
* @param items array of items in the inventory
|
* @param items array of items in the inventory
|
||||||
*/
|
*/
|
||||||
public DispenserBlock(int data, BaseItemStack[] items) {
|
public DispenserBlock(int data, BaseItemStack[] items) {
|
||||||
super(BlockID.DISPENSER, data, 9);
|
super(BlockID.DISPENSER, data, 9);
|
||||||
this.setItems(items);
|
this.setItems(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNbtId() {
|
public String getNbtId() {
|
||||||
return "Trap";
|
return "Trap";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getNbtData() {
|
public CompoundTag getNbtData() {
|
||||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
Map<String, Tag> values = new HashMap<String, Tag>();
|
||||||
values.put("Items", new ListTag("Items", CompoundTag.class,
|
values.put("Items", new ListTag("Items", CompoundTag.class,
|
||||||
serializeInventory(getItems())));
|
serializeInventory(getItems())));
|
||||||
return new CompoundTag(getNbtId(), values);
|
return new CompoundTag(getNbtId(), values);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNbtData(CompoundTag rootTag) {
|
public void setNbtData(CompoundTag rootTag) {
|
||||||
try {
|
try {
|
||||||
if (rootTag == null) {
|
if (rootTag == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Tag> values = rootTag.getValue();
|
Map<String, Tag> values = rootTag.getValue();
|
||||||
|
|
||||||
Tag t = values.get("id");
|
Tag t = values.get("id");
|
||||||
if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Trap")) {
|
if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Trap")) {
|
||||||
throw new DataException("'Trap' tile entity expected");
|
throw new DataException("'Trap' tile entity expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<CompoundTag> items = new ArrayList<CompoundTag>();
|
List<CompoundTag> items = new ArrayList<CompoundTag>();
|
||||||
for (Tag tag : NBTUtils.getChildTag(values, "Items", ListTag.class).getValue()) {
|
for (Tag tag : NBTUtils.getChildTag(values, "Items", ListTag.class).getValue()) {
|
||||||
if (!(tag instanceof CompoundTag)) {
|
if (!(tag instanceof CompoundTag)) {
|
||||||
throw new DataException("CompoundTag expected as child tag of Trap Items");
|
throw new DataException("CompoundTag expected as child tag of Trap Items");
|
||||||
}
|
}
|
||||||
|
|
||||||
items.add((CompoundTag) tag);
|
items.add((CompoundTag) tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
setItems(deserializeInventory(items));
|
setItems(deserializeInventory(items));
|
||||||
} catch (DataException e) {
|
} catch (DataException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,167 +1,167 @@
|
|||||||
/*
|
/*
|
||||||
* WorldEdit, a Minecraft world manipulation toolkit
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* 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
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
* for more details.
|
* for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.blocks;
|
package com.sk89q.worldedit.blocks;
|
||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.ListTag;
|
import com.sk89q.jnbt.ListTag;
|
||||||
import com.sk89q.jnbt.NBTUtils;
|
import com.sk89q.jnbt.NBTUtils;
|
||||||
import com.sk89q.jnbt.ShortTag;
|
import com.sk89q.jnbt.ShortTag;
|
||||||
import com.sk89q.jnbt.StringTag;
|
import com.sk89q.jnbt.StringTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.world.DataException;
|
import com.sk89q.worldedit.world.DataException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a furnace block.
|
* Represents a furnace block.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class FurnaceBlock extends ContainerBlock {
|
public class FurnaceBlock extends ContainerBlock {
|
||||||
|
|
||||||
private short burnTime;
|
private short burnTime;
|
||||||
private short cookTime;
|
private short cookTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct an empty furnace block with the default orientation.
|
* Construct an empty furnace block with the default orientation.
|
||||||
*
|
*
|
||||||
* @param type type ID
|
* @param type type ID
|
||||||
*/
|
*/
|
||||||
public FurnaceBlock(int type) {
|
public FurnaceBlock(int type) {
|
||||||
super(type, 2);
|
super(type, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct an empty furnace block with a given orientation.
|
* Construct an empty furnace block with a given orientation.
|
||||||
*
|
*
|
||||||
* @param type type ID
|
* @param type type ID
|
||||||
* @param data orientation
|
* @param data orientation
|
||||||
*/
|
*/
|
||||||
public FurnaceBlock(int type, int data) {
|
public FurnaceBlock(int type, int data) {
|
||||||
super(type, data, 2);
|
super(type, data, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct an furnace block with a given orientation and inventory.
|
* Construct an furnace block with a given orientation and inventory.
|
||||||
*
|
*
|
||||||
* @param type type ID
|
* @param type type ID
|
||||||
* @param data orientation
|
* @param data orientation
|
||||||
* @param items inventory items
|
* @param items inventory items
|
||||||
*/
|
*/
|
||||||
public FurnaceBlock(int type, int data, BaseItemStack[] items) {
|
public FurnaceBlock(int type, int data, BaseItemStack[] items) {
|
||||||
super(type, data, 2);
|
super(type, data, 2);
|
||||||
setItems(items);
|
setItems(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the burn time.
|
* Get the burn time.
|
||||||
*
|
*
|
||||||
* @return the burn time
|
* @return the burn time
|
||||||
*/
|
*/
|
||||||
public short getBurnTime() {
|
public short getBurnTime() {
|
||||||
return burnTime;
|
return burnTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the burn time.
|
* Set the burn time.
|
||||||
*
|
*
|
||||||
* @param burnTime the burn time
|
* @param burnTime the burn time
|
||||||
*/
|
*/
|
||||||
public void setBurnTime(short burnTime) {
|
public void setBurnTime(short burnTime) {
|
||||||
this.burnTime = burnTime;
|
this.burnTime = burnTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the cook time.
|
* Get the cook time.
|
||||||
*
|
*
|
||||||
* @return the cook time
|
* @return the cook time
|
||||||
*/
|
*/
|
||||||
public short getCookTime() {
|
public short getCookTime() {
|
||||||
return cookTime;
|
return cookTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the cook time.
|
* Set the cook time.
|
||||||
*
|
*
|
||||||
* @param cookTime the cook time to set
|
* @param cookTime the cook time to set
|
||||||
*/
|
*/
|
||||||
public void setCookTime(short cookTime) {
|
public void setCookTime(short cookTime) {
|
||||||
this.cookTime = cookTime;
|
this.cookTime = cookTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNbtId() {
|
public String getNbtId() {
|
||||||
return "Furnace";
|
return "Furnace";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getNbtData() {
|
public CompoundTag getNbtData() {
|
||||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
Map<String, Tag> values = new HashMap<String, Tag>();
|
||||||
values.put("Items", new ListTag("Items", CompoundTag.class,
|
values.put("Items", new ListTag("Items", CompoundTag.class,
|
||||||
serializeInventory(getItems())));
|
serializeInventory(getItems())));
|
||||||
values.put("BurnTime", new ShortTag("BurnTime", burnTime));
|
values.put("BurnTime", new ShortTag("BurnTime", burnTime));
|
||||||
values.put("CookTime", new ShortTag("CookTime", cookTime));
|
values.put("CookTime", new ShortTag("CookTime", cookTime));
|
||||||
return new CompoundTag(getNbtId(), values);
|
return new CompoundTag(getNbtId(), values);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNbtData(CompoundTag rootTag) {
|
public void setNbtData(CompoundTag rootTag) {
|
||||||
if (rootTag == null) {
|
if (rootTag == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Map<String, Tag> values = rootTag.getValue();
|
Map<String, Tag> values = rootTag.getValue();
|
||||||
|
|
||||||
Tag t = values.get("id");
|
Tag t = values.get("id");
|
||||||
if (!(t instanceof StringTag)
|
if (!(t instanceof StringTag)
|
||||||
|| !((StringTag) t).getValue().equals("Furnace")) {
|
|| !((StringTag) t).getValue().equals("Furnace")) {
|
||||||
throw new RuntimeException("'Furnace' tile entity expected");
|
throw new RuntimeException("'Furnace' tile entity expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
ListTag items = NBTUtils.getChildTag(values, "Items", ListTag.class);
|
ListTag items = NBTUtils.getChildTag(values, "Items", ListTag.class);
|
||||||
|
|
||||||
List<CompoundTag> compound = new ArrayList<CompoundTag>();
|
List<CompoundTag> compound = new ArrayList<CompoundTag>();
|
||||||
|
|
||||||
for (Tag tag : items.getValue()) {
|
for (Tag tag : items.getValue()) {
|
||||||
if (!(tag instanceof CompoundTag)) {
|
if (!(tag instanceof CompoundTag)) {
|
||||||
throw new RuntimeException("CompoundTag expected as child tag of Furnace Items");
|
throw new RuntimeException("CompoundTag expected as child tag of Furnace Items");
|
||||||
}
|
}
|
||||||
compound.add((CompoundTag) tag);
|
compound.add((CompoundTag) tag);
|
||||||
}
|
}
|
||||||
setItems(deserializeInventory(compound));
|
setItems(deserializeInventory(compound));
|
||||||
|
|
||||||
t = values.get("BurnTime");
|
t = values.get("BurnTime");
|
||||||
if (t instanceof ShortTag) {
|
if (t instanceof ShortTag) {
|
||||||
burnTime = ((ShortTag) t).getValue();
|
burnTime = ((ShortTag) t).getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
t = values.get("CookTime");
|
t = values.get("CookTime");
|
||||||
if (t instanceof ShortTag) {
|
if (t instanceof ShortTag) {
|
||||||
cookTime = ((ShortTag) t).getValue();
|
cookTime = ((ShortTag) t).getValue();
|
||||||
}
|
}
|
||||||
} catch (DataException e) {
|
} catch (DataException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,123 +1,123 @@
|
|||||||
/*
|
/*
|
||||||
* WorldEdit, a Minecraft world manipulation toolkit
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* 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
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
* for more details.
|
* for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.blocks;
|
package com.sk89q.worldedit.blocks;
|
||||||
|
|
||||||
import com.sk89q.jnbt.ByteTag;
|
import com.sk89q.jnbt.ByteTag;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.StringTag;
|
import com.sk89q.jnbt.StringTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A note block.
|
* A note block.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class NoteBlock extends BaseBlock implements TileEntityBlock {
|
public class NoteBlock extends BaseBlock implements TileEntityBlock {
|
||||||
|
|
||||||
private byte note;
|
private byte note;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the note block with a data value of 0.
|
* Construct the note block with a data value of 0.
|
||||||
*/
|
*/
|
||||||
public NoteBlock() {
|
public NoteBlock() {
|
||||||
super(BlockID.NOTE_BLOCK);
|
super(BlockID.NOTE_BLOCK);
|
||||||
this.note = 0;
|
this.note = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the note block with a given data value.
|
* Construct the note block with a given data value.
|
||||||
*
|
*
|
||||||
* @param data data value
|
* @param data data value
|
||||||
*/
|
*/
|
||||||
public NoteBlock(int data) {
|
public NoteBlock(int data) {
|
||||||
super(BlockID.NOTE_BLOCK, data);
|
super(BlockID.NOTE_BLOCK, data);
|
||||||
this.note = 0;
|
this.note = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the note block with a given data value and note.
|
* Construct the note block with a given data value and note.
|
||||||
*
|
*
|
||||||
* @param data data value
|
* @param data data value
|
||||||
* @param note note
|
* @param note note
|
||||||
*/
|
*/
|
||||||
public NoteBlock(int data, byte note) {
|
public NoteBlock(int data, byte note) {
|
||||||
super(BlockID.NOTE_BLOCK, data);
|
super(BlockID.NOTE_BLOCK, data);
|
||||||
this.note = note;
|
this.note = note;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the note.
|
* Get the note.
|
||||||
*
|
*
|
||||||
* @return the note
|
* @return the note
|
||||||
*/
|
*/
|
||||||
public byte getNote() {
|
public byte getNote() {
|
||||||
return note;
|
return note;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the note.
|
* Set the note.
|
||||||
*
|
*
|
||||||
* @param note the note to set
|
* @param note the note to set
|
||||||
*/
|
*/
|
||||||
public void setNote(byte note) {
|
public void setNote(byte note) {
|
||||||
this.note = note;
|
this.note = note;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNbtData() {
|
public boolean hasNbtData() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNbtId() {
|
public String getNbtId() {
|
||||||
return "Music";
|
return "Music";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getNbtData() {
|
public CompoundTag getNbtData() {
|
||||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
Map<String, Tag> values = new HashMap<String, Tag>();
|
||||||
values.put("note", new ByteTag("note", note));
|
values.put("note", new ByteTag("note", note));
|
||||||
return new CompoundTag(getNbtId(), values);
|
return new CompoundTag(getNbtId(), values);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNbtData(CompoundTag rootTag) {
|
public void setNbtData(CompoundTag rootTag) {
|
||||||
if (rootTag == null) {
|
if (rootTag == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Tag> values = rootTag.getValue();
|
Map<String, Tag> values = rootTag.getValue();
|
||||||
|
|
||||||
Tag t;
|
Tag t;
|
||||||
|
|
||||||
t = values.get("id");
|
t = values.get("id");
|
||||||
if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Music")) {
|
if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Music")) {
|
||||||
throw new RuntimeException("'Music' tile entity expected");
|
throw new RuntimeException("'Music' tile entity expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
t = values.get("note");
|
t = values.get("note");
|
||||||
if (t instanceof ByteTag) {
|
if (t instanceof ByteTag) {
|
||||||
note = ((ByteTag) t).getValue();
|
note = ((ByteTag) t).getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,194 +1,194 @@
|
|||||||
/*
|
/*
|
||||||
* WorldEdit, a Minecraft world manipulation toolkit
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
* Copyright (C) WorldEdit team and contributors
|
* Copyright (C) WorldEdit team and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* 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
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
* Free Software Foundation, either version 3 of the License, or
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
* for more details.
|
* for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.blocks;
|
package com.sk89q.worldedit.blocks;
|
||||||
|
|
||||||
import com.sk89q.jnbt.ByteTag;
|
import com.sk89q.jnbt.ByteTag;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.StringTag;
|
import com.sk89q.jnbt.StringTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A skull block.
|
* A skull block.
|
||||||
*/
|
*/
|
||||||
public class SkullBlock extends BaseBlock implements TileEntityBlock {
|
public class SkullBlock extends BaseBlock implements TileEntityBlock {
|
||||||
|
|
||||||
private String owner = ""; // notchian
|
private String owner = ""; // notchian
|
||||||
private byte skullType; // stored here for block, in damage value for item
|
private byte skullType; // stored here for block, in damage value for item
|
||||||
private byte rot; // only matters if block data == 0x1 (on floor)
|
private byte rot; // only matters if block data == 0x1 (on floor)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the skull block with a default type of skelton.
|
* Construct the skull block with a default type of skelton.
|
||||||
* @param data data value to set, controls placement
|
* @param data data value to set, controls placement
|
||||||
*/
|
*/
|
||||||
public SkullBlock(int data) {
|
public SkullBlock(int data) {
|
||||||
this(data, (byte) 0);
|
this(data, (byte) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the skull block with a given type.
|
* Construct the skull block with a given type.
|
||||||
* 0 - skeleton
|
* 0 - skeleton
|
||||||
* 1 - wither skelly
|
* 1 - wither skelly
|
||||||
* 2 - zombie
|
* 2 - zombie
|
||||||
* 3 - human
|
* 3 - human
|
||||||
* 4 - creeper
|
* 4 - creeper
|
||||||
* @param data data value to set, controls placement
|
* @param data data value to set, controls placement
|
||||||
* @param type type of skull
|
* @param type type of skull
|
||||||
*/
|
*/
|
||||||
public SkullBlock(int data, byte type) {
|
public SkullBlock(int data, byte type) {
|
||||||
this(data, type, (byte) 0);
|
this(data, type, (byte) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the skull block with a given type and rotation.
|
* Construct the skull block with a given type and rotation.
|
||||||
* @param data data value to set, controls placement
|
* @param data data value to set, controls placement
|
||||||
* @param type type of skull
|
* @param type type of skull
|
||||||
* @param rot rotation (if on floor)
|
* @param rot rotation (if on floor)
|
||||||
*/
|
*/
|
||||||
public SkullBlock(int data, byte type, byte rot) {
|
public SkullBlock(int data, byte type, byte rot) {
|
||||||
super(BlockID.HEAD, data);
|
super(BlockID.HEAD, data);
|
||||||
if (type < (byte) 0 || type > (byte) 4) {
|
if (type < (byte) 0 || type > (byte) 4) {
|
||||||
this.skullType = (byte) 0;
|
this.skullType = (byte) 0;
|
||||||
} else {
|
} else {
|
||||||
this.skullType = type;
|
this.skullType = type;
|
||||||
}
|
}
|
||||||
this.rot = rot;
|
this.rot = rot;
|
||||||
this.owner = "";
|
this.owner = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the skull block with a given rotation and owner.
|
* Construct the skull block with a given rotation and owner.
|
||||||
* The type is assumed to be player unless owner is null or empty.
|
* The type is assumed to be player unless owner is null or empty.
|
||||||
* @param data data value to set, controls placement
|
* @param data data value to set, controls placement
|
||||||
* @param rot rotation of skull
|
* @param rot rotation of skull
|
||||||
* @param owner name of player
|
* @param owner name of player
|
||||||
*/
|
*/
|
||||||
public SkullBlock(int data, byte rot, String owner) {
|
public SkullBlock(int data, byte rot, String owner) {
|
||||||
super(BlockID.HEAD, data);
|
super(BlockID.HEAD, data);
|
||||||
this.rot = rot;
|
this.rot = rot;
|
||||||
this.setOwner(owner);
|
this.setOwner(owner);
|
||||||
if (owner == null || owner.isEmpty()) this.skullType = (byte) 0;
|
if (owner == null || owner.isEmpty()) this.skullType = (byte) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the skull's owner. Automatically sets type to player if not empty or null.
|
* Set the skull's owner. Automatically sets type to player if not empty or null.
|
||||||
* @param owner player name to set the skull to
|
* @param owner player name to set the skull to
|
||||||
*/
|
*/
|
||||||
public void setOwner(String owner) {
|
public void setOwner(String owner) {
|
||||||
if (owner == null) {
|
if (owner == null) {
|
||||||
this.owner = "";
|
this.owner = "";
|
||||||
} else {
|
} else {
|
||||||
if (owner.length() > 16 || owner.isEmpty()) this.owner = "";
|
if (owner.length() > 16 || owner.isEmpty()) this.owner = "";
|
||||||
else this.owner = owner;
|
else this.owner = owner;
|
||||||
}
|
}
|
||||||
if (this.owner != null && !this.owner.isEmpty()) this.skullType = (byte) 3;
|
if (this.owner != null && !this.owner.isEmpty()) this.skullType = (byte) 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the skull's owner. Returns null if unset.
|
* Get the skull's owner. Returns null if unset.
|
||||||
* @return player name or null
|
* @return player name or null
|
||||||
*/
|
*/
|
||||||
public String getOwner() {
|
public String getOwner() {
|
||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the type of skull.
|
* Get the type of skull.
|
||||||
* @return the skullType
|
* @return the skullType
|
||||||
*/
|
*/
|
||||||
public byte getSkullType() {
|
public byte getSkullType() {
|
||||||
return skullType;
|
return skullType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the type of skull;
|
* Set the type of skull;
|
||||||
* @param skullType the skullType to set
|
* @param skullType the skullType to set
|
||||||
*/
|
*/
|
||||||
public void setSkullType(byte skullType) {
|
public void setSkullType(byte skullType) {
|
||||||
this.skullType = skullType;
|
this.skullType = skullType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get rotation of skull. This only means anything if the block data is 1.
|
* Get rotation of skull. This only means anything if the block data is 1.
|
||||||
* @return the rotation
|
* @return the rotation
|
||||||
*/
|
*/
|
||||||
public byte getRot() {
|
public byte getRot() {
|
||||||
return rot;
|
return rot;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the rotation of skull.
|
* Set the rotation of skull.
|
||||||
* @param rot the rotation to set
|
* @param rot the rotation to set
|
||||||
*/
|
*/
|
||||||
public void setRot(byte rot) {
|
public void setRot(byte rot) {
|
||||||
this.rot = rot;
|
this.rot = rot;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNbtData() {
|
public boolean hasNbtData() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNbtId() {
|
public String getNbtId() {
|
||||||
return "Skull";
|
return "Skull";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getNbtData() {
|
public CompoundTag getNbtData() {
|
||||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
Map<String, Tag> values = new HashMap<String, Tag>();
|
||||||
values.put("SkullType", new ByteTag("SkullType", skullType));
|
values.put("SkullType", new ByteTag("SkullType", skullType));
|
||||||
if (owner == null) owner = "";
|
if (owner == null) owner = "";
|
||||||
values.put("ExtraType", new StringTag("ExtraType", owner));
|
values.put("ExtraType", new StringTag("ExtraType", owner));
|
||||||
values.put("Rot", new ByteTag("Rot", rot));
|
values.put("Rot", new ByteTag("Rot", rot));
|
||||||
return new CompoundTag(getNbtId(), values);
|
return new CompoundTag(getNbtId(), values);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNbtData(CompoundTag rootTag) {
|
public void setNbtData(CompoundTag rootTag) {
|
||||||
if (rootTag == null) {
|
if (rootTag == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Tag> values = rootTag.getValue();
|
Map<String, Tag> values = rootTag.getValue();
|
||||||
|
|
||||||
Tag t;
|
Tag t;
|
||||||
|
|
||||||
t = values.get("id");
|
t = values.get("id");
|
||||||
if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Skull")) {
|
if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Skull")) {
|
||||||
throw new RuntimeException("'Skull' tile entity expected");
|
throw new RuntimeException("'Skull' tile entity expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
t = values.get("SkullType");
|
t = values.get("SkullType");
|
||||||
if (t instanceof ByteTag) {
|
if (t instanceof ByteTag) {
|
||||||
skullType = ((ByteTag) t).getValue();
|
skullType = ((ByteTag) t).getValue();
|
||||||
}
|
}
|
||||||
t = values.get("ExtraType");
|
t = values.get("ExtraType");
|
||||||
if (t != null && t instanceof StringTag) {
|
if (t != null && t instanceof StringTag) {
|
||||||
owner = ((StringTag) t).getValue();
|
owner = ((StringTag) t).getValue();
|
||||||
}
|
}
|
||||||
t = values.get("Rot");
|
t = values.get("Rot");
|
||||||
if (t instanceof ByteTag) {
|
if (t instanceof ByteTag) {
|
||||||
rot = ((ByteTag) t).getValue();
|
rot = ((ByteTag) t).getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user