From ebd1300751e945b602ba83413ed0a5e5ac0bc996 Mon Sep 17 00:00:00 2001 From: Up Date: Tue, 21 May 2024 20:41:15 +0200 Subject: [PATCH] add clientside config for loop-de-loops --- .../java/dev/cammiescorner/icarus/IcarusConfig.java | 7 ++++++- .../icarus/client/ClientPlayerFallbackValues.java | 1 + .../icarus/client/IcarusClientConfig.java | 12 ++++++++++++ .../icarus/mixin/client/MouseHandlerMixin.java | 4 +++- .../src/main/resources/assets/icarus/lang/en_us.json | 4 +++- .../src/main/resources/assets/icarus/lang/pt_br.json | 4 +++- 6 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 Common/src/main/java/dev/cammiescorner/icarus/client/IcarusClientConfig.java diff --git a/Common/src/main/java/dev/cammiescorner/icarus/IcarusConfig.java b/Common/src/main/java/dev/cammiescorner/icarus/IcarusConfig.java index cc83768..f5293d9 100644 --- a/Common/src/main/java/dev/cammiescorner/icarus/IcarusConfig.java +++ b/Common/src/main/java/dev/cammiescorner/icarus/IcarusConfig.java @@ -2,9 +2,11 @@ import com.teamresourceful.resourcefulconfig.common.annotations.Config; import com.teamresourceful.resourcefulconfig.common.annotations.ConfigEntry; +import com.teamresourceful.resourcefulconfig.common.annotations.InlineCategory; import com.teamresourceful.resourcefulconfig.common.config.EntryType; import com.teamresourceful.resourcefulconfig.web.annotations.Link; import com.teamresourceful.resourcefulconfig.web.annotations.WebInfo; +import dev.cammiescorner.icarus.client.IcarusClientConfig; @WebInfo( title = "Icarus", @@ -30,7 +32,7 @@ @Config(Icarus.MODID) public final class IcarusConfig { - @ConfigEntry(id = "can_loop_de_loop", type = EntryType.BOOLEAN, translation = "config.icarus.can_loop_de_loop") + @ConfigEntry(id = "can_loop_de_loop", type = EntryType.BOOLEAN, translation = "config.icarus.can_loop_de_loop_server") public static boolean canLoopDeLoop = true; @ConfigEntry(id = "armor_slows", type = EntryType.BOOLEAN, translation = "config.icarus.armor_slows") public static boolean armorSlows = true; @@ -54,4 +56,7 @@ public final class IcarusConfig { public static int maxHeightAboveWorld = 64; @ConfigEntry(id = "flying_target_radius", type = EntryType.FLOAT, translation = "config.icarus.flying_target_radius") public static float flyingTargetRadius = 0.25f; + + @InlineCategory + public static IcarusClientConfig client; } diff --git a/Common/src/main/java/dev/cammiescorner/icarus/client/ClientPlayerFallbackValues.java b/Common/src/main/java/dev/cammiescorner/icarus/client/ClientPlayerFallbackValues.java index 4d48367..292df91 100644 --- a/Common/src/main/java/dev/cammiescorner/icarus/client/ClientPlayerFallbackValues.java +++ b/Common/src/main/java/dev/cammiescorner/icarus/client/ClientPlayerFallbackValues.java @@ -1,5 +1,6 @@ package dev.cammiescorner.icarus.client; +import dev.cammiescorner.icarus.IcarusConfig; import dev.cammiescorner.icarus.api.IcarusPlayerValues; import dev.cammiescorner.icarus.util.ServerPlayerFallbackValues; diff --git a/Common/src/main/java/dev/cammiescorner/icarus/client/IcarusClientConfig.java b/Common/src/main/java/dev/cammiescorner/icarus/client/IcarusClientConfig.java new file mode 100644 index 0000000..bfed8b4 --- /dev/null +++ b/Common/src/main/java/dev/cammiescorner/icarus/client/IcarusClientConfig.java @@ -0,0 +1,12 @@ +package dev.cammiescorner.icarus.client; + +import com.teamresourceful.resourcefulconfig.common.annotations.Category; +import com.teamresourceful.resourcefulconfig.common.annotations.ConfigEntry; +import com.teamresourceful.resourcefulconfig.common.config.EntryType; + +@Category(id = "client", translation = "config_category.icarus.client") +public final class IcarusClientConfig { + + @ConfigEntry(id = "can_loop_de_loop", type = EntryType.BOOLEAN, translation = "config.icarus.can_loop_de_loop_client") + public static boolean canLoopDeLoop = true; +} diff --git a/Common/src/main/java/dev/cammiescorner/icarus/mixin/client/MouseHandlerMixin.java b/Common/src/main/java/dev/cammiescorner/icarus/mixin/client/MouseHandlerMixin.java index da477f7..934949d 100644 --- a/Common/src/main/java/dev/cammiescorner/icarus/mixin/client/MouseHandlerMixin.java +++ b/Common/src/main/java/dev/cammiescorner/icarus/mixin/client/MouseHandlerMixin.java @@ -1,5 +1,7 @@ package dev.cammiescorner.icarus.mixin.client; +import dev.cammiescorner.icarus.IcarusConfig; +import dev.cammiescorner.icarus.client.IcarusClientConfig; import dev.cammiescorner.icarus.util.IcarusHelper; import net.minecraft.client.Minecraft; import net.minecraft.client.MouseHandler; @@ -18,7 +20,7 @@ public class MouseHandlerMixin { @ModifyArg(method = "turnPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;turn(DD)V"), index = 0) public double changeLookDirectionX(double x) { - if (minecraft.player != null && minecraft.player.isFallFlying() && IcarusHelper.hasWings(minecraft.player) && IcarusHelper.getConfigValues(minecraft.player).canLoopDeLoop() && (minecraft.player.getXRot() > 90 || minecraft.player.getXRot() < -90)) + if (minecraft.player != null && minecraft.player.isFallFlying() && IcarusClientConfig.canLoopDeLoop && IcarusHelper.hasWings(minecraft.player) && IcarusHelper.getConfigValues(minecraft.player).canLoopDeLoop() && (minecraft.player.getXRot() > 90 || minecraft.player.getXRot() < -90)) return -x; return x; diff --git a/Common/src/main/resources/assets/icarus/lang/en_us.json b/Common/src/main/resources/assets/icarus/lang/en_us.json index c8e96d8..aa7db6f 100644 --- a/Common/src/main/resources/assets/icarus/lang/en_us.json +++ b/Common/src/main/resources/assets/icarus/lang/en_us.json @@ -90,7 +90,8 @@ "item.icarus.discords_wings": "Discord's Wings", "item.icarus.zanzas_wings": "Zanza's Wings", - "config.icarus.can_loop_de_loop": "Can the player do loop-de-loops?", + "config.icarus.can_loop_de_loop_server": "Can players do loop-de-loops?", + "config.icarus.can_loop_de_loop_client": "Can you do loop-de-loops?", "config.icarus.armor_slows": "Does armor slow the player down?", "config.icarus.can_slow_fall": "Can the player slow-fall by Sneaking while flying?", "config.icarus.max_slowed_multiplier": "Maximum multiplier armor can slow you by.", @@ -102,6 +103,7 @@ "config.icarus.max_height_enabled": "Whether or not to prevent flight above the maximum height allowed", "config.icarus.max_height_above_world": "Maximum height above the world build limit that players can fly to", "config.icarus.flying_target_radius": "How much the targeting hitbox of a flying player is increased by", + "config_category.icarus.client": "Client Settings", "effect.icarus.flightless": "Flightless", diff --git a/Common/src/main/resources/assets/icarus/lang/pt_br.json b/Common/src/main/resources/assets/icarus/lang/pt_br.json index dd78540..fedeef7 100644 --- a/Common/src/main/resources/assets/icarus/lang/pt_br.json +++ b/Common/src/main/resources/assets/icarus/lang/pt_br.json @@ -90,7 +90,8 @@ "item.icarus.discords_wings": "Asas do Discord", "item.icarus.zanzas_wings": "Asas da Zanza", - "config.icarus.can_loop_de_loop": "O jogador consegue fazer loop-de-loops?", + "config.icarus.can_loop_de_loop_server": "O jogador consegue fazer loop-de-loops?", + "config.icarus.can_loop_de_loop_client": "Can you do loop-de-loops?", "config.icarus.armor_slows": "A armadura desacelera o jogador?", "config.icarus.can_slow_fall": "O jogador pode cair lentamente se ele apertar Shift enquanto caí?", "config.icarus.max_slowed_multiplier": "Multiplicador Máximo de lentidão recebido por armadura.", @@ -102,6 +103,7 @@ "config.icarus.max_height_enabled": "Whether or not to prevent flight above the maximum height allowed", "config.icarus.max_height_above_world": "Maximum height above the world build limit that players can fly to", "config.icarus.flying_target_radius": "How much the targeting hitbox of a flying player is increased by", + "config_category.icarus.client": "Client Settings", "effect.icarus.flightless": "Flightless",