Jump to content

Cerandior

Members
  • Posts

    385
  • Joined

  • Last visited

Everything posted by Cerandior

  1. 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.
  2. 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.
  3. I recorded this quick gif. Am I setting the breakpoint right?
  4. 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?
  5. 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.
  6. 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.
  7. @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")); } }
  8. 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.
  9. @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.
  10. 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?
  11. 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
  12. Just a note. Don't just copy and paste the code I gave you. I have nothing against it, but if you don't understand what's going on then It's kind of pointless because even if you get it working, you won't be able to change anything. Also, for some of those methods, like the one that registers your capability, you can use your IDE to get to an implementation of that method to see what exactly that method is expecting for parameters, and what it does with them (ctl+b if on IntelliJ).
  13. Where you register the capability, at the second parameter you don't pass an instance of your capability interface. You have to pass an instance of your storage class. The last parameter is a new instance of your default implementation of your capability. The one that implements your interface.
  14. The first parameter you pass is a resource location containing your modid and a string name for your capability. The second parameter, you have to pass a new instance of the default implementation of your capability. This what I did and it works: https://github.com/Cerandior/VanillaExtended/blob/master/src/main/java/teabx/vanillaextended/main/EventHandler.java
  15. That's from the docs. Those are the events you must subscribe to depending on what type of thing you want to attach your capability. In your case. You use the one for entities and check if the entity is an instance of a player. If yes, attach it to that player.
  16. Yes, if you want to have a look at it, go here: https://github.com/Cerandior/VanillaExtended/tree/master/src/main/java/teabx/vanillaextended I got my Event Handler under "main" package.
  17. At cap, you should pass a new instance of the default implementation for your capability. I just got into capabilities myself lately, and they are a handful if you never worked with such things before. Very tricky to get things working because the docs are a little outdated.
  18. 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.
  19. Never really used them before. Guess it's going to take some time experimenting until I get the hang of them. Thanks!
  20. It is an outdated article. Those are all things I remember in past versions. You can't do the same thing anymore it seems.
  21. 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.
  22. Which version of Forge is this?
  23. That's a big oof from me. Been in front of the screen for a while now, maybe that's a sign I should back off. Thought onItemRightClick was void and didn't even look at the return right in my face. Sorry for wasting your time.
  24. That is what I tried as well, but I get an "unreachable statement" error. Never happened to me before. No idea what is going on. Screenshot of the error: https://prnt.sc/oxrq57
×
×
  • Create New...

Important Information

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