/* * This messy function is a work in progress. It is a temporary setup for * placing a custom block from my mod over the door of the given npch. * * Returns the location of where the sign should be placed. * * Needs to be rewritten badly. */ public static BlockPos placeBlockOverDoor( ItemStack stack, EntityPlayer playerIn, World worldIn, NPCHouse npch, String block_name, float hitX, float hitY, float hitZ) { String placeMe = ("bh_housing:" + block_name); BlockPos door = BlockHelper.findDoor(worldIn, npch); if (!door.equals(npch.getCorner(0))) { int north = npch.getCorner(0).getZ(); int south = npch.getCorner(2).getZ(); int west = npch.getCorner(0).getX(); int east = npch.getCorner(1).getX(); BlockPos placeHere = door; boolean shouldUse = false; EnumFacing direction = EnumFacing.NORTH; if (worldIn.getBlockState(placeHere).getBlock() instanceof NPCHouse_Block) { return placeHere; } else if (door.getX() == west) { placeHere = door.up().west(); direction = EnumFacing.WEST; } else if (door.getX() == east) { placeHere = door.up().east(); direction = EnumFacing.EAST; } else if (door.getZ() == north) { placeHere = door.up().north(); direction = EnumFacing.NORTH; } else if (door.getZ() == south) { placeHere = door.up().south(); direction = EnumFacing.SOUTH; } shouldUse = worldIn.setBlockState( placeHere, NPCHouse_Block.getBlockFromName(placeMe) .getDefaultState() .withProperty(NPCHouse_Block.FACING, direction), 3); if (shouldUse) { --stack.stackSize; if (stack.stackSize == 0) { playerIn.destroyCurrentEquippedItem(); } if (block_name == "npch_block") { NPCHouse_Block npchblock = (NPCHouse_Block) worldIn.getBlockState(placeHere).getBlock(); npchblock.setNPCHouse(npch); } IBlockState temp = worldIn.getBlockState(placeHere); if (temp.getBlock().getRegistryName() == "npch_block") { ItemBlock.setTileEntityNBT( worldIn, playerIn, placeHere, new ItemStack(Block.getBlockFromName("npch_block"), 1)); } } return placeHere; } return null; }