MinecraftForge/MinecraftForge — pull request #59 by psxlover (2012-05-14 17:08:23+00:00)
Title: ISetBlockHandler hook 

A hook in world.setBlock and world.setBlockAndMetadata allowing a class to be informed whenever a block changes. I wanted it to be a bit more general so I also added the ability to prevent the block from changing.

Heres a small example: https://gist.github.com/2695062
Note that it is just the simplest mod I could thing of that could use such a hook and it probably could be done a lot more efficiently. What it does is prevent the user (any user, unfortunately there is no way to know who is trying to place the block from these methods, which kind of limits it's usability) from placing tnt in a 100 radius from the spawn.

This hook should only be used to replace resource heavy functions that search a whole area for block changes (I should probably should have stated that in the Javadoc), such as Buildcraft's quarry that in order to choose which block to mine next searches the whole quarry area from the top till it finds a mineable block. In a default size mine (9x9) by average it does 9*9*32=2592 more iterations than what it needs.