Posted June 28, 201411 yr I'm new to forging, and trying out block breaking. Naturally, I want to break blocks the "right" way (meaning, I want to break blocks as though a player had broken them with the right tool without enchantment.). I've gotten blocks to break with this method, which tree-capitator seems to use: public void breakBlock(World w, Block b, int x,int y,int z){ ArrayList<ItemStack> drops=b.getDrops(world, x, y, z, world.getBlockMetadata(x, y, z), 0); b.dropBlockAsItem(w, x, y, z, world.getBlockMetadata(x, y, z), 0); world.removeTileEntity(x, y, z); world.setBlockToAir(x, y, z); } But it seems like I should break blocks this way: public void breakBlock(World w, Block b, int x,int y,int z){ int fortune = 0; boolean silkTouch=false; int metadata = w.getBlockMetadata(x, y, z); ArrayList<ItemStack> drops = b.getDrops(w, x, y, z, metadata, fortune); ForgeEventFactory.fireBlockHarvesting(drops, w, b, x, y, z, metadata, fortune, 1, false, null); } However, the latter doesn't work. I know there's more than one way to solve a problem, but if one adheres to convention, I'd rather use that way. Anyone know how the player does it?
June 28, 201411 yr I think that you have to call this in the end of your method: super.breakBlock(world, x, y, z, block, meta); To break your block with a specific tool you can use "harvestBlock", then player.getHeldItem().getItem(). I hope this will help.
June 28, 201411 yr Author Thanks for the advice , but it didn't work (assuming that the superclass in your response was Block.)
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.