diff options
author | Andrew Ardill <andrew.ardill@gmail.com> | 2011-01-19 05:44:01 +0800 |
---|---|---|
committer | Warren <evilseph@unaligned.org> | 2011-01-19 07:51:28 +0800 |
commit | eace2d0f8a29ee629b8254bb5d8ee611e5d3024b (patch) | |
tree | 90c02ee3171a7ff125bd45445c3ce7e6fda64360 /src/main/java/net/minecraft/server/ItemFlintAndSteel.java | |
parent | abc4b35bcd68af4fd1fb4c593f4e6f86a0fa4fe3 (diff) | |
download | craftbukkit-eace2d0f8a29ee629b8254bb5d8ee611e5d3024b.tar craftbukkit-eace2d0f8a29ee629b8254bb5d8ee611e5d3024b.tar.gz craftbukkit-eace2d0f8a29ee629b8254bb5d8ee611e5d3024b.tar.lz craftbukkit-eace2d0f8a29ee629b8254bb5d8ee611e5d3024b.tar.xz craftbukkit-eace2d0f8a29ee629b8254bb5d8ee611e5d3024b.zip |
Further fixes to fire events
Moved lava ignition event into the correct position.
Spam should be reduced significantly.
Diffstat (limited to 'src/main/java/net/minecraft/server/ItemFlintAndSteel.java')
-rw-r--r-- | src/main/java/net/minecraft/server/ItemFlintAndSteel.java | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/src/main/java/net/minecraft/server/ItemFlintAndSteel.java b/src/main/java/net/minecraft/server/ItemFlintAndSteel.java index ff46663d..cd54a2b7 100644 --- a/src/main/java/net/minecraft/server/ItemFlintAndSteel.java +++ b/src/main/java/net/minecraft/server/ItemFlintAndSteel.java @@ -3,12 +3,16 @@ package net.minecraft.server; import java.util.Random; // CraftBukkit start +import org.bukkit.Server; +import org.bukkit.block.BlockFace; +import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.block.CraftBlock; import org.bukkit.craftbukkit.inventory.CraftItemStack; -import org.bukkit.craftbukkit.entity.CraftPlayer; +import org.bukkit.entity.Player; import org.bukkit.event.Event.Type; import org.bukkit.event.player.PlayerItemEvent; import org.bukkit.event.block.BlockIgniteEvent; +import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; // CraftBukkit end public class ItemFlintAndSteel extends Item { @@ -20,9 +24,6 @@ public class ItemFlintAndSteel extends Item { } public boolean a(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) { - // CraftBukkit - get the clicked block - CraftBlock blockClicked = (CraftBlock) ((WorldServer) world).getWorld().getBlockAt(i, j, k); - if (l == 0) { j--; } @@ -45,17 +46,26 @@ public class ItemFlintAndSteel extends Item { if (i1 == 0) { // CraftBukkit start - Flint and steel - CraftItemStack itemInHand = new CraftItemStack(itemstack); - CraftPlayer thePlayer = new CraftPlayer(((WorldServer) world).getServer(), (EntityPlayerMP) entityplayer); - PlayerItemEvent pie = new PlayerItemEvent(Type.PLAYER_ITEM, thePlayer, itemInHand, blockClicked, CraftBlock.notchToBlockFace(l)); - ((WorldServer) world).getServer().getPluginManager().callEvent(pie); + Server server = ((WorldServer)world).getServer(); + CraftWorld cworld = ((WorldServer)world).getWorld(); - org.bukkit.block.Block pblock = (((WorldServer) world).getWorld().getBlockAt(i, j, k)); - BlockIgniteEvent bie = new BlockIgniteEvent((org.bukkit.block.Block) pblock, BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, thePlayer); - ((WorldServer) world).getServer().getPluginManager().callEvent(bie); + Type eventType = Type.PLAYER_ITEM; + Player thePlayer = (Player) entityplayer.getBukkitEntity(); + CraftItemStack itemInHand = new CraftItemStack(itemstack); + org.bukkit.block.Block blockClicked = cworld.getBlockAt(i, j, k); + BlockFace blockFace = CraftBlock.notchToBlockFace(l); + + PlayerItemEvent pie = new PlayerItemEvent(eventType, thePlayer, itemInHand, blockClicked, blockFace); + server.getPluginManager().callEvent(pie); boolean preventLighter = pie.isCancelled(); - boolean preventFire = bie.isCancelled(); + boolean preventFire = false; + if (blockClicked.getTypeId() != Block.ar.bi){ + IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL; + BlockIgniteEvent bie = new BlockIgniteEvent(blockClicked, igniteCause, thePlayer); + server.getPluginManager().callEvent(bie); + preventFire = bie.isCancelled(); + } if (preventLighter || preventFire) { return false; |