diff options
| author | Léo Kosman <leo.kosman@proton.me> | 2024-08-24 12:55:01 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-24 12:55:01 +0200 |
| commit | 34dc864a495699f1311651c92111884653b42806 (patch) | |
| tree | fcfe59c6d292f4c52d3c81cd51dd019b0e72b388 /src/client | |
| parent | 1973cd58deb902e6df6a152b38e6585a0bf61a5e (diff) | |
| parent | d1d56e097d1aaa90358069370f454e65fc9dbbd5 (diff) | |
Merge pull request #4 from anhgelus/feat/config
[Feat] Config file
Diffstat (limited to 'src/client')
6 files changed, 79 insertions, 15 deletions
diff --git a/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java b/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java index e6de219..1f92573 100644 --- a/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java +++ b/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java @@ -1,20 +1,35 @@ package world.anhgelus.molehunt.client; -import com.mojang.authlib.GameProfile; import net.fabricmc.api.ClientModInitializer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.UUID; +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; +import world.anhgelus.molehunt.config.ConfigPayload; public class MolehuntClient implements ClientModInitializer { - public static final String MOD_ID = "molehunt"; - public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); - - public final static GameProfile ANONYMOUS_PROFILE = new GameProfile(UUID.fromString("015f3266-4e0a-412e-9b80-1ca76af79453"), "Molehunt"); + private static boolean SHOW_SKINS = false; + private static boolean SHOW_NAMETAGS = false; + private static boolean SHOW_TAB = false; @Override public void onInitializeClient() { + ClientPlayNetworking.registerGlobalReceiver(ConfigPayload.ID, (payload, context) -> { + context.client().execute(() -> { + SHOW_SKINS = payload.showSkins(); + SHOW_NAMETAGS = payload.showNametags(); + SHOW_TAB = payload.showTab(); + }); + }); + } + + public static boolean showSkins() { + return SHOW_SKINS; + } + + public static boolean showNameTags() { + return SHOW_NAMETAGS; + } + + public static boolean showTab() { + return SHOW_TAB; } } 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 7996c49..3482abb 100644 --- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java +++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java @@ -9,12 +9,13 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+import world.anhgelus.molehunt.client.MolehuntClient;
@Mixin(EntityRenderer.class)
public class NoNametags<T extends Entity> {
@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)) return;
+ if (!(entity instanceof PlayerEntity) || MolehuntClient.showNameTags()) 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 8ef33fd..00308ea 100644 --- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoPlayerListHud.java +++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoPlayerListHud.java @@ -5,11 +5,13 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+import world.anhgelus.molehunt.client.MolehuntClient;
@Mixin(PlayerListHud.class)
public class NoPlayerListHud {
@Inject(at = @At("HEAD"), method = "render", cancellable = true)
public void render(CallbackInfo ci) {
+ if (MolehuntClient.showTab()) 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 edbfd15..775d789 100644 --- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java +++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java @@ -7,18 +7,20 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+import world.anhgelus.molehunt.Molehunt;
import world.anhgelus.molehunt.client.MolehuntClient;
@Mixin(AbstractClientPlayerEntity.class)
public class NoSkin {
@Inject(at = @At("HEAD"), method = "getSkinTextures", cancellable = true)
public void getSkin(CallbackInfoReturnable<SkinTextures> cir) {
+ if (MolehuntClient.showSkins()) return;
cir.setReturnValue(new SkinTextures(
- Identifier.of(MolehuntClient.MOD_ID, "textures/skin.png"),
- null,
- null,
- null,
- SkinTextures.Model.WIDE, true)
+ Identifier.of(Molehunt.MOD_ID, "textures/skin.png"),
+ null,
+ null,
+ null,
+ SkinTextures.Model.WIDE, true)
);
}
}
diff --git a/src/client/resources/assets/molehunt/lang/en_us.json b/src/client/resources/assets/molehunt/lang/en_us.json new file mode 100644 index 0000000..3a50d81 --- /dev/null +++ b/src/client/resources/assets/molehunt/lang/en_us.json @@ -0,0 +1,22 @@ +{ + "commands.molehunt.stop.failed": "The Molehunt game has not been started yet.", + "commands.molehunt.timer.show": "Showing Molehunt timer.", + "commands.molehunt.timer.hide": "Hiding Molehunt timer.", + "commands.molehunt.moles.list": "List of moles:", + "commands.molehunt.moles.list.deny": "You can't see the list of moles.", + "commands.molehunt.stop.success": "The Molehunt game has been stopped.", + "molehunt.game.end.suspense.title": "§eAnd the winners are...", + "molehunt.game.end.winners.moles.title": "§cThe Moles!", + "molehunt.game.end.winners.survivors.title": "§aNot the Moles!", + "molehunt.game.end.winners.subtitle": "§6The Moles were", + "molehunt.game.start.suspense": "§eYou are...", + "molehunt.game.start.mole.title": "§cThe Mole!", + "molehunt.game.start.mole.subtitle": "§eGet the list of moles with §6/molehunt moles", + "molehunt.game.start.survivor": "§aNot the Mole!", + "gamerule.molehunt:gameDuration": "Duration of a game", + "gamerule.molehunt:molePercentage": "Percentage of Mole", + "gamerule.molehunt:moleCount": "Number of Mole", + "gamerule.molehunt:showNametags": "Show players' nametag", + "gamerule.molehunt:showTab": "Enable the tab", + "gamerule.molehunt:showSkins": "Show players' skin" +}
\ No newline at end of file diff --git a/src/client/resources/assets/molehunt/lang/fr_fr.json b/src/client/resources/assets/molehunt/lang/fr_fr.json new file mode 100644 index 0000000..bb73ca8 --- /dev/null +++ b/src/client/resources/assets/molehunt/lang/fr_fr.json @@ -0,0 +1,22 @@ +{ + "commands.molehunt.stop.failed": "La partie de Molehunt n'a pas encore commencé.", + "commands.molehunt.timer.show": "Affiche le timer.", + "commands.molehunt.timer.hide": "Cache le timer.", + "commands.molehunt.moles.list": "Liste des taupes:", + "commands.molehunt.moles.list.deny": "Vous ne pouvez pas voir la liste des taupes.", + "commands.molehunt.stop.success": "La partie de Molehunt a été stoppée.", + "molehunt.game.end.suspense.title": "§eEt les gagnants sont...", + "molehunt.game.end.winners.moles.title": "§cLes Taupes !", + "molehunt.game.end.winners.survivors.title": "§aPas les Taupes !", + "molehunt.game.end.winners.subtitle": "§Les Taupes sont", + "molehunt.game.start.suspense": "§eVous êtes...", + "molehunt.game.start.mole.title": "§cLa Taupe !", + "molehunt.game.start.mole.subtitle": "§eRécupérer la liste des taupes avec §6/molehunt moles", + "molehunt.game.start.survivor": "§aPas la Taupe!", + "gamerule.molehunt:gameDuration": "Durée d'une partie", + "gamerule.molehunt:molePercentage": "Pourcentage de Taupes", + "gamerule.molehunt:moleCount": "Nombre de Taupes", + "gamerule.molehunt:showNametags": "Affiche les nametags des joueurs", + "gamerule.molehunt:showTab": "Active le tab", + "gamerule.molehunt:showSkins": "Affiche les skins des joueurs" +}
\ No newline at end of file |
