mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 11:44:19 +01:00
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. By: Stefan <admin@fearthe1337.com>
This commit is contained in:
parent
d4fdb3d6f7
commit
23b276843f
1 changed files with 10 additions and 24 deletions
|
@ -1018,32 +1018,18 @@ public class CraftWorld implements World {
|
||||||
} else if (Hanging.class.isAssignableFrom(clazz)) {
|
} else if (Hanging.class.isAssignableFrom(clazz)) {
|
||||||
Block block = getBlockAt(location);
|
Block block = getBlockAt(location);
|
||||||
BlockFace face = BlockFace.SELF;
|
BlockFace face = BlockFace.SELF;
|
||||||
if (block.getRelative(BlockFace.EAST).getTypeId() == 0) {
|
|
||||||
face = BlockFace.EAST;
|
BlockFace[] faces = new BlockFace[]{BlockFace.EAST,BlockFace.NORTH,BlockFace.WEST,BlockFace.SOUTH};
|
||||||
} else if (block.getRelative(BlockFace.NORTH).getTypeId() == 0) {
|
for(BlockFace dir : faces){
|
||||||
face = BlockFace.NORTH;
|
net.minecraft.server.Block nmsBlock = CraftMagicNumbers.getBlock(block.getRelative(dir));
|
||||||
} else if (block.getRelative(BlockFace.WEST).getTypeId() == 0) {
|
if(nmsBlock.getMaterial().isBuildable() || BlockDiodeAbstract.d(nmsBlock)) {
|
||||||
face = BlockFace.WEST;
|
face = dir;
|
||||||
} else if (block.getRelative(BlockFace.SOUTH).getTypeId() == 0) {
|
break;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EnumDirection dir = CraftBlock.blockFaceToNotch(face).opposite();
|
||||||
|
|
||||||
if (Painting.class.isAssignableFrom(clazz)) {
|
if (Painting.class.isAssignableFrom(clazz)) {
|
||||||
entity = new EntityPainting(world, new BlockPosition((int) x, (int) y, (int) z), dir);
|
entity = new EntityPainting(world, new BlockPosition((int) x, (int) y, (int) z), dir);
|
||||||
} else if (ItemFrame.class.isAssignableFrom(clazz)) {
|
} else if (ItemFrame.class.isAssignableFrom(clazz)) {
|
||||||
|
|
Loading…
Reference in a new issue