diff options
author | feildmaster <admin@feildmaster.com> | 2012-12-21 23:56:54 -0600 |
---|---|---|
committer | feildmaster <admin@feildmaster.com> | 2012-12-21 23:56:54 -0600 |
commit | 2ee62eb580d88bdd59bf42ea4c6f9a12255398dd (patch) | |
tree | f7698023dde127e4f94fbbc4e0e116ad472f7b85 /src/main/java/org | |
parent | fdb4b2d911b66c2dff05ba39b4ab58a34f6ff911 (diff) | |
download | craftbukkit-2ee62eb580d88bdd59bf42ea4c6f9a12255398dd.tar craftbukkit-2ee62eb580d88bdd59bf42ea4c6f9a12255398dd.tar.gz craftbukkit-2ee62eb580d88bdd59bf42ea4c6f9a12255398dd.tar.lz craftbukkit-2ee62eb580d88bdd59bf42ea4c6f9a12255398dd.tar.xz craftbukkit-2ee62eb580d88bdd59bf42ea4c6f9a12255398dd.zip |
Implement API to get and set FireworkMeta on Firework entities
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java index 78e5baa1..6bc22e4c 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java @@ -1,15 +1,37 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityFireworks; +import net.minecraft.server.Item; +import net.minecraft.server.ItemStack; +import org.bukkit.Material; import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.entity.EntityType; import org.bukkit.entity.Firework; +import org.bukkit.inventory.meta.FireworkMeta; public class CraftFirework extends CraftEntity implements Firework { + private static final int FIREWORK_ITEM_INDEX = 8; + + private final CraftItemStack item; public CraftFirework(CraftServer server, EntityFireworks entity) { super(server, entity); + + ItemStack item = getHandle().getDataWatcher().f(FIREWORK_ITEM_INDEX); + + if (item == null) { + item = new ItemStack(Item.FIREWORKS); + getHandle().getDataWatcher().watch(FIREWORK_ITEM_INDEX, item); + } + + this.item = CraftItemStack.asCraftMirror(item); + + // Ensure the item is a firework... + if (this.item.getType() != Material.FIREWORK) { + this.item.setType(Material.FIREWORK); + } } @Override @@ -25,4 +47,12 @@ public class CraftFirework extends CraftEntity implements Firework { public EntityType getType() { return EntityType.FIREWORK; } + + public FireworkMeta getFireworkMeta() { + return (FireworkMeta) item.getItemMeta(); + } + + public void setFireworkMeta(FireworkMeta meta) { + item.setItemMeta(meta); + } } |