Not worth doing.
The ea82 will bolt up to the flywheel and gearbox of the ea81. But to fit the EA82 you will have to widen the chassis rails to clear the cam boxes and covers.
If you're really desperate there are engines available on gumtree. One on there (can't remember in what state) for $350.
And if you're looking into an engine transplant, go for an EJ22. The wiring is the hardest part. Either drop an ea82 5spd box in with an adaptor plate or fit the EJ AWD box (diff ratio and tyre size won't match though). Both require mods to fit but have been done before.
With the knock and the detonation:
Knock: reseal the oil pump to ensure it's pumping as much oil as possible! Remove the crank pulley to remove the oil pump, otherwise you'll crack the pump - and you don't want to do that (might as well buy another engine if that happens!).
Detonation: check the valve clearances first. Then check spark timing. Also ensure all vacuum lines are attached properly and not cracked or leaking.
Check the carb's throttle shaft for play. If there's lots, replace the carby with one in better condition. If you can freely wiggle the throttle shaft this can lean out the fuel mixture creating detonation. A weber carb can be a solution but can cause other issues, not to mention it takes away a fair chunk of money that could go towards an EJ22 conversion. Have the hitachi carby rebuilt/fully serviced.
In hot weather shorting out the radiator temp switch (single yellow wire) will run the fans all the time. Add a wire from the switch to the body somewhere secure to trigger the thermofan circuit. This will keep the engine on operating temp and avoid higher running temps that trigger the fans at about 95*C. Normal engine running temp is usually 82*C.
Keep oil level up and ensure the same for your coolant. Run a thick oil. I run Penrite mineral "extra 10" 20w-60. Recently I've used a 25w-60 as I'm using oil, this seems to have stopped the issue.
That could keep your ea81 going a bit longer
when looked after and not flogged every day these engines are the bullet proof one in the EA family - the EJ22 is the "offspring" of this engine
Cheers
Bennie