--- a/net/minecraft/server/BlockRedstoneOre.java +++ b/net/minecraft/server/BlockRedstoneOre.java @@ -2,6 +2,11 @@ import java.util.Random; +// CraftBukkit start +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.entity.EntityInteractEvent; +// CraftBukkit end + public class BlockRedstoneOre extends Block { public static final BlockStateBoolean a = BlockRedstoneTorch.LIT; @@ -13,14 +18,30 @@ @Override public void attack(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman) { - interact(iblockdata, world, blockposition); + interact(iblockdata, world, blockposition, entityhuman); // CraftBukkit - add entityhuman super.attack(iblockdata, world, blockposition, entityhuman); } @Override public void stepOn(World world, BlockPosition blockposition, Entity entity) { - interact(world.getType(blockposition), world, blockposition); - super.stepOn(world, blockposition, entity); + // CraftBukkit start + // interact(world.getType(blockposition), world, blockposition); + // super.stepOn(world, blockposition, entity); + if (entity instanceof EntityHuman) { + org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null); + if (!event.isCancelled()) { + interact(world.getType(blockposition), world, blockposition, entity); // add entity + super.stepOn(world, blockposition, entity); + } + } else { + EntityInteractEvent event = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ())); + world.getServer().getPluginManager().callEvent(event); + if (!event.isCancelled()) { + interact(world.getType(blockposition), world, blockposition, entity); // add entity + super.stepOn(world, blockposition, entity); + } + } + // CraftBukkit end } @Override @@ -28,7 +49,7 @@ if (world.isClientSide) { playEffect(world, blockposition); } else { - interact(iblockdata, world, blockposition); + interact(iblockdata, world, blockposition, entityhuman); // CraftBukkit - add entityhuman } ItemStack itemstack = entityhuman.b(enumhand); @@ -36,9 +57,14 @@ return itemstack.getItem() instanceof ItemBlock && (new BlockActionContext(entityhuman, enumhand, itemstack, movingobjectpositionblock)).b() ? EnumInteractionResult.PASS : EnumInteractionResult.SUCCESS; } - private static void interact(IBlockData iblockdata, World world, BlockPosition blockposition) { + private static void interact(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { // CraftBukkit - add Entity playEffect(world, blockposition); if (!(Boolean) iblockdata.get(BlockRedstoneOre.a)) { + // CraftBukkit start + if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata.set(BlockRedstoneOre.a, true)).isCancelled()) { + return; + } + // CraftBukkit end world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.a, true), 3); } @@ -52,6 +78,11 @@ @Override public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) { if ((Boolean) iblockdata.get(BlockRedstoneOre.a)) { + // CraftBukkit start + if (CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, iblockdata.set(BlockRedstoneOre.a, false)).isCancelled()) { + return; + } + // CraftBukkit end worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.a, false), 3); } @@ -60,12 +91,25 @@ @Override public void dropNaturally(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) { super.dropNaturally(iblockdata, worldserver, blockposition, itemstack); + /* CraftBukkit start - Delegated to getExpDrop if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) { int i = 1 + worldserver.random.nextInt(5); this.dropExperience(worldserver, blockposition, i); } + // */ + + } + @Override + public int getExpDrop(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) { + if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) { + int i = 1 + worldserver.random.nextInt(5); + + return i; + } + return 0; + // CraftBukkit end } private static void playEffect(World world, BlockPosition blockposition) {