Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.10.2][Solved] Synchronization of RF energy in TileEntity


Roboguy99
 Share

Recommended Posts

I'm trying to implement the RF energy API on a TileEntity. I'm having quite a bit of trouble with synchronizing the energy between server and client though. What confuses me most is that I am already synchronizing another variable,

processTimeRemaining

, without an issue. Replicating the same steps for energy has not worked.

 

I thought perhaps I need a packet, but

processTimeRemaining

works without one, which confuses me.

 

The exact issue is with a progress bar in the GUI not being synced correctly; investigation shows this is because the client/server show different values for the energy. As I said, this issue does not exist with

processTimeRemaining

.

 

Code:

 

TileEntity update

TileEntity sync code (various methods as well as energy getters/setters until pretty much the end of the class)

Container

Gui

 

I'm sure it's something stupid and obvious; it normally is. I've spent hours trying various things, and nothing has worked so far, and I am very confused. Any help is appreciated.

I have no idea what I'm doing.

Link to comment
Share on other sites

So the link to sync code doesn't actually link to anything that does syncing.

That would be here: https://github.com/JakeStanger/Chemistry/blob/master/src/main/java/roboguy99/chemistry/tile/TileOreProcessor.java#L543

 

The part you linked to instead, however, uses magic numbers.  Fuck, did BlockState property enums teach you nothing?

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.

Link to comment
Share on other sites

Err...I'm going to say no, they did not...Perhaps you should explain what you mean by BlockState property enums more?

 

That code is far from being finished and tidied, and yes, I know, the magic numbers do need to go ASAP. Hell, the whole class is a disgusting mess that needs splitting.

 

The get/set field methods do sorta sync, but I guess that's not properly syncing between server/client?

 

What *should* I be doing to sync then? And why does

processTimeRemaining

sync when the energy doesn't?

I have no idea what I'm doing.

Link to comment
Share on other sites

Kill me.

 

public int getField(int id)
{
	switch (id)
	{
		case 0:
			return this.processTimeRemaining;
		case 1:
			return TileOreProcessor.PROCESS_TIME;
		case 2:
			return this.energyStorage.getEnergyStored();
		case 3:
			return this.energyStorage.getMaxEnergyStored();
	}

	return 0;
}

public void setField(int id, int value)
{
	switch (id)
	{
		case 0:
			this.processTimeRemaining = value;
			break;
		case 3:
			this.energyStorage.setEnergyStored(value);
	}
}

 

setField

case 3

should be

case 2

.

 

Further evidence that magic numbers are hell. I'm changing them now.

I have no idea what I'm doing.

Link to comment
Share on other sites

See, I never would have even noticed. I saw magic numbers and went "fuck this, I'm going to assume it's correct."  I couldn't even tell that these methods were (partly) responsible for sync.

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.

Link to comment
Share on other sites

Yeah, but the 1.7.10 and the 1.8 version have a massive difference: In 1.8 IEnergyProvider and IEnergyReceiver extend IEnergyHandler and not the other way around.

 

True. It would be stupid to port it yourself if the devs did it for you anyway. I just said it for the sake of saying it really.

I have no idea what I'm doing.

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

 Share



×
×
  • Create New...

Important Information

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