Conflict with MS Utilities
ExcitedName opened this issue ยท 6 comments
I am not entirely sure which mod is the source of the conflict so I am submitting bug reports to both developers. With the MS Utilities mod installed both the sleeping bag and hammock set spawn upon usage. I have turned off the set spawn any time setting in the config of MS Utilities on the server and client and have tested both on a dedicated server and just the client, the results are the same. I am not sure if it is because of how you register sleeping bags and hammocks, or something similar, or if it is on MS Utilities end. Thank you for your time.
Minecraft Version: 1.12
Java Version: 1.8.0_144
Mod Version: [1.12.0] MS Utilities 1.2.6
I believe I may have figured out the conflict, although this is only from looking at the code of our respective mods and no actual testing.
Comforts prevents players setting spawns by cancelling the PlayerSetSpawn event when it fires from sleeping bags and hammocks. This event is fired from the EntityPlayer#setSpawnPoint method, which subsequently calls EntityPlayer#setSpawnChunk if the spawn dimension is not 0.
The conflict comes when MS Utilities hooks into the PlayerSleepInBed event. Whenever a player sleeps in bed, MS Utilities calls EntityPlayer#setSpawnPoint AND EntityPlayer#setSpawnChunk. Thus, Comforts appropriately cancels the set spawn from EntityPlayer#setSpawnPoint but MS Utilities proceeds to set the spawn again with EntityPlayer#setSpawnChunk, thus avoiding the cancellation because this method does not call the necessary event.
I believe a solution is best reached on MS Utilities's end, as there is no easy way I can think of off the top of my head to accommodate for this scenario on my end.
Please let me know if the situation changes in such a way that requires my assistance, I'll do anything in my power to help.
That makes sense. After further testing it occurs with two other sleeping system mods, Simple Bedrolls and Simple bedding. Simple bedrolls is stated as simply setting the time to the next day and bypasses all spawn methods. I find this interesting considering it is still happening with MS Utilities. I have only done a little modding with Minecraft, I have yet to get far enough to use any methods or events like these, but if I understand you and what the developer of MS Util has stated on their curse site, this shouldn't be happening with Simple Bedrolls at all. I will copy and paste your response to the issue I created with MS Utils and hopefully we can get to the bottom of this. I will most certainly keep you apprised of the situation. Thank you for you time and energy.
The short explanation is that MS Utilities always sets the spawn whenever you sleep. If Simple Bedrolls does not touch the spawn methods, it will naturally fall back to where MS Utilities set the spawn to be.
oh okay, I think I get it now. I looked back at what you previously wrote. The PlayerSetSpawn event is within both the EntityPlayer#setSpawnPoint method and the EntityPlayer#setSpawnChunk method. In the case of Comforts, even though you cancel the PlayerSetSpawn event within the EntityPlayer#setSpawnPoint method, you are still using the PlayerSleepInBed event. Which MS Util then hooks into and calls on the EntityPlayer#setSpawnPoint method, which Comforts cancels, as well as the EntityPlayer#setSpawnChunk method, which Comforts does not cancel, then sets spawn. So if MS Utils didn't call of the EntityPlayer#setSpawnChunk method and only called on EntityPlayer#setSpawnPoint method then there shouldn't be a problem.
In the case of Simple Bedrolls, even if it is not touching any spawn methods it still calls on the PlayerSleepInBed event in order to set the time, I would imagine anyway. And since MS Util hooks into that event it calls the EntityPlayer#setSpawnPoint method and EntityPlayer#setSpawnChunk method, which in this case where not cancelled at all, setting spawn.
Is that what you are saying? Lol, I realize that I just basically reworded what you said, but it better helps me understand. Thanks for taking the time to explain it.
The only part you got wrong is that PlayerSetSpawn is only fired from EntityPlayer#setSpawnPoint. It is not fired from EntityPlayer#setSpawnChunk. Since the event does not fire from the latter method, there is nothing for me to cancel. Everything else you said is correct to my own understanding.