if(world.isRemote)
{
return true;
}
TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(x, y, z);
int metadata = world.getBlockMetadata(x, y, z);
if(entityplayer.getCurrentEquippedItem() != null)
{
Item tool = entityplayer.getCurrentEquippedItem().getItem();
if(MekanismUtils.hasUsableWrench(entityplayer, x, y, z))
{
if(entityplayer.isSneaking() && metadata != 13)
{
dismantleBlock(world, x, y, z, false);
return true;
}
if(ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|tools") && tool instanceof IToolWrench)
((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z);
int change = ForgeDirection.ROTATION_MATRIX[ForgeDirection.UP.ordinal()][tileEntity.facing];
if(tileEntity instanceof TileEntityLogisticalSorter)
{
if(!((TileEntityLogisticalSorter)tileEntity).hasInventory())
{
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity tile = Coord4D.get(tileEntity).getFromSide(dir).getTileEntity(world);
if(tile instanceof IInventory)
{
change = dir.getOpposite().ordinal();
break;
}
}
}
}
tileEntity.setFacing((short)change);
world.notifyBlocksOfNeighborChange(x, y, z, this);
return true;
}
}