diff options
author | Erik Broes <erikbroes@grum.nl> | 2011-03-21 00:25:26 +0100 |
---|---|---|
committer | Erik Broes <erikbroes@grum.nl> | 2011-03-21 00:31:13 +0100 |
commit | 324efa8224818aa04402203b1ccbb9839b44061e (patch) | |
tree | 8f5550f37a671bf2bce48f318354e518570bb97b /src/main/java/net/minecraft/server/ItemFlintAndSteel.java | |
parent | 0d2dc3902c1341be9bb1c51ab7e2be1a925788e3 (diff) | |
download | craftbukkit-324efa8224818aa04402203b1ccbb9839b44061e.tar craftbukkit-324efa8224818aa04402203b1ccbb9839b44061e.tar.gz craftbukkit-324efa8224818aa04402203b1ccbb9839b44061e.tar.lz craftbukkit-324efa8224818aa04402203b1ccbb9839b44061e.tar.xz craftbukkit-324efa8224818aa04402203b1ccbb9839b44061e.zip |
Fix BlockPlace
Diffstat (limited to 'src/main/java/net/minecraft/server/ItemFlintAndSteel.java')
-rw-r--r-- | src/main/java/net/minecraft/server/ItemFlintAndSteel.java | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/src/main/java/net/minecraft/server/ItemFlintAndSteel.java b/src/main/java/net/minecraft/server/ItemFlintAndSteel.java index 8affb99b..cad14054 100644 --- a/src/main/java/net/minecraft/server/ItemFlintAndSteel.java +++ b/src/main/java/net/minecraft/server/ItemFlintAndSteel.java @@ -1,15 +1,14 @@ package net.minecraft.server; // CraftBukkit start -import org.bukkit.block.BlockFace; +import org.bukkit.block.BlockState; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftWorld; -import org.bukkit.craftbukkit.block.CraftBlock; -import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.craftbukkit.block.CraftBlockState; +import org.bukkit.craftbukkit.event.CraftEventFactory; 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.BlockPlaceEvent; import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; // CraftBukkit end @@ -22,11 +21,7 @@ public class ItemFlintAndSteel extends Item { } public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { - // CraftBukkit start - store the clicked block - CraftWorld craftWorld = ((WorldServer) world).getWorld(); - CraftServer craftServer = ((WorldServer) world).getServer(); - org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k); - // CraftBukkit end + int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit; if (l == 0) { --j; @@ -55,34 +50,37 @@ public class ItemFlintAndSteel extends Item { int i1 = world.getTypeId(i, j, k); if (i1 == 0) { - // CraftBukkit start - Flint and steel - Type eventType = Type.PLAYER_ITEM; - Player thePlayer = (Player) entityhuman.getBukkitEntity(); - CraftItemStack itemInHand = new CraftItemStack(itemstack); - BlockFace blockFace = CraftBlock.notchToBlockFace(l); - - PlayerItemEvent event = new PlayerItemEvent(eventType, thePlayer, itemInHand, blockClicked, blockFace); - craftServer.getPluginManager().callEvent(event); + // CraftBukkit start - store the clicked block + CraftWorld craftWorld = ((WorldServer) world).getWorld(); + CraftServer craftServer = ((WorldServer) world).getServer(); + org.bukkit.block.Block blockClicked = craftWorld.getBlockAt(i, j, k); - boolean preventLighter = event.isCancelled(); + Player thePlayer = (Player) entityhuman.getBukkitEntity(); IgniteCause igniteCause = BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL; BlockIgniteEvent eventIgnite = new BlockIgniteEvent(blockClicked, igniteCause, thePlayer); craftServer.getPluginManager().callEvent(eventIgnite); boolean preventFire = eventIgnite.isCancelled(); - if (preventLighter) { - return false; - } - if (preventFire) { itemstack.b(1); return false; } // CraftBukkit end + BlockState blockState = CraftBlockState.getBlockState(world, i, j, k); // CraftBukkit + world.a((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "fire.ignite", 1.0F, b.nextFloat() * 0.4F + 0.8F); world.e(i, j, k, Block.FIRE.id); + + // CraftBukkit start + BlockPlaceEvent placeEvent = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, Block.FIRE.id); + + if (placeEvent.isCancelled() || !placeEvent.canBuild()) { + placeEvent.getBlockPlaced().setTypeIdAndData(0, (byte)0, false); + return false; + } + // CraftBukkit end } itemstack.b(1); |