
Game Stages not being added on player login events
p1ut0nium-git opened this issue ยท 3 comments
Environment Details
Mod Version: 7.3.10
Game Version: 1.16.5
Loader Type: Forge
Loader Version: 36.2.9
Game Type: Client
The Issue
I am using CraftTweaker version: 7.1.2.468
This doesn't seem to work (tested in single player map; haven't tested on server yet). The player joins, and they don't have the "hostile" game stage, yet they don't receive the "peaceful" game stage:
StageHelper.grantStageOnJoinWithCondition(player => !player.hasGameStage("hostile"), "peaceful");
The example from the CraftTweaker docs doesn't work either:
StageHelper.grantStageOnJoinWithCondition(player => !player.isCreative(), "join_example_two");
I am using the import statement:
import mods.gamestages.StageHelper;
This doesn't work either:
import crafttweaker.api.event.entity.player.MCPlayerLoggedInEvent;
CTEventManager.register<MCPlayerLoggedInEvent>((event) => {
var player = event.player;
player.addGameStage("peaceful");
});
Log Files
No errors in log file
I've tested out the scripts you have posted and can not reproduce this issue. I combined all three snips you posted into the following script and all three stages were applied.
import crafttweaker.api.event.entity.player.MCPlayerLoggedInEvent;
import crafttweaker.api.events.CTEventManager;
import mods.gamestages.StageHelper;
StageHelper.grantStageOnJoinWithCondition(player => !player.hasGameStage("hostile"), "peaceful");
StageHelper.grantStageOnJoinWithCondition(player => !player.isCreative(), "join_example_two");
CTEventManager.register<MCPlayerLoggedInEvent>((event) => {
var player = event.player;
player.addGameStage("peaceful2");
player.sendMessage("hi");
});
Steps I Took
- Create a script file with the
.zs
extension in the/scripts
folder - Make sure the script is saved.
- Load the game and join a world
- Run
/gamestage info
to see your stages.
Potential Cause
I asked a few others to try running the script with the same versions you listed and they also had no issue. This suggests that the issue is specific to you or your game environment.
- Are you using a pirated version of the game? This is not supported and has been known to cause issues with GameStages due to players having inconsistent game IDs.
- Can you reproduce the issue without any of your other mods? If so, another mod may be cancelling the event and you will need to review your modlist.
- Are you forgetting to save the script file? You would be surprised how many issues are caused by this.
Not pirated. Definitely saved scripts. So it is probably some kind of mod conflict. I'll look further into it.