Jump to content

Disabling recipes


matijas1

Recommended Posts

Is there a way to stop being able to craft something after you have registered it in the game?

For example being able to upgrade something via crafting only 3 times or a number from NBT.

I want to make something like upgradeable tools and armor and this is kinda killing me right now.

Thanks in advance :)

Link to comment
Share on other sites

I actually didn't remove it from the game but put it into the condition of the matches() function.

Although i cant seem to find a way to differentiate the NBTTags of the items because they're all the same itemstack and have the same category.

If i differentiate the category by using an array of strings i still need which item in a row it is which contains the category so it would be an endless loop or when another person crafts the item between your upgrading of items it would give you the wrong tag

Link to comment
Share on other sites

For setting NBTTags i have this

public void onUpdate(ItemStack itemStack, World world, Entity player,int par4,boolean par5)

{

if(update)

{

sockets[NBTHelp.getInt(itemStack, "iterator")]--;

  NBTHelp.setInteger(itemStack,ModItems.sockets,sockets(i));

update = false;

}

 

update is only true if the item is crafted.

If i have it like this different swords share the same sockets variable and i'm not sure why

public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4)

{

if (itemStack.stackTagCompound != null)

{

list.add("Number of sockets: " +

NBTHelp.getInt(itemStack,ModItems.sockets));

}

}

Link to comment
Share on other sites

To give each sword that's crafted a random number of sockets in which u could put gems.

So the sockets variable is the number of sockets on the sword and i need each sword to keep track of its own number.

In my case the first sword that's crafted gets a tag with the number but the rest are just modifying that number instead of having their own.

Link to comment
Share on other sites

It's not hard but i don't know why each sword isn't activating the addInformation()  function and working with its number but instead modifying the first and not having the tag displayed.

EDIT: Tested a bit and it seems that the onCrafted isn't called with

GameRegistry.addShapelessRecipe

 

This is the function:

public void onCrafted(ItemStack itemStack, World world, EntityPlayer player)

{

sockets = ModItems.rngint(1,3);

NBTHelp.setInteger(itemStack,ModItems.sockets,sockets);

NBTHelp.setString(itemStack,"owner", player.getDisplayName());

NBTHelp.setInteger(itemStack, "iterator", i);

i++;

if(i == 10000)

i=0;

}

EDIT 2:Wow i am a total idiot sorry for wasting your time...if you noticed I have onCrafted instead of onCreated...

Link to comment
Share on other sites

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.