From 365a7e7906c3623eddef7401b27c1db635439787 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Tue, 17 Mar 2026 14:30:43 +0100 Subject: fix(): cannot launch game invalid version number invalid identifier for gamerules infinite recursive mixin --- .../client/mixin/NoCustomizableSkinOverlay.java | 6 - .../java/world/anhgelus/molehunt/Molehunt.java | 129 +++++++++------------ 2 files changed, 58 insertions(+), 77 deletions(-) (limited to 'src') diff --git a/src/client/java/world/anhgelus/molehunt/client/mixin/NoCustomizableSkinOverlay.java b/src/client/java/world/anhgelus/molehunt/client/mixin/NoCustomizableSkinOverlay.java index af299ea..bdba025 100644 --- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoCustomizableSkinOverlay.java +++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoCustomizableSkinOverlay.java @@ -3,7 +3,6 @@ package world.anhgelus.molehunt.client.mixin; import net.minecraft.client.Options; import net.minecraft.world.entity.player.PlayerModelPart; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -11,14 +10,9 @@ import world.anhgelus.molehunt.client.MolehuntClient; @Mixin(Options.class) public abstract class NoCustomizableSkinOverlay { - @Shadow - public void setModelPart(PlayerModelPart part, boolean enabled) {} - @Inject(at = @At("HEAD"), method = "setModelPart", cancellable = true) public void togglePlayerModelPart(PlayerModelPart part, boolean enabled, CallbackInfo ci) { if (MolehuntClient.showSkins()) return; - setModelPart(part, true); - ((Options) (Object) this).broadcastOptions(); ci.cancel(); } } diff --git a/src/main/java/world/anhgelus/molehunt/Molehunt.java b/src/main/java/world/anhgelus/molehunt/Molehunt.java index 984f906..966d6c5 100644 --- a/src/main/java/world/anhgelus/molehunt/Molehunt.java +++ b/src/main/java/world/anhgelus/molehunt/Molehunt.java @@ -42,84 +42,71 @@ public class Molehunt implements ModInitializer { public static final String MOD_ID = "molehunt"; public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); - public static Config CONFIG; - public static final SimpleConfig CONFIG_FILE = Config.configFile(MOD_ID); - public static final GameRule GAME_DURATION = GameRuleBuilder .forInteger(CONFIG_FILE.getOrDefault("game_duration", 90)) .category(GameRuleCategory.MISC) - .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "gameDurationMinutes")); - + .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "game_duration_minutes")); public static final GameRule MOLE_PERCENTAGE = GameRuleBuilder .forInteger(CONFIG_FILE.getOrDefault("mole_percentage", 25)) .range(0, 100) .category(GameRuleCategory.MISC) - .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "molePercentage")); - + .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "mole_percentage")); public static final GameRule MOLE_COUNT = GameRuleBuilder .forInteger(CONFIG_FILE.getOrDefault("mole_count", -1)) .category(GameRuleCategory.MISC) - .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "moleCount")); - + .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "mole_count")); public static final GameRule SHOW_NAMETAGS = GameRuleBuilder .forBoolean(CONFIG_FILE.getOrDefault("show_nametags", false)) .category(GameRuleCategory.MISC) - .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "showNametags")); - + .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "show_nametags")); public static final GameRule SHOW_TAB = GameRuleBuilder .forBoolean(CONFIG_FILE.getOrDefault("show_tab", false)) .category(GameRuleCategory.MISC) - .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "showTab")); - + .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "show_tab")); public static final GameRule SHOW_SKINS = GameRuleBuilder .forBoolean(CONFIG_FILE.getOrDefault("show_skins", false)) .category(GameRuleCategory.MISC) - .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "showSkins")); - + .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "show_skins")); public static final GameRule INITIAL_WORLD_SIZE = GameRuleBuilder .forInteger(CONFIG_FILE.getOrDefault("initial_world_size", 600)) .minValue(0) .category(GameRuleCategory.MISC) - .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "initialWorldSize")); - + .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "initial_world_size")); public static final GameRule FINAL_WORLD_SIZE = GameRuleBuilder .forInteger(CONFIG_FILE.getOrDefault("final_world_size", 100)) .minValue(0) .category(GameRuleCategory.MISC) - .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "finalWorldSize")); - + .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "final_world_size")); public static final GameRule MOVING_STARTING_TIME_OFFSET = GameRuleBuilder .forInteger(CONFIG_FILE.getOrDefault("border_moving_starting_time_offset", 30)) .minValue(0) .category(GameRuleCategory.MISC) - .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "borderMovingStartingTimeOffsetMinutes")); - + .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "border_moving_starting_time_offset_minutes")); public static final GameRule ENABLE_PORTALS = GameRuleBuilder .forBoolean(CONFIG_FILE.getOrDefault("enable_portals", false)) .category(GameRuleCategory.MISC) - .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "enablePortals")); - + .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "enable_portals")); public static final GameRule FOOD_ON_START = GameRuleBuilder .forBoolean(CONFIG_FILE.getOrDefault("food_on_start", true)) .category(GameRuleCategory.MISC) - .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "foodOnStart")); - - public Game game; - + .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "food_on_start")); + public static Config CONFIG; public static HashMap timerVisibility = new HashMap<>(); - private static void sendConfigPayload(T v, MinecraftServer server) { - if (CONFIG == null) return; - CONFIG.sendConfigPayload(); - } - static { GameRuleEvents.changeCallback(SHOW_NAMETAGS).register(Molehunt::sendConfigPayload); GameRuleEvents.changeCallback(SHOW_TAB).register(Molehunt::sendConfigPayload); GameRuleEvents.changeCallback(SHOW_SKINS).register(Molehunt::sendConfigPayload); } + public Game game; + + private static void sendConfigPayload(T v, MinecraftServer server) { + if (CONFIG == null) return; + CONFIG.sendConfigPayload(); + } + @Override public void onInitialize() { LOGGER.info("Initializing Molehunt"); @@ -128,10 +115,10 @@ public class Molehunt implements ModInitializer { command.then(literal("start") .requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS)) .executes(context -> { - game = new Game(context.getSource().getServer()); - game.start(); - return Command.SINGLE_SUCCESS; - })); + game = new Game(context.getSource().getServer()); + game.start(); + return Command.SINGLE_SUCCESS; + })); command.then(literal("timer").requires(CommandSourceStack::isPlayer).then( literal("show").executes(context -> { var player = context.getSource().getPlayer(); @@ -142,7 +129,7 @@ public class Molehunt implements ModInitializer { if (game == null || !game.started()) { player.connection.send(new ClientboundSetActionBarTextPacket( - Component.translatable("commands.molehunt.error.game_not_started").withStyle(ChatFormatting.RED) + Component.translatable("commands.molehunt.error.game_not_started").withStyle(ChatFormatting.RED) )); } else { player.connection.send(new ClientboundSetActionBarTextPacket(Component.translationArg(game.getRemainingText()))); @@ -163,45 +150,45 @@ public class Molehunt implements ModInitializer { command.then(literal("role") .requires(CommandSourceStack::isPlayer) .executes(context -> { - if (game == null || !game.started()) { - throw (new SimpleCommandExceptionType(Component.translatable("commands.molehunt.error.game_not_started"))).create(); - } - - final var source = context.getSource(); - final var player = source.getPlayer(); - assert player != null; - - if (game.isMole(player)) { - source.sendSuccess( - () -> Component.translatable("commands.molehunt.role.mole") - .append("\n\n") - .append(Component.translatable("commands.molehunt.role.mole.list", game.getMolesAsString())), - false); - } else if (player.isSpectator()) { - source.sendSuccess( - () -> Component.translatable("commands.molehunt.role.survivor.mole_count", game.getMoles().size()), - false); - } else { - source.sendSuccess( - () -> Component.translatable("commands.molehunt.role.survivor") - .append("\n\n") - .append(Component.translatable("commands.molehunt.role.survivor.mole_count", game.getMoles().size())), - false); - } - - return Command.SINGLE_SUCCESS; - })); + if (game == null || !game.started()) { + throw (new SimpleCommandExceptionType(Component.translatable("commands.molehunt.error.game_not_started"))).create(); + } + + final var source = context.getSource(); + final var player = source.getPlayer(); + assert player != null; + + if (game.isMole(player)) { + source.sendSuccess( + () -> Component.translatable("commands.molehunt.role.mole") + .append("\n\n") + .append(Component.translatable("commands.molehunt.role.mole.list", game.getMolesAsString())), + false); + } else if (player.isSpectator()) { + source.sendSuccess( + () -> Component.translatable("commands.molehunt.role.survivor.mole_count", game.getMoles().size()), + false); + } else { + source.sendSuccess( + () -> Component.translatable("commands.molehunt.role.survivor") + .append("\n\n") + .append(Component.translatable("commands.molehunt.role.survivor.mole_count", game.getMoles().size())), + false); + } + + return Command.SINGLE_SUCCESS; + })); command.then(literal("stop") .requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS)) .executes(context -> { - if (game == null || !game.started()) { - throw (new SimpleCommandExceptionType(Component.translatable("commands.molehunt.error.game_not_started"))).create(); - } + if (game == null || !game.started()) { + throw (new SimpleCommandExceptionType(Component.translatable("commands.molehunt.error.game_not_started"))).create(); + } - game.stop(); + game.stop(); - return Command.SINGLE_SUCCESS; - })); + return Command.SINGLE_SUCCESS; + })); ServerLifecycleEvents.SERVER_STARTED.register(server -> CONFIG = new Config(server)); -- cgit v1.2.3