Posted June 30, 201312 yr Again me, the title basically says it. I'm using a reflection method in my main class to prevent chopping wood with your bare hands, so that you'll need proper tools to actually chop the wood. Works fine so far, but when trying to chop the wood with one of my newly imported copper axe (which I assume is the proper tool), it does not harvest the wooden block. Either it does not get recognized as tool, or it is recognized as weapon. But then, there seems to benothing wrong with the code? Axe Code package MetallurgyRealism; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.EnumToolMaterial; import net.minecraft.item.ItemAxe; public class ToolAxeCopper extends ItemAxe{ public ToolAxeCopper(int i, EnumToolMaterial enumToolMaterial){ super(i, enumToolMaterial); setMaxStackSize(1); setCreativeTab(MetallurgyRealismModBase.MetallurgyRealismTab); } @Override public void registerIcons(IconRegister iconRegister) { itemIcon = iconRegister.registerIcon("MetallurgyRealism:axecopper"); } } Enum Code public static EnumToolMaterial CopperMaterial = EnumHelper.addToolMaterial("CopperMaterial", 3, 5, 15.0F, 1, 15); Register and ID code public static Item toolAxeCopper; int toolAxeCopperID = 6029; toolAxeCopper = new ToolAxeCopper(toolAxeCopperID, CopperMaterial).setUnlocalizedName("axecopper"); GameRegistry.registerItem(toolAxeCopper, "ToolAxeCopper"); LanguageRegistry.addName(toolAxeCopper, "Copper Axe");
June 30, 201312 yr Author I think I found the solution. Of what ever reason the game treated my tool as weapon, so I had to put this code snippet into the axe class... public boolean canHarvestBlock(Block par1Block) { return par1Block.blockID == Block.wood.blockID; } ...I believe that the video tutorial that learned me how to import tools/weapons mixed both items. It's obvious that tools need another method of coding. However, it's working now, plus the code like I imported now, is much easier then the actual tool code needed...
June 30, 201312 yr I think I found the solution. Of what ever reason the game treated my tool as weapon, so I had to put this code snippet into the axe class... public boolean canHarvestBlock(Block par1Block) { return par1Block.blockID == Block.wood.blockID; } ...I believe that the video tutorial that learned me how to import tools/weapons mixed both items. It's obvious that tools need another method of coding. However, it's working now, plus the code like I imported now, is much easier then the actual tool code needed... The problem I see here is that you can only harvest wooden logs with your axe. To let your axe harvest all wooden types, you can check if the block's material is equal to the Material.wood. Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
June 30, 201312 yr Author public boolean canHarvestBlock(Block par1Block) { return par1Block.blockID == Block.wood.blockID || par1Block.blockID == Block.chest.blockID || par1Block.blockID == Block.planks.blockID || par1Block.blockID == Block.bookShelf.blockID || par1Block.blockID == Block.stoneDoubleSlab.blockID || par1Block.blockID == Block.stoneSingleSlab.blockID || par1Block.blockID == Block.pumpkin.blockID || par1Block.blockID == Block.pumpkinLantern.blockID; }
July 1, 201312 yr public boolean canHarvestBlock(Block par1Block) { return par1Block.blockID == Block.wood.blockID || par1Block.blockID == Block.chest.blockID || par1Block.blockID == Block.planks.blockID || par1Block.blockID == Block.bookShelf.blockID || par1Block.blockID == Block.stoneDoubleSlab.blockID || par1Block.blockID == Block.stoneSingleSlab.blockID || par1Block.blockID == Block.pumpkin.blockID || par1Block.blockID == Block.pumpkinLantern.blockID; } I notice "stoneDoubleSlab" and "stoneSingleSlab" in there... mayhap you want to change that to woodDouble/SingleSlab? BEWARE OF GOD --- Co-author of Pentachoron Labs' SBFP Tech.
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.