Posted May 23, 201411 yr Hey Guys! I wanted to create a crafting table which uses a special item to craft. The item has a durability of 64. One damage point should be added on crafting. The problem is that this doesn't work. Code: Item: package com.bedrockminer.magicum.item; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.Item; import net.minecraft.util.IIcon; import com.bedrockminer.magicum.Main; import com.bedrockminer.magicum.creative.Tabs; import com.bedrockminer.magicum.element.Elements; public class ItemEssence extends Item { private final Elements element; private IIcon iconDamage1; private IIcon iconDamage2; public ItemEssence(String unlocalizedName, Elements element) { super(); this.setUnlocalizedName(unlocalizedName); this.setTextureName(Main.MODID + ":" + unlocalizedName); this.setCreativeTab(Tabs.essences); this.setMaxDamage(64); this.setMaxStackSize(1); this.element = element; } public Elements getElement() { return this.element; } @Override public IIcon getIconFromDamage(int damage) { if (damage > 2 * this.getMaxDamage() / 3) return this.iconDamage2; if (damage > this.getMaxDamage() / 3) return this.iconDamage1; return this.itemIcon; } @Override public void registerIcons(IIconRegister reg) { this.itemIcon = reg.registerIcon(this.getIconString() + "_stage_0"); this.iconDamage1 = reg.registerIcon(this.getIconString() + "_stage_1"); this.iconDamage2 = reg.registerIcon(this.getIconString() + "_stage_2"); } } onCrafting: public void onPlayerCrafting(EntityPlayer player, ItemStack stack) { for (int i = 9; i < 12; i ++) { Main.log("loop"); Elements element = Elements.None; if (i - 9 < this.neededElements.size()) element = this.neededElements.get(i - 9); if (element != Elements.None) { this.te.getStackInSlot(i).damageItem(1, player); Main.log("damage"); } } } The log "damage" is written in the console. The method is called from onSlotChange of the corresponding slot. @Override public void onSlotChanged() { super.onSlotChanged(); this.owner.onCraftMatrixChanged(this.inventory); } I hope someone understands the problem... http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
May 23, 201411 yr Author I now created a small method which reads the damage of the stack, adds one, sets this new value to the stack and finally sets the stack as a slot of the inventory. But WHY is this that complicated?! http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
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.