Fabric, fix GameMode.NOT_SET removed in 1.17 (#3053)

This commit is contained in:
Tjeu Kayim 2021-06-10 22:12:03 +02:00 committed by GitHub
parent ad49508b74
commit 044deccd22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -75,7 +75,8 @@ public class FabricPlayerCalculator implements ContextCalculator<ServerPlayerEnt
@Override @Override
public void calculate(@NonNull ServerPlayerEntity target, @NonNull ContextConsumer consumer) { public void calculate(@NonNull ServerPlayerEntity target, @NonNull ContextConsumer consumer) {
GameMode mode = target.interactionManager.getGameMode(); GameMode mode = target.interactionManager.getGameMode();
if (this.gamemode && mode != null && mode != GameMode.NOT_SET) { final int GAME_MODE_NOT_SET = -1; // GameMode.NOT_SET with ID -1 was removed in 1.17
if (this.gamemode && mode != null && mode.getId() != GAME_MODE_NOT_SET) {
consumer.accept(DefaultContextKeys.GAMEMODE_KEY, GAMEMODE_NAMER.name(mode)); consumer.accept(DefaultContextKeys.GAMEMODE_KEY, GAMEMODE_NAMER.name(mode));
} }