From 8ee6f8cd25b2e959ed60227783cab6b40ebfbd5b Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Tue, 24 Jul 2018 18:41:49 -0400 Subject: [PATCH] SPIGOT-4147: Fix ItemFrames not able to be placed UP or DOWN By: Senmori --- .../bukkit/craftbukkit/entity/CraftHanging.java | 15 ++------------- .../bukkit/craftbukkit/entity/CraftItemFrame.java | 11 ++++++++++- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java index 411c023de1..d9a871a8cc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHanging.java @@ -1,11 +1,10 @@ package org.bukkit.craftbukkit.entity; -import net.minecraft.server.BlockPosition; import net.minecraft.server.EntityHanging; import net.minecraft.server.EnumDirection; -import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.entity.EntityType; import org.bukkit.entity.Hanging; @@ -51,17 +50,7 @@ public class CraftHanging extends CraftEntity implements Hanging { public BlockFace getFacing() { EnumDirection direction = this.getHandle().direction; if (direction == null) return BlockFace.SELF; - switch (direction) { - case SOUTH: - default: - return BlockFace.SOUTH; - case WEST: - return BlockFace.WEST; - case NORTH: - return BlockFace.NORTH; - case EAST: - return BlockFace.EAST; - } + return CraftBlock.notchToBlockFace(direction); } @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java index 95647efc78..75812a5899 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItemFrame.java @@ -1,6 +1,7 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.BlockPosition; +import net.minecraft.server.EntityHanging; import net.minecraft.server.EntityItemFrame; import net.minecraft.server.EnumDirection; import net.minecraft.server.ItemStack; @@ -12,6 +13,7 @@ import org.bukkit.Rotation; import org.bukkit.block.BlockFace; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.entity.EntityType; import org.bukkit.entity.ItemFrame; @@ -21,8 +23,15 @@ public class CraftItemFrame extends CraftHanging implements ItemFrame { super(server, entity); } + @Override public boolean setFacingDirection(BlockFace face, boolean force) { - if (!super.setFacingDirection(face, force)) { + EntityHanging hanging = getHandle(); + EnumDirection oldDir = hanging.direction; + EnumDirection newDir = CraftBlock.blockFaceToNotch(face); + + getHandle().setDirection(newDir); + if (!force && !hanging.survives()) { + hanging.setDirection(oldDir); return false; }