Jump to content

[Solved] Modding 1.7 Need a method/function that adds to an int


Recommended Posts

Posted

Hey every one I'm currently working on my custom Harry Potter mod and I'm trying to change my spell system, what I'm trying to do and need help with is making a method/function in an item that every time a statement is true it adds +1 to an int, the int will then be used in the onItemRightClick to determine which spell is selected. Also if when the int hit like for example 40 it would start from 0 again Any help is appreciated

Posted

You should probably use the item damage for this. It's a value that is attached to every ItemStack.

 

The only problem I'm having with this is, that i can't find a method that works so when the player is sneaking the item damage changes

Posted

If I'm reading this correctly, you want to increment some integer every time a certain condition is true.

 

If the condition is that the player is sneaking, then it's quite difficult to do inside the item class itself. You'd have to use an event handler and check for a sneaking event. This is how you would do this for most conditions.

 

It will be much easier if the condition is that the player uses the item while sneaking. Then you can add the relevant code to the onItemRightClick() method using an if statement to check for the conditions.

 

Switching to another topic, n = (n + 1) % 40; will increment n and loop back to 0 once n reaches 40. (n will be from 0 to 39.)

 

 

 

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.