diff options
Diffstat (limited to 'src/client/java/world')
5 files changed, 71 insertions, 77 deletions
diff --git a/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java b/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java index 03198ee..f495d40 100644 --- a/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java +++ b/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java @@ -9,49 +9,49 @@ import world.anhgelus.molehunt.game.GamePayload; public class MolehuntClient implements ClientModInitializer { - private static boolean SHOW_SKINS = false; - 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) -> context.client().execute(() -> { - 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); - }); - - } - - public static boolean showSkins() { - return SHOW_SKINS; - } - - public static boolean showNameTags() { - return SHOW_NAMETAGS; - } - - public static boolean showTab() { - return SHOW_TAB; - } - - public static boolean gameStarted() { - return GAME_STARTED; - } + private static boolean SHOW_SKINS = false; + private static boolean SHOW_NAMETAGS = false; + private static boolean SHOW_TAB = false; + + private static boolean GAME_STARTED = false; + + public static boolean showSkins() { + return SHOW_SKINS; + } + + public static boolean showNameTags() { + return SHOW_NAMETAGS; + } + + public static boolean showTab() { + return SHOW_TAB; + } + + public static boolean gameStarted() { + return GAME_STARTED; + } + + @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(); + })); + 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); + }); + + } } 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 c2c0ab0..f253cd8 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.option.GameOptions; import net.minecraft.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(GameOptions.class) public abstract class NoCustomizableSkinOverlay { - @Shadow - private void setPlayerModelPart(PlayerModelPart part, boolean enabled) {} - - @Inject(at = @At("HEAD"), method = "setPlayerModelPart", cancellable = true) - public void togglePlayerModelPart(PlayerModelPart part, boolean enabled, CallbackInfo ci) { - if (MolehuntClient.showSkins()) return; - setPlayerModelPart(part, true); - ((GameOptions) (Object) this).sendClientSettings(); - ci.cancel(); - } + @Inject(at = @At("HEAD"), method = "setPlayerModelPart", cancellable = true) + public void togglePlayerModelPart(PlayerModelPart part, boolean enabled, CallbackInfo ci) { + if (MolehuntClient.showSkins()) return; + ci.cancel(); + } } 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 555fb00..cea817d 100644 --- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java +++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java @@ -7,7 +7,6 @@ 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.entity.player.PlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@@ -16,9 +15,10 @@ 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 = "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();
+ }
}
\ 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 4473b12..d889f06 100644 --- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoPlayerListHud.java +++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoPlayerListHud.java @@ -9,9 +9,9 @@ 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() || !MolehuntClient.gameStarted()) return;
- ci.cancel();
- }
+ @Inject(at = @At("HEAD"), method = "render", 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 b6b67cc..945ef9b 100644 --- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java +++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java @@ -14,14 +14,14 @@ import world.anhgelus.molehunt.client.MolehuntClient; @Mixin(AbstractClientPlayerEntity.class)
public class NoSkin {
- @Inject(at = @At("HEAD"), method = "getSkin", cancellable = true)
- public void getSkin(CallbackInfoReturnable<SkinTextures> cir) {
- if (MolehuntClient.showSkins() || !MolehuntClient.gameStarted()) return;
- cir.setReturnValue(SkinTextures.create(
- new AssetInfo.TextureAssetInfo(Identifier.of(Molehunt.MOD_ID, "skin")),
- null,
- null,
- PlayerSkinType.WIDE
- ));
- }
+ @Inject(at = @At("HEAD"), method = "getSkin", cancellable = true)
+ public void getSkin(CallbackInfoReturnable<SkinTextures> cir) {
+ if (MolehuntClient.showSkins() || !MolehuntClient.gameStarted()) return;
+ cir.setReturnValue(SkinTextures.create(
+ new AssetInfo.TextureAssetInfo(Identifier.of(Molehunt.MOD_ID, "skin")),
+ null,
+ null,
+ PlayerSkinType.WIDE
+ ));
+ }
}
|
