gabriellsh Posted July 30, 2016 Share Posted July 30, 2016 So, heres the code I have: package tutorial; import java.util.Set; import com.google.common.collect.Multimap; import com.google.common.collect.Sets; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.init.Blocks; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.*; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class MultiTool extends ItemTool { private static final Set<Block> effectiveBlocks = Sets.newHashSet(new Block[] {Blocks.PLANKS, Blocks.BOOKSHELF, Blocks.LOG, Blocks.LOG2, Blocks.CHEST, Blocks.PUMPKIN, Blocks.LIT_PUMPKIN, Blocks.MELON_BLOCK, Blocks.LADDER, Blocks.WOODEN_BUTTON, Blocks.WOODEN_PRESSURE_PLATE, Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE, Blocks.DOUBLE_STONE_SLAB, Blocks.GOLDEN_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.LIT_REDSTONE_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE, Blocks.SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.STONE_SLAB, Blocks.STONE_BUTTON, Blocks.STONE_PRESSURE_PLATE, Blocks.CLAY, Blocks.DIRT, Blocks.FARMLAND, Blocks.GRASS, Blocks.GRAVEL, Blocks.MYCELIUM, Blocks.SAND, Blocks.SNOW, Blocks.SNOW_LAYER, Blocks.SOUL_SAND, Blocks.GRASS_PATH});; protected MultiTool(ToolMaterial material) { super(10.0F, -2.8F, material, effectiveBlocks); } public boolean canHarvestBlock(IBlockState blockIn){ return true; } public boolean onBlockisDestroyed(ItemStack stack, World worldIn, IBlockState state, BlockPos pos, EntityLivingBase entityLiving){ BlockPos top = pos.up(); BlockPos bottom = pos.down(); worldIn.destroyBlock(top, true); worldIn.setBlockToAir(bottom); return true; } } That is actually a tool that breaks every block, but I'm trying to make it break a 3x3 area. I know it may sound simple for some of you, but I just started modding yestarday, and although I have some java knowledge, I'm not the most skillfull programmer. I'd really apreciate if any of you guys could give me a hint on how to do this. (Sorry for the spelling mistakes I may have commited, English is not my main language) Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted July 30, 2016 Share Posted July 30, 2016 If you mean like this then here you go and all credit to the ones who posted it. http://www.minecraftforge.net/forum/index.php/topic,40887.0.html Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
gabriellsh Posted July 30, 2016 Author Share Posted July 30, 2016 The thing is, this should have replaced the bottom block and the top block with air, but it doesn't... Atleast this part should've worked: public boolean onBlockisDestroyed(ItemStack stack, World worldIn, IBlockState state, BlockPos pos, EntityLivingBase entityLiving){ BlockPos top = pos.up(); BlockPos bottom = pos.down(); worldIn.destroyBlock(top, true); worldIn.setBlockToAir(bottom); return true; } Quote Link to comment Share on other sites More sharing options...
gabriellsh Posted July 30, 2016 Author Share Posted July 30, 2016 I think I got the problem, I misspelled the method name Gonna try it now... Quote Link to comment Share on other sites More sharing options...
gabriellsh Posted July 30, 2016 Author Share Posted July 30, 2016 Got it to work, thanks for the help! Heres the code, if anyone needs it: public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState state, BlockPos pos, EntityLivingBase entityLiving){ BlockPos top = pos.up(); BlockPos bottom = pos.down(); worldIn.destroyBlock(top, true); worldIn.setBlockToAir(bottom); return true; } Quote Link to comment Share on other sites More sharing options...
MCrafterzz Posted July 31, 2016 Share Posted July 31, 2016 Change the name to solved if you have solved it. Also happy that my thread was useful for over people to. On thing though, this wont work with enchantments, so do you want your multitool to be enchantable? Quote http://i.imgur.com/J4rrGt6.png[/img] [Creator of mcrafterzz mod] Link to comment Share on other sites More sharing options...
MCrafterzz Posted July 31, 2016 Share Posted July 31, 2016 Another thing, your multitool wont be effective on modded blocks, take a look on my multitool: http://pastebin.com/jFmqACY9 Quote http://i.imgur.com/J4rrGt6.png[/img] [Creator of mcrafterzz mod] Link to comment Share on other sites More sharing options...
Recommended Posts
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.