Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (โ‹ฎ) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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 :)

  • Author

Thanks for the quick reply i'll read that and its per player and per item.

I should also probably mention that its a normal shaped/shapeless recipe

  • Author

Wouldn't the removing written like that only remove the last recipe that was registered?

Anyway got it to craft and such but it doesn't call the function onCreated to write the NBTTag which would be useful.

Sorry if i am being kinda nooby to this

  • Author

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

  • Author

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));

}

}

  • Author

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.

  • Author

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...

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions โ†’ Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.