aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java28
-rw-r--r--src/client/java/world/anhgelus/molehunt/client/mixin/NoCustomizableSkinOverlay.java45
-rw-r--r--src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java22
-rw-r--r--src/client/java/world/anhgelus/molehunt/client/mixin/NoPlayerListHud.java6
-rw-r--r--src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java21
-rw-r--r--src/client/resources/assets/molehunt/lang/en_us.json1
-rw-r--r--src/client/resources/assets/molehunt/lang/fr_fr.json1
7 files changed, 76 insertions, 48 deletions
diff --git a/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java b/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java
index f495d40..d479674 100644
--- a/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java
+++ b/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java
@@ -1,14 +1,17 @@
package world.anhgelus.molehunt.client;
import net.fabricmc.api.ClientModInitializer;
-import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
-import net.minecraft.entity.player.PlayerModelPart;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import world.anhgelus.molehunt.Molehunt;
import world.anhgelus.molehunt.config.ConfigPayload;
import world.anhgelus.molehunt.game.GamePayload;
public class MolehuntClient implements ClientModInitializer {
+ public static final Logger LOGGER = LoggerFactory.getLogger(Molehunt.MOD_ID + " - client");
+
private static boolean SHOW_SKINS = false;
private static boolean SHOW_NAMETAGS = false;
private static boolean SHOW_TAB = false;
@@ -33,25 +36,14 @@ public class MolehuntClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
- ClientPlayNetworking.registerGlobalReceiver(ConfigPayload.ID, (payload, context) -> context.client().execute(() -> {
+ LOGGER.info("Initializing client");
+ ClientPlayNetworking.registerGlobalReceiver(ConfigPayload.ID, (payload, context) -> {
SHOW_SKINS = payload.showSkins();
SHOW_NAMETAGS = payload.showNametags();
SHOW_TAB = payload.showTab();
- }));
- ClientPlayNetworking.registerGlobalReceiver(GamePayload.ID, (payload, context) -> context.client().execute(() -> GAME_STARTED = payload.gameLaunched()));
-
- // Needed because else `client.options` is null
- ClientLifecycleEvents.CLIENT_STARTED.register(client -> {
- var options = client.options;
-
- options.setPlayerModelPart(PlayerModelPart.CAPE, true);
- options.setPlayerModelPart(PlayerModelPart.HAT, true);
- options.setPlayerModelPart(PlayerModelPart.JACKET, true);
- options.setPlayerModelPart(PlayerModelPart.LEFT_SLEEVE, true);
- options.setPlayerModelPart(PlayerModelPart.RIGHT_SLEEVE, true);
- options.setPlayerModelPart(PlayerModelPart.LEFT_PANTS_LEG, true);
- options.setPlayerModelPart(PlayerModelPart.RIGHT_PANTS_LEG, true);
});
-
+ ClientPlayNetworking.registerGlobalReceiver(GamePayload.ID, (payload, context) -> {
+ GAME_STARTED = payload.gameLaunched();
+ });
}
}
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 f253cd8..95d85d9 100644
--- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoCustomizableSkinOverlay.java
+++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoCustomizableSkinOverlay.java
@@ -1,18 +1,55 @@
package world.anhgelus.molehunt.client.mixin;
-import net.minecraft.client.option.GameOptions;
-import net.minecraft.entity.player.PlayerModelPart;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.Options;
+import net.minecraft.server.level.ClientInformation;
+import net.minecraft.world.entity.player.PlayerModelPart;
import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import world.anhgelus.molehunt.client.MolehuntClient;
-@Mixin(GameOptions.class)
+@Mixin(Options.class)
public abstract class NoCustomizableSkinOverlay {
- @Inject(at = @At("HEAD"), method = "setPlayerModelPart", cancellable = true)
+ @Unique
+ private static int fullParts;
+
+ static {
+ for (PlayerModelPart part : PlayerModelPart.values()) {
+ fullParts |= part.getMask();
+ }
+ }
+
+ @Shadow
+ protected Minecraft minecraft;
+
+ @Inject(at = @At("HEAD"), method = "setModelPart", cancellable = true)
public void togglePlayerModelPart(PlayerModelPart part, boolean enabled, CallbackInfo ci) {
if (MolehuntClient.showSkins()) return;
ci.cancel();
}
+
+ @Inject(at = @At("RETURN"), method = "buildPlayerInformation", cancellable = true)
+ public void buildPlayerInformation(CallbackInfoReturnable<ClientInformation> cir) {
+ if (MolehuntClient.showSkins()) return;
+ final var opts = (Options) (Object) this;
+
+ cir.setReturnValue(
+ new ClientInformation(
+ opts.languageCode,
+ opts.renderDistance().get(),
+ opts.chatVisibility().get(),
+ opts.chatColors().get(),
+ fullParts,
+ opts.mainHand().get(),
+ this.minecraft.isTextFilteringEnabled(),
+ opts.allowServerListing().get(),
+ opts.particles().get()
+ )
+ );
+ }
}
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 cea817d..a50c3e3 100644
--- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java
+++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java
@@ -1,24 +1,20 @@
package world.anhgelus.molehunt.client.mixin;
-import net.minecraft.client.render.command.OrderedRenderCommandQueue;
-import net.minecraft.client.render.entity.EntityRenderer;
-import net.minecraft.client.render.entity.state.EntityRenderState;
-import net.minecraft.client.render.state.CameraRenderState;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.EntityType;
+import net.minecraft.client.renderer.entity.EntityRenderer;
+import net.minecraft.client.renderer.entity.state.EntityRenderState;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.entity.player.Player;
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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import world.anhgelus.molehunt.client.MolehuntClient;
@Mixin(EntityRenderer.class)
public class NoNametags<T extends Entity, S extends EntityRenderState> {
- @Inject(at = @At("HEAD"), method = "render", cancellable = true)
- private void renderLabelOrNot(S state, MatrixStack matrices, OrderedRenderCommandQueue queue, CameraRenderState cameraState, CallbackInfo ci) {
- if (EntityType.PLAYER != state.entityType || MolehuntClient.showNameTags() || !MolehuntClient.gameStarted())
- return;
- ci.cancel();
+ @Inject(at = @At("HEAD"), method = "shouldShowName", cancellable = true)
+ private void renderLabelOrNot(T entity, double distanceToCameraSq, CallbackInfoReturnable<Boolean> cir) {
+ if (!(entity instanceof Player) || MolehuntClient.showNameTags() || !MolehuntClient.gameStarted()) return;
+ cir.setReturnValue(false);
}
} \ 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 d889f06..c846e7d 100644
--- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoPlayerListHud.java
+++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoPlayerListHud.java
@@ -1,15 +1,15 @@
package world.anhgelus.molehunt.client.mixin;
-import net.minecraft.client.gui.hud.PlayerListHud;
+import net.minecraft.client.gui.components.PlayerTabOverlay;
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)
+@Mixin(PlayerTabOverlay.class)
public class NoPlayerListHud {
- @Inject(at = @At("HEAD"), method = "render", cancellable = true)
+ @Inject(at = @At("HEAD"), method = "setVisible", cancellable = true)
public void render(CallbackInfo ci) {
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 945ef9b..7007948 100644
--- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java
+++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java
@@ -1,10 +1,10 @@
package world.anhgelus.molehunt.client.mixin;
-import net.minecraft.client.network.AbstractClientPlayerEntity;
-import net.minecraft.entity.player.PlayerSkinType;
-import net.minecraft.entity.player.SkinTextures;
-import net.minecraft.util.AssetInfo;
-import net.minecraft.util.Identifier;
+import net.minecraft.client.player.AbstractClientPlayer;
+import net.minecraft.core.ClientAsset;
+import net.minecraft.resources.Identifier;
+import net.minecraft.world.entity.player.PlayerModelType;
+import net.minecraft.world.entity.player.PlayerSkin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@@ -12,16 +12,17 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import world.anhgelus.molehunt.Molehunt;
import world.anhgelus.molehunt.client.MolehuntClient;
-@Mixin(AbstractClientPlayerEntity.class)
+@Mixin(AbstractClientPlayer.class)
public class NoSkin {
@Inject(at = @At("HEAD"), method = "getSkin", cancellable = true)
- public void getSkin(CallbackInfoReturnable<SkinTextures> cir) {
+ public void getSkin(CallbackInfoReturnable<PlayerSkin> cir) {
if (MolehuntClient.showSkins() || !MolehuntClient.gameStarted()) return;
- cir.setReturnValue(SkinTextures.create(
- new AssetInfo.TextureAssetInfo(Identifier.of(Molehunt.MOD_ID, "skin")),
+ cir.setReturnValue(new PlayerSkin(
+ new ClientAsset.ResourceTexture(Identifier.fromNamespaceAndPath(Molehunt.MOD_ID, "skin")),
null,
null,
- PlayerSkinType.WIDE
+ PlayerModelType.WIDE,
+ true
));
}
}
diff --git a/src/client/resources/assets/molehunt/lang/en_us.json b/src/client/resources/assets/molehunt/lang/en_us.json
index 5bbd6f5..393d6dd 100644
--- a/src/client/resources/assets/molehunt/lang/en_us.json
+++ b/src/client/resources/assets/molehunt/lang/en_us.json
@@ -1,5 +1,6 @@
{
"commands.molehunt.error.game_not_started": "The Molehunt game has not been started yet.",
+ "commands.molehunt.error.game_already_started": "The Molehunt game has already been started yet.",
"commands.molehunt.timer.show": "Showing Molehunt timer.",
"commands.molehunt.timer.hide": "Hiding Molehunt timer.",
"commands.molehunt.role.mole": "§cYou are a Mole.\nKill all the survivors before the timer runs out.",
diff --git a/src/client/resources/assets/molehunt/lang/fr_fr.json b/src/client/resources/assets/molehunt/lang/fr_fr.json
index cc5133d..b66060e 100644
--- a/src/client/resources/assets/molehunt/lang/fr_fr.json
+++ b/src/client/resources/assets/molehunt/lang/fr_fr.json
@@ -1,5 +1,6 @@
{
"commands.molehunt.error.game_not_started": "La partie de Molehunt n'a pas encore commencé.",
+ "commands.molehunt.error.game_already_started": "La partie de Molehunt a déjà été lancée.",
"commands.molehunt.timer.show": "Le timer est maintenant affiché.",
"commands.molehunt.timer.hide": "Le timer est maintenant caché.",
"commands.molehunt.role.mole": "§cVous êtes une taupe.\nTuez tous les survivants avant la fin de la partie..",