Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.12.2] Item glint and durabilitybar prolem


SaltStation
 Share

Recommended Posts

Hello everyone.

 

I made an item which changes its durabilitybar and enchantment glint depending on how often you rightclick.

Every instance of this item now has the same glint and durabilitybar even if their value is different on the server.

I think this is because I saved the values for the glint and durabilitybar method in my item class.

Because my NBTTagcompund is stuck in onItemRightClick.

What is the proper way of saving these values for every instance of my item?

 

Thanks in advance.

Link to comment
Share on other sites

10 minutes ago, SaltStation said:

Hello everyone.

 

I made an item which changes its durabilitybar and enchantment glint depending on how often you rightclick.

Every instance of this item now has the same glint and durabilitybar even if their value is different on the server.

I think this is because I saved the values for the glint and durabilitybar method in my item class.

Because my NBTTagcompund is stuck in onItemRightClick.

What is the proper way of saving these values for every instance of my item?

 

Thanks in advance.

I think you have to create a capability which is added to your itemStack.

Documentation

  • Thanks 1
Link to comment
Share on other sites

37 minutes ago, SaltStation said:

I think this is because I saved the values for the glint and durabilitybar method in my item class.

It is. There is only one Item. You want per-stack data, you need to store the data in the stack (old: nbt, new: capabilities). You cheated, it broke, and no one is surprised. 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • So I am coding a AFK mod which basically holds left click in servers (Skyblock). The problem is that once I tabbed out , the island sometimes restarts and I am warped to the community centre. I have coded so it automatically rejoin, but it doesn't hold left click anymore even I used the setKeyBindState method for keyBindAttack(I am tabbed out at this point). But after I went in the game window again, it somehow works again without me pressing left click. So is there any way that I can make setKeyBindState work after tabbing out and rejoining a server? P.S. I observed that after rejoining the server if I am tabbed out, my mouse cursor would somehow move to the centre of the game screen automatically so maybe some other code is affecting.
    • I'm struggling to find the correct methods and classes, and I cannot find the latest documentation for 1.18.1-39.0.59 for example if I need to get the current player dimension name, I found this post: But there is no such attribute names. After searching the mod source code of an public available repository I found that the method I need to call is obtained through player.level.dimension().location().getPath() and not from worldObj (as the post said) nor getName() or something easier to guess, this is pretty confusing. I use to code faster but this procedure of trial and error of guessing the attributes and methods is too slow, and can be solved with good docs. Do I have the wrong environment? or What is happening? Where can I find the correct latest documentation? At last I must say that I'm new into forge but not new into programming. Thank your for your attention, any help is appreciated.
    • I would recommend using the official format: https://minecraft.fandom.com/wiki/Raw_JSON_text_format#Java_Edition
    • Hello, I created a custom entity which shoots snowballs at the player and other mobs. Now I want it to look at the target while doing so --> rotating its head to it/at least rotate its body in the targets direction I tried to use this.lookAt(enitity) which doesnt seem to work. Spawning Particles doesnt work either public void tick() { this.attackTimer++; LivingEntity targetentity = this.snowmanCannon.getTarget(); this.snowmanCannon.setAttacking(true); Level level = this.snowmanCannon.level; this.snowmanCannon.getLookControl().setLookAt(targetentity); if(!this.snowmanCannon.hasLineOfSight(targetentity)) { } else if (this.attackTimer == 1) { this.snowmanCannon.setAttacking(true); Vec3 pos1 = this.snowmanCannon.getEyePosition().add(0,-0.5,0); Vec3 pos2 = targetentity.getEyePosition(); Vec3 dir = pos2.subtract(this.snowmanCannon.getEyePosition()); SnowmanCannonProjectile snowball = new SnowmanCannonProjectile(level, pos1.x, pos1.y, pos1.z); snowball.shoot(dir.x, dir.y, dir.z, 4.5F, 0.1F); this.snowmanCannon.playSound(SoundEvents.SNOW_GOLEM_SHOOT, 1.0F, 1.0F); level.addAlwaysVisibleParticle(ParticleTypes.EXPLOSION, pos1.x, pos1.y, pos1.z, 1d, 1d, 1d); level.addFreshEntity(snowball); } if (this.attackTimer == 3) { this.snowmanCannon.setAttacking(false); this.attackTimer = 0; } } Thank you for any help
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.