Jump to content

[1.14.4] (What happened to itemstack NBT tags) - Problems with Capabilites + Durability Bar


Recommended Posts

Posted (edited)

It's been a while since I have worked with NBT Data, but it seems like none of the methods that existed before related to nbt exist now.

 

For starters, there doesn't seem to be a "onUpdate" method for items right now. That's where I used to create the tag.So basically, I can't even figure out how to give items tags let alone do anything with it. Also, it seems like there are two types of tags right now?! Looking through some classes, I found mentions of shareTags and normal Tags. What is their difference?

Could someone point me in the right direction. How do you setup tag compounds for items in 1.14?
Thank you in advance.

Edited by Cerandior
Posted

Maybe look at this? [LINK]

  • Like 1

A few bytes about me:

public class Xander402 extends Modder implements IForumMember {
    int javaExperience, moddingExperience;
    LearningWay preferredLearningWay;
    public Xander402() {
        this.javaExperience = BIG;
        this.moddingExperience = NOT_SO_BIG;
        this.preferredLearningWay = LearningWay.through("exampes");
      	super(/*displayName*/"Xander402", /*moddingSince*/"1.9", preferredLearningWay);
    }
    @Override
    public Goal getReasonOfJoining(Forum forum) { return new Goal(() -> { while (true) moddingExperience++; }); }
}

 

Posted

You should be using Capabilities now.

  • Like 1

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.

Posted (edited)
On 11/29/2019 at 10:15 PM, Draco18s said:

You should be using Capabilities now.

Those docs are a little outdated. Things were a little different for me for 1.14.

I managed to get it working, but I don't understand some of the things I did to get it working.

What exactly is LazyOptional? That is so confusing. Why do I have to return an instance of LazyOptional instead of an instance of my Capability when I try to get the capability?

I used the .orElse(null) (which seems to return an instance of my Capability automatically?) method to get the capability after looking at the class of LazyOptional, however I am not sure if that's how you are supposed to do it. I must clarify. It did work without errors, but I don't know if it is the correct way of doing things.

 

Apart from having a little trouble understanding capabilities, I can't seem to get the durability bar to display correctly. I am trying to give a certain item a cooldown after usage. I implemented this through capabilities and the cooldown bit seems to work, however I want to use the durability bar to display the "time left" before next use, and the durability bar is not being rendered at all. It probably has to do with showDurabilityBar method, but I am not sure.

Everything related to my capabilities you can find here: https://github.com/Cerandior/VanillaExtended/tree/master/src/main/java/teabx/vanillaextended/capabilities

 

And here is the item in question: https://github.com/Cerandior/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/items/LordStaff.java

 

Thank you for your help.

Edited by Cerandior
Posted
3 hours ago, Cerandior said:

What exactly is LazyOptional? That is so confusing. Why do I have to return an instance of LazyOptional instead of an instance of my Capability when I try to get the capability?

A LazyOptional allows you to create the actual Capability when it is needed (but the LazyOptional can exist before then!) For most use-cases, you'll create them both at the same time.

3 hours ago, Cerandior said:

I used the .orElse(null) (which seems to return an instance of my Capability automatically?)

It will, if your capability was already created. You can also use ifPresent() which takes a lambda expression in the form of x=>{ /* your code here*/ } where x is your capability.

 

  • Thanks 1

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.

Posted
52 minutes ago, diesieben07 said:

LazyOptional is exactly what it's name suggests: It is an optional value (the requested capability or nothing if the capability is not provided by the queried capability provider) which is lazily computed (only once you ask for it's value is that value actually computed).

Don't want to be a nuisance, but I am having trouble with that durability bar. It is not being updated correctly. Is it because there is a lack of communication between the server and the client at the moment? (I haven't setup packets yet).

Here is the class of the item: https://github.com/Cerandior/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/items/LordStaff.java

Posted
1 hour ago, diesieben07 said:

Capability NBT is not sent to the client by default. You have to override getShareTag and readShareTag in your Item class.

I am still not getting any data in the client even when I use the itemstack.getShareTag. I am little confused, how am I supposed to implement this?

Posted
7 minutes ago, diesieben07 said:

Show what you tried.

    @Nullable
    @Override
    public CompoundNBT getShareTag(ItemStack stack) {
        ICoolDownItem cap = stack.getCapability(CapabilityRegistry.COOLDOWN_ITEM, null).orElse(null);
        CompoundNBT nbt = new CompoundNBT();
        nbt.putInt("cooldown", cap.getCooldown());
        nbt.putInt("maxcooldown", cap.getMaxCooldown());
        return nbt;
    }

    @Override
    public void readShareTag(ItemStack stack, @Nullable CompoundNBT nbt) { }

    @Override
    public boolean showDurabilityBar(ItemStack stack) {
        return true;
    }

    @Override
    public double getDurabilityForDisplay(ItemStack stack) {
        return 1-(stack.getShareTag().getInt("cooldown")/stack.getShareTag().getInt("maxcooldown"));
    }


I feel like I am doing the same thing I was doing before with extra steps. I think the problem is at the getShareTag, but I am not sure.

Posted
10 minutes ago, diesieben07 said:

Well... your readShareTag does... nothing. What did you expect?

 

Also, why are you using orElse(null), but then blindly calling methods on the result? If you expect the capability to always be there, use orElseThrow with a meaningful error message instead of failing with a meaningless, random NullPointerException.

I was doing something before, but I got rid of it before posting it here. I was using the nbt data to update the values in the capability but that didn't work. What am I supposed to do with the data I have stored in the nbt tag at the readShareTag?

About the second thing. I just stuck at the first thing that didn't give me any errors, did not think it through. Will change them, thank you.

Posted
2 minutes ago, diesieben07 said:

This:

Show what you tried.

@Override
public void readShareTag(ItemStack stack, @Nullable CompoundNBT nbt) {
    if(nbt != null){
        ICoolDownItem cap = stack.getCapability(CapabilityRegistry.COOLDOWN_ITEM, null).orElseThrow(null);
        cap.setCooldown(nbt.getInt("cooldown"));
    }
}
Posted (edited)
18 minutes ago, diesieben07 said:

That should work... Are the methods called? Use the debugger.

 

Seems like readShareTag is not being called at all.

 

https://prnt.sc/q4rds0
Here, at the getDurabilityForDisplay, the cooldown has not been updated in the capability.

Edited by Cerandior
Posted
Just now, diesieben07 said:

That should be impossible, because it is called every time an ItemStack of your item is received on the client.

 

I put the breakpoint at it, and intelliJ didn't pause the debugging nor show any data below.

This is the class of my item: https://github.com/Cerandior/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/items/LordStaff.java

in case I have done anything blatantly stupid.

Posted (edited)
2 minutes ago, diesieben07 said:

Apparently this changed in 1.14.4 and it's now completely impossible to sync the capability data of itemstacks, because the share tag is ignored except for when the client takes stacks from the creative menu.

 

So... nothing you can do.

When you say completely impossible, you mean like I can't do anything at all about it? Even with packets? That is kind of disappointing. When is the next version of forge planned for release? 

Edited by Cerandior
Posted (edited)
11 minutes ago, diesieben07 said:

I am stupid and didn't even read the code right...

 

It's that getShareTag is (basically) always used when writing stacks and readShareTag is always used when reading them.

 

It should be impossible for you to see readShareTag not being called.

 

I recorded this quick gif. Am I setting the breakpoint right?

 

 

Edited by Cerandior
Posted (edited)
8 minutes ago, diesieben07 said:

I mean... it looks fine?

Well I got everything working except for the representation of the cooldown through the durability bar.
The breakpoint is set correctly and readNBT is not called. I don't really know what else I can do from here. Is there any chance that I have screwed up the item in some other way that does not allow it to have a shared tag?

The github link I provided before contains all the files of the project I am currently working on. When you got the time maybe you can look at it . At the moment, I can't ask you to do anything more, I have spent enough of your time already.

I can't think of anything else to do myself. Anyway, thank you for your help.

Edited by Cerandior
Posted
4 minutes ago, diesieben07 said:

There is literally one way for getShareTag not to be called: You have overridden shouldSyncTag to return false.

Considering you haven't done that: I'm guessing something about your setup is broken so that the breakpoint doesnt trigger even though the method is called.

I even put some System.out.println (which is a stupid way to debug, I know) in both methods, but nothing shows up in the console.

Posted (edited)
6 hours ago, diesieben07 said:

That is ancient...

Please update.

 

I just moved over to Build: 1.14.4-28.1.96. Yet the same problem persists. Can anybody else recreate the same thing in this version of forge? Or has anything similar to this been reported before?

Edited by Cerandior

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • New users at Temureceive a 40 Off discount on orders over 40 Off Use the code [acx318439] during checkout to get TemuDiscount 40 Off For New Users. You n save 40 Off off your first order with the Promo Code available for a limited time only. Extra 30% off for new and existing customers + Up to $40 Off % off & more. Temu Promo Codes for New users- [acx318439] Temudiscount code for New customers- [acx318439] Temu $40 Off Promo Code- [acx318439] what are Temu codes- acx318439 does Temu give you $40 Off - [acx318439] Yes Verified Temu Promo Code january 2025- {acx318439} TemuNew customer offer {acx318439} Temudiscount codejanuary 2025 {acx318439} 40 off Promo Code Temu {acx318439} Temu 40% off any order {acx318439} 40 dollar off Temu code {acx318439} TemuCoupon $40 Off off for New customers There are a number of discounts and deals shoppers n take advantage of with the Teemu Coupon Bundle [acx318439]. TemuCoupon $40 Off off for New customers [acx318439] will save you $40 Off on your order. To get a discount, click on the item to purchase and enter the code. You n think of it as a supercharged savings pack for all your shopping needs Temu Promo Code 80% off – [acx318439] Free Temu codes 50% off – [acx318439] TemuCoupon $40 Off off – [acx318439] Temu buy to get ₱39 – [acx318439] Temu 129 coupon bundle – [acx318439] Temu buy 3 to get €99 – [acx318439] Exclusive $40 Off Off TemuDiscount Code Temu $40 Off Off Promo Code : (acx318439) Temu Discount Code $40 Off Bundle acx318439) acx318439 Temu $40 Off off Promo Code for Exsting users : acx318439) Temu Promo Code $40 Off off Temu 40 Off coupon code (acx318439) will save you 40 Off on your order. To get a discount, click on the item to purchase and enter the code. Yes, Temu offers 40 Off Coupon Code “acx318439” for Existing Customers.  You can get a 40 Off bonus plus 30% off any purchase at Temu with the 40 Off Coupon Bundle at Temu if you sign up with the referral code [acx318439] and make a first purchase of $40 Off or more. Temu Promo Code 40 off-{acx318439} Temu Promo Code -{acx318439} Temu Promo Code $40 Off off-{acx318439} kubonus code -{acx318439} Get ready to unlock a world of savings with our free Temu UK coupons! We’ve got you covered with a wide range of Temu UK coupon code options that will help you maximize your shopping experience.30% Off Temu UK Coupons, Promo Codes + 25% Cash Back [ acx318439]   Yes, Temu offers 40 off coupon code {acx318439} for first-time users. You can get a $40 bonus plus 40% off any purchase at Temu with the $40 Coupon Bundle if you sign up with the referral code [acx318439] and make a first purchase of $40 or more. If you are who wish to join Temu, then you should use this exclusive TemuCoupon code 40 off (acx318439) and get 40 off on your purchase with Temu. You can get a 40% discount with TemuCoupon code {acx318439}. This exclusive offer is for existing customers and can be used for a 40 reduction on your total purchase. Enter coupon code {acx318439} at checkout to avail of the discount. You can use the code {acx318439} to get a 40 off TemuCoupon as a new customer. Apply this TemuCoupon code $40 off (acx318439) to get a $40 discount on your shopping with Temu. If you’re a first-time user and looking for a TemuCoupon code $40 first time user(acx318439) then using this code will give you a flat $40 Off and a 90% discount on your Temu shopping.     •    acx318439: Enjoy flat 40% off on your first Temu order.     •    acx318439: Download the Temu app and get an additional 40% off.     •    acx318439: Celebrate spring with up to 90% discount on selected items.     •    acx318439: Score up to 90% off on clearance items.     •    acx318439: Beat the heat with hot summer savings of up to 90% off.     •    acx318439: Temu UK Coupon Code to 40% off on Appliances at Temu. How to Apply Temu Coupon Code? Using the TemuCoupon code $40 off is a breeze. All you need to do is follow these simple steps:     1    Visit the Temu website or app and browse through the vast collection of products.     2    Once you’ve added the items you wish to purchase to your cart, proceed to the checkout page.     3    During the checkout process, you’ll be prompted to enter a coupon code or promo code.     4    Type in the coupon code: [acx318439] and click “Apply.”     5    Voila! You’ll instantly see the $40 discount reflected in your total purchase amount. Temu New User Coupon: Up To 90% OFF For Existing Customers Temu Existing customer’s coupon codes are designed just for new customers, offering the biggest discounts 90% and the best deals currently available on Temu. To maximize your savings, download the Temu app and apply our Temu new user coupon during checkout.     •    acx318439: New users can get up to 80% extra off.     •    acx318439: Get a massive 40% off your first order!     •    acx318439: Get 20% off on your first order; no minimum spending required.     •    acx318439: Take an extra 15% off your first order on top of existing discounts.     •    acx318439: Temu UK Enjoy a 40% discount on your entire first purchase.  
    • New users at Temureceive a 40 Off discount on orders over 40 Off Use the code [acx318439] during checkout to get TemuDiscount 40 Off For New Users. You n save 40 Off off your first order with the Promo Code available for a limited time only. Extra 30% off for new and existing customers + Up to $40 Off % off & more. Temu Promo Codes for New users- [acx318439] Temudiscount code for New customers- [acx318439] Temu $40 Off Promo Code- [acx318439] what are Temu codes- acx318439 does Temu give you $40 Off - [acx318439] Yes Verified Temu Promo Code january 2025- {acx318439} TemuNew customer offer {acx318439} Temudiscount codejanuary 2025 {acx318439} 40 off Promo Code Temu {acx318439} Temu 40% off any order {acx318439} 40 dollar off Temu code {acx318439} TemuCoupon $40 Off off for New customers There are a number of discounts and deals shoppers n take advantage of with the Teemu Coupon Bundle [acx318439]. TemuCoupon $40 Off off for New customers [acx318439] will save you $40 Off on your order. To get a discount, click on the item to purchase and enter the code. You n think of it as a supercharged savings pack for all your shopping needs Temu Promo Code 80% off – [acx318439] Free Temu codes 50% off – [acx318439] TemuCoupon $40 Off off – [acx318439] Temu buy to get ₱39 – [acx318439] Temu 129 coupon bundle – [acx318439] Temu buy 3 to get €99 – [acx318439] Exclusive $40 Off Off TemuDiscount Code Temu $40 Off Off Promo Code : (acx318439) Temu Discount Code $40 Off Bundle acx318439) acx318439 Temu $40 Off off Promo Code for Exsting users : acx318439) Temu Promo Code $40 Off off Temu 40 Off coupon code (acx318439) will save you 40 Off on your order. To get a discount, click on the item to purchase and enter the code. Yes, Temu offers 40 Off Coupon Code “acx318439” for Existing Customers.  You can get a 40 Off bonus plus 30% off any purchase at Temu with the 40 Off Coupon Bundle at Temu if you sign up with the referral code [acx318439] and make a first purchase of $40 Off or more. Temu Promo Code 40 off-{acx318439} Temu Promo Code -{acx318439} Temu Promo Code $40 Off off-{acx318439} kubonus code -{acx318439} Get ready to unlock a world of savings with our free Temu UK coupons! We’ve got you covered with a wide range of Temu UK coupon code options that will help you maximize your shopping experience.30% Off Temu UK Coupons, Promo Codes + 25% Cash Back [ acx318439]   Yes, Temu offers 40 off coupon code {acx318439} for first-time users. You can get a $40 bonus plus 40% off any purchase at Temu with the $40 Coupon Bundle if you sign up with the referral code [acx318439] and make a first purchase of $40 or more. If you are who wish to join Temu, then you should use this exclusive TemuCoupon code 40 off (acx318439) and get 40 off on your purchase with Temu. You can get a 40% discount with TemuCoupon code {acx318439}. This exclusive offer is for existing customers and can be used for a 40 reduction on your total purchase. Enter coupon code {acx318439} at checkout to avail of the discount. You can use the code {acx318439} to get a 40 off TemuCoupon as a new customer. Apply this TemuCoupon code $40 off (acx318439) to get a $40 discount on your shopping with Temu. If you’re a first-time user and looking for a TemuCoupon code $40 first time user(acx318439) then using this code will give you a flat $40 Off and a 90% discount on your Temu shopping.     •    acx318439: Enjoy flat 40% off on your first Temu order.     •    acx318439: Download the Temu app and get an additional 40% off.     •    acx318439: Celebrate spring with up to 90% discount on selected items.     •    acx318439: Score up to 90% off on clearance items.     •    acx318439: Beat the heat with hot summer savings of up to 90% off.     •    acx318439: Temu UK Coupon Code to 40% off on Appliances at Temu. How to Apply Temu Coupon Code? Using the TemuCoupon code $40 off is a breeze. All you need to do is follow these simple steps:     1    Visit the Temu website or app and browse through the vast collection of products.     2    Once you’ve added the items you wish to purchase to your cart, proceed to the checkout page.     3    During the checkout process, you’ll be prompted to enter a coupon code or promo code.     4    Type in the coupon code: [acx318439] and click “Apply.”     5    Voila! You’ll instantly see the $40 discount reflected in your total purchase amount. Temu New User Coupon: Up To 90% OFF For Existing Customers Temu Existing customer’s coupon codes are designed just for new customers, offering the biggest discounts 90% and the best deals currently available on Temu. To maximize your savings, download the Temu app and apply our Temu new user coupon during checkout.     •    acx318439: New users can get up to 80% extra off.     •    acx318439: Get a massive 40% off your first order!     •    acx318439: Get 20% off on your first order; no minimum spending required.     •    acx318439: Take an extra 15% off your first order on top of existing discounts.     •    acx318439: Temu UK Enjoy a 40% discount on your entire first purchase.  
    • New users at Temureceive a 40 Off discount on orders over 40 Off Use the code [acx318439] during checkout to get TemuDiscount 40 Off For New Users. You n save 40 Off off your first order with the Promo Code available for a limited time only. Extra 30% off for new and existing customers + Up to $40 Off % off & more. Temu Promo Codes for New users- [acx318439] Temudiscount code for New customers- [acx318439] Temu $40 Off Promo Code- [acx318439] what are Temu codes- acx318439 does Temu give you $40 Off - [acx318439] Yes Verified Temu Promo Code january 2025- {acx318439} TemuNew customer offer {acx318439} Temudiscount codejanuary 2025 {acx318439} 40 off Promo Code Temu {acx318439} Temu 40% off any order {acx318439} 40 dollar off Temu code {acx318439} TemuCoupon $40 Off off for New customers There are a number of discounts and deals shoppers n take advantage of with the Teemu Coupon Bundle [acx318439]. TemuCoupon $40 Off off for New customers [acx318439] will save you $40 Off on your order. To get a discount, click on the item to purchase and enter the code. You n think of it as a supercharged savings pack for all your shopping needs Temu Promo Code 80% off – [acx318439] Free Temu codes 50% off – [acx318439] TemuCoupon $40 Off off – [acx318439] Temu buy to get ₱39 – [acx318439] Temu 129 coupon bundle – [acx318439] Temu buy 3 to get €99 – [acx318439] Exclusive $40 Off Off TemuDiscount Code Temu $40 Off Off Promo Code : (acx318439) Temu Discount Code $40 Off Bundle acx318439) acx318439 Temu $40 Off off Promo Code for Exsting users : acx318439) Temu Promo Code $40 Off off Temu 40 Off coupon code (acx318439) will save you 40 Off on your order. To get a discount, click on the item to purchase and enter the code. Yes, Temu offers 40 Off Coupon Code “acx318439” for Existing Customers.  You can get a 40 Off bonus plus 30% off any purchase at Temu with the 40 Off Coupon Bundle at Temu if you sign up with the referral code [acx318439] and make a first purchase of $40 Off or more. Temu Promo Code 40 off-{acx318439} Temu Promo Code -{acx318439} Temu Promo Code $40 Off off-{acx318439} kubonus code -{acx318439} Get ready to unlock a world of savings with our free Temu UK coupons! We’ve got you covered with a wide range of Temu UK coupon code options that will help you maximize your shopping experience.30% Off Temu UK Coupons, Promo Codes + 25% Cash Back [ acx318439]   Yes, Temu offers 40 off coupon code {acx318439} for first-time users. You can get a $40 bonus plus 40% off any purchase at Temu with the $40 Coupon Bundle if you sign up with the referral code [acx318439] and make a first purchase of $40 or more. If you are who wish to join Temu, then you should use this exclusive TemuCoupon code 40 off (acx318439) and get 40 off on your purchase with Temu. You can get a 40% discount with TemuCoupon code {acx318439}. This exclusive offer is for existing customers and can be used for a 40 reduction on your total purchase. Enter coupon code {acx318439} at checkout to avail of the discount. You can use the code {acx318439} to get a 40 off TemuCoupon as a new customer. Apply this TemuCoupon code $40 off (acx318439) to get a $40 discount on your shopping with Temu. If you’re a first-time user and looking for a TemuCoupon code $40 first time user(acx318439) then using this code will give you a flat $40 Off and a 90% discount on your Temu shopping.     •    acx318439: Enjoy flat 40% off on your first Temu order.     •    acx318439: Download the Temu app and get an additional 40% off.     •    acx318439: Celebrate spring with up to 90% discount on selected items.     •    acx318439: Score up to 90% off on clearance items.     •    acx318439: Beat the heat with hot summer savings of up to 90% off.     •    acx318439: Temu UK Coupon Code to 40% off on Appliances at Temu. How to Apply Temu Coupon Code? Using the TemuCoupon code $40 off is a breeze. All you need to do is follow these simple steps:     1    Visit the Temu website or app and browse through the vast collection of products.     2    Once you’ve added the items you wish to purchase to your cart, proceed to the checkout page.     3    During the checkout process, you’ll be prompted to enter a coupon code or promo code.     4    Type in the coupon code: [acx318439] and click “Apply.”     5    Voila! You’ll instantly see the $40 discount reflected in your total purchase amount. Temu New User Coupon: Up To 90% OFF For Existing Customers Temu Existing customer’s coupon codes are designed just for new customers, offering the biggest discounts 90% and the best deals currently available on Temu. To maximize your savings, download the Temu app and apply our Temu new user coupon during checkout.     •    acx318439: New users can get up to 80% extra off.     •    acx318439: Get a massive 40% off your first order!     •    acx318439: Get 20% off on your first order; no minimum spending required.     •    acx318439: Take an extra 15% off your first order on top of existing discounts.     •    acx318439: Temu UK Enjoy a 40% discount on your entire first purchase.  
    • It is an issue with Pixelmon - maybe report it to the creators
    • Please read the FAQ (https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/) and post logs as described there for further help.  
  • Topics

×
×
  • Create New...

Important Information

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