SPIGOT-206 Further checks and fixes for Hanging entities.

Adds an check for existing entities before selecting the location allowing
for hanging entities to be spawned in blocks where there already is an
hanging entity at the default rotation.
Fixes the CraftHanging setRotation function to use the new 1.8 logic.

By: Stefan <admin@fearthe1337.com>
This commit is contained in:
CraftBukkit/Spigot
2014-12-14 17:22:59 +01:00
parent 83a169e567
commit 77a6c4c7a7
3 changed files with 110 additions and 14 deletions

View File

@@ -23,11 +23,8 @@ public class CraftHanging extends CraftEntity implements Hanging {
}
public boolean setFacingDirection(BlockFace face, boolean force) {
Block block = getLocation().getBlock().getRelative(getAttachedFace()).getRelative(face.getOppositeFace()).getRelative(getFacing());
EntityHanging hanging = getHandle();
BlockPosition old = hanging.getBlockPosition();
EnumDirection dir = hanging.direction;
hanging.blockPosition = new BlockPosition(block.getX(), block.getY(), block.getZ());
switch (face) {
case SOUTH:
default:
@@ -45,7 +42,6 @@ public class CraftHanging extends CraftEntity implements Hanging {
}
if (!force && !hanging.survives()) {
// Revert since it doesn't fit
hanging.blockPosition = old;
hanging.setDirection(dir);
return false;
}