diff options
author | FearThe1337 <admin@fearthe1337.com> | 2014-12-17 23:45:49 +0100 |
---|---|---|
committer | md_5 <git@md-5.net> | 2014-12-21 09:59:45 +1100 |
commit | 89944c09c92a54039bbf6b1608f6822a11f33e0e (patch) | |
tree | 9124404e64f1972c6ca2fd4f5a22ae86f5751226 /src/main/java | |
parent | ce7dd34b5c96a417a2ad870d66c79180eacda57d (diff) | |
download | craftbukkit-89944c09c92a54039bbf6b1608f6822a11f33e0e.tar craftbukkit-89944c09c92a54039bbf6b1608f6822a11f33e0e.tar.gz craftbukkit-89944c09c92a54039bbf6b1608f6822a11f33e0e.tar.lz craftbukkit-89944c09c92a54039bbf6b1608f6822a11f33e0e.tar.xz craftbukkit-89944c09c92a54039bbf6b1608f6822a11f33e0e.zip |
SPIGOT-231 and SPIGOT-229. Fix itemframe behaviour.
Confirmed fix for itemframes not showing up. Based on the code in
CraftPainting.
Besids this fix we now pass null itemstacks directly to the
EntityItemFrame to allow the removal of items in ItemFrames.
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java index 82370939..d27f24f8 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java @@ -1,6 +1,9 @@ package org.bukkit.craftbukkit.entity; +import net.minecraft.server.BlockPosition; import net.minecraft.server.EntityItemFrame; +import net.minecraft.server.EnumDirection; +import net.minecraft.server.ItemStack; import net.minecraft.server.WorldServer; import org.apache.commons.lang.Validate; @@ -23,16 +26,31 @@ public class CraftItemFrame extends CraftHanging implements ItemFrame { return false; } - WorldServer world = ((CraftWorld) this.getWorld()).getHandle(); - world.getTracker().untrackEntity(this.getHandle()); - world.getTracker().track(this.getHandle()); + update(); + return true; } + private void update() { + EntityItemFrame old = this.getHandle(); + + WorldServer world = ((CraftWorld) getWorld()).getHandle(); + BlockPosition position = old.getBlockPosition(); + EnumDirection direction = old.getDirection(); + ItemStack item = old.getItem() != null ? old.getItem().cloneItemStack() : null; + + old.die(); + + EntityItemFrame frame = new EntityItemFrame(world,position,direction); + frame.setItem(item); + world.addEntity(frame); + this.entity = frame; + } + + public void setItem(org.bukkit.inventory.ItemStack item) { if (item == null || item.getTypeId() == 0) { - getHandle().getDataWatcher().add(2, 5); - getHandle().getDataWatcher().update(2); + getHandle().setItem(null); } else { getHandle().setItem(CraftItemStack.asNMSCopy(item)); } |