Bukkit/CraftBukkit — pull request #603 by wilsonsd (2011-12-19 22:49:47+00:00)
Title: Moved some code from BlockTNT.onPlace to BlockTNT.postPlace.

Fix for BUKKIT-89.

BUKKIT-89: If a player places a TNT block next to a redstone torch (so
the block is already powered), but the BlockPlaceEvent is cancelled,
the TNT block still ignites as explodes. It should just return to the
player's inventory.

Cause for bug: In ItemBlock.a, on line 91, the call to
setRawTypeIdAndData causes a call to BlockTNT.onPlace. This checks if
the TNT block is powered, and if so, replaces it with an
EntityTNTPrimed. All this happens before the BlockPlaceEvent is
fired. So even if the event is cancelled, the EntityTNTPrimed is
still there, getting ready to explode.

Fix: In BlockTNT, move the check to see if the location of the block
is powered from onPlace to postPlace. This way, the block doesn't
turn into an EntityTNTPrimed until after the event has fired.

(This is a cleaned up version of https://github.com/Bukkit/CraftBukkit/pull/569)