Jump to content

Recommended Posts

Posted

Good day. I have a problem! When I add the recipe to craft an instrument, it works well. But when I take a damaged tool from the crafting grid disappears

Is code of tool:

 

public class Mortar extends Item {

public Mortar(String name) {

super();

this.setCreativeTab(HighEnergetics.tabHEI);

this.setUnlocalizedName(name);

this.setMaxDamage( 27 );

this.setMaxStackSize( 1 );

}

 

@Override

public ItemStack getContainerItem(ItemStack itemStack )

{

itemStack.setItemDamage( itemStack.getItemDamage() + 1 );

return itemStack;

}

 

@Override

public boolean hasContainerItem(ItemStack stack)

{

return true;

}

 

}

 

And of recipe:

 

GameRegistry.addRecipe(new ItemStack(HEItems.copperDust), new Object[] {"MI", 'M', new ItemStack(HEItems.mortar, 1, OreDictionary.WILDCARD_VALUE), 'I', HEItems.copperIngot});

 

 

I want tool like hammer from IC2

Posted

That's the method.

 

Remember that you're working with pointers, so you don't want to operate on the input until the product is removed from the output slot. If you act on the original, you could damage it while the output dust is just sitting in the slot waiting to be grabbed (and if the grid is updated every tick, then that might be why your mortar disappeared).

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

Sorry about that. We may have a language barrier.

 

Make a copy of the item stack using the object's copy method. Manipulate and return the copy.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.