Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/20/20 in all areas

  1. You are already registering an entity type of your custom arrow entity in the code above...just use the ENTITY_TYPES#register method of your deferred register instead of using the vanilla registry. Also, did you remember to bind your entity to its renderer?
    1 point
  2. That makes a ton of sense now... it's strange that it's set like that though, if ImageButton has a constructor that accepts text, you would think it would render on the button by default. Normally it just passes StringTextComponent.field_240750_d_ (an empty string), so having another hurdle seems redundant.
    1 point
  3. The constructor of both of the button you are using passes Button.field_238486_s_ (empty), whereas there won't be any hovered text/tooltip being displayed, so I assume you are talking about the text that is rendered on the button: ImageButton overrides renderButton and does not call super.renderButton(...) (but Button did), and in Widged#renderButton it draws the title you passed in, therefore ImageButton does not render the title, but Button does.
    1 point
  4. I cannot for the life of me understand how capabilities work. It may just be the way I'm needing to implement them, so I'll be talking about that specifically. I'm currently making a mod that adds a modifier to the player's health to allow for more than just the generic 20 max health. Previously I used a class that contained a player cache and had functions to store and modify the NBT data of said player. Well, I was recently told to use capabilities now, but I have absolutely no idea how to do that. From what I understand, capabilities are supposed to be an easy way to store data alongside Minecraft classes. For example, an easy way to store data for a furnace or something. What I don't understand is how the hell this is supposed to work; what is a capability? Is it a modification to the way things work? Or is it supposed to be an easy interface between NBT data and Minecraft objects? How the hell do you attach a capability to an Entity? Do I need to provide my own Capability Provider, or use one of Forge's? If I need to use one of Forge's, which one do i use? How do I provide my own, in the case I need to do that (the forge documentation is useless and outdated). What does it mean to "expose" a capability? What is a capability type? What does it mean to "attach" a capability? Capabilities do not make sense at all! I will attempt to break this down so you can understand what I don't: "In general terms, each capability provides a feature in the form of an interface, alongside with a default implementation which can be requested, and a storage handler for at least this default implementation. " "each capability provides a feature in the form of an interface," what does this even mean? I've completed my college course on Java and still have no idea what this implies. A Java interface is used to easily describe classes and provides a layer of abstraction, it is not supposed to provide features. You cannot "implement" a feature using an interface. "alongside with a default implementation which can be requested," what? A default implementation versus... what, a custom one? Someone else's? Why not just implement what you need instead of attempting to provide an interface? "a storage handler for at least this default implementation," again, what is this 'default implementation', and what other types of implementations are there? Also, what in the world is this implementation? I, alongside many others, learn best by example, but the examples on the Forge docs don't provide any context whatsoever. The text refers to things that haven't been talked about, and implies that you have already created things that you didn't even know existed. How am I supposed to have made an "instance of the underlying capability type" if I didn't even know I needed to make one? Maybe I'm just having a hard time understanding Forge's documentation, but I have no idea what capabilities are supposed to be, what they provide in functionality, and how they're supposed to be "easier" than just directly interfacing with a player's NBT data. And yes, I have looked in the source, and no, it doesn't help whatsoever because if I don't even know what they do in the first place how am I supposed to understand an implementation? Note: Once I truly understand the purpose of a capability and how to implement one, I would love to make a PR to help improve the wording of the docs.
    1 point
  5. Oh right! I had completely forgotten about there being two different event busses. Yes! It works now! Thank you everyone who helped me out with this! I really, really, really appreciate it! Thank you for being understanding with me through being an idiot sometimes as well haha. A lot of good topics were covered here so I really hope this thread will also help some other people using capabilities! As some example code, here's the gist showing all of what I've done to get this capability registered and working. Again, thank you so so much! https://gist.github.com/FireController1847/c7a50144f45806a996d13efcff468d1b
    1 point
  6. A capability is a way to attach data to an object that doesn't belong to you. IE the player. It's actually incredibly simple. You need a Capability instance with the @CapabilityInject annotation above it. You need to register your Capability using CapabilityManager.INSTANCE.register(Class<Some Base class where your capability data will be stored>, new IStorageInstance, new Callable) The IStorageInstance has two methods that save and load data for the capability. The new Callable needs to create an instance of your base class. Then you also need to use the AttachCapabilitiesEvent to attach it to the object you want to attach it to. You use AttachCapabilitiesEvent#addCapability(ID, new ICapabilityProvider) The ICapabilityProvider is the object that provides the way to get the Capability data from the object it is attached to.
    1 point
×
×
  • Create New...

Important Information

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