Posted April 22, 201510 yr So, I need my tool (hammer if you're wondering) to break a 3x3, 5x5, or, 7x7 set of blocks for what ever it is set to. Basically, you shift + right-click the hammer to open the GUI and select the size of area you want to destroy etc. But, that's not my problem; my problem is how to go about destroying the blocks! I was thinking about using the BreakEvent but, still not sure if that will work. Any input would be great! I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.
April 22, 201510 yr When it is breaking something, onBlockDestroyed or onBlockStartBreak perhaps, you can use world.setBlock(x, y, z, Blocks.air); multiple times to break blocks. Also, you may want to somehow drop the block once set to air. No method comes to mind for that at the moment. Hope this helps.
April 23, 201510 yr Author Aren't those only for classes that extend Block? I found World#func_147480_a() destroys the block and can add drops if you set the boolean to true. I'm gonna try it in my BreakEvent. I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.
April 23, 201510 yr Author So, the break block method in World seemed to work but, when I place things like obsidian or bedrock around the area to break it also breaks the bedrock. I'm sure you can see my problem here. Would love some help on how to prevent this? Here's my code for breaking it (slightly messy. ): @SubscribeEvent public void onBlockBreak(BreakEvent event) { EntityPlayer player = event.getPlayer(); if(event.world != null && player != null) { if(player.inventory.getCurrentItem().getItem() != null) { if(player.inventory.getCurrentItem().getItem().equals(CrewMod.crewHammer)) { int direction = MathHelper.floor_double((double)(player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; ItemStack hammer = player.inventory.getCurrentItem(); //System.out.println("ITEM IN HAND IS CREW HAMMER"); Block block = event.block; World world = event.world; int x = event.x; int y = event.y; int z = event.z; NBTTagCompound cmp = hammer.stackTagCompound; if(cmp != null) { //System.out.println("CMP IS NOT NULL"); if(cmp.getString("MiningSize") != null) { System.out.println("MININGSIZE IS NOT NULL"); if(cmp.getString("MiningSize").equals("1x1")) { System.out.println("1x1"); return; }else if(cmp.getString("MiningSize").equals("3x3")) { //System.out.println("3x3"); this.breakThreeByThree(world, x, y, z, direction); }else if(cmp.getString("MiningSize").equals("5x5")) { }else if(cmp.getString("MiningSize").equals("7x7")) { } } } } } } } public void breakThreeByThree(World world, int x, int y, int z, int playerFacing) { if(playerFacing == 0 || playerFacing == 2) { //SOUTH world.func_147480_a(x, y + 1, z, true); world.func_147480_a(x - 1, y + 1, z, true); world.func_147480_a(x + 1, y + 1, z, true); world.func_147480_a(x, y - 1, z, true); world.func_147480_a(x - 1, y - 1, z, true); world.func_147480_a(x + 1, y - 1, z, true); world.func_147480_a(x - 1, y, z, true); world.func_147480_a(x + 1, y, z, true); }else { world.func_147480_a(x, y + 1, z, true); world.func_147480_a(x, y + 1, z - 1, true); world.func_147480_a(x, y + 1, z + 1, true); world.func_147480_a(x, y - 1, z, true); world.func_147480_a(x, y - 1, z - 1, true); world.func_147480_a(x, y - 1, z + 1, true); world.func_147480_a(x, y, z - 1, true); world.func_147480_a(x, y, z + 1, true); } } I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.
April 23, 201510 yr I think the best way to solve this is checking if a block can be broke before you break it. You can simply use world.getBlock(x,y,z) in combination with a check for that. Projects: Discontinued: - N2ConfigAPI - Meachanical Crafting Table Latest: - CollectionUtils Coöperations: - InGameConfigManager
April 23, 201510 yr Aren't those only for classes that extend Block? No, they are for items, use it instead. No method comes to mind for that at the moment. Block.harvestBlock, But this will not set block to air.. So, the break block method in World seemed to work but, when I place things like obsidian or bedrock around the area to break it also breaks the bedrock. For that, you can look in tinkers construct's hammer source, here: https://github.com/SlimeKnights/TinkersConstruct Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
April 23, 201510 yr Author Thank you for that, elix. But, when looking at their code it slightly confuses me. They created a bunch of classes that re-handle block events, onBlockStartBreaking and, a few rayTrace methods. I feel like there is a cleaner way of doing things but can't seem to find a good place to start. I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.
April 23, 201510 yr Author I believe they solved a way to break the block beside the one actually broken by comparing the hardness. I need to make sure that the extra blocks are for one, able to broken by the tool set (pickaxe) and two, the hardness doesn't exceed a certain amount like, breaking stone breaks obsidian around it. I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.
April 23, 201510 yr The raytrace methods in their code are probably to detect which way the player is looking. This is because the player can break blocks below, above, and on all sides of them with the tinker's hammer. Just a guess.
April 23, 201510 yr Author Well yes I know that. It's used to check the side of the block to set the variables correctly. I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.
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.