Bukkit/CraftBukkit — pull request #664 by wilsonsd (2012-02-03 03:35:30+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 pull request is the same as an old one, but with names updated to the new version of Minecraft.)