AnZaNaMa Posted February 2, 2016 Share Posted February 2, 2016 Hi, I'm posting again. I've been working on the tech system in my mod and I currently working on pipes. These pipes are supposed to transfer energy out of any TileEntity that's a PowerProvider and into any TileEntity that's a PowerAcceptor. That seems to be working fairly well, except that when the pipe grabs energy from a PowerProvider, it is adding power to the pipe but not removing it from the Provider. Here's where the transferPower() function is called: https://github.com/AnZaNaMa/EnergyTools/blob/master/src/main/java/com/AnZaNaMa/EnergyTools/Entity/TileEntity/TileEntityPipe.java#L56 and here's the transferPower function: https://github.com/AnZaNaMa/EnergyTools/blob/master/src/main/java/com/AnZaNaMa/EnergyTools/api/Tech/PowerConnectable.java#L201 Quote - Just because things are the way they are doesn't mean they can't be the way you want them to be. Unless they're aspen trees. You can tell they're aspens 'cause the way they are. Link to comment Share on other sites More sharing options...
starwarsmace Posted February 3, 2016 Share Posted February 3, 2016 Hi, I'm posting again. I've been working on the tech system in my mod and I currently working on pipes. These pipes are supposed to transfer energy out of any TileEntity that's a PowerProvider and into any TileEntity that's a PowerAcceptor. That seems to be working fairly well, except that when the pipe grabs energy from a PowerProvider, it is adding power to the pipe but not removing it from the Provider. Here's where the transferPower() function is called: https://github.com/AnZaNaMa/EnergyTools/blob/master/src/main/java/com/AnZaNaMa/EnergyTools/Entity/TileEntity/TileEntityPipe.java#L56 and here's the transferPower function: https://github.com/AnZaNaMa/EnergyTools/blob/master/src/main/java/com/AnZaNaMa/EnergyTools/api/Tech/PowerConnectable.java#L201 public void subtractEnergy(int energy){ this.energyContained = this.energyContained + energy; } Its never helpful to add energy when you want to be removing it. Quote I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does! Link to comment Share on other sites More sharing options...
AnZaNaMa Posted February 3, 2016 Author Share Posted February 3, 2016 oh yeah that might be a problem, but thats not what is going on. I had changed that to what it is because before I used -= and i thought maybe that was messing it up. It still does it when I fix that. Quote - Just because things are the way they are doesn't mean they can't be the way you want them to be. Unless they're aspen trees. You can tell they're aspens 'cause the way they are. Link to comment Share on other sites More sharing options...
AnZaNaMa Posted February 3, 2016 Author Share Posted February 3, 2016 I realized I was not syncing energy values from server to client, so I thought maybe adding that would fix the problem. The energy still doesn't transfer correctly. Quote - Just because things are the way they are doesn't mean they can't be the way you want them to be. Unless they're aspen trees. You can tell they're aspens 'cause the way they are. Link to comment Share on other sites More sharing options...
Cerandior Posted February 3, 2016 Share Posted February 3, 2016 In the title you say that you cant reduce the energy stored on the pipe, while on the topic you wrote that you can add power to a pipe but it is not substracting that energy from the provider. I don't know how you set up your base tile entities classes and it would be good to actually answer this. Are your pipes considered energy providers? Quote Link to comment Share on other sites More sharing options...
AnZaNaMa Posted February 3, 2016 Author Share Posted February 3, 2016 Pipes are defined as neither PowerProviders nor PowerAcceptors. They are a child class of PowerConnectable which is the same class PowerProvider and PowerAcceptor branch off of. What's currently happening is that when I have a PowerProvider connected to a pipe, the function grabPower() is being called energy is being transferred into the pipe. However, the energy is not being removed from the PowerProvider. This is the function that is being called when the energy transfer takes place: https://github.com/AnZaNaMa/EnergyTools/blob/master/src/main/java/com/AnZaNaMa/EnergyTools/api/Tech/PowerConnectable.java#L202 Quote - Just because things are the way they are doesn't mean they can't be the way you want them to be. Unless they're aspen trees. You can tell they're aspens 'cause the way they are. Link to comment Share on other sites More sharing options...
AnZaNaMa Posted February 4, 2016 Author Share Posted February 4, 2016 FOUND IT! I was using an Energizer as my PowerProvider (because currently it's the only one) and I looked in the PowerProvider class. It had its own energyContained variable which the energizer was using, meaning I was changing the PowerConnectable energyContained and it was displaying the PowerProvider energyContained. I have since consolidated it into just the PowerConnectable class and removed the protected field from all field variables, then encapsulated them. Quote - Just because things are the way they are doesn't mean they can't be the way you want them to be. Unless they're aspen trees. You can tell they're aspens 'cause the way they are. Link to comment Share on other sites More sharing options...
Recommended Posts
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.