Bewitchment (Legacy)

Bewitchment (Legacy)

9M Downloads

Demon pledges are acting odd

Sunconure11 opened this issue ยท 15 comments

commented

After some deciding, I've decided to make this issue public, solely for anyone else who wants to take a stab at this.

Basically, demon pledging to either baphomet or leonard is acting really weird.

The pledges are not syncing correctly when exiting a world, both in singleplayer and multiplayer.

https://gyazo.com/74a1d4dba964831da0f3e42b7276b76f

A description of the issue, by @cybercat5555

oh I think there might be an issue with pledging in MP
sometimes after relogging or even dying, you'll be unpledged, but the demon is still neutral
tested with baphy with the server that has my modpack

alright a bit of testing:
in creative, you can constantly get new pacts from baphomet, not sure if intended?
in survival, it seems to "flicker" between being pledged and not? Like the next says "you are not pledged to baphomet" but then it rapidly switches to "you have received pact xxx for 7 days"

seems to do the same thing regardless of if its in one session, or if quit then rejoined
in the above gif, I was in survival mode and has about 19 levels
but baphy is still neutral to me, and I'm not wearing the besmirched stuff, so it seems I'm in some weird limbo of being pledged and not pledged

Class possibly at fault:

https://github.com/Um-Mitternacht/Bewitchment/blob/1.12.2/src/main/java/com/bewitchment/api/capability/extendedworld/ExtendedWorld.java

Relevant forge documentation:

https://mcforge.readthedocs.io/en/1.12.x/datastorage/worldsaveddata/

commented

This has been since resolved

commented

From a quick check:

  • mixing players.getPersistentID() with players.getUniqueID() is prone to fail you one time or another.
  • NBTTagCompound already support UUID getter/setter, instead of using string format, and probably much faster.
  • adding a dump of the pledges to the logs when they change would help finding the issue since it appears to be reproductible, possibly with a configuration option so it only spams whoever investigate the issue.
commented

Did changes relating to the first thing you noted.

Code probably needs a deeper look, but luckily, GitHub made it easier for people to navigate codebases.

commented

Is the flickering text the only issue? I think that's because ExtendedWorld isn't being synced to the client - the demon's processInteraction gets called on client & server but they have different data, and they both call player.sendStatusMessage causing two different messages to be sent.
You basically have two options there:

  • Synchronize the pledges to the client, so the client knows when an interaction should cause a pact to be created. Personally I'd move that info to ExtendedPlayer and tag it onto your existing sync logic there.
  • Add a !world.isRemote check and only run the interaction logic on the server, then send a packet to the client to handle the sound effect
commented

Paging @cybercat5555 to explain the issue in greater detail, since she first spotted it.

commented
commented

According to one individual at least, the code is probably related to the entity itself.

commented

EntityLeonard is the other pledgable.

Of note is that pledging to one of the entity pledges you to all after reloading a world.

commented

840E4121-F3FF-4CEE-8120-A61AC8A55B7D

commented

Screenshot 2020-05-17 16 10 33

commented

Looks like it worked aside from the fact one can get infinite pacts from Baphomet.

commented

That can be arranged. Should it fail if you have any active contract effect, or only one acquired from Baphomet specifically?

commented

Any active contract

Also as mentioned, check EntityLeonard, to see if there are issues there too

commented

Leonard only gives brewing buffs right? I still get an extra brew after leaving and re-entering my SP world so that seems fine. Would encourage someone to test in MP, I can't at the moment.

commented

Pretty much, I just want to make sure it's syncing correctly.