Posted March 9, 20178 yr Hi, I'm making a little mod and I want to use the new Forge Energy API with it - specifically, have a block receive and use power. After a couple hours on the interwebs, I couldn't find any good explanations of how to do this (I literally just have an EnergyStorage inside of a TileEntity at the moment). I would appreciate it if anyone could explain this or even just give me some basic code to learn from. (I'm brand new to the Capabilities system too, so a quick explanation of that wouldn't go amiss.) Many thanks, -Matthew Edited March 11, 20178 yr by m_lugg
March 9, 20178 yr Explanation of capabilities: http://mcforge.readthedocs.io/en/latest/datastorage/capabilities/ Replace everything you've read with the energy API equivalent, and you've got a TileEntity capable of handling energy. Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
March 9, 20178 yr Author Thanks! One quick question: How would I write the currently stored energy into NBT? I presume I would use ENERGY_CAPABILITY.writeNBT with my EnergyStorage as the first parameter; but I am confused as to what the EnumFacing is for. EDIT: After a re-read, would I be correct in saying that that can be anything, since my EnergyStorage can be used from any face? Edited March 9, 20178 yr by m_lugg
March 9, 20178 yr myEnergyStorage.writeToNBT() 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.
March 9, 20178 yr Author 2 minutes ago, Draco18s said: myEnergyStorage.writeToNBT() That doesn't exist for me?
March 9, 20178 yr There should be a method with a similar name (because I don't have Eclipse open and don't feel like finding it for you). Its not static, you call it on the energy storage instance itself. Edited March 9, 20178 yr by Draco18s 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.
March 9, 20178 yr EnergyStorage doesn't implement INBTSerializable, so it doesn't have methods to read it from/write it to NBT. Either get the capability's IStorage (Capability#getStorage) and use that to read from/write to NBT or do it yourself (storing the energy in a single integer tag). 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.
March 10, 20178 yr Author Sorry for the delay in replying. I've got everything working now, thanks One last question; I'm making a block that I want to consume power. That's working fine, but the problem is if I place _ANOTHER_ block which consumes power next to it, it sees the capability and extracts energy from it. Should I remove the getCapability override, or is there another way to get around this? Thanks -Matthew
March 11, 20178 yr Author Don't worry, I figured it out. Energy cables are responsible for putting the energy into the machine, not the machine itself. Thanks for all your help!
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.