Jump to content

[1.8] [SOLVED] Can't Reduce Amount of energy in a pipe


AnZaNaMa

Recommended Posts

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

- 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

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. xD

 

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

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.

- 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

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.

- 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

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?

Link to comment
Share on other sites

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

- 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

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.

- 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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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