From dfbc5bbfd20a22edb2596b4d73248df57a4cce20 Mon Sep 17 00:00:00 2001 From: anhgelus Date: Sat, 24 Aug 2024 13:05:11 +0000 Subject: feat(network): send game state to client and disable mixins when game is not launched --- .../anhgelus/molehunt/client/MolehuntClient.java | 12 ++ .../anhgelus/molehunt/client/mixin/NoNametags.java | 2 +- .../molehunt/client/mixin/NoPlayerListHud.java | 2 +- .../anhgelus/molehunt/client/mixin/NoSkin.java | 2 +- src/main/java/world/anhgelus/molehunt/Game.java | 178 -------------------- .../java/world/anhgelus/molehunt/Molehunt.java | 17 +- .../java/world/anhgelus/molehunt/game/Game.java | 186 +++++++++++++++++++++ .../world/anhgelus/molehunt/game/GamePayload.java | 23 +++ 8 files changed, 237 insertions(+), 185 deletions(-) delete mode 100644 src/main/java/world/anhgelus/molehunt/Game.java create mode 100644 src/main/java/world/anhgelus/molehunt/game/Game.java create mode 100644 src/main/java/world/anhgelus/molehunt/game/GamePayload.java diff --git a/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java b/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java index 1f92573..c8a4d95 100644 --- a/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java +++ b/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java @@ -3,6 +3,7 @@ package world.anhgelus.molehunt.client; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; import world.anhgelus.molehunt.config.ConfigPayload; +import world.anhgelus.molehunt.game.GamePayload; public class MolehuntClient implements ClientModInitializer { @@ -10,6 +11,8 @@ public class MolehuntClient implements ClientModInitializer { private static boolean SHOW_NAMETAGS = false; private static boolean SHOW_TAB = false; + private static boolean GAME_STARTED = false; + @Override public void onInitializeClient() { ClientPlayNetworking.registerGlobalReceiver(ConfigPayload.ID, (payload, context) -> { @@ -19,6 +22,11 @@ public class MolehuntClient implements ClientModInitializer { SHOW_TAB = payload.showTab(); }); }); + ClientPlayNetworking.registerGlobalReceiver(GamePayload.ID, (payload, context) -> { + context.client().execute(() -> { + GAME_STARTED = payload.gameLaunched(); + }); + }); } public static boolean showSkins() { @@ -32,4 +40,8 @@ public class MolehuntClient implements ClientModInitializer { public static boolean showTab() { return SHOW_TAB; } + + public static boolean gameStarted() { + return GAME_STARTED; + } } diff --git a/src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java b/src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java index 3482abb..7f334a0 100644 --- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java +++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java @@ -15,7 +15,7 @@ import world.anhgelus.molehunt.client.MolehuntClient; public class NoNametags { @Inject(at = @At("HEAD"), method = "render", cancellable = true) private void renderLabelOrNot(T entity, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { - if (!(entity instanceof PlayerEntity) || MolehuntClient.showNameTags()) return; + if (!(entity instanceof PlayerEntity) || MolehuntClient.showNameTags() || !MolehuntClient.gameStarted()) return; ci.cancel(); } } \ No newline at end of file diff --git a/src/client/java/world/anhgelus/molehunt/client/mixin/NoPlayerListHud.java b/src/client/java/world/anhgelus/molehunt/client/mixin/NoPlayerListHud.java index 00308ea..4473b12 100644 --- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoPlayerListHud.java +++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoPlayerListHud.java @@ -11,7 +11,7 @@ import world.anhgelus.molehunt.client.MolehuntClient; public class NoPlayerListHud { @Inject(at = @At("HEAD"), method = "render", cancellable = true) public void render(CallbackInfo ci) { - if (MolehuntClient.showTab()) return; + if (MolehuntClient.showTab() || !MolehuntClient.gameStarted()) return; ci.cancel(); } } diff --git a/src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java b/src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java index 775d789..6638c1b 100644 --- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java +++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java @@ -14,7 +14,7 @@ import world.anhgelus.molehunt.client.MolehuntClient; public class NoSkin { @Inject(at = @At("HEAD"), method = "getSkinTextures", cancellable = true) public void getSkin(CallbackInfoReturnable cir) { - if (MolehuntClient.showSkins()) return; + if (MolehuntClient.showSkins() || !MolehuntClient.gameStarted()) return; cir.setReturnValue(new SkinTextures( Identifier.of(Molehunt.MOD_ID, "textures/skin.png"), null, diff --git a/src/main/java/world/anhgelus/molehunt/Game.java b/src/main/java/world/anhgelus/molehunt/Game.java deleted file mode 100644 index dbe7ebd..0000000 --- a/src/main/java/world/anhgelus/molehunt/Game.java +++ /dev/null @@ -1,178 +0,0 @@ -package world.anhgelus.molehunt; - -import net.minecraft.network.packet.s2c.play.OverlayMessageS2CPacket; -import net.minecraft.network.packet.s2c.play.SubtitleS2CPacket; -import net.minecraft.network.packet.s2c.play.TitleFadeS2CPacket; -import net.minecraft.network.packet.s2c.play.TitleS2CPacket; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.Text; -import net.minecraft.world.GameMode; -import net.minecraft.world.GameRules; -import world.anhgelus.molehunt.utils.TimeUtils; - -import java.util.*; -import java.util.concurrent.ThreadLocalRandom; -import java.util.stream.Collectors; - -public class Game { - - private Timer timer = new Timer(); - public final int defaultTime = Molehunt.CONFIG.getGameDuration()*60; - private int remaining = defaultTime; - - private final MinecraftServer server; - - private final List moles = new ArrayList<>(); - - private final TitleFadeS2CPacket timing = new TitleFadeS2CPacket(20, 40, 20); - - private boolean started = false; - - public Game(MinecraftServer server) { - this.server = server; - } - - public void start() { - final int n = Molehunt.CONFIG.getMoleCount() < 0 - ? Math.floorDiv(server.getCurrentPlayerCount(), Math.floorDiv(100, Molehunt.CONFIG.getMolePercentage())) - : Molehunt.CONFIG.getMoleCount(); - - final var playerManager = server.getPlayerManager(); - - final var players = new ArrayList<>(playerManager.getPlayerList()); - for (int i = 0; i < n && !players.isEmpty(); i++) { - final var r = ThreadLocalRandom.current().nextInt(0, players.size()); - final var mole = players.get(r); - if (mole == null) throw new IllegalStateException("Mole is null!"); - moles.add(mole); - players.remove(r); - } - - final var gamerules = server.getGameRules(); - // immutable gamerules - gamerules.get(GameRules.SHOW_DEATH_MESSAGES).set(false, server); - gamerules.get(GameRules.ANNOUNCE_ADVANCEMENTS).set(false, server); - // gamerules for the start - gamerules.get(GameRules.DO_IMMEDIATE_RESPAWN).set(true, server); - gamerules.get(GameRules.DO_ENTITY_DROPS).set(false, server); - - final var title = new TitleS2CPacket(Text.translatable("molehunt.game.start.suspense")); - playerManager.getPlayerList().forEach(p -> { - p.kill(); - p.networkHandler.sendPacket(timing); - p.networkHandler.sendPacket(title); - p.changeGameMode(GameMode.SURVIVAL); - }); - - server.setDefaultGameMode(GameMode.SPECTATOR); - - timer.schedule(new TimerTask() { - @Override - public void run() { - playerManager.getPlayerList().forEach(p -> { - p.networkHandler.sendPacket(timing); - if (moles.contains(p)) { - p.networkHandler.sendPacket(new TitleS2CPacket(Text.translatable("molehunt.game.start.mole.title"))); - p.networkHandler.sendPacket(new SubtitleS2CPacket(Text.translatable("molehunt.game.start.mole.subtitle"))); - } else { - p.networkHandler.sendPacket(new TitleS2CPacket(Text.translatable("molehunt.game.start.survivor"))); - } - // reset health and food level - p.setHealth(p.getMaxHealth()); - p.getHungerManager().setFoodLevel(20); - p.getHungerManager().setSaturationLevel(5.0f); - }); - // reset gamerules after the start - gamerules.get(GameRules.DO_IMMEDIATE_RESPAWN).set(false, server); - gamerules.get(GameRules.DO_ENTITY_DROPS).set(true, server); - // reset time and weather - server.getOverworld().setTimeOfDay(0); - server.getOverworld().resetWeather(); - started = true; - - timer.scheduleAtFixedRate(new TimerTask() { - @Override - public void run() { - remaining--; - playerManager.getPlayerList().forEach(player -> { - if (Molehunt.timerVisibility.getOrDefault(player, true)) { - player.networkHandler.sendPacket(new OverlayMessageS2CPacket(Text.of(getShortRemainingText()))); - } - }); - playerManager.sendToAll(timing); - if (remaining == 0) end(); - } - }, 5*1000, 1000); - } - }, 4*1000); - } - - public void stop() { - server.getPlayerManager().broadcast(Text.translatable("commands.molehunt.stop.success"), false); - end(); - } - - public void end() { - timer.cancel(); - timer = new Timer(); - started = false; - final var pm = server.getPlayerManager(); - final var winnerSuspense = new TitleS2CPacket(Text.translatable("molehunt.game.end.suspense.title")); - pm.getPlayerList().forEach(p -> { - p.networkHandler.sendPacket(timing); - p.networkHandler.sendPacket(winnerSuspense); - p.changeGameMode(GameMode.CREATIVE); - }); - timer.schedule(new TimerTask() { - @Override - public void run() { - TitleS2CPacket winner; - if (gameWonByMoles()) { - winner = new TitleS2CPacket(Text.translatable("molehunt.game.end.winners.moles.title")); - } else { - winner = new TitleS2CPacket(Text.translatable("molehunt.game.end.winners.survivors.title")); - } - pm.sendToAll(new SubtitleS2CPacket(Text.translatable("molehunt.game.end.winners.subtitle") - .append(" " + getMolesAsString())) - ); - pm.sendToAll(winner); - pm.sendToAll(timing); - moles.clear(); - } - }, 4*1000); - } - - public Text getShortRemainingText() { - return Text.of("§c" + TimeUtils.printShortTime(remaining)); - } - - public List getMoles() { - return moles; - } - - public String getMolesAsString() { - return moles.stream() - .map(ServerPlayerEntity::getDisplayName) - .filter(Objects::nonNull) - .map(Text::getString) - .collect(Collectors.joining(", ")); - } - - public boolean isAMole(ServerPlayerEntity player) { - return moles.contains(player); - } - - public boolean gameWonByMoles() { - return new HashSet<>(moles).containsAll(server.getPlayerManager().getPlayerList()); - } - - public void updateMole(ServerPlayerEntity oldPlayer, ServerPlayerEntity newPlayer) { - moles.remove(oldPlayer); - moles.add(newPlayer); - } - - public boolean hasStarted() { - return started; - } -} diff --git a/src/main/java/world/anhgelus/molehunt/Molehunt.java b/src/main/java/world/anhgelus/molehunt/Molehunt.java index d7c0d58..afd6960 100644 --- a/src/main/java/world/anhgelus/molehunt/Molehunt.java +++ b/src/main/java/world/anhgelus/molehunt/Molehunt.java @@ -24,6 +24,8 @@ import org.slf4j.LoggerFactory; import world.anhgelus.molehunt.config.Config; import world.anhgelus.molehunt.config.ConfigPayload; import world.anhgelus.molehunt.config.SimpleConfig; +import world.anhgelus.molehunt.game.Game; +import world.anhgelus.molehunt.game.GamePayload; import java.util.HashMap; @@ -150,11 +152,18 @@ public class Molehunt implements ModInitializer { newPlayer.changeGameMode(GameMode.SPECTATOR); }); - ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> ServerPlayNetworking.send( - handler.player, - new ConfigPayload(CONFIG.areNametagsEnabled(), CONFIG.areSkinsEnabled(), CONFIG.isTabEnabled()) - )); + ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> { + ServerPlayNetworking.send( + handler.player, + new ConfigPayload(CONFIG.areNametagsEnabled(), CONFIG.areSkinsEnabled(), CONFIG.isTabEnabled()) + ); + ServerPlayNetworking.send( + handler.player, + new GamePayload(game != null && game.hasStarted()) + ); + }); PayloadTypeRegistry.playS2C().register(ConfigPayload.ID, ConfigPayload.CODEC); + PayloadTypeRegistry.playS2C().register(GamePayload.ID, GamePayload.CODEC); } } diff --git a/src/main/java/world/anhgelus/molehunt/game/Game.java b/src/main/java/world/anhgelus/molehunt/game/Game.java new file mode 100644 index 0000000..a98516c --- /dev/null +++ b/src/main/java/world/anhgelus/molehunt/game/Game.java @@ -0,0 +1,186 @@ +package world.anhgelus.molehunt.game; + +import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; +import net.minecraft.network.packet.s2c.play.OverlayMessageS2CPacket; +import net.minecraft.network.packet.s2c.play.SubtitleS2CPacket; +import net.minecraft.network.packet.s2c.play.TitleFadeS2CPacket; +import net.minecraft.network.packet.s2c.play.TitleS2CPacket; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.text.Text; +import net.minecraft.world.GameMode; +import net.minecraft.world.GameRules; +import world.anhgelus.molehunt.Molehunt; +import world.anhgelus.molehunt.utils.TimeUtils; + +import java.util.*; +import java.util.concurrent.ThreadLocalRandom; +import java.util.stream.Collectors; + +public class Game { + + private Timer timer = new Timer(); + public final int defaultTime = Molehunt.CONFIG.getGameDuration()*60; + private int remaining = defaultTime; + + private final MinecraftServer server; + + private final List moles = new ArrayList<>(); + + private final TitleFadeS2CPacket timing = new TitleFadeS2CPacket(20, 40, 20); + + private boolean started = false; + + public Game(MinecraftServer server) { + this.server = server; + } + + public void start() { + final int n = Molehunt.CONFIG.getMoleCount() < 0 + ? Math.floorDiv(server.getCurrentPlayerCount(), Math.floorDiv(100, Molehunt.CONFIG.getMolePercentage())) + : Molehunt.CONFIG.getMoleCount(); + + final var playerManager = server.getPlayerManager(); + + final var players = new ArrayList<>(playerManager.getPlayerList()); + for (int i = 0; i < n && !players.isEmpty(); i++) { + final var r = ThreadLocalRandom.current().nextInt(0, players.size()); + final var mole = players.get(r); + if (mole == null) throw new IllegalStateException("Mole is null!"); + moles.add(mole); + players.remove(r); + } + + final var gamerules = server.getGameRules(); + // immutable gamerules + gamerules.get(GameRules.SHOW_DEATH_MESSAGES).set(false, server); + gamerules.get(GameRules.ANNOUNCE_ADVANCEMENTS).set(false, server); + // gamerules for the start + gamerules.get(GameRules.DO_IMMEDIATE_RESPAWN).set(true, server); + gamerules.get(GameRules.DO_ENTITY_DROPS).set(false, server); + + final var title = new TitleS2CPacket(Text.translatable("molehunt.game.start.suspense")); + playerManager.getPlayerList().forEach(p -> { + p.kill(); + p.networkHandler.sendPacket(timing); + p.networkHandler.sendPacket(title); + p.changeGameMode(GameMode.SURVIVAL); + }); + + server.setDefaultGameMode(GameMode.SPECTATOR); + + timer.schedule(new TimerTask() { + @Override + public void run() { + playerManager.getPlayerList().forEach(p -> { + p.networkHandler.sendPacket(timing); + if (moles.contains(p)) { + p.networkHandler.sendPacket(new TitleS2CPacket(Text.translatable("molehunt.game.start.mole.title"))); + p.networkHandler.sendPacket(new SubtitleS2CPacket(Text.translatable("molehunt.game.start.mole.subtitle"))); + } else { + p.networkHandler.sendPacket(new TitleS2CPacket(Text.translatable("molehunt.game.start.survivor"))); + } + // reset health and food level + p.setHealth(p.getMaxHealth()); + p.getHungerManager().setFoodLevel(20); + p.getHungerManager().setSaturationLevel(5.0f); + }); + // reset gamerules after the start + gamerules.get(GameRules.DO_IMMEDIATE_RESPAWN).set(false, server); + gamerules.get(GameRules.DO_ENTITY_DROPS).set(true, server); + // reset time and weather + server.getOverworld().setTimeOfDay(0); + server.getOverworld().resetWeather(); + changeState(true); + + timer.scheduleAtFixedRate(new TimerTask() { + @Override + public void run() { + remaining--; + playerManager.getPlayerList().forEach(player -> { + if (Molehunt.timerVisibility.getOrDefault(player, true)) { + player.networkHandler.sendPacket(new OverlayMessageS2CPacket(Text.of(getShortRemainingText()))); + } + }); + playerManager.sendToAll(timing); + if (remaining == 0) end(); + } + }, 5*1000, 1000); + } + }, 4*1000); + } + + public void stop() { + server.getPlayerManager().broadcast(Text.translatable("commands.molehunt.stop.success"), false); + end(); + } + + public void end() { + timer.cancel(); + timer = new Timer(); + changeState(false); + final var pm = server.getPlayerManager(); + final var winnerSuspense = new TitleS2CPacket(Text.translatable("molehunt.game.end.suspense.title")); + pm.getPlayerList().forEach(p -> { + p.networkHandler.sendPacket(timing); + p.networkHandler.sendPacket(winnerSuspense); + p.changeGameMode(GameMode.CREATIVE); + }); + timer.schedule(new TimerTask() { + @Override + public void run() { + TitleS2CPacket winner; + if (gameWonByMoles()) { + winner = new TitleS2CPacket(Text.translatable("molehunt.game.end.winners.moles.title")); + } else { + winner = new TitleS2CPacket(Text.translatable("molehunt.game.end.winners.survivors.title")); + } + pm.sendToAll(new SubtitleS2CPacket(Text.translatable("molehunt.game.end.winners.subtitle") + .append(" " + getMolesAsString())) + ); + pm.sendToAll(winner); + pm.sendToAll(timing); + moles.clear(); + } + }, 4*1000); + } + + public Text getShortRemainingText() { + return Text.of("§c" + TimeUtils.printShortTime(remaining)); + } + + public List getMoles() { + return moles; + } + + public String getMolesAsString() { + return moles.stream() + .map(ServerPlayerEntity::getDisplayName) + .filter(Objects::nonNull) + .map(Text::getString) + .collect(Collectors.joining(", ")); + } + + public boolean isAMole(ServerPlayerEntity player) { + return moles.contains(player); + } + + public boolean gameWonByMoles() { + return new HashSet<>(moles).containsAll(server.getPlayerManager().getPlayerList()); + } + + public void updateMole(ServerPlayerEntity oldPlayer, ServerPlayerEntity newPlayer) { + moles.remove(oldPlayer); + moles.add(newPlayer); + } + + public boolean hasStarted() { + return started; + } + + private void changeState(boolean hasStarted) { + started = hasStarted; + final var payload = new GamePayload(hasStarted); + server.getPlayerManager().getPlayerList().forEach(p -> ServerPlayNetworking.send(p, payload)); + } +} diff --git a/src/main/java/world/anhgelus/molehunt/game/GamePayload.java b/src/main/java/world/anhgelus/molehunt/game/GamePayload.java new file mode 100644 index 0000000..4f7b8ce --- /dev/null +++ b/src/main/java/world/anhgelus/molehunt/game/GamePayload.java @@ -0,0 +1,23 @@ +package world.anhgelus.molehunt.game; + +import net.minecraft.network.RegistryByteBuf; +import net.minecraft.network.codec.PacketCodec; +import net.minecraft.network.codec.PacketCodecs; +import net.minecraft.network.packet.CustomPayload; +import net.minecraft.util.Identifier; +import world.anhgelus.molehunt.Molehunt; + +public record GamePayload(boolean gameLaunched) implements CustomPayload { + public static final Identifier GAME_PACKET_ID = Identifier.of(Molehunt.MOD_ID, "game"); + + public static final CustomPayload.Id ID = new CustomPayload.Id<>(GAME_PACKET_ID); + public static final PacketCodec CODEC = PacketCodec.tuple( + PacketCodecs.BOOL, GamePayload::gameLaunched, + GamePayload::new + ); + + @Override + public Id getId() { + return ID; + } +} -- cgit v1.2.3 From 8d1ce55f1c2592968c76786083a81151cfc004a3 Mon Sep 17 00:00:00 2001 From: anhgelus Date: Sat, 24 Aug 2024 16:40:02 +0000 Subject: build(docs): install writerside --- Writerside/c.list | 6 ++++++ Writerside/cfg/buildprofiles.xml | 13 +++++++++++++ Writerside/md.tree | 10 ++++++++++ Writerside/topics/introduction.md | 5 +++++ Writerside/v.list | 5 +++++ Writerside/writerside.cfg | 8 ++++++++ 6 files changed, 47 insertions(+) create mode 100644 Writerside/c.list create mode 100644 Writerside/cfg/buildprofiles.xml create mode 100644 Writerside/md.tree create mode 100644 Writerside/topics/introduction.md create mode 100644 Writerside/v.list create mode 100644 Writerside/writerside.cfg diff --git a/Writerside/c.list b/Writerside/c.list new file mode 100644 index 0000000..c4c77a2 --- /dev/null +++ b/Writerside/c.list @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/Writerside/cfg/buildprofiles.xml b/Writerside/cfg/buildprofiles.xml new file mode 100644 index 0000000..8ddb9c7 --- /dev/null +++ b/Writerside/cfg/buildprofiles.xml @@ -0,0 +1,13 @@ + + + + + + + + true + + + + diff --git a/Writerside/md.tree b/Writerside/md.tree new file mode 100644 index 0000000..a3f2998 --- /dev/null +++ b/Writerside/md.tree @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/Writerside/topics/introduction.md b/Writerside/topics/introduction.md new file mode 100644 index 0000000..c5446c3 --- /dev/null +++ b/Writerside/topics/introduction.md @@ -0,0 +1,5 @@ +# Introduction + +Molehunt is a mod creating the Molehunt game in Minecraft. +You can watch this [video](https://www.youtube.com/watch?v=NJBjQ8T_1cc) to understand what it is. +If you are speaking French, I realized this [30 seconds video](https://cdn.anhgelus.world/molehunt-presentation.mp4) explaining the concept. diff --git a/Writerside/v.list b/Writerside/v.list new file mode 100644 index 0000000..2d12cb3 --- /dev/null +++ b/Writerside/v.list @@ -0,0 +1,5 @@ + + + + + diff --git a/Writerside/writerside.cfg b/Writerside/writerside.cfg new file mode 100644 index 0000000..c8afa7c --- /dev/null +++ b/Writerside/writerside.cfg @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file -- cgit v1.2.3 From b3ab83266a69d8be10057fa7e6d285bc81a3e671 Mon Sep 17 00:00:00 2001 From: anhgelus Date: Sat, 24 Aug 2024 16:43:33 +0000 Subject: docs(writerside): installation --- Writerside/topics/introduction.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Writerside/topics/introduction.md b/Writerside/topics/introduction.md index c5446c3..7c6b8f4 100644 --- a/Writerside/topics/introduction.md +++ b/Writerside/topics/introduction.md @@ -3,3 +3,13 @@ Molehunt is a mod creating the Molehunt game in Minecraft. You can watch this [video](https://www.youtube.com/watch?v=NJBjQ8T_1cc) to understand what it is. If you are speaking French, I realized this [30 seconds video](https://cdn.anhgelus.world/molehunt-presentation.mp4) explaining the concept. + +## Installation + +Download the mod for your version. + +The mod requires [Fabric-API](https://modrinth.com/mod/fabric-api) to works. +[Simple Voice Chat](https://modrinth.com/plugin/simple-voice-chat) is highly recommended. + +The mod has to be installed on the server *and* on every client. + -- cgit v1.2.3 From f8e49bdad3ff71a7b054714e97caf1023987debe Mon Sep 17 00:00:00 2001 From: anhgelus Date: Sat, 24 Aug 2024 17:03:08 +0000 Subject: docs(writerside): configuration --- Writerside/md.tree | 1 + Writerside/topics/configuration.md | 71 ++++++++++++++++++++++++++++++++++++++ Writerside/topics/introduction.md | 1 - 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 Writerside/topics/configuration.md diff --git a/Writerside/md.tree b/Writerside/md.tree index a3f2998..870bbb4 100644 --- a/Writerside/md.tree +++ b/Writerside/md.tree @@ -7,4 +7,5 @@ start-page="introduction.md"> + \ No newline at end of file diff --git a/Writerside/topics/configuration.md b/Writerside/topics/configuration.md new file mode 100644 index 0000000..e6fc92a --- /dev/null +++ b/Writerside/topics/configuration.md @@ -0,0 +1,71 @@ +# Configuration + +The mod has two configurations. +The first one modifies the settings of the current world. +The second one modifies the default settings of all your worlds. + +## Common concept + +- Game's duration: `game_duration` (or `gameDuration`). +Sets the game's duration in minutes (default: 90). +- Percentage of mole: `mole_percentage` (or `molePercentage`). +Sets the percentage of mole (default: 25). +- Number of mole: `mole_count` (or `moleCount`). +Sets the number of mole (default: -1). +If you want to use the percentage of mole instead, set this value to -1. +- Enable players' nametag: `show_nametags` (or `showNametags`). +Players' nametag is visible (default: false). +- Enable players' skin: `show_skins` (or `showSkins`). +Players' skin is visible (default: false). +- Enable tab: `show_tab` (or `showTab`). +Tab can be used (default: false). + +Every clientside rules (nametag, skin and tab) are only used by the client during a game. +Before and after the game, they are not used. + +## Configuration per world + +All settings can be modified via gamerules. + +Every gamerule related to this mod starts with the prefix `molehunt:`. + +## Modifying default configuration + +> These settings do not override the configuration per world! +{style="note"} + +A configuration file is available inside the `config` folder. +This is `molehunt.properties`. + +### Default configuration + +```ini +# Molehunt mod configuration file + +# The duration of a molehunt game, in minutes. +# Default: 90 minutes (1 hour 30 minutes). +game_duration = 90 + +# Mole percentage. +# For example, a mole percentage of 25% will get 1 mole every 4 players. +# Default: 25 %. +mole_percentage = 25 + +# Mole count (absolute). +# This setting will overwrite the mole_percentage setting. +# If set below 0, this setting is disabled. +# Default: -1. +mole_count = -1 + +# Show nametags +# Default: false +show_nametags = false + +# Show skins +# Default: false +show_skins = false + +# Show tab +# Default: false +show_tab = false +``` diff --git a/Writerside/topics/introduction.md b/Writerside/topics/introduction.md index 7c6b8f4..78749be 100644 --- a/Writerside/topics/introduction.md +++ b/Writerside/topics/introduction.md @@ -12,4 +12,3 @@ The mod requires [Fabric-API](https://modrinth.com/mod/fabric-api) to works. [Simple Voice Chat](https://modrinth.com/plugin/simple-voice-chat) is highly recommended. The mod has to be installed on the server *and* on every client. - -- cgit v1.2.3 From d819094e8dc23384ac86d06ac20bb8dfc7d162fe Mon Sep 17 00:00:00 2001 From: anhgelus Date: Sat, 24 Aug 2024 17:09:49 +0000 Subject: docs(writerside): usage --- Writerside/md.tree | 1 + Writerside/topics/usage.md | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 Writerside/topics/usage.md diff --git a/Writerside/md.tree b/Writerside/md.tree index 870bbb4..d77dee5 100644 --- a/Writerside/md.tree +++ b/Writerside/md.tree @@ -8,4 +8,5 @@ + \ No newline at end of file diff --git a/Writerside/topics/usage.md b/Writerside/topics/usage.md new file mode 100644 index 0000000..2a02033 --- /dev/null +++ b/Writerside/topics/usage.md @@ -0,0 +1,13 @@ +# Usage + +To start a game, execute `/molehunt start`. +You must be OP. + +To stop a game, execute `/molehunt stop`. +You must be OP. +(They are already an automatic end if there is no more survivors or if the time is over.) + +To get the list of moles, use `/molehunt moles`. +You must be a mole. + +To edit the timer above the hotbar, use `/molehunt timer show` to enable and `/molehunt timer hide` to disable. -- cgit v1.2.3 From 1e42af1d9ac1e0bc7d26c8323272fd6a32e3c400 Mon Sep 17 00:00:00 2001 From: anhgelus Date: Sat, 24 Aug 2024 17:18:05 +0000 Subject: ci(actions): build and publish wiki to github pages --- .github/workflows/build-docs.yml | 76 +++++++++++++++++++++++++++++++++++++++ README.md | 2 ++ Writerside/topics/introduction.md | 2 +- Writerside/writerside.cfg | 2 +- 4 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build-docs.yml diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml new file mode 100644 index 0000000..efd7cb3 --- /dev/null +++ b/.github/workflows/build-docs.yml @@ -0,0 +1,76 @@ +name: Build documentation + +on: + push: + branches: ["main"] + workflow_dispatch: + +env: + INSTANCE: 'Writerside/md' + ARTIFACT: 'webHelpMD2-all.zip' + DOCKER_VERSION: '241.18775' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Build docs using Writerside Docker builder + uses: JetBrains/writerside-github-action@v4 + with: + instance: ${{ env.INSTANCE }} + artifact: ${{ env.ARTIFACT }} + docker-version: ${{ env.DOCKER_VERSION }} + + - name: Save artifact with build results + uses: actions/upload-artifact@v4 + with: + name: docs + path: | + artifacts/${{ env.ARTIFACT }} + artifacts/report.json + retention-days: 7 + test: + needs: build + runs-on: ubuntu-latest + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: docs + path: artifacts + + - name: Test documentation + uses: JetBrains/writerside-checker-action@v1 + with: + instance: ${{ env.INSTANCE }} + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + needs: [build, test] + runs-on: ubuntu-latest + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: docs + + - name: Unzip artifact + run: unzip -O UTF-8 -qq '${{ env.ARTIFACT }}' -d dir + + - name: Setup Pages + uses: actions/configure-pages@v4 + + - name: Package and upload Pages artifact + uses: actions/upload-pages-artifact@v3 + with: + path: dir + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/README.md b/README.md index f739a69..b81628c 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ Molehunt is a Minecraft mod creating the game with the same name in this cubic game. +A complete wiki is available [here](https://www.anhgelus.world/molehunt/). + ## Usage Install the mod on the server and on all clients. diff --git a/Writerside/topics/introduction.md b/Writerside/topics/introduction.md index 78749be..3311fd0 100644 --- a/Writerside/topics/introduction.md +++ b/Writerside/topics/introduction.md @@ -1,6 +1,6 @@ # Introduction -Molehunt is a mod creating the Molehunt game in Minecraft. +[Molehunt](https://modrinth.com/mod/molehunt-mod) is a mod creating the Molehunt game in Minecraft. You can watch this [video](https://www.youtube.com/watch?v=NJBjQ8T_1cc) to understand what it is. If you are speaking French, I realized this [30 seconds video](https://cdn.anhgelus.world/molehunt-presentation.mp4) explaining the concept. diff --git a/Writerside/writerside.cfg b/Writerside/writerside.cfg index c8afa7c..1e00bbe 100644 --- a/Writerside/writerside.cfg +++ b/Writerside/writerside.cfg @@ -4,5 +4,5 @@ - + \ No newline at end of file -- cgit v1.2.3 From 5bd6eca40a47f590114075e67a7c08e98083757f Mon Sep 17 00:00:00 2001 From: anhgelus Date: Sat, 24 Aug 2024 17:24:23 +0000 Subject: ci(actions): fix bad permission on publish --- .github/workflows/build-docs.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index efd7cb3..84f9cb0 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -5,6 +5,10 @@ on: branches: ["main"] workflow_dispatch: +permissions: + id-token: write + pages: write + env: INSTANCE: 'Writerside/md' ARTIFACT: 'webHelpMD2-all.zip' -- cgit v1.2.3 From f9702feda784bfe7fef3cb8b8d0ddb420010ea5b Mon Sep 17 00:00:00 2001 From: anhgelus Date: Sat, 24 Aug 2024 17:28:31 +0000 Subject: docs(): fix spelling mistake --- README.md | 2 +- Writerside/topics/introduction.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b81628c..b3de1f7 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Molehunt is a Minecraft mod creating the game with the same name in this cubic game. -A complete wiki is available [here](https://www.anhgelus.world/molehunt/). +A complete wiki is available [here](https://www.anhgelus.world/molehunt/introduction.html). ## Usage diff --git a/Writerside/topics/introduction.md b/Writerside/topics/introduction.md index 3311fd0..f1fa63e 100644 --- a/Writerside/topics/introduction.md +++ b/Writerside/topics/introduction.md @@ -2,7 +2,7 @@ [Molehunt](https://modrinth.com/mod/molehunt-mod) is a mod creating the Molehunt game in Minecraft. You can watch this [video](https://www.youtube.com/watch?v=NJBjQ8T_1cc) to understand what it is. -If you are speaking French, I realized this [30 seconds video](https://cdn.anhgelus.world/molehunt-presentation.mp4) explaining the concept. +If you are speaking French, I made this [30 seconds video](https://cdn.anhgelus.world/molehunt-presentation.mp4) explaining the concept. ## Installation -- cgit v1.2.3