Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
at develop 81 lines 2.4 kB view raw
1package net.minecraft.server; 2 3// CraftBukkit start 4 5import org.bukkit.craftbukkit.block.CraftBlockState; 6import org.bukkit.craftbukkit.event.CraftEventFactory; 7import org.bukkit.entity.Player; 8import org.bukkit.event.block.BlockIgniteEvent; 9import org.bukkit.event.block.BlockPlaceEvent; 10// CraftBukkit end 11 12public class ItemFlintAndSteel extends Item { 13 14 public ItemFlintAndSteel(int i) { 15 super(i); 16 this.maxStackSize = 1; 17 this.d(64); 18 } 19 20 public boolean a(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l) { 21 int clickedX = i, clickedY = j, clickedZ = k; // CraftBukkit 22 23 if (l == 0) { 24 --j; 25 } 26 27 if (l == 1) { 28 ++j; 29 } 30 31 if (l == 2) { 32 --k; 33 } 34 35 if (l == 3) { 36 ++k; 37 } 38 39 if (l == 4) { 40 --i; 41 } 42 43 if (l == 5) { 44 ++i; 45 } 46 47 int i1 = world.getTypeId(i, j, k); 48 49 if (i1 == 0) { 50 // CraftBukkit start - store the clicked block 51 org.bukkit.block.Block blockClicked = world.getWorld().getBlockAt(i, j, k); 52 Player thePlayer = (Player) entityhuman.getBukkitEntity(); 53 54 BlockIgniteEvent eventIgnite = new BlockIgniteEvent(blockClicked, BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL, thePlayer); 55 world.getServer().getPluginManager().callEvent(eventIgnite); 56 57 if (eventIgnite.isCancelled()) { 58 itemstack.damage(1, entityhuman); 59 return false; 60 } 61 62 CraftBlockState blockState = CraftBlockState.getBlockState(world, i, j, k); 63 // CraftBukkit end 64 65 world.makeSound((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D, "fire.ignite", 1.0F, b.nextFloat() * 0.4F + 0.8F); 66 world.setTypeId(i, j, k, Block.FIRE.id); 67 68 // CraftBukkit start 69 BlockPlaceEvent placeEvent = CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockState, clickedX, clickedY, clickedZ, Block.FIRE.id); 70 71 if (placeEvent.isCancelled() || !placeEvent.canBuild()) { 72 placeEvent.getBlockPlaced().setTypeIdAndData(0, (byte) 0, false); 73 return false; 74 } 75 // CraftBukkit end 76 } 77 78 itemstack.damage(1, entityhuman); 79 return true; 80 } 81}