Darkhax-Minecraft / Game-Stages

An API for universal player based progression.
https://minecraft.curseforge.com/projects/game-stages
GNU Lesser General Public License v2.1
63 stars 17 forks source link

Game Stages not being added on player login events #68

Closed p1ut0nium-git closed 2 years ago

p1ut0nium-git commented 2 years ago

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

Darkhax commented 2 years ago

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

  1. Create a script file with the .zs extension in the /scripts folder
  2. Make sure the script is saved.
  3. Load the game and join a world
  4. 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.

  1. 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.
  2. 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.
  3. Are you forgetting to save the script file? You would be surprised how many issues are caused by this.
p1ut0nium-git commented 2 years ago

Not pirated. Definitely saved scripts. So it is probably some kind of mod conflict. I'll look further into it.

p1ut0nium-git commented 2 years ago

It does work in a new world with just these mods: