public boolean setFacingDirection(BlockFace face, boolean force) { EntityHanging hanging = getHandle(); EnumDirection dir = hanging.direction; switch (face) { case SOUTH: default: getHandle().setDirection(EnumDirection.SOUTH); break; case WEST: getHandle().setDirection(EnumDirection.WEST); break; case NORTH: getHandle().setDirection(EnumDirection.NORTH); break; case EAST: getHandle().setDirection(EnumDirection.EAST); break; } if (!force && !hanging.survives()) { // Revert since it doesn't fit hanging.setDirection(dir); return false; } return true; }
public boolean setFacingDirection(BlockFace face, boolean force) { Block block = getLocation().getBlock().getRelative(getAttachedFace()).getRelative(face.getOppositeFace()).getRelative(getFacing()); EntityHanging hanging = getHandle(); int x = hanging.x, y = hanging.y, z = hanging.z, dir = hanging.direction; hanging.x = block.getX(); hanging.y = block.getY(); hanging.z = block.getZ(); switch (face) { case SOUTH: default: getHandle().setDirection(0); break; case WEST: getHandle().setDirection(1); break; case NORTH: getHandle().setDirection(2); break; case EAST: getHandle().setDirection(3); break; } if (!force && !hanging.survives()) { // Revert since it doesn't fit hanging.x = x; hanging.y = y; hanging.z = z; hanging.setDirection(dir); return false; } return true; }
public CraftHanging(CraftServer server, EntityHanging entity) { super(server, entity); }
@Override public EntityHanging getHandle() { return (EntityHanging) entity; }