From b880bd518f798ea3a16424fe995d58eb3e0e2776 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Sun, 23 Jan 2011 00:37:36 -0800 Subject: [PATCH] Added full tile entity data support for all block types that use it, including chests, dispensers, furnaces, mob spawners, and note blocks. By: sk89q --- .../src/main/java/org/bukkit/block/Chest.java | 9 ++++ .../java/org/bukkit/block/ContainerBlock.java | 17 ++++++ .../main/java/org/bukkit/block/Dispenser.java | 9 ++++ .../main/java/org/bukkit/block/Furnace.java | 36 +++++++++++++ .../java/org/bukkit/block/MobSpawner.java | 52 +++++++++++++++++++ .../main/java/org/bukkit/block/NoteBlock.java | 22 ++++++++ .../main/java/org/bukkit/entity/MobType.java | 18 ++++++- 7 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 paper-api/src/main/java/org/bukkit/block/Chest.java create mode 100644 paper-api/src/main/java/org/bukkit/block/ContainerBlock.java create mode 100644 paper-api/src/main/java/org/bukkit/block/Dispenser.java create mode 100644 paper-api/src/main/java/org/bukkit/block/Furnace.java create mode 100644 paper-api/src/main/java/org/bukkit/block/MobSpawner.java create mode 100644 paper-api/src/main/java/org/bukkit/block/NoteBlock.java diff --git a/paper-api/src/main/java/org/bukkit/block/Chest.java b/paper-api/src/main/java/org/bukkit/block/Chest.java new file mode 100644 index 0000000000..8d2af5d9ae --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/block/Chest.java @@ -0,0 +1,9 @@ +package org.bukkit.block; + +/** + * Represents a chest. + * + * @author sk89q + */ +public interface Chest extends BlockState, ContainerBlock { +} diff --git a/paper-api/src/main/java/org/bukkit/block/ContainerBlock.java b/paper-api/src/main/java/org/bukkit/block/ContainerBlock.java new file mode 100644 index 0000000000..6c271ffa3a --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/block/ContainerBlock.java @@ -0,0 +1,17 @@ +package org.bukkit.block; + +import org.bukkit.inventory.Inventory; + +/** + * Indicates a block type that has inventory. + * + * @author sk89q + */ +public interface ContainerBlock { + /** + * Get the block's inventory. + * + * @return + */ + public Inventory getInventory(); +} diff --git a/paper-api/src/main/java/org/bukkit/block/Dispenser.java b/paper-api/src/main/java/org/bukkit/block/Dispenser.java new file mode 100644 index 0000000000..6469251467 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/block/Dispenser.java @@ -0,0 +1,9 @@ +package org.bukkit.block; + +/** + * Represents a dispenser. + * + * @author sk89q + */ +public interface Dispenser extends BlockState, ContainerBlock { +} diff --git a/paper-api/src/main/java/org/bukkit/block/Furnace.java b/paper-api/src/main/java/org/bukkit/block/Furnace.java new file mode 100644 index 0000000000..6f3e2bea5a --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/block/Furnace.java @@ -0,0 +1,36 @@ +package org.bukkit.block; + +/** + * Represents a furnace. + * + * @author sk89q + */ +public interface Furnace extends BlockState, ContainerBlock { + /** + * Get burn time. + * + * @return + */ + public short getBurnTime(); + + /** + * Set burn time. + * + * @param burnTime + */ + public void setBurnTime(short burnTime); + + /** + * Get cook time. + * + * @return + */ + public short getCookTime(); + + /** + * Set cook time. + * + * @param cookTime + */ + public void setCookTime(short cookTime); +} diff --git a/paper-api/src/main/java/org/bukkit/block/MobSpawner.java b/paper-api/src/main/java/org/bukkit/block/MobSpawner.java new file mode 100644 index 0000000000..53c2ee6b27 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/block/MobSpawner.java @@ -0,0 +1,52 @@ +package org.bukkit.block; + +import org.bukkit.entity.MobType; + +/** + * Represents a mob spawner. + * + * @author sk89q + */ +public interface MobSpawner extends BlockState { + /** + * Get the spawner's mob type. + * + * @return + */ + public MobType getMobType(); + + /** + * Set the spawner mob type. + * + * @param mobType + */ + public void setMobType(MobType mobType); + + /** + * Get the spawner's mob type. + * + * @return + */ + public String getMobTypeId(); + + /** + * Set the spawner mob type. + * + * @param mobType + */ + public void setMobTypeId(String mobType); + + /** + * Get the spawner's delay. + * + * @return + */ + public int getDelay(); + + /** + * Set the spawner's delay. + * + * @param delay + */ + public void setDelay(int delay); +} diff --git a/paper-api/src/main/java/org/bukkit/block/NoteBlock.java b/paper-api/src/main/java/org/bukkit/block/NoteBlock.java new file mode 100644 index 0000000000..5e318a1994 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/block/NoteBlock.java @@ -0,0 +1,22 @@ +package org.bukkit.block; + +/** + * Represents a note. + * + * @author sk89q + */ +public interface NoteBlock extends BlockState { + /** + * Gets the note. + * + * @return + */ + public byte getNote(); + + /** + * Set the note. + * + * @param note + */ + public void setNote(byte note); +} diff --git a/paper-api/src/main/java/org/bukkit/entity/MobType.java b/paper-api/src/main/java/org/bukkit/entity/MobType.java index 7f52a7ad59..9fc3f933f2 100644 --- a/paper-api/src/main/java/org/bukkit/entity/MobType.java +++ b/paper-api/src/main/java/org/bukkit/entity/MobType.java @@ -1,5 +1,9 @@ package org.bukkit.entity; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.Map; + public enum MobType { CHICKEN("Chicken"), COW("Cow"), @@ -13,6 +17,15 @@ public enum MobType { ZOMBIE("Zombie"); private String name; + + private static final Map mapping + = new HashMap(); + + static { + for (MobType type : EnumSet.allOf(MobType.class)) { + mapping.put(type.name, type); + } + } private MobType(String name) { this.name = name; @@ -21,5 +34,8 @@ public enum MobType { public String getName() { return name; } - + + public static MobType fromName(String name) { + return mapping.get(name); + } }