Jump to content

Recommended Posts

Posted

I'd got some kind of anomaly during creation of my Forge 1.12.2 modification.
 

Short description: world.isRemote somehow returns true on server side.

 

Long description:

I have a class which extends Entity. I have put logic into onUpdate function and I was suprised when I figured out that this method is called on client side. I have added check to make sure that my logic is performed on server side. However, this check always fails. I have decided to test if I had accidentally called

world.spawnEntity

on client side (which is impossible!), so I put

logger.info(world.isRemote);

after that line (btw, what is the best method for testing?).

 

This check has returned "true", what means that it was executed at the client side, but console thread says that this text was printed from server thread. I am feeling competely lost.

 

The only one my proposition is that the problem is that I am using common logger for client and server sides, but I have never seen such

 

Github repository: https://github.com/mystery-coder/Souls-Industry/tree/dev

Problematical code parts:

forgemod.mystery.soulsindustry.tile.TileLamp.consume(...)

(Event is called from TickEvent.ServerTickEvent handler),

forgemod.mystery.soulsindustry.entity.EntityWisp.onUpdate()

 

Any help would be appreciated.

 

Posted
1 minute ago, V0idWa1k3r said:

Well, your TileLamp only registers itself as an event subscriber on the client, so the event handler method only fires on the client, and as such the wisp is only spawned on the client.

Oh, God! How could I miss that?!
 

Thank you very much. I am filling myself so stupid...

 

But can you explain me then why are

PowerDistributionEvent

being called if they are server-side? (They are posted only on server)

Posted

I think this happens because the event bus doesn't care about threads(and is static), and simply sends the event to all listeners. While you are posting the event on the server thread it goes to the event bus which iterates through all listeners, which the client-sided TEs are and gives the event to them. So in a way you made a jump from a server event to a client listener.

I don't know for sure though and can only be guessing from my inspection of the EventBus class.

  • Like 1

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.