Explorar el Código

port to 1.16.1

TheIllusiveC4 hace 5 años
padre
commit
e762b93cbf

+ 1 - 0
.github/ISSUE_TEMPLATE/config.yml

@@ -0,0 +1 @@
+blank_issues_enabled: false

+ 2 - 6
docs/CHANGELOG.md

@@ -4,10 +4,6 @@ All notable changes to this project will be documented in this file.
 The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project does not adhere to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
 This project uses MCVERSION-MAJORMOD.MAJORAPI.MINOR.PATCH.
 
-## [3.0.0.1](https://github.com/TheIllusiveC4/CustomFoV/compare/031306751e3bbc7101bc506b7695577e4af721ea...master) - 2020.02.13
-### Fixed
-- Fixed issue with underwater FoV glitching [#2](https://github.com/TheIllusiveC4/CustomFoV/issues/2)
-
-## [3.0](https://github.com/TheIllusiveC4/CustomFoV/compare/1.14.x...031306751e3bbc7101bc506b7695577e4af721ea) - 2020.02.09
+## [4.0](https://github.com/TheIllusiveC4/CustomFoV/compare/1.15.x...master) - 2020.07.03
 ### Changed
-- Ported to 1.15.2 Forge
+- Ported to 1.16.1 Forge

+ 4 - 4
gradle.properties

@@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx3G
 org.gradle.daemon=false
 
 # Mod
-mod_version=3.0.0.1
+mod_version=4.0
 mod_group=top.theillusivec4.customfov
 mod_id=customfov
 mod_name=Custom FoV
@@ -13,9 +13,9 @@ mod_description=Allows customization of various field of view settings.
 mod_icon=customfov_icon.png
 
 # Dependencies
-version_minecraft=FORGE-1.15.2
-version_forge=1.15.2-31.1.0
-version_mcp=20200201-1.15.1
+version_minecraft=FORGE-1.16.1
+version_forge=1.16.1-32.0.34
+version_mcp=20200514-1.16
 
 # Curse
 curse_id=303938

BIN
gradle/wrapper/gradle-wrapper.jar


+ 2 - 2
gradle/wrapper/gradle-wrapper.properties

@@ -1,6 +1,6 @@
-#Fri Feb 15 14:07:50 PST 2019
+#Wed Jul 01 02:12:49 PDT 2020
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip

+ 1 - 1
gradlew

@@ -28,7 +28,7 @@ APP_NAME="Gradle"
 APP_BASE_NAME=`basename "$0"`
 
 # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+DEFAULT_JVM_OPTS='"-Xmx64m"'
 
 # Use the maximum available, or set MAX_FD != -1 to use that value.
 MAX_FD="maximum"

+ 1 - 1
gradlew.bat

@@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0
 set APP_HOME=%DIRNAME%
 
 @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
+set DEFAULT_JVM_OPTS="-Xmx64m"
 
 @rem Find java.exe
 if defined JAVA_HOME goto findJavaFromJavaHome

+ 19 - 5
src/main/java/top/theillusivec4/customfov/CustomFoV.java

@@ -20,13 +20,16 @@
 package top.theillusivec4.customfov;
 
 import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.eventbus.api.IEventBus;
+import net.minecraftforge.fml.ExtensionPoint;
 import net.minecraftforge.fml.ModLoadingContext;
 import net.minecraftforge.fml.common.Mod;
 import net.minecraftforge.fml.config.ModConfig;
+import net.minecraftforge.fml.config.ModConfig.ModConfigEvent;
 import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
 import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
-import top.theillusivec4.customfov.core.EventHandlerFoV;
-import top.theillusivec4.customfov.core.FoVConfig;
+import net.minecraftforge.fml.network.FMLNetworkConstants;
+import org.apache.commons.lang3.tuple.Pair;
 
 @Mod(CustomFoV.MODID)
 public class CustomFoV {
@@ -34,11 +37,22 @@ public class CustomFoV {
   public static final String MODID = "customfov";
 
   public CustomFoV() {
-    FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setupClient);
-    ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, FoVConfig.spec);
+    IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();
+    eventBus.addListener(this::setupClient);
+    eventBus.addListener(this::config);
+    ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, CustomFoVConfig.CONFIG_SPEC);
+    ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.DISPLAYTEST,
+        () -> Pair.of(() -> FMLNetworkConstants.IGNORESERVERONLY, (a, b) -> true));
   }
 
   private void setupClient(final FMLClientSetupEvent evt) {
-    MinecraftForge.EVENT_BUS.register(new EventHandlerFoV());
+    MinecraftForge.EVENT_BUS.register(new CustomFoVEventHandler());
+  }
+
+  private void config(final ModConfigEvent evt) {
+
+    if (evt.getConfig().getModId().equals(MODID)) {
+      CustomFoVConfig.bake();
+    }
   }
 }

+ 205 - 0
src/main/java/top/theillusivec4/customfov/CustomFoVConfig.java

@@ -0,0 +1,205 @@
+/*
+ * Copyright (C) 2018-2019  C4
+ *
+ * This file is part of CustomFoV, a mod made for Minecraft.
+ *
+ * CustomFoV is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * CustomFoV is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with CustomFoV.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package top.theillusivec4.customfov;
+
+import net.minecraftforge.common.ForgeConfigSpec;
+import net.minecraftforge.common.ForgeConfigSpec.DoubleValue;
+import net.minecraftforge.common.ForgeConfigSpec.EnumValue;
+import org.apache.commons.lang3.tuple.Pair;
+
+public class CustomFoVConfig {
+
+  static final ForgeConfigSpec CONFIG_SPEC;
+  static final Config CONFIG;
+  private static final String CONFIG_PREFIX = "gui." + CustomFoV.MODID + ".config.";
+
+  static {
+    final Pair<Config, ForgeConfigSpec> specPair = new ForgeConfigSpec.Builder()
+        .configure(Config::new);
+    CONFIG_SPEC = specPair.getRight();
+    CONFIG = specPair.getLeft();
+  }
+
+  public static FovChangePermission fovChangePermission;
+  //Flying
+  public static double flyingModifier;
+  public static double flyingMax;
+  public static double flyingMin;
+  //Aiming
+  public static double aimingModifier;
+  public static double aimingMax;
+  public static double aimingMin;
+  //Sprinting
+  public static double sprintingModifier;
+  public static double sprintingMax;
+  public static double sprintingMin;
+  //Effects
+  public static double effectsModifier;
+  public static double effectsMax;
+  public static double effectsMin;
+  //Underwater
+  public static double underwaterModifier;
+  public static double underwaterMax;
+  public static double underwaterMin;
+
+  public static void bake() {
+    fovChangePermission = CONFIG.fovChangePermission.get();
+
+    flyingModifier = CONFIG.flyingModifier.get();
+    flyingMax = CONFIG.flyingMax.get();
+    flyingMin = CONFIG.flyingMin.get();
+
+    aimingModifier = CONFIG.aimingModifier.get();
+    aimingMax = CONFIG.aimingMax.get();
+    aimingMin = CONFIG.aimingMin.get();
+
+    sprintingModifier = CONFIG.sprintingModifier.get();
+    sprintingMax = CONFIG.sprintingMax.get();
+    sprintingMin = CONFIG.sprintingMin.get();
+
+    effectsModifier = CONFIG.effectsModifier.get();
+    effectsMax = CONFIG.effectsMax.get();
+    effectsMin = CONFIG.effectsMin.get();
+
+    underwaterModifier = CONFIG.underwaterModifier.get();
+    underwaterMax = CONFIG.underwaterMax.get();
+    underwaterMin = CONFIG.underwaterMin.get();
+  }
+
+  public static class Config {
+
+    final EnumValue<FovChangePermission> fovChangePermission;
+    //Flying
+    final DoubleValue flyingModifier;
+    final DoubleValue flyingMax;
+    final DoubleValue flyingMin;
+    //Aiming
+    final DoubleValue aimingModifier;
+    final DoubleValue aimingMax;
+    final DoubleValue aimingMin;
+    //Sprinting
+    final DoubleValue sprintingModifier;
+    final DoubleValue sprintingMax;
+    final DoubleValue sprintingMin;
+    //Effects
+    final DoubleValue effectsModifier;
+    final DoubleValue effectsMax;
+    final DoubleValue effectsMin;
+    //Underwater
+    final DoubleValue underwaterModifier;
+    final DoubleValue underwaterMax;
+    final DoubleValue underwaterMin;
+
+    public Config(ForgeConfigSpec.Builder builder) {
+
+      fovChangePermission = builder.comment(
+          "Determines which source is allowed to change FoV" + "\nNONE - No FoV changes allowed"
+              + "\nVANILLA - Only vanilla FoV changes will be applied"
+              + "\nMODDED - Only modded FoV changes will be applied"
+              + "\nALL - All FoV changes will be applied")
+          .translation(CONFIG_PREFIX + "fovChangePermission")
+          .defineEnum("fovChangePermission", FovChangePermission.ALL);
+
+      builder.push("flying");
+
+      flyingModifier = builder.comment("The modifier to multiply by the original FoV modifier")
+          .translation(CONFIG_PREFIX + "flyingModifier")
+          .defineInRange("flyingModifier", 1.0d, 0.0d, 10.0d);
+
+      flyingMax = builder.comment("The maximum FoV flying modifier value")
+          .translation(CONFIG_PREFIX + "flyingMax")
+          .defineInRange("flyingMax", 10.0d, -10.0d, 10.0d);
+
+      flyingMin = builder.comment("The minimum FoV flying modifier value")
+          .translation(CONFIG_PREFIX + "flyingMin")
+          .defineInRange("flyingMin", -10.0d, -10.0d, 10.0d);
+
+      builder.pop();
+
+      builder.push("aiming");
+
+      aimingModifier = builder.comment("The modifier to multiply by the original FoV modifier")
+          .translation(CONFIG_PREFIX + "aimingModifier")
+          .defineInRange("aimingModifier", 1.0d, 0.0d, 10.0d);
+
+      aimingMax = builder.comment("The maximum FoV aiming modifier value")
+          .translation(CONFIG_PREFIX + "aimingMax")
+          .defineInRange("aimingMax", 10.0d, -10.0d, 10.0d);
+
+      aimingMin = builder.comment("The minimum FoV aiming modifier value")
+          .translation(CONFIG_PREFIX + "aimingMin")
+          .defineInRange("aimingMin", -10.0d, -10.0d, 10.0d);
+
+      builder.pop();
+
+      builder.push("sprinting");
+
+      sprintingModifier = builder.comment("The modifier to multiply by the original FoV modifier")
+          .translation(CONFIG_PREFIX + "sprintingModifier")
+          .defineInRange("sprintingModifier", 1.0d, 0.0d, 10.0d);
+
+      sprintingMax = builder.comment("The maximum FoV sprinting modifier value")
+          .translation(CONFIG_PREFIX + "sprintingMax")
+          .defineInRange("sprintingMax", 10.0d, -10.0d, 10.0d);
+
+      sprintingMin = builder.comment("The minimum FoV sprinting modifier value")
+          .translation(CONFIG_PREFIX + "sprintingMin")
+          .defineInRange("sprintingMin", -10.0d, -10.0d, 10.0d);
+
+      builder.pop();
+
+      builder.push("speedEffects");
+
+      effectsModifier = builder.comment("The modifier to multiply by the original FoV modifier")
+          .translation(CONFIG_PREFIX + "effectsModifier")
+          .defineInRange("effectsModifier", 1.0d, 0.0d, 10.0d);
+
+      effectsMax = builder.comment("The maximum FoV effects modifier value")
+          .translation(CONFIG_PREFIX + "effectsMax")
+          .defineInRange("effectsMax", 10.0d, -10.0d, 10.0d);
+
+      effectsMin = builder.comment("The minimum FoV effects modifier value")
+          .translation(CONFIG_PREFIX + "effectsMin")
+          .defineInRange("effectsMin", -10.0d, -10.0d, 10.0d);
+
+      builder.pop();
+
+      builder.push("underwater");
+
+      underwaterModifier = builder.comment("The modifier to multiply by the original FoV modifier")
+          .translation(CONFIG_PREFIX + "underwaterModifier")
+          .defineInRange("underwaterModifier", 1.0d, 0.0d, 10.0d);
+
+      underwaterMax = builder.comment("The maximum FoV underwater modifier value")
+          .translation(CONFIG_PREFIX + "underwaterMax")
+          .defineInRange("underwaterMax", 10.0d, -10.0d, 10.0d);
+
+      underwaterMin = builder.comment("The minimum FoV underwater modifier value")
+          .translation(CONFIG_PREFIX + "underwaterMin")
+          .defineInRange("underwaterMin", -10.0d, -10.0d, 10.0d);
+
+      builder.pop();
+    }
+  }
+
+  public enum FovChangePermission {
+    NONE, VANILLA, MODDED, ALL
+  }
+}

+ 141 - 0
src/main/java/top/theillusivec4/customfov/CustomFoVEventHandler.java

@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2018-2019  C4
+ *
+ * This file is part of CustomFoV, a mod made for Minecraft.
+ *
+ * CustomFoV is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * CustomFoV is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with CustomFoV.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package top.theillusivec4.customfov;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.entity.ai.attributes.Attributes;
+import net.minecraft.entity.ai.attributes.ModifiableAttributeInstance;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.fluid.FluidState;
+import net.minecraft.item.Items;
+import net.minecraft.util.math.MathHelper;
+import net.minecraftforge.client.event.EntityViewRenderEvent;
+import net.minecraftforge.client.event.FOVUpdateEvent;
+import net.minecraftforge.eventbus.api.EventPriority;
+import net.minecraftforge.eventbus.api.SubscribeEvent;
+import top.theillusivec4.customfov.CustomFoVConfig.FovChangePermission;
+
+public class CustomFoVEventHandler {
+
+  private static float fovModifier;
+
+  @SubscribeEvent(priority = EventPriority.HIGHEST)
+  public void foVUpdatePre(FOVUpdateEvent evt) {
+
+    if (CustomFoVConfig.fovChangePermission != FovChangePermission.NONE) {
+
+      if (CustomFoVConfig.fovChangePermission == FovChangePermission.MODDED) {
+        evt.setNewfov(1.0F);
+      } else {
+        fovModifier = getNewFovModifier();
+        evt.setNewfov(fovModifier);
+      }
+    }
+  }
+
+  @SubscribeEvent(priority = EventPriority.LOWEST)
+  public void fovUpdatePost(FOVUpdateEvent evt) {
+
+    if (CustomFoVConfig.fovChangePermission == FovChangePermission.NONE) {
+      evt.setNewfov(1.0F);
+    } else if (CustomFoVConfig.fovChangePermission == FovChangePermission.VANILLA) {
+      evt.setNewfov(fovModifier);
+    }
+  }
+
+  @SubscribeEvent(priority = EventPriority.HIGHEST)
+  public void onFoVModifier(EntityViewRenderEvent.FOVModifier evt) {
+    FluidState fluidstate = evt.getInfo().getFluidState();
+
+    if (fluidstate.isEmpty()) {
+      return;
+    }
+    float originalModifier = 60.0F / 70.0F;
+    double originalFOV = evt.getFOV() / originalModifier;
+
+    if (CustomFoVConfig.fovChangePermission == FovChangePermission.NONE
+        || CustomFoVConfig.fovChangePermission == FovChangePermission.MODDED) {
+      evt.setFOV(originalFOV);
+    } else {
+      evt.setFOV(originalFOV * (1.0F - getConfiguredValue((1.0F - originalModifier),
+          CustomFoVConfig.underwaterModifier, CustomFoVConfig.underwaterMax,
+          CustomFoVConfig.underwaterMin)));
+    }
+  }
+
+  private float getNewFovModifier() {
+    PlayerEntity player = Minecraft.getInstance().player;
+    float modifier = 1.0F;
+
+    if (player == null) {
+      return 0.0F;
+    }
+
+    if (player.abilities.isFlying) {
+      modifier *=
+          1.0F + getConfiguredValue(0.1F, CustomFoVConfig.flyingModifier, CustomFoVConfig.flyingMax,
+              CustomFoVConfig.flyingMin);
+    }
+    ModifiableAttributeInstance attribute = player.getAttribute(Attributes.field_233821_d_);
+
+    if (attribute != null) {
+      float speedModifier = (float) (
+          (attribute.getValue() / (double) player.abilities.getWalkSpeed() + 1.0D) / 2.0D);
+      float value = (float) attribute.getValue();
+      float effPercent = Math.abs(
+          (value / (player.isSprinting() ? 1.3F : 1.0F) - player.abilities.getWalkSpeed()) / (value
+              - player.abilities.getWalkSpeed()));
+      float configModifier = getConfiguredValue(effPercent * (speedModifier - 1),
+          CustomFoVConfig.effectsModifier, CustomFoVConfig.effectsMax, CustomFoVConfig.effectsMin);
+
+      if (player.isSprinting()) {
+        float sprintPercent = 1.0F - effPercent;
+        float sprintModifier = getConfiguredValue(sprintPercent * (speedModifier - 1),
+            CustomFoVConfig.sprintingModifier, CustomFoVConfig.sprintingMax,
+            CustomFoVConfig.sprintingMin);
+        configModifier += sprintModifier;
+      }
+      modifier = (float) ((double) modifier * (1.0D + configModifier));
+    }
+
+    if (player.abilities.getWalkSpeed() == 0.0F || Float.isNaN(modifier) || Float
+        .isInfinite(modifier)) {
+      modifier = 1.0F;
+    }
+
+    if (player.isHandActive() && player.getActiveItemStack().getItem() == Items.BOW) {
+      int i = player.getItemInUseMaxCount();
+      float f1 = (float) i / 20.0F;
+
+      if (f1 > 1.0F) {
+        f1 = 1.0F;
+      } else {
+        f1 = f1 * f1;
+      }
+      modifier *= 1.0F - getConfiguredValue(f1 * 0.15F, CustomFoVConfig.aimingModifier,
+          CustomFoVConfig.aimingMax, CustomFoVConfig.aimingMin);
+    }
+    return modifier;
+  }
+
+  private float getConfiguredValue(float original, double modifier, double max, double min) {
+    return (float) MathHelper.clamp(original * modifier, min, max);
+  }
+}

+ 0 - 127
src/main/java/top/theillusivec4/customfov/core/EventHandlerFoV.java

@@ -1,127 +0,0 @@
-/*
- * Copyright (C) 2018-2019  C4
- *
- * This file is part of CustomFoV, a mod made for Minecraft.
- *
- * CustomFoV is free software: you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * CustomFoV is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with CustomFoV.  If not, see <https://www.gnu.org/licenses/>.
- */
-
-package top.theillusivec4.customfov.core;
-
-import net.minecraft.block.BlockState;
-import net.minecraft.block.material.Material;
-import net.minecraft.client.Minecraft;
-import net.minecraft.entity.SharedMonsterAttributes;
-import net.minecraft.entity.ai.attributes.IAttributeInstance;
-import net.minecraft.entity.player.PlayerEntity;
-import net.minecraft.fluid.IFluidState;
-import net.minecraft.item.Items;
-import net.minecraft.util.math.MathHelper;
-import net.minecraftforge.client.event.EntityViewRenderEvent;
-import net.minecraftforge.client.event.FOVUpdateEvent;
-import net.minecraftforge.eventbus.api.EventPriority;
-import net.minecraftforge.eventbus.api.SubscribeEvent;
-
-public class EventHandlerFoV {
-
-  @SubscribeEvent(priority = EventPriority.HIGHEST)
-  public void onFoVUpdatePre(FOVUpdateEvent evt) {
-    evt.setNewfov(FoVConfig.staticFoV.get() ? 1.0f : getNewFovModifier());
-  }
-
-  @SubscribeEvent(priority = EventPriority.LOWEST)
-  public void onFovUpdatePost(FOVUpdateEvent evt) {
-
-    if (FoVConfig.superStaticFoV.get()) {
-      evt.setNewfov(1.0F);
-    }
-  }
-
-  @SubscribeEvent(priority = EventPriority.HIGHEST)
-  public void onFoVModifier(EntityViewRenderEvent.FOVModifier evt) {
-    IFluidState ifluidstate = evt.getInfo().getFluidState();
-
-    if (ifluidstate.isEmpty()) {
-      return;
-    }
-    float originalModifier = 60.0F / 70.0F;
-    double originalFOV = evt.getFOV() / originalModifier;
-
-    if (FoVConfig.staticFoV.get() || FoVConfig.superStaticFoV.get()) {
-      evt.setFOV(originalFOV);
-      return;
-    }
-
-    evt.setFOV(originalFOV * (1.0F - getConfiguredValue((1.0F - originalModifier),
-        FoVConfig.underwaterModifier.get(),
-        FoVConfig.underwaterMax.get(), FoVConfig.underwaterMin.get())));
-  }
-
-  private float getNewFovModifier() {
-    PlayerEntity player = Minecraft.getInstance().player;
-    float modifier = 1.0F;
-
-    if (player.abilities.isFlying) {
-      modifier *=
-          1.0F + getConfiguredValue(0.1F, FoVConfig.flyingModifier.get(), FoVConfig.flyingMax.get(),
-              FoVConfig.flyingMin.get());
-    }
-    IAttributeInstance iattributeinstance = player
-        .getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);
-    float speedModifier = (float) (
-        (iattributeinstance.getValue() / (double) player.abilities.getWalkSpeed() + 1.0D) / 2.0D);
-    float value = (float) iattributeinstance.getValue();
-    float effPercent = Math
-        .abs((value / (player.isSprinting() ? 1.3F : 1.0F) - player.abilities.getWalkSpeed())
-            / (value - player.abilities.getWalkSpeed()));
-    float configModifier = getConfiguredValue(effPercent * (speedModifier - 1),
-        FoVConfig.effectsModifier.get(),
-        FoVConfig.effectsMax.get(), FoVConfig.effectsMin.get());
-
-    if (player.isSprinting()) {
-      float sprintPercent = 1.0F - effPercent;
-      float sprintModifier = getConfiguredValue(sprintPercent * (speedModifier - 1),
-          FoVConfig.sprintingModifier.get(),
-          FoVConfig.sprintingMax.get(), FoVConfig.sprintingMin.get());
-      configModifier += sprintModifier;
-    }
-
-    modifier = (float) ((double) modifier * (1.0D + configModifier));
-
-    if (player.abilities.getWalkSpeed() == 0.0F || Float.isNaN(modifier) || Float
-        .isInfinite(modifier)) {
-      modifier = 1.0F;
-    }
-
-    if (player.isHandActive() && player.getActiveItemStack().getItem() == Items.BOW) {
-      int i = player.getItemInUseMaxCount();
-      float f1 = (float) i / 20.0F;
-
-      if (f1 > 1.0F) {
-        f1 = 1.0F;
-      } else {
-        f1 = f1 * f1;
-      }
-      modifier *= 1.0F - getConfiguredValue(f1 * 0.15F, FoVConfig.aimingModifier.get(),
-          FoVConfig.aimingMax.get(),
-          FoVConfig.aimingMin.get());
-    }
-
-    return modifier;
-  }
-
-  private float getConfiguredValue(float original, double modifier, double max, double min) {
-    return (float) MathHelper.clamp(original * modifier, min, max);
-  }
-}

+ 0 - 177
src/main/java/top/theillusivec4/customfov/core/FoVConfig.java

@@ -1,177 +0,0 @@
-/*
- * Copyright (C) 2018-2019  C4
- *
- * This file is part of CustomFoV, a mod made for Minecraft.
- *
- * CustomFoV is free software: you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published
- * by the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * CustomFoV is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with CustomFoV.  If not, see <https://www.gnu.org/licenses/>.
- */
-
-package top.theillusivec4.customfov.core;
-
-import net.minecraftforge.common.ForgeConfigSpec;
-import net.minecraftforge.common.ForgeConfigSpec.BooleanValue;
-import net.minecraftforge.common.ForgeConfigSpec.Builder;
-import net.minecraftforge.common.ForgeConfigSpec.DoubleValue;
-import top.theillusivec4.customfov.CustomFoV;
-
-public class FoVConfig {
-
-  public static final ForgeConfigSpec spec;
-  static final BooleanValue staticFoV;
-  static final BooleanValue superStaticFoV;
-  //Flying
-  static final DoubleValue flyingModifier;
-  static final DoubleValue flyingMax;
-  static final DoubleValue flyingMin;
-  //Aiming
-  static final DoubleValue aimingModifier;
-  static final DoubleValue aimingMax;
-  static final DoubleValue aimingMin;
-  //Sprinting
-  static final DoubleValue sprintingModifier;
-  static final DoubleValue sprintingMax;
-  static final DoubleValue sprintingMin;
-  //Effects
-  static final DoubleValue effectsModifier;
-  static final DoubleValue effectsMax;
-  static final DoubleValue effectsMin;
-  //Underwater
-  static final DoubleValue underwaterModifier;
-  static final DoubleValue underwaterMax;
-  static final DoubleValue underwaterMin;
-  private static final String CONFIG_PREFIX = "gui." + CustomFoV.MODID + ".config.";
-
-  static {
-    Builder builder = new Builder();
-
-    {
-      staticFoV = builder
-          .comment("Set to true to disable all vanilla FoV modifiers")
-          .translation(CONFIG_PREFIX + "staticFoV")
-          .define("staticFoV", false);
-
-      superStaticFoV = builder
-          .comment("Set to true to disable all FoV modifiers, including modded ones")
-          .translation(CONFIG_PREFIX + "superStaticFoV")
-          .define("superStaticFoV", false);
-    }
-
-    {
-      builder.push("Flying");
-
-      flyingModifier = builder
-          .comment("The modifier to multiply by the original FoV modifier")
-          .translation(CONFIG_PREFIX + "flyingModifier")
-          .defineInRange("flyingModifier", 1.0d, 0.0d, 10.0d);
-
-      flyingMax = builder
-          .comment("The maximum FoV flying modifier value")
-          .translation(CONFIG_PREFIX + "flyingMax")
-          .defineInRange("flyingMax", 10.0d, -10.0d, 10.0d);
-
-      flyingMin = builder
-          .comment("The minimum FoV flying modifier value")
-          .translation(CONFIG_PREFIX + "flyingMin")
-          .defineInRange("flyingMin", -10.0d, -10.0d, 10.0d);
-
-      builder.pop();
-    }
-
-    {
-      builder.push("Aiming");
-
-      aimingModifier = builder
-          .comment("The modifier to multiply by the original FoV modifier")
-          .translation(CONFIG_PREFIX + "aimingModifier")
-          .defineInRange("aimingModifier", 1.0d, 0.0d, 10.0d);
-
-      aimingMax = builder
-          .comment("The maximum FoV aiming modifier value")
-          .translation(CONFIG_PREFIX + "aimingMax")
-          .defineInRange("aimingMax", 10.0d, -10.0d, 10.0d);
-
-      aimingMin = builder
-          .comment("The minimum FoV aiming modifier value")
-          .translation(CONFIG_PREFIX + "aimingMin")
-          .defineInRange("aimingMin", -10.0d, -10.0d, 10.0d);
-
-      builder.pop();
-    }
-
-    {
-      builder.push("Sprinting");
-
-      sprintingModifier = builder
-          .comment("The modifier to multiply by the original FoV modifier")
-          .translation(CONFIG_PREFIX + "sprintingModifier")
-          .defineInRange("sprintingModifier", 1.0d, 0.0d, 10.0d);
-
-      sprintingMax = builder
-          .comment("The maximum FoV sprinting modifier value")
-          .translation(CONFIG_PREFIX + "sprintingMax")
-          .defineInRange("sprintingMax", 10.0d, -10.0d, 10.0d);
-
-      sprintingMin = builder
-          .comment("The minimum FoV sprinting modifier value")
-          .translation(CONFIG_PREFIX + "sprintingMin")
-          .defineInRange("sprintingMin", -10.0d, -10.0d, 10.0d);
-
-      builder.pop();
-    }
-
-    {
-      builder.push("Speed Effects");
-
-      effectsModifier = builder
-          .comment("The modifier to multiply by the original FoV modifier")
-          .translation(CONFIG_PREFIX + "effectsModifier")
-          .defineInRange("effectsModifier", 1.0d, 0.0d, 10.0d);
-
-      effectsMax = builder
-          .comment("The maximum FoV effects modifier value")
-          .translation(CONFIG_PREFIX + "effectsMax")
-          .defineInRange("effectsMax", 10.0d, -10.0d, 10.0d);
-
-      effectsMin = builder
-          .comment("The minimum FoV effects modifier value")
-          .translation(CONFIG_PREFIX + "effectsMin")
-          .defineInRange("effectsMin", -10.0d, -10.0d, 10.0d);
-
-      builder.pop();
-    }
-
-    {
-      builder.push("Underwater");
-
-      underwaterModifier = builder
-          .comment("The modifier to multiply by the original FoV modifier")
-          .translation(CONFIG_PREFIX + "underwaterModifier")
-          .defineInRange("underwaterModifier", 1.0d, 0.0d, 10.0d);
-
-      underwaterMax = builder
-          .comment("The maximum FoV underwater modifier value")
-          .translation(CONFIG_PREFIX + "underwaterMax")
-          .defineInRange("underwaterMax", 10.0d, -10.0d, 10.0d);
-
-      underwaterMin = builder
-          .comment("The minimum FoV underwater modifier value")
-          .translation(CONFIG_PREFIX + "underwaterMin")
-          .defineInRange("underwaterMin", -10.0d, -10.0d, 10.0d);
-
-      builder.pop();
-    }
-
-    spec = builder.build();
-  }
-}

+ 3 - 3
src/main/resources/META-INF/mods.toml

@@ -1,5 +1,5 @@
 modLoader="javafml"
-loaderVersion="[31,)"
+loaderVersion="[32,)"
 issueTrackerURL="https://github.com/TheIllusiveC4/CustomFoV/issues"
 logoFile="${mod_icon}"
 [[mods]]
@@ -14,12 +14,12 @@ ${mod_description}
 [[dependencies.customfov]]
     modId="forge"
     mandatory=true
-    versionRange="[31,)"
+    versionRange="[32,)"
     ordering="NONE"
     side="CLIENT"
 [[dependencies.customfov]]
     modId="minecraft"
     mandatory=true
-    versionRange="[1.15.2,1.16)"
+    versionRange="[1.16.1,1.17)"
     ordering="NONE"
     side="CLIENT"