Posted October 1, 20169 yr So, i learned how tu use Capabilities on TEs. This is really simple. I know the Energy Capability can also be used for Itemstacks, but how do i create an item that uses engery, has internal storage and more with the CapabilityEnergy so that for example my maschines can charge it. I searched a lot the pat hours and only find tutorials or example code for the rf api(which only works with interfaces) or how to create own capabilities, which again isnt my goal I think i will just need a bit of a starting point here
October 1, 20169 yr I don't understand what you're getting at here. Do you not have an Energy framework API here? In regards to your machine charging your items. You could give the item damage capabilities (this.setMaxDamage(int); ) and then programme it to "discharge" (take damage) as a visual representation of it. Your machines could be coded to look for instances of that item class type and if true, if you have internal energy stored and your machine is an energy provider, if the item's nbt is not full, internalMachineEnergy --; itemNBTEnergy ++; or something along those lines.
October 2, 20169 yr You need to create an implementation of ICapabilityProvider to provide the IEnergyStorage instance. The ICapabilityProvider also needs to implement INBTSerializable to save the IEnergyStorage to NBT. Because you often need to implement these interfaces together, Forge provides the ICapabilitySerializable interface which is simply a combination of the two. Once you have the ICapabiltiyProvider implementation, override Item#initCapabilities to create and return an instance of it. This isn't specific to the energy capability, it applies to any capability you want an item to provide. Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
October 2, 20169 yr Author Thank you very much, i got the same idea while looking at examples for the Tesla Api an hour ago, everythign works fine
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.