hotrods20 Posted July 2, 2013 Share Posted July 2, 2013 I am currently developing a mod that adds some custom weapons. I am not entirely sure on what is wrong so I'll post code. public static EnumToolMaterial obsidian = EnumHelper.addToolMaterial("OBSIDIAN", 3, -1, 6.0F, 2, 14); public static Item oSword = new ItemSword(3500, OTMain.obsidian).setCreativeTab(tabObsidianTools).setUnlocalizedName("oSword"); public static Item oAxe = new ItemAxe(3501, OTMain.obsidian).setCreativeTab(tabObsidianTools).setUnlocalizedName("oAxe"); public static Item oHoe = new ItemHoe(3502, OTMain.obsidian).setCreativeTab(tabObsidianTools).setUnlocalizedName("oHoe"); public static Item oPickaxe = new ItemPickaxe(3503, OTMain.obsidian).setCreativeTab(tabObsidianTools).setUnlocalizedName("oPickaxe"); public static Item oSpade = new ItemSpade(3504, OTMain.obsidian).setCreativeTab(tabObsidianTools).setUnlocalizedName("oSpade"); The problem I am having is when I place the items in the enchantment table, no enchantments show up. I can do /enchant and I can place them in Anvils and enchant them. Any suggestions or anyone know how to get enchantments to appear for these items? Solution: So, if a tool material has 0 or lower amount of uses, then it won't be able to be enchanted in a enchantment table. Solution is to modify the tool in its own class to not take any damage from anything. That means if you want to have items that don't suffer from durability loss, you need to have: @Override public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving) { par1ItemStack.damageItem(0, par3EntityLiving); return true; } @Override public boolean onBlockDestroyed(ItemStack par1ItemStack, World par2World, int par3, int par4, int par5, int par6, EntityLiving par7EntityLiving) { par1ItemStack.damageItem(0, par7EntityLiving); return true; } In each items class file or in a main tools file they all read file. Quote http://www.slothygaming.com/img/ota.png[/img] If your grammar is shit and you blatantly don't know what you're doing, I will not help you. Link to comment Share on other sites More sharing options...
Centipede Posted July 2, 2013 Share Posted July 2, 2013 take a look at the class file named EnumEnchantmentType.java Quote Never understood why textures were so complicated. Link to comment Share on other sites More sharing options...
Centipede Posted July 2, 2013 Share Posted July 2, 2013 public int getItemEnchantability() { return 1; } you'll need that. return 1; is basically saying yes it can be enchanted Quote Never understood why textures were so complicated. Link to comment Share on other sites More sharing options...
hotrods20 Posted July 2, 2013 Author Share Posted July 2, 2013 My items are tools and weapons, so shouldn't they default to being able to be enchanted? Quote http://www.slothygaming.com/img/ota.png[/img] If your grammar is shit and you blatantly don't know what you're doing, I will not help you. Link to comment Share on other sites More sharing options...
Centipede Posted July 2, 2013 Share Posted July 2, 2013 no, i pulled that sample from the itemBow.java file. a vanilla item. Quote Never understood why textures were so complicated. Link to comment Share on other sites More sharing options...
Centipede Posted July 2, 2013 Share Posted July 2, 2013 plus, why don't you add the line and test it. if it works i'm right, if it doesn't, keep trouble shooting. Quote Never understood why textures were so complicated. Link to comment Share on other sites More sharing options...
Centipede Posted July 2, 2013 Share Posted July 2, 2013 Also, 50$ says it works my way Quote Never understood why textures were so complicated. Link to comment Share on other sites More sharing options...
hotrods20 Posted July 2, 2013 Author Share Posted July 2, 2013 I just use the ItemSword.java which is a vanilla class. By using that and using my custom tool material, it should work. The code from ItemSword.java: public int getItemEnchantability() { return this.toolMaterial.getEnchantability(); }[/Code] This should work because it gets the ability to be enchanted from the material. My material: [Code]public static EnumToolMaterial obsidian = EnumHelper.addToolMaterial("OBSIDIAN", 3, -1, 6.0F, 2, 14);[/Code] The last number in my code is the ability for the item to be enchanted's factor. That one is equal to iron. Gold having the highest of course. Quote http://www.slothygaming.com/img/ota.png[/img] If your grammar is shit and you blatantly don't know what you're doing, I will not help you. Link to comment Share on other sites More sharing options...
Centipede Posted July 2, 2013 Share Posted July 2, 2013 ^works too, but it's easier with the code i supplied. Basically, yes this can be enchanted. what can be enchanted onto it is already determined by the item type. either weapon or tool etc. Your doing work minecraft already does. (code supplied is tested) public int getItemEnchantability() { return 1; } in case you missed it from my spam Quote Never understood why textures were so complicated. Link to comment Share on other sites More sharing options...
Centipede Posted July 2, 2013 Share Posted July 2, 2013 ah, i see what your doing, you have a custom item type. hm.. Quote Never understood why textures were so complicated. Link to comment Share on other sites More sharing options...
Centipede Posted July 2, 2013 Share Posted July 2, 2013 i'd recommend not using a custom item material for now, and let it be treated as gold iron diamond etc. I honestly don't know how to add enchanting compatibility to custom blocks, it's probably something within the material file. Quote Never understood why textures were so complicated. Link to comment Share on other sites More sharing options...
hotrods20 Posted July 2, 2013 Author Share Posted July 2, 2013 Yeah, it seems like it. Quote http://www.slothygaming.com/img/ota.png[/img] If your grammar is shit and you blatantly don't know what you're doing, I will not help you. Link to comment Share on other sites More sharing options...
hotrods20 Posted July 2, 2013 Author Share Posted July 2, 2013 I've come to the conclusion that when the ItemSword class is looking for a material, it will only accept materials that have been declared in EnumToolMaterial because I had my Obsidian material just copy the EnumToolMaterial.IRON and it let my tool be enchanted. Is it possibly how the material is added to the game? Quote http://www.slothygaming.com/img/ota.png[/img] If your grammar is shit and you blatantly don't know what you're doing, I will not help you. Link to comment Share on other sites More sharing options...
Centipede Posted July 2, 2013 Share Posted July 2, 2013 Seems to be a problem with how you may have declared the obsidian as a material. then the enchant class isn't recognizing it as a material so it can't enchant to it Quote Never understood why textures were so complicated. Link to comment Share on other sites More sharing options...
Centipede Posted July 2, 2013 Share Posted July 2, 2013 give me the code for the sword and the main file where the sword is declared, and i'll look at it Quote Never understood why textures were so complicated. Link to comment Share on other sites More sharing options...
hotrods20 Posted July 2, 2013 Author Share Posted July 2, 2013 public static EnumToolMaterial obsidian = EnumHelper.addToolMaterial("OBSIDIAN", 3, -1, 6.0F, 2, 12); public static Item oSword = new ItemSword(3500, obsidian).setCreativeTab(tabObsidianTools).setUnlocalizedName("oSword"); public static Item oAxe = new ItemAxe(3501, obsidian).setCreativeTab(tabObsidianTools).setUnlocalizedName("oAxe"); public static Item oHoe = new ItemHoe(3502, obsidian).setCreativeTab(tabObsidianTools).setUnlocalizedName("oHoe"); public static Item oPickaxe = new ItemPickaxe(3503, obsidian).setCreativeTab(tabObsidianTools).setUnlocalizedName("oPickaxe"); public static Item oSpade = new ItemSpade(3504, obsidian).setCreativeTab(tabObsidianTools).setUnlocalizedName("oSpade"); That is all the code that I have created in the sense of creating the items. I have already registered the items and all that. The sword code can be found in ItemSword in net.minecraft.item. Quote http://www.slothygaming.com/img/ota.png[/img] If your grammar is shit and you blatantly don't know what you're doing, I will not help you. Link to comment Share on other sites More sharing options...
hotrods20 Posted July 2, 2013 Author Share Posted July 2, 2013 I did try adding classes for each item I am adding but it still didn't help. It seems like the enchantment table just doesn't get the value for my item. Has any mods made items that can be enchanted via enchantment table? Quote http://www.slothygaming.com/img/ota.png[/img] If your grammar is shit and you blatantly don't know what you're doing, I will not help you. 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.