Posted December 18, 20177 yr Ok so I tried looking at choonster's TestMod3 and tried to copy what he did but it still doesn't work now, getisRepairable is now not needed in 1.12 right? ModTools: https://pastebin.com/UKvs2YrK ModItems: https://pastebin.com/kGppZQvw My Sword package com.TheRPGAdventurer.ROTD.client.items; import com.TheRPGAdventurer.ROTD.RealmOfTheDragons; import com.TheRPGAdventurer.ROTD.client.init.ModItems; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraft.util.ResourceLocation; public class ItemModSword extends ItemSword { public ItemModSword(ToolMaterial material, String unlocalizedName) { super(material); this.setUnlocalizedName(unlocalizedName); this.setRegistryName(new ResourceLocation(RealmOfTheDragons.MODID, unlocalizedName)); } } Mod PickAxe package com.TheRPGAdventurer.ROTD.client.items; import com.TheRPGAdventurer.ROTD.RealmOfTheDragons; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; public class ItemModPickAxe extends ItemPickaxe { public ItemModPickAxe(ToolMaterial material, String unlocalizedName) { super(material); this.setUnlocalizedName(unlocalizedName); this.setRegistryName(new ResourceLocation(RealmOfTheDragons.MODID, unlocalizedName)); } } ModAxe (I did not extend ItemAxe because It won't register) package com.TheRPGAdventurer.ROTD.client.items; import java.util.Set; import com.TheRPGAdventurer.ROTD.RealmOfTheDragons; import com.google.common.collect.Sets; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemTool; import net.minecraft.util.ResourceLocation; public class ItemModAxe extends ItemTool { private static final Set<Block> EFFECTIVE_ON = 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}); private static final float[] ATTACK_DAMAGES = new float[] {6.0F, 8.0F, 8.0F, 8.0F, 6.0F}; private static final float[] ATTACK_SPEEDS = new float[] { -3.2F, -3.2F, -3.1F, -3.0F, -3.0F}; public ItemModAxe(ToolMaterial material, String unlocalizedName) { super(material, EFFECTIVE_ON); this.setUnlocalizedName(unlocalizedName); this.setRegistryName(new ResourceLocation(RealmOfTheDragons.MODID, unlocalizedName)); } public float getStrVsBlock(ItemStack stack, IBlockState state) { Material material = state.getMaterial(); return material != Material.WOOD && material != Material.PLANTS && material != Material.VINE ? super.getStrVsBlock(stack, state) : this.efficiencyOnProperMaterial; } } Edited December 19, 20177 yr by TheRPGAdventurer
December 18, 20177 yr My harvest swords can be repaired with the ToolMaterial's repair item in anvils and I don't override any repairing-related methods or subscribe to any anvil-related events to achieve this; it just works by default. It looks like ModTools.initRepairs isn't being called from anywhere, since it's private and not called in ModTools. This means that your ToolMaterials' repair items aren't being initialised; which would explain why your tools can't be repaired. 3 hours ago, TheRPGAdventurer said: (I did not extend ItemAxe because It won't register) What do you mean by "it won't register"? Did you try to use the ItemAxe(ToolMaterial) constructor with a non-Vanilla ToolMaterial only to find that it threw an ArrayIndexOutOfBoundsException? You need to use the ItemAxe(ToolMaterial, float, float) constructor for modded ToolMaterials; the ItemAxe(ToolMaterial) constructor uses the ToolMaterial's ordinal as an index for the ATTACK_DAMAGES and ATTACK_SPEEDS arrays, which only have values for the Vanilla ToolMaterials. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
December 18, 20177 yr Author 5 hours ago, Choonster said: It looks like ModTools.initRepairs isn't being called from anywhere, since it's private and not called in ModTools. This means that your ToolMaterials' repair items aren't being initialised; which would explain why your tools can't be repaired. Where do I have to call it so it could be initialised?
December 18, 20177 yr Author 2 minutes ago, TheRPGAdventurer said: Where do I have to call it so it could be initialised? ModItems line 240: initialiseItems(); Nevermind
December 20, 20177 yr Author On 12/18/2017 at 3:54 PM, Choonster said: My harvest swords can be repaired with the ToolMaterial's repair item in anvils and I don't override any repairing-related methods or subscribe to any anvil-related events to achieve this; it just works by default. It looks like ModTools.initRepairs isn't being called from anywhere, since it's private and not called in ModTools. This means that your ToolMaterials' repair items aren't being initialised; which would explain why your tools can't be repaired. What do you mean by "it won't register"? Did you try to use the ItemAxe(ToolMaterial) constructor with a non-Vanilla ToolMaterial only to find that it threw an ArrayIndexOutOfBoundsException? You need to use the ItemAxe(ToolMaterial, float, float) constructor for modded ToolMaterials; the ItemAxe(ToolMaterial) constructor uses the ToolMaterial's ordinal as an index for the ATTACK_DAMAGES and ATTACK_SPEEDS arrays, which only have values for the Vanilla ToolMaterials. Also I forgot to ask you, what, or where is the attack speed value of each Item.
December 20, 20177 yr Author 4 minutes ago, TheRPGAdventurer said: Also I forgot to ask you, what, or where is the attack speed value of each Item. got no value for the speed.
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.