summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorStefan <admin@fearthe1337.com>2014-12-13 17:26:00 +0100
committerStefan <admin@fearthe1337.com>2014-12-13 19:15:29 +0100
commit01f0122a9e4ab863595a39ca4dca342f10dcc477 (patch)
tree4a2e3f9cdd121b9ed43ddd77e1c04c92daf9cf3a /src/main/java
parent354449ae9ad4019885eb3244ba8b06da4906cc6d (diff)
downloadcraftbukkit-01f0122a9e4ab863595a39ca4dca342f10dcc477.tar
craftbukkit-01f0122a9e4ab863595a39ca4dca342f10dcc477.tar.gz
craftbukkit-01f0122a9e4ab863595a39ca4dca342f10dcc477.tar.lz
craftbukkit-01f0122a9e4ab863595a39ca4dca342f10dcc477.tar.xz
craftbukkit-01f0122a9e4ab863595a39ca4dca342f10dcc477.zip
Fix the spawning of HangingEntities by picking the right direction
Related to SPIGOT-206. Currently HangingEntities should be located next to the block they are hanging on. With the direction set to the opposite of the block they are hanging from. This code is modified to find the correct direction.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftWorld.java34
1 files changed, 10 insertions, 24 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 83efd6ae..a7d3e5fa 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -1018,32 +1018,18 @@ public class CraftWorld implements World {
} else if (Hanging.class.isAssignableFrom(clazz)) {
Block block = getBlockAt(location);
BlockFace face = BlockFace.SELF;
- if (block.getRelative(BlockFace.EAST).getTypeId() == 0) {
- face = BlockFace.EAST;
- } else if (block.getRelative(BlockFace.NORTH).getTypeId() == 0) {
- face = BlockFace.NORTH;
- } else if (block.getRelative(BlockFace.WEST).getTypeId() == 0) {
- face = BlockFace.WEST;
- } else if (block.getRelative(BlockFace.SOUTH).getTypeId() == 0) {
- face = BlockFace.SOUTH;
- }
- EnumDirection dir;
- switch (face) {
- case SOUTH:
- default:
- dir = EnumDirection.SOUTH;
- break;
- case WEST:
- dir = EnumDirection.WEST;
- break;
- case NORTH:
- dir = EnumDirection.NORTH;
- break;
- case EAST:
- dir = EnumDirection.EAST;
- break;
+
+ BlockFace[] faces = new BlockFace[]{BlockFace.EAST,BlockFace.NORTH,BlockFace.WEST,BlockFace.SOUTH};
+ for(BlockFace dir : faces){
+ net.minecraft.server.Block nmsBlock = CraftMagicNumbers.getBlock(block.getRelative(dir));
+ if(nmsBlock.getMaterial().isBuildable() || BlockDiodeAbstract.d(nmsBlock)) {
+ face = dir;
+ break;
+ }
}
+ EnumDirection dir = CraftBlock.blockFaceToNotch(face).opposite();
+
if (Painting.class.isAssignableFrom(clazz)) {
entity = new EntityPainting(world, new BlockPosition((int) x, (int) y, (int) z), dir);
} else if (ItemFrame.class.isAssignableFrom(clazz)) {