mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 11:05:40 +00:00
Fix PlayerChangeGameModeEvent (#8441)
This commit is contained in:
1 parent
5c9258491f
commit
5e295f2485
3 files changed
+27
-8
No files matched your search
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2021.
|
||||
* Copyright (c) 2016-2022.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -41,8 +41,16 @@ public class PlayerGameModeEventTest
|
||||
{
|
||||
if (!ENABLE) return;
|
||||
LOGGER.info("{} changed game mode. Current GameType: {}. New Game Type: {}", event.getPlayer(), event.getCurrentGameMode(), event.getNewGameMode());
|
||||
// prevent changing to SURVIVAL
|
||||
if (event.getNewGameMode() == GameType.SURVIVAL)
|
||||
{
|
||||
event.setCanceled(true);
|
||||
}
|
||||
else if (event.getNewGameMode() == GameType.SPECTATOR)
|
||||
{
|
||||
// when changing to SPECTATOR, change to SURVIVAL instead
|
||||
event.setNewGameMode(GameType.SURVIVAL);
|
||||
}
|
||||
}
|
||||
|
||||
@Mod.EventBusSubscriber(modid="player_game_mode_event_test", value=Dist.CLIENT, bus=Mod.EventBusSubscriber.Bus.FORGE)
|
||||
|
||||
Reference in new issue
Block a user