Adds support for configuring the timings via Clith Config and Mod Menu.
This commit is contained in:
@@ -11,11 +11,8 @@ version = project.mod_version + "-" + project.minecraft_version + "-fabric"
|
||||
group = project.maven_group
|
||||
|
||||
repositories {
|
||||
// Add repositories to retrieve artifacts from in here.
|
||||
// You should only use this when depending on other mods because
|
||||
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
||||
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
||||
// for more information about repositories.
|
||||
maven { url "https://maven.shedaniel.me/" }
|
||||
maven { url "https://maven.terraformersmc.com/" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -26,6 +23,8 @@ dependencies {
|
||||
|
||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
modApi "me.shedaniel.cloth:cloth-config-fabric:${project.cloth_version}"
|
||||
modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}"
|
||||
|
||||
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
|
||||
// You may need to force-disable transitiveness on them.
|
||||
|
||||
@@ -7,6 +7,9 @@ org.gradle.jvmargs=-Xmx1G
|
||||
yarn_mappings=1.16.4+build.9
|
||||
loader_version=0.11.1
|
||||
|
||||
cloth_version=4.11.14
|
||||
modmenu_version=1.16.8
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 0.1
|
||||
maven_group = markil3
|
||||
|
||||
326
src/main/java/markil3/immersive_hud/ConfigManager.java
Normal file
326
src/main/java/markil3/immersive_hud/ConfigManager.java
Normal file
@@ -0,0 +1,326 @@
|
||||
package markil3.immersive_hud;
|
||||
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import me.shedaniel.autoconfig.AutoConfig;
|
||||
import me.shedaniel.autoconfig.ConfigData;
|
||||
import me.shedaniel.autoconfig.annotation.Config;
|
||||
import me.shedaniel.autoconfig.annotation.ConfigEntry;
|
||||
|
||||
import static markil3.immersive_hud.Main.TICKS_PER_SECOND;
|
||||
|
||||
/**
|
||||
* Configuration manager of this mod, which reads from and writes to this mod's
|
||||
* configuration file.
|
||||
* <p>
|
||||
* The methods that change this mod's configuration do not automatically write
|
||||
* those changes to the configuration file on disk. Instead, they only update
|
||||
* the configuration in memory. To write any changes, use the {@link #save()}
|
||||
* method.
|
||||
*
|
||||
* @author Markil 3
|
||||
*/
|
||||
@Config(name = "immersive_hud")
|
||||
public class ConfigManager implements ConfigData
|
||||
{
|
||||
public static class TimeValues
|
||||
{
|
||||
private static final int SHOW_TIME = 6 * TICKS_PER_SECOND;
|
||||
private static final int FADE_IN = TICKS_PER_SECOND / 2;
|
||||
private static final int FADE_OUT = TICKS_PER_SECOND;
|
||||
|
||||
@ConfigEntry.Gui.Excluded
|
||||
private final String name;
|
||||
private int maxTime = SHOW_TIME;
|
||||
private int fadeIn = FADE_IN;
|
||||
private int fadeOut = FADE_OUT;
|
||||
|
||||
TimeValues(String name)
|
||||
{
|
||||
final int MAX_TIME = 10 * 60 * TICKS_PER_SECOND;
|
||||
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the maximum time that the hotbar can be on the screen,
|
||||
* including fading.
|
||||
*
|
||||
* @return The maximum hotbar display time.
|
||||
*/
|
||||
public int getMaxTime()
|
||||
{
|
||||
return this.maxTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the time that the hotbar takes to fade in.
|
||||
*
|
||||
* @return The hotbar fade in time.
|
||||
*/
|
||||
public int getFadeInTime()
|
||||
{
|
||||
return this.fadeIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the time that the hotbar takes to fade out.
|
||||
*
|
||||
* @return The hotbar fade out time.
|
||||
*/
|
||||
public int getFadeOutTime()
|
||||
{
|
||||
return this.fadeOut;
|
||||
}
|
||||
|
||||
public void setMaxTime(int time)
|
||||
{
|
||||
this.maxTime = time;
|
||||
}
|
||||
|
||||
public void setFadeInTime(int time)
|
||||
{
|
||||
this.fadeIn = time;
|
||||
}
|
||||
|
||||
public void setFadeOutTime(int time)
|
||||
{
|
||||
this.fadeOut = time;
|
||||
}
|
||||
}
|
||||
|
||||
@ConfigEntry.Gui.TransitiveObject
|
||||
@ConfigEntry.Gui.Tooltip
|
||||
@ConfigEntry.Gui.PrefixText
|
||||
private TimeValues hotbarTime = new TimeValues("hotbar");
|
||||
@ConfigEntry.Gui.TransitiveObject
|
||||
@ConfigEntry.Gui.Tooltip
|
||||
@ConfigEntry.Gui.PrefixText
|
||||
private TimeValues experienceTime = new TimeValues("experience");
|
||||
@ConfigEntry.Gui.TransitiveObject
|
||||
@ConfigEntry.Gui.Tooltip
|
||||
@ConfigEntry.Gui.PrefixText
|
||||
private TimeValues jumpTime = new TimeValues("jump");
|
||||
@ConfigEntry.Gui.TransitiveObject
|
||||
@ConfigEntry.Gui.Tooltip
|
||||
@ConfigEntry.Gui.PrefixText
|
||||
private TimeValues healthTime = new TimeValues("health");
|
||||
@ConfigEntry.Gui.TransitiveObject
|
||||
@ConfigEntry.Gui.Tooltip
|
||||
@ConfigEntry.Gui.PrefixText
|
||||
private TimeValues hungerTime = new TimeValues("hunger");
|
||||
@ConfigEntry.Gui.TransitiveObject
|
||||
@ConfigEntry.Gui.Tooltip
|
||||
@ConfigEntry.Gui.PrefixText
|
||||
private TimeValues effectTime = new TimeValues("effect");
|
||||
@ConfigEntry.Gui.Tooltip
|
||||
@ConfigEntry.Gui.PrefixText
|
||||
private int crosshairTime = 6 * TICKS_PER_SECOND;
|
||||
@ConfigEntry.Gui.Tooltip
|
||||
@ConfigEntry.Gui.PrefixText
|
||||
private int handTime = 30 * TICKS_PER_SECOND;
|
||||
@ConfigEntry.Gui.Tooltip
|
||||
@ConfigEntry.Gui.PrefixText
|
||||
private boolean showArmor = true;
|
||||
@ConfigEntry.Gui.Tooltip
|
||||
@ConfigEntry.Gui.PrefixText
|
||||
private double minHealth = 0.5;
|
||||
@ConfigEntry.Gui.Tooltip
|
||||
@ConfigEntry.Gui.PrefixText
|
||||
@ConfigEntry.BoundedDiscrete(max = 20)
|
||||
private int minHunger = 17;
|
||||
|
||||
/**
|
||||
* Returns the instance of this class.
|
||||
*
|
||||
* @return the instance of this class
|
||||
*/
|
||||
public static ConfigManager getInstance()
|
||||
{
|
||||
return AutoConfig.getConfigHolder(ConfigManager.class).getConfig();
|
||||
}
|
||||
|
||||
// Validations
|
||||
|
||||
/**
|
||||
* Obtains time values related to the hotbar.
|
||||
*
|
||||
* @return The hotbar display time values.
|
||||
*/
|
||||
public TimeValues getHotbarTime()
|
||||
{
|
||||
return this.hotbarTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains time values related to the experience bar.
|
||||
*
|
||||
* @return The experience bar display time values.
|
||||
*/
|
||||
public TimeValues getExperienceTime()
|
||||
{
|
||||
return this.experienceTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains time values related to the jump bar.
|
||||
*
|
||||
* @return The jump display time values.
|
||||
*/
|
||||
public TimeValues getJumpTime()
|
||||
{
|
||||
return this.jumpTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains time values related to the health bar.
|
||||
*
|
||||
* @return The health display time values.
|
||||
*/
|
||||
public TimeValues getHealthTime()
|
||||
{
|
||||
return this.healthTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains time values related to the hunger bar.
|
||||
*
|
||||
* @return The hunger display time values.
|
||||
*/
|
||||
public TimeValues getHungerTime()
|
||||
{
|
||||
return this.hungerTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains time values related to potion effects.
|
||||
*
|
||||
* @return Potion display time values.
|
||||
*/
|
||||
public TimeValues getPotionTime()
|
||||
{
|
||||
return this.effectTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the time that the crosshairs are allowed to display.
|
||||
*
|
||||
* @return The crosshair display time values.
|
||||
*/
|
||||
public int getCrosshairTime()
|
||||
{
|
||||
return this.crosshairTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the time that the hands are allowed to display.
|
||||
*
|
||||
* @return The hand display time values.
|
||||
*/
|
||||
public int getHandTime()
|
||||
{
|
||||
return this.handTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the armor bar should render.
|
||||
*
|
||||
* @return Whether or not armor shows on the HUD.
|
||||
*/
|
||||
public boolean shouldShowArmor()
|
||||
{
|
||||
return this.showArmor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the minimum health for fading. Anything below that and the health
|
||||
* always displays.
|
||||
*
|
||||
* @return The health boundary, from 0 to 1.
|
||||
*/
|
||||
public double getMinHealth()
|
||||
{
|
||||
return this.minHealth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the minimum hunger for fading. Anything below that and the hunger
|
||||
* always displays.
|
||||
*
|
||||
* @return The hunger boundary, from 0 to 20.
|
||||
*/
|
||||
public int getMinHunger()
|
||||
{
|
||||
return this.minHunger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the time that the hands are allowed to display.
|
||||
*
|
||||
* @param time - The hand display time values.
|
||||
*/
|
||||
public void setCrosshairTime(int time)
|
||||
{
|
||||
this.crosshairTime = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the time that the hands are allowed to display.
|
||||
*
|
||||
* @param time - The hand display time values.
|
||||
*/
|
||||
public void setHandTime(int time)
|
||||
{
|
||||
this.handTime = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the armor bar should render.
|
||||
*
|
||||
* @param show - Whether or not armor shows on the HUD.
|
||||
*/
|
||||
public void shouldShowArmor(boolean show)
|
||||
{
|
||||
this.showArmor = show;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the minimum health for fading. Anything below that and the health
|
||||
* always displays.
|
||||
*
|
||||
* @param boundary - The health boundary, from 0 to 1.
|
||||
*/
|
||||
public void setMinHealth(double boundary)
|
||||
{
|
||||
this.minHealth = MathHelper.clamp(boundary, 0, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the minimum hunger for fading. Anything below that and the hunger
|
||||
* always displays.
|
||||
*
|
||||
* @param boundary - The hunger boundary, from 0 to 20.
|
||||
*/
|
||||
public void setMinHunger(int boundary)
|
||||
{
|
||||
this.minHunger = MathHelper.clamp(boundary, 0, 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validatePostLoad() throws ValidationException
|
||||
{
|
||||
this.setMinHealth(this.minHealth);
|
||||
}
|
||||
/**
|
||||
* Saves changes to this mod's configuration.
|
||||
*/
|
||||
// public void save()
|
||||
// {
|
||||
// SPEC.save();
|
||||
// }
|
||||
}
|
||||
@@ -17,9 +17,18 @@
|
||||
*/
|
||||
package markil3.immersive_hud;
|
||||
|
||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.minecraft.client.gui.DrawableHelper;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
|
||||
import me.shedaniel.autoconfig.AutoConfig;
|
||||
import me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer;
|
||||
import me.shedaniel.clothconfig2.api.ConfigBuilder;
|
||||
import me.shedaniel.clothconfig2.api.ConfigCategory;
|
||||
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
|
||||
import me.shedaniel.clothconfig2.gui.entries.DoubleListEntry;
|
||||
|
||||
/**
|
||||
* The main entry point for the Immersive HUD mod.
|
||||
@@ -27,11 +36,158 @@ import net.minecraft.client.util.math.MatrixStack;
|
||||
* @author Markil 3
|
||||
* @version 0.1-1.16.4-fabric
|
||||
*/
|
||||
public class Main implements ModInitializer
|
||||
public class Main implements ModInitializer, ModMenuApi
|
||||
{
|
||||
public static final int TICKS_PER_SECOND = 20;
|
||||
|
||||
@Override
|
||||
public void onInitialize()
|
||||
{
|
||||
AutoConfig.register(ConfigManager.class, Toml4jConfigSerializer::new);
|
||||
}
|
||||
|
||||
private void startTimeField(ConfigEntryBuilder entryBuilder,
|
||||
ConfigCategory cat,
|
||||
ConfigManager.TimeValues value)
|
||||
{
|
||||
final float SHOW_TIME = 6;
|
||||
final float FADE_IN = 0.25F;
|
||||
final float FADE_OUT = 0.5F;
|
||||
|
||||
DoubleListEntry maxTime =
|
||||
entryBuilder.startDoubleField(new TranslatableText(
|
||||
"option.immersive_hud." + value.getName() +
|
||||
"MaxTime"),
|
||||
(float) value.getMaxTime() / TICKS_PER_SECOND)
|
||||
.setDefaultValue(SHOW_TIME)
|
||||
.setMin(0)
|
||||
.setMax(10 * 60 * TICKS_PER_SECOND) // 10 Minutes
|
||||
.setTooltip(new TranslatableText(
|
||||
"tooltip.immersive_hud." + value.getName() +
|
||||
"MaxTime"))
|
||||
.setSaveConsumer(val -> value.setMaxTime((int) (val * TICKS_PER_SECOND)))
|
||||
.build();
|
||||
|
||||
DoubleListEntry fadeIn =
|
||||
entryBuilder.startDoubleField(new TranslatableText(
|
||||
"option.immersive_hud." + value.getName() +
|
||||
"FadeIn"),
|
||||
(float) value.getFadeInTime() / TICKS_PER_SECOND)
|
||||
.setDefaultValue(FADE_IN)
|
||||
.setMin(0)
|
||||
.setMax(10 * 60 * TICKS_PER_SECOND)
|
||||
.setTooltip(new TranslatableText(
|
||||
"tooltip.immersive_hud." + value.getName() +
|
||||
"FadeIn"))
|
||||
.setSaveConsumer(val -> value.setFadeInTime((int) (val * TICKS_PER_SECOND)))
|
||||
.build();
|
||||
|
||||
DoubleListEntry fadeOut =
|
||||
entryBuilder.startDoubleField(new TranslatableText(
|
||||
"option.immersive_hud." + value.getName() +
|
||||
"FadeOut"),
|
||||
(float) value.getFadeOutTime() / TICKS_PER_SECOND)
|
||||
.setDefaultValue(FADE_OUT)
|
||||
.setMin(0)
|
||||
.setMax(10 * 60 * TICKS_PER_SECOND)
|
||||
.setTooltip(new TranslatableText(
|
||||
"tooltip.immersive_hud." + value.getName() +
|
||||
"FadeOut"))
|
||||
.setSaveConsumer(val -> value.setFadeOutTime((int) (val * TICKS_PER_SECOND)))
|
||||
.build();
|
||||
|
||||
cat.addEntry(maxTime);
|
||||
cat.addEntry(fadeIn);
|
||||
cat.addEntry(fadeOut);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigScreenFactory<?> getModConfigScreenFactory()
|
||||
{
|
||||
return screen -> {
|
||||
ConfigCategory general;
|
||||
ConfigEntryBuilder entryBuilder;
|
||||
ConfigManager instance = ConfigManager.getInstance();
|
||||
final ConfigBuilder builder = ConfigBuilder.create()
|
||||
.setParentScreen(screen)
|
||||
.setTitle(new TranslatableText(
|
||||
"immersive_hud.configGui.title"))
|
||||
.setSavingRunnable(() -> {
|
||||
AutoConfig.getConfigHolder(ConfigManager.class).save();
|
||||
});
|
||||
general =
|
||||
builder.getOrCreateCategory(new TranslatableText(
|
||||
"category.immersive_hud.general"));
|
||||
entryBuilder = builder.entryBuilder();
|
||||
|
||||
startTimeField(entryBuilder,
|
||||
general,
|
||||
instance.getHotbarTime());
|
||||
startTimeField(entryBuilder,
|
||||
general,
|
||||
instance.getExperienceTime());
|
||||
startTimeField(entryBuilder,
|
||||
general,
|
||||
instance.getJumpTime());
|
||||
startTimeField(entryBuilder,
|
||||
general,
|
||||
instance.getHealthTime());
|
||||
startTimeField(entryBuilder,
|
||||
general,
|
||||
instance.getHungerTime());
|
||||
startTimeField(entryBuilder,
|
||||
general,
|
||||
instance.getPotionTime());
|
||||
|
||||
general.addEntry(entryBuilder.startDoubleField(new TranslatableText(
|
||||
"option.immersive_hud" +
|
||||
".crosshairTime"),
|
||||
(float) instance.getCrosshairTime() / TICKS_PER_SECOND)
|
||||
.setDefaultValue(6)
|
||||
.setTooltip(new TranslatableText(
|
||||
"tooltip.immersive_hud" +
|
||||
".crosshairTime"))
|
||||
.setSaveConsumer(val -> instance.setCrosshairTime((int) (val * TICKS_PER_SECOND)))
|
||||
.build());
|
||||
|
||||
general.addEntry(entryBuilder.startDoubleField(new TranslatableText(
|
||||
"option.immersive_hud.handTime"),
|
||||
(float) instance.getHandTime() / TICKS_PER_SECOND)
|
||||
.setDefaultValue(30)
|
||||
.setTooltip(new TranslatableText(
|
||||
"tooltip.immersive_hud.handTime"))
|
||||
.setSaveConsumer(val -> instance.setHandTime((int) (val * TICKS_PER_SECOND)))
|
||||
.build());
|
||||
|
||||
general.addEntry(entryBuilder.startDoubleField(new TranslatableText(
|
||||
"option.immersive_hud.minHealth"),
|
||||
instance.getMinHealth())
|
||||
.setDefaultValue(0.5)
|
||||
.setTooltip(new TranslatableText(
|
||||
"tooltip.immersive_hud.minHealth"))
|
||||
.setSaveConsumer(val -> instance.setMinHealth(val))
|
||||
.build());
|
||||
|
||||
general.addEntry(entryBuilder.startIntField(new TranslatableText(
|
||||
"option.immersive_hud.minHunger"),
|
||||
instance.getMinHunger())
|
||||
.setDefaultValue(17)
|
||||
.setTooltip(new TranslatableText(
|
||||
"tooltip.immersive_hud.minHunger"))
|
||||
.setSaveConsumer(val -> instance.setMinHunger(val))
|
||||
.build());
|
||||
|
||||
general.addEntry(entryBuilder.startBooleanToggle(new TranslatableText(
|
||||
"option.immersive_hud.showArmor"),
|
||||
instance.shouldShowArmor())
|
||||
.setDefaultValue(true)
|
||||
.setTooltip(new TranslatableText(
|
||||
"tooltip.immersive_hud.showArmor"))
|
||||
.setSaveConsumer(val -> instance.shouldShowArmor(val))
|
||||
.build());
|
||||
|
||||
return builder.build();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,9 +201,16 @@ public class Main implements ModInitializer
|
||||
*
|
||||
* @since 0.1-1.16.4-fabric
|
||||
*/
|
||||
static float getAlpha(int renderTime)
|
||||
static float getAlpha(double renderTime, double maxTime, double fadeInTime, double fadeOutTime)
|
||||
{
|
||||
return Math.min(renderTime / 20.0F,
|
||||
1.0F);
|
||||
if (renderTime <= fadeOutTime)
|
||||
{
|
||||
return (float) (renderTime / fadeOutTime);
|
||||
}
|
||||
else if (renderTime > maxTime - fadeInTime)
|
||||
{
|
||||
return (float) ((maxTime - renderTime) / fadeInTime);
|
||||
}
|
||||
return 1F;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,9 +45,6 @@ import net.minecraft.util.hit.EntityHitResult;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@@ -61,33 +58,17 @@ import java.util.Optional;
|
||||
*/
|
||||
public class TimerUtils
|
||||
{
|
||||
/**
|
||||
* The number of ticks that the hand will be onscreen. Every tick is 1/20th
|
||||
* of a second.
|
||||
*/
|
||||
private static final int HAND_TIME = 10 * 20;
|
||||
/**
|
||||
* The number of ticks most elements will be onscreen. Every tick is 1/20th
|
||||
* of a second.
|
||||
*/
|
||||
private static final int VISUAL_TIME = 6 * 20;
|
||||
/**
|
||||
* The number of ticks that the health and hunger bars will be onscreen.
|
||||
* Every tick is 1/20th of a second.
|
||||
*/
|
||||
private static final int HEALTH_TIME = (int) ((float) VISUAL_TIME * 2.5);
|
||||
|
||||
/**
|
||||
* How many more ticks the hand will be onscreen. Every tick is 1/20th of a
|
||||
* second.
|
||||
*/
|
||||
private static int mainHandTime, offHandTime;
|
||||
private static double mainHandTime, offHandTime;
|
||||
|
||||
/**
|
||||
* How many more ticks the crosshair will be onscreen. Every tick is 1/20th
|
||||
* of a second.
|
||||
*/
|
||||
private static int crosshairTime;
|
||||
private static double crosshairTime;
|
||||
/**
|
||||
* If true, then the hand (and crosshairs) will be locked onto the screen
|
||||
* without disappearing until this flag is updated.
|
||||
@@ -100,13 +81,13 @@ public class TimerUtils
|
||||
*/
|
||||
private static int mapLock;
|
||||
|
||||
private static HashMap<StatusEffect, Integer> effectTime = new HashMap<>();
|
||||
private static HashMap<StatusEffect, Double> effectTime = new HashMap<>();
|
||||
|
||||
/**
|
||||
* How many more ticks the hotbar will be onscreen. Every tick is 1/20th of
|
||||
* a second.
|
||||
*/
|
||||
private static int hotbarTime;
|
||||
private static double hotbarTime;
|
||||
/**
|
||||
* The last hotbar slot that was selected. This is used to check for a
|
||||
* change in the hotbar slot.
|
||||
@@ -122,7 +103,7 @@ public class TimerUtils
|
||||
* How many more ticks the health bar will be onscreen. Every tick is 1/20th
|
||||
* of a second.
|
||||
*/
|
||||
private static int healthTime;
|
||||
private static double healthTime;
|
||||
/**
|
||||
* Records what the health was previously. Used to check for a change in the
|
||||
* health.
|
||||
@@ -140,7 +121,7 @@ public class TimerUtils
|
||||
* How many more ticks the hunger bar will be onscreen. Every tick is 1/20th
|
||||
* of a second.
|
||||
*/
|
||||
private static int hungerTime;
|
||||
private static double hungerTime;
|
||||
/**
|
||||
* Records what the hunger level was previously. Used to check for a change
|
||||
* in hunger.
|
||||
@@ -156,7 +137,7 @@ public class TimerUtils
|
||||
* How many more ticks the mount's health bar will be onscreen. Every tick
|
||||
* is 1/20th of a second.
|
||||
*/
|
||||
private static int mountTime;
|
||||
private static double mountTime;
|
||||
/**
|
||||
* Records what the health of the mount was previously. Used to check for a
|
||||
* change in the health.
|
||||
@@ -172,13 +153,13 @@ public class TimerUtils
|
||||
* How many more ticks the mount's jump bar will be onscreen. Every tick is
|
||||
* 1/20th of a second.
|
||||
*/
|
||||
private static int jumpTime;
|
||||
private static double jumpTime;
|
||||
|
||||
/**
|
||||
* How many more ticks the experience bar will be onscreen. Every tick is
|
||||
* 1/20th of a second.
|
||||
*/
|
||||
private static int experienceTime;
|
||||
private static double experienceTime;
|
||||
/**
|
||||
* Records what the experience was previously. Used to check for a change in
|
||||
* the health.
|
||||
@@ -213,7 +194,12 @@ public class TimerUtils
|
||||
*/
|
||||
public static int getHotbarTranslation()
|
||||
{
|
||||
return (int) (22F * (1 - Main.getAlpha(hotbarTime)));
|
||||
ConfigManager.TimeValues hotbar =
|
||||
ConfigManager.getInstance().getHotbarTime();
|
||||
return (int) (22F * (1 - Main.getAlpha(hotbarTime,
|
||||
hotbar.getMaxTime(),
|
||||
hotbar.getFadeInTime(),
|
||||
hotbar.getFadeOutTime())));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -224,7 +210,13 @@ public class TimerUtils
|
||||
*/
|
||||
public static int getExperienceTranslation()
|
||||
{
|
||||
return (int) ((12F + (22 - getHotbarTranslation())) * (1 - Main.getAlpha(experienceTime))) + getHotbarTranslation();
|
||||
ConfigManager.TimeValues experience =
|
||||
ConfigManager.getInstance().getExperienceTime();
|
||||
return (int) ((12F + (22 - getHotbarTranslation())) * (1 - Main.getAlpha(
|
||||
experienceTime,
|
||||
experience.getMaxTime(),
|
||||
experience.getFadeInTime(),
|
||||
experience.getFadeOutTime()))) + getHotbarTranslation();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -235,7 +227,13 @@ public class TimerUtils
|
||||
*/
|
||||
public static int getJumpTranslation()
|
||||
{
|
||||
return (int) ((12F + (22 - getHotbarTranslation())) * (1 - Main.getAlpha(jumpTime))) + getHotbarTranslation();
|
||||
ConfigManager.TimeValues jump =
|
||||
ConfigManager.getInstance().getExperienceTime();
|
||||
return (int) ((12F + (22 - getHotbarTranslation())) * (1 - Main.getAlpha(
|
||||
jumpTime,
|
||||
jump.getMaxTime(),
|
||||
jump.getFadeInTime(),
|
||||
jump.getFadeOutTime()))) + getHotbarTranslation();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -246,7 +244,27 @@ public class TimerUtils
|
||||
*/
|
||||
public static float getHealthTranslation()
|
||||
{
|
||||
return 7 * (1 - Math.max(Main.getAlpha(experienceTime), Main.getAlpha(jumpTime))) + 22 * (1 - Main.getAlpha(hotbarTime));//Math.min(, getHotbarTranslation());
|
||||
ConfigManager.TimeValues hotbar =
|
||||
ConfigManager.getInstance().getHotbarTime();
|
||||
ConfigManager.TimeValues experience =
|
||||
ConfigManager.getInstance().getExperienceTime();
|
||||
ConfigManager.TimeValues jump =
|
||||
ConfigManager.getInstance().getJumpTime();
|
||||
|
||||
float hotbarAlpha = Main.getAlpha(hotbarTime,
|
||||
hotbar.getMaxTime(),
|
||||
hotbar.getFadeInTime(),
|
||||
hotbar.getFadeOutTime());
|
||||
float experienceAlpha = Main.getAlpha(experienceTime,
|
||||
experience.getMaxTime(),
|
||||
experience.getFadeInTime(),
|
||||
experience.getFadeOutTime());
|
||||
float jumpAlpha = Main.getAlpha(jumpTime,
|
||||
jump.getMaxTime(),
|
||||
jump.getFadeInTime(),
|
||||
jump.getFadeOutTime());
|
||||
return 7 * (1 - Math.max(experienceAlpha,
|
||||
jumpAlpha)) + 22 * (1 - hotbarAlpha);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -261,6 +279,12 @@ public class TimerUtils
|
||||
*/
|
||||
public static void onClick(Hand hand, boolean clear)
|
||||
{
|
||||
ConfigManager.TimeValues health =
|
||||
ConfigManager.getInstance().getHealthTime();
|
||||
ConfigManager.TimeValues hunger =
|
||||
ConfigManager.getInstance().getHungerTime();
|
||||
double handTime = ConfigManager.getInstance().getHandTime();
|
||||
|
||||
MinecraftClient mc = MinecraftClient.getInstance();
|
||||
LivingEntity entity;
|
||||
Item item;
|
||||
@@ -290,23 +314,27 @@ public class TimerUtils
|
||||
.map(ItemStack::getItem)
|
||||
.orElse(null);
|
||||
}
|
||||
crosshairTime = VISUAL_TIME;
|
||||
crosshairTime = ConfigManager.getInstance().getCrosshairTime();
|
||||
if (hand == Hand.MAIN_HAND)
|
||||
{
|
||||
mainHandTime = HAND_TIME;
|
||||
mainHandTime = handTime;
|
||||
mainHandLock = item != null;
|
||||
}
|
||||
else
|
||||
{
|
||||
offHandTime = HAND_TIME;
|
||||
offHandTime = handTime;
|
||||
offHandLock = item != null;
|
||||
}
|
||||
if (item != null)
|
||||
{
|
||||
if (item.isFood())
|
||||
{
|
||||
healthTime = HEALTH_TIME;
|
||||
hungerTime = HEALTH_TIME;
|
||||
healthTime = health.getMaxTime() - (healthTime > 0 ?
|
||||
health.getFadeInTime() :
|
||||
0);
|
||||
hungerTime = hunger.getMaxTime() - (hungerTime > 0 ?
|
||||
hunger.getFadeInTime() :
|
||||
0);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -326,9 +354,12 @@ public class TimerUtils
|
||||
*
|
||||
* @since 0.1-1.16.4-fabric
|
||||
*/
|
||||
public static boolean onRenderHand(Hand hand, MatrixStack matrixStack)
|
||||
public static boolean onRenderHand(Hand hand,
|
||||
MatrixStack matrixStack,
|
||||
float ticks)
|
||||
{
|
||||
final int HAND_UP_TIME = 20;
|
||||
final float HAND_UP_TIME = 20F;
|
||||
|
||||
switch (hand)
|
||||
{
|
||||
case OFF_HAND:
|
||||
@@ -338,7 +369,10 @@ public class TimerUtils
|
||||
}
|
||||
else if (!offHandLock && (mapLock & 0b01) == 0)
|
||||
{
|
||||
offHandTime--;
|
||||
if (offHandTime > 0)
|
||||
{
|
||||
offHandTime -= ticks;
|
||||
}
|
||||
if (offHandTime < HAND_UP_TIME)
|
||||
{
|
||||
matrixStack
|
||||
@@ -356,8 +390,10 @@ public class TimerUtils
|
||||
}
|
||||
else if (!mainHandLock && (mapLock & 0b10) == 0)
|
||||
{
|
||||
System.out.println("Decreasing main hand time");
|
||||
mainHandTime--;
|
||||
if (mainHandTime > 0)
|
||||
{
|
||||
mainHandTime -= ticks;
|
||||
}
|
||||
if (mainHandTime < HAND_UP_TIME)
|
||||
{
|
||||
matrixStack
|
||||
@@ -380,8 +416,11 @@ public class TimerUtils
|
||||
*
|
||||
* @since 0.1-1.16.4-fabric
|
||||
*/
|
||||
public static boolean drawCrosshair()
|
||||
public static boolean drawCrosshair(float ticks)
|
||||
{
|
||||
final double CROSSHAIR_TIME =
|
||||
ConfigManager.getInstance().getCrosshairTime();
|
||||
|
||||
MinecraftClient mc = MinecraftClient.getInstance();
|
||||
Entity entity = mc.getCameraEntity();
|
||||
boolean changed = false;
|
||||
@@ -409,7 +448,7 @@ public class TimerUtils
|
||||
{
|
||||
setAlpha(Main.getAlpha(crosshairTime > 0 ?
|
||||
crosshairTime :
|
||||
VISUAL_TIME));
|
||||
CROSSHAIR_TIME, CROSSHAIR_TIME, 0, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -417,7 +456,7 @@ public class TimerUtils
|
||||
}
|
||||
if (crosshairTime > 0)
|
||||
{
|
||||
crosshairTime--;
|
||||
crosshairTime -= ticks;
|
||||
}
|
||||
return canceled;
|
||||
}
|
||||
@@ -430,14 +469,18 @@ public class TimerUtils
|
||||
*
|
||||
* @since 0.1-1.16.4-fabric
|
||||
*/
|
||||
public static boolean drawMountHealth(MatrixStack stack)
|
||||
public static boolean drawMountHealth(MatrixStack stack, float ticks)
|
||||
{
|
||||
/*
|
||||
* When the health percentage falls to this level or below, the
|
||||
* health bar won't disappear, allowing the player to be constantly
|
||||
* reminded of their low health.
|
||||
*/
|
||||
final float CONST_BOUNDARY = 0.5F;
|
||||
final double HEALTH_BOUNDARY =
|
||||
ConfigManager.getInstance().getMinHealth();
|
||||
|
||||
ConfigManager.TimeValues healthTimes =
|
||||
ConfigManager.getInstance().getHealthTime();
|
||||
|
||||
MinecraftClient mc = MinecraftClient.getInstance();
|
||||
Entity entity = mc.getCameraEntity();
|
||||
@@ -466,24 +509,41 @@ public class TimerUtils
|
||||
}
|
||||
if (changed)
|
||||
{
|
||||
mountTime = VISUAL_TIME;
|
||||
mountTime = healthTimes.getMaxTime() - (mountTime > 0 ?
|
||||
healthTimes.getFadeInTime() :
|
||||
0);
|
||||
}
|
||||
else if (mountTime > 0)
|
||||
{
|
||||
mountTime--;
|
||||
mountTime -= ticks;
|
||||
}
|
||||
|
||||
/*
|
||||
* Only makes a change if the player is healthy. Otherwise,
|
||||
* the bar is shown.
|
||||
*/
|
||||
if (mountHealth / mountMaxHealth > HEALTH_BOUNDARY)
|
||||
{
|
||||
if (mountTime > 0)
|
||||
{
|
||||
stack.push();
|
||||
stack.translate(0F,
|
||||
getHealthTranslation(),
|
||||
0F);
|
||||
setAlpha(Main.getAlpha(mountTime));
|
||||
setAlpha(Main.getAlpha(mountTime,
|
||||
healthTimes.getMaxTime(),
|
||||
healthTimes.getFadeInTime(),
|
||||
healthTimes.getFadeOutTime()));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
stack.push();
|
||||
stack.translate(0F,
|
||||
getHealthTranslation(),
|
||||
0F);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the timings of some of the potions currently affecting the
|
||||
@@ -508,20 +568,30 @@ public class TimerUtils
|
||||
* player.
|
||||
*
|
||||
* @param effectinstance - The effect to update
|
||||
* @param ticks
|
||||
*/
|
||||
public static boolean updatePotion(StatusEffectInstance effectinstance)
|
||||
public static boolean updatePotion(StatusEffectInstance effectinstance,
|
||||
float ticks)
|
||||
{
|
||||
Integer time = effectTime.get(effectinstance.getEffectType());
|
||||
final int BLINK_TIME = 200;
|
||||
|
||||
ConfigManager.TimeValues potion =
|
||||
ConfigManager.getInstance().getPotionTime();
|
||||
|
||||
Double time = effectTime.get(effectinstance.getEffectType());
|
||||
if (time == null)
|
||||
{
|
||||
effectTime.put(effectinstance.getEffectType(),
|
||||
(time = VISUAL_TIME));
|
||||
(time = (double) potion.getMaxTime()));
|
||||
}
|
||||
else
|
||||
{
|
||||
effectTime.put(effectinstance.getEffectType(), (time -= 1));
|
||||
effectTime.put(effectinstance.getEffectType(), (time -= ticks));
|
||||
}
|
||||
return Main.getAlpha(time) > 0;
|
||||
return Main.getAlpha(time,
|
||||
potion.getMaxTime(),
|
||||
potion.getFadeInTime(),
|
||||
potion.getFadeOutTime()) > 0 || effectinstance.getDuration() <= BLINK_TIME;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -533,6 +603,8 @@ public class TimerUtils
|
||||
*/
|
||||
public static float getPotionAlpha(StatusEffectInstance effectinstance)
|
||||
{
|
||||
ConfigManager.TimeValues potion =
|
||||
ConfigManager.getInstance().getPotionTime();
|
||||
final int BLINK_TIME = 200;
|
||||
float effectAlpha = 0.0F;
|
||||
if (effectinstance.getDuration() <= BLINK_TIME)
|
||||
@@ -549,7 +621,10 @@ public class TimerUtils
|
||||
{
|
||||
effectAlpha =
|
||||
Main.getAlpha(effectTime.getOrDefault(effectinstance.getEffectType(),
|
||||
0));
|
||||
0.0),
|
||||
potion.getMaxTime(),
|
||||
potion.getFadeInTime(),
|
||||
potion.getFadeOutTime());
|
||||
}
|
||||
return effectAlpha;
|
||||
}
|
||||
@@ -564,14 +639,19 @@ public class TimerUtils
|
||||
*/
|
||||
public static boolean drawArmor()
|
||||
{
|
||||
ConfigManager.TimeValues healthTimes;
|
||||
/*
|
||||
* Sets the armor to fade in and out in sync with the health.
|
||||
* Technically, since this method gets called before health, it will
|
||||
* be 1 tick behind, but I'm not too concerned about it.
|
||||
*/
|
||||
if (healthTime > 0)
|
||||
if (ConfigManager.getInstance().shouldShowArmor() && healthTime > 0)
|
||||
{
|
||||
setAlpha(Main.getAlpha(healthTime));
|
||||
healthTimes = ConfigManager.getInstance().getHealthTime();
|
||||
setAlpha(Main.getAlpha(healthTime,
|
||||
healthTimes.getMaxTime(),
|
||||
healthTimes.getFadeInTime(),
|
||||
healthTimes.getFadeOutTime()));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -585,14 +665,17 @@ public class TimerUtils
|
||||
*
|
||||
* @since 0.1-1.16.4-fabric
|
||||
*/
|
||||
public static boolean drawHealth()
|
||||
public static boolean drawHealth(float ticks)
|
||||
{
|
||||
/*
|
||||
* When the health percentage falls to this level or below, the
|
||||
* health bar won't disappear, allowing the player to be constantly
|
||||
* reminded of their low health.
|
||||
*/
|
||||
final float HEALTH_BOUNDARY = 0.5F;
|
||||
final double HEALTH_BOUNDARY =
|
||||
ConfigManager.getInstance().getMinHealth();
|
||||
ConfigManager.TimeValues healthTimes =
|
||||
ConfigManager.getInstance().getHealthTime();
|
||||
|
||||
MinecraftClient mc = MinecraftClient.getInstance();
|
||||
LivingEntity entity;
|
||||
@@ -623,11 +706,13 @@ public class TimerUtils
|
||||
}
|
||||
if (changed)
|
||||
{
|
||||
healthTime = HEALTH_TIME;
|
||||
healthTime = healthTimes.getMaxTime() - (healthTime > 0 ?
|
||||
healthTimes.getFadeInTime() :
|
||||
0);
|
||||
}
|
||||
else if (healthTime > 0)
|
||||
{
|
||||
healthTime--;
|
||||
healthTime -= ticks;
|
||||
}
|
||||
/*
|
||||
* Only makes a change if the player is healthy. Otherwise,
|
||||
@@ -635,7 +720,10 @@ public class TimerUtils
|
||||
*/
|
||||
if (health / maxHealth > HEALTH_BOUNDARY)
|
||||
{
|
||||
setAlpha(Main.getAlpha(healthTime));
|
||||
setAlpha(Main.getAlpha(healthTime,
|
||||
healthTimes.getMaxTime(),
|
||||
healthTimes.getFadeInTime(),
|
||||
healthTimes.getFadeOutTime()));
|
||||
}
|
||||
return canceled;
|
||||
}
|
||||
@@ -648,14 +736,16 @@ public class TimerUtils
|
||||
*
|
||||
* @since 0.1-1.16.4-fabric
|
||||
*/
|
||||
public static boolean drawHunger()
|
||||
public static boolean drawHunger(float ticks)
|
||||
{
|
||||
/*
|
||||
* When hunger falls to this level or below, the hunger bar won't
|
||||
* disappear, allowing the player to be constantly reminded of their
|
||||
* low hunger.
|
||||
*/
|
||||
final int HUNGER_BOUNDARY = 15;
|
||||
final int HUNGER_BOUNDARY = ConfigManager.getInstance().getMinHunger();
|
||||
ConfigManager.TimeValues hungerTimes =
|
||||
ConfigManager.getInstance().getHungerTime();
|
||||
|
||||
MinecraftClient mc = MinecraftClient.getInstance();
|
||||
PlayerEntity entity;
|
||||
@@ -689,32 +779,44 @@ public class TimerUtils
|
||||
}
|
||||
if (changed)
|
||||
{
|
||||
hungerTime = HEALTH_TIME;
|
||||
hungerTime = hungerTimes.getMaxTime() - (hungerTime > 0 ?
|
||||
hungerTimes.getFadeInTime() :
|
||||
0);
|
||||
}
|
||||
else if (hungerTime > 0)
|
||||
{
|
||||
hungerTime--;
|
||||
hungerTime -= ticks;
|
||||
}
|
||||
|
||||
canceled = hungerTime == 0 && hunger > HUNGER_BOUNDARY;
|
||||
if (!canceled)
|
||||
if (hungerTime <= 0 && hunger > HUNGER_BOUNDARY)
|
||||
{
|
||||
setAlpha(Main.getAlpha(hungerTime));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
setAlpha(Main.getAlpha(hungerTime,
|
||||
hungerTimes.getMaxTime(),
|
||||
hungerTimes.getFadeInTime(),
|
||||
hungerTimes.getFadeOutTime()));
|
||||
return false;
|
||||
}
|
||||
return canceled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether or not to draw the horse jump bar, adjusting the alpha
|
||||
* as needed.
|
||||
*
|
||||
* @param stack
|
||||
*
|
||||
* @return If true, then cancel drawing the jump bar.
|
||||
*
|
||||
* @since 0.1-1.16.4-fabric
|
||||
* @param stack
|
||||
*/
|
||||
public static boolean drawJumpbar(MatrixStack stack)
|
||||
public static boolean drawJumpbar(MatrixStack stack, float ticks)
|
||||
{
|
||||
ConfigManager.TimeValues jump =
|
||||
ConfigManager.getInstance().getJumpTime();
|
||||
|
||||
MinecraftClient mc = MinecraftClient.getInstance();
|
||||
ClientPlayerEntity entity;
|
||||
if (mc.getCameraEntity() instanceof ClientPlayerEntity)
|
||||
@@ -728,17 +830,22 @@ public class TimerUtils
|
||||
|
||||
if (entity.method_3151() > 0)
|
||||
{
|
||||
jumpTime = VISUAL_TIME;
|
||||
jumpTime = jump.getMaxTime() - (jumpTime > 0 ?
|
||||
jump.getFadeInTime() :
|
||||
0);
|
||||
}
|
||||
else if (jumpTime > 0)
|
||||
{
|
||||
jumpTime--;
|
||||
jumpTime -= ticks;
|
||||
}
|
||||
if (jumpTime > 0)
|
||||
{
|
||||
stack.push();
|
||||
stack.translate(0F, TimerUtils.getJumpTranslation(), 0F);
|
||||
setAlpha(Main.getAlpha(jumpTime));
|
||||
setAlpha(Main.getAlpha(jumpTime,
|
||||
jump.getMaxTime(),
|
||||
jump.getFadeInTime(),
|
||||
jump.getFadeOutTime()));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -752,8 +859,11 @@ public class TimerUtils
|
||||
*
|
||||
* @since 0.1-1.16.4-fabric
|
||||
*/
|
||||
public static boolean drawExperience(MatrixStack stack)
|
||||
public static boolean drawExperience(MatrixStack stack, float ticks)
|
||||
{
|
||||
ConfigManager.TimeValues experience =
|
||||
ConfigManager.getInstance().getExperienceTime();
|
||||
|
||||
MinecraftClient mc = MinecraftClient.getInstance();
|
||||
ClientPlayerEntity entity;
|
||||
boolean changed = false;
|
||||
@@ -774,17 +884,22 @@ public class TimerUtils
|
||||
}
|
||||
if (changed)
|
||||
{
|
||||
experienceTime = VISUAL_TIME;
|
||||
experienceTime = experience.getMaxTime() - (experienceTime > 0 ?
|
||||
experience.getFadeInTime() :
|
||||
0);
|
||||
}
|
||||
else if (experienceTime > 0)
|
||||
{
|
||||
experienceTime--;
|
||||
experienceTime -= ticks;
|
||||
}
|
||||
if (experienceTime > 0)
|
||||
{
|
||||
stack.push();
|
||||
stack.translate(0F, TimerUtils.getExperienceTranslation(), 0F);
|
||||
setAlpha(Main.getAlpha(experienceTime));
|
||||
setAlpha(Main.getAlpha(experienceTime,
|
||||
experience.getMaxTime(),
|
||||
experience.getFadeInTime(),
|
||||
experience.getFadeOutTime()));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -797,11 +912,19 @@ public class TimerUtils
|
||||
*
|
||||
* @return If true, then cancel drawing the hotbar.
|
||||
*
|
||||
* @see #recolorHotbar()
|
||||
* @see #recolorHotbar(MatrixStack)
|
||||
* @since 0.1-1.16.4-fabric
|
||||
*/
|
||||
public static boolean updateHotbar()
|
||||
public static boolean updateHotbar(float ticks)
|
||||
{
|
||||
ConfigManager.TimeValues health =
|
||||
ConfigManager.getInstance().getHealthTime();
|
||||
ConfigManager.TimeValues hunger =
|
||||
ConfigManager.getInstance().getHungerTime();
|
||||
ConfigManager.TimeValues hotbar =
|
||||
ConfigManager.getInstance().getHotbarTime();
|
||||
double handTime = ConfigManager.getInstance().getHandTime();
|
||||
|
||||
MinecraftClient mc = MinecraftClient.getInstance();
|
||||
ClientPlayerEntity entity;
|
||||
Item item, handItem = null;
|
||||
@@ -959,18 +1082,22 @@ public class TimerUtils
|
||||
*/
|
||||
if (item.isFood())
|
||||
{
|
||||
healthTime = HEALTH_TIME;
|
||||
hungerTime = HEALTH_TIME;
|
||||
healthTime = health.getMaxTime() - (healthTime > 0 ?
|
||||
health.getFadeInTime() :
|
||||
0);
|
||||
hungerTime = hunger.getMaxTime() - (hungerTime > 0 ?
|
||||
hunger.getFadeInTime() :
|
||||
0);
|
||||
}
|
||||
if (i == 0)
|
||||
{
|
||||
mainHandItem = item;
|
||||
mainHandTime = HAND_TIME;
|
||||
mainHandTime = handTime;
|
||||
}
|
||||
else if (i == 1)
|
||||
{
|
||||
offHandItem = item;
|
||||
offHandTime = HAND_TIME;
|
||||
offHandTime = handTime;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
@@ -982,17 +1109,19 @@ public class TimerUtils
|
||||
if (selectedHotbarSlot != entity.inventory.selectedSlot)
|
||||
{
|
||||
selectedHotbarSlot = entity.inventory.selectedSlot;
|
||||
mainHandTime = HAND_TIME;
|
||||
mainHandTime = handTime;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (changed)
|
||||
{
|
||||
hotbarTime = VISUAL_TIME;
|
||||
hotbarTime = hotbar.getMaxTime() - (hotbarTime > 0 ?
|
||||
hotbar.getFadeInTime() :
|
||||
0);
|
||||
}
|
||||
else if (hotbarTime > 0)
|
||||
{
|
||||
hotbarTime--;
|
||||
hotbarTime -= ticks;
|
||||
}
|
||||
|
||||
return hotbarTime == 0;
|
||||
@@ -1008,9 +1137,14 @@ public class TimerUtils
|
||||
*/
|
||||
public static void recolorHotbar(MatrixStack stack)
|
||||
{
|
||||
ConfigManager.TimeValues hotbar =
|
||||
ConfigManager.getInstance().getHotbarTime();
|
||||
RenderSystem.pushMatrix();
|
||||
stack.push();
|
||||
RenderSystem.translatef(0F, TimerUtils.getHotbarTranslation(), 0F);
|
||||
setAlpha(Main.getAlpha(hotbarTime));
|
||||
setAlpha(Main.getAlpha(hotbarTime,
|
||||
hotbar.getMaxTime(),
|
||||
hotbar.getFadeInTime(),
|
||||
hotbar.getFadeOutTime()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class HeldItemHook
|
||||
int light,
|
||||
CallbackInfo callbackInfo)
|
||||
{
|
||||
if (TimerUtils.onRenderHand(hand, matrices))
|
||||
if (TimerUtils.onRenderHand(hand, matrices, tickDelta))
|
||||
{
|
||||
callbackInfo.cancel();
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class HudHook
|
||||
cancellable = true)
|
||||
public void startCrosshair(MatrixStack stack, CallbackInfo callbackInfo)
|
||||
{
|
||||
if (TimerUtils.drawCrosshair())
|
||||
if (TimerUtils.drawCrosshair(MinecraftClient.getInstance().getTickDelta()))
|
||||
{
|
||||
callbackInfo.cancel();
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class HudHook
|
||||
int x,
|
||||
CallbackInfo callbackInfo)
|
||||
{
|
||||
if (TimerUtils.drawJumpbar(stack))
|
||||
if (TimerUtils.drawJumpbar(stack, MinecraftClient.getInstance().getTickDelta()))
|
||||
{
|
||||
callbackInfo.cancel();
|
||||
}
|
||||
@@ -139,7 +139,7 @@ public class HudHook
|
||||
int x,
|
||||
CallbackInfo callbackInfo)
|
||||
{
|
||||
if (TimerUtils.drawExperience(stack))
|
||||
if (TimerUtils.drawExperience(stack, MinecraftClient.getInstance().getTickDelta()))
|
||||
{
|
||||
callbackInfo.cancel();
|
||||
}
|
||||
@@ -204,7 +204,7 @@ public class HudHook
|
||||
cancellable = true)
|
||||
public void startMountHealth(MatrixStack stack, CallbackInfo callbackInfo)
|
||||
{
|
||||
if (TimerUtils.drawMountHealth(stack))
|
||||
if (TimerUtils.drawMountHealth(stack, MinecraftClient.getInstance().getTickDelta()))
|
||||
{
|
||||
callbackInfo.cancel();
|
||||
}
|
||||
@@ -260,7 +260,7 @@ public class HudHook
|
||||
public boolean shouldRenderPotion(StatusEffectInstance effect)
|
||||
{
|
||||
currentEffect = effect;
|
||||
return TimerUtils.updatePotion(effect);
|
||||
return TimerUtils.updatePotion(effect, MinecraftClient.getInstance().getTickDelta());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -316,7 +316,7 @@ public class HudHook
|
||||
MatrixStack matrices,
|
||||
CallbackInfo callbackInfo)
|
||||
{
|
||||
if (TimerUtils.updateHotbar())
|
||||
if (TimerUtils.updateHotbar(tickDelta))
|
||||
{
|
||||
callbackInfo.cancel();
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package markil3.immersive_hud.mixin;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.util.profiler.DummyProfiler;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -74,7 +75,7 @@ public class ProfilerHook
|
||||
* Resets the transparency from the previous call.
|
||||
*/
|
||||
TimerUtils.setAlpha(1F);
|
||||
if (TimerUtils.drawHealth())
|
||||
if (TimerUtils.drawHealth(MinecraftClient.getInstance().getTickDelta()))
|
||||
{
|
||||
TimerUtils.setAlpha(0F);
|
||||
}
|
||||
@@ -84,7 +85,7 @@ public class ProfilerHook
|
||||
* Resets the transparency from the previous call.
|
||||
*/
|
||||
TimerUtils.setAlpha(1F);
|
||||
if (TimerUtils.drawHunger())
|
||||
if (TimerUtils.drawHunger(MinecraftClient.getInstance().getTickDelta()))
|
||||
{
|
||||
TimerUtils.setAlpha(0F);
|
||||
}
|
||||
|
||||
49
src/main/resources/assets/immersive_hud/lang/en_us.json
Normal file
49
src/main/resources/assets/immersive_hud/lang/en_us.json
Normal file
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"immersive_hud.configGui.title": "Immersive HUD Configuration",
|
||||
"option.immersive_hud.hotbarMaxTime": "Hotbar Display Time",
|
||||
"option.immersive_hud.hotbarFadeIn": "Hotbar Fade In Time",
|
||||
"option.immersive_hud.hotbarFadeOut": "Hotbar Fade Out Time",
|
||||
"option.immersive_hud.experienceMaxTime": "Experience Display Time",
|
||||
"option.immersive_hud.experienceFadeIn": "Experience Fade In Time",
|
||||
"option.immersive_hud.experienceFadeOut": "Experience Fade Out Time",
|
||||
"option.immersive_hud.jumpMaxTime": "Jump Bar Display Time",
|
||||
"option.immersive_hud.jumpFadeIn": "Jump Bar Fade In Time",
|
||||
"option.immersive_hud.jumpFadeOut": "Jump Bar Fade Out Time",
|
||||
"option.immersive_hud.healthMaxTime": "Health Bar Display Time",
|
||||
"option.immersive_hud.healthFadeIn": "Health Bar Fade In Time",
|
||||
"option.immersive_hud.healthFadeOut": "Health Bar Fade Out Time",
|
||||
"option.immersive_hud.hungerMaxTime": "Hunger Bar Display Time",
|
||||
"option.immersive_hud.hungerFadeIn": "Hunger Bar Fade In Time",
|
||||
"option.immersive_hud.hungerFadeOut": "Hunger Bar Fade Out Time",
|
||||
"option.immersive_hud.effectMaxTime": "Potion Display Time",
|
||||
"option.immersive_hud.effectFadeIn": "Potion Fade In Time",
|
||||
"option.immersive_hud.effectFadeOut": "Potion Fade Out Time",
|
||||
"option.immersive_hud.crosshairTime": "Crosshair Display Time",
|
||||
"option.immersive_hud.handTime": "Hand Display Time",
|
||||
"option.immersive_hud.minHealth": "Minimum Health Fade",
|
||||
"option.immersive_hud.minHunger": "Minimum Hunger Fade",
|
||||
"option.immersive_hud.showArmor": "Show Armor",
|
||||
"tooltip.immersive_hud.hotbarMaxTime": "How long the hotbar can be displayed on screen in seconds",
|
||||
"tooltip.immersive_hud.hotbarFadeIn": "How many seconds it takes for the hotbar to fade in",
|
||||
"tooltip.immersive_hud.hotbarFadeOut": "How many seconds it takes for the hotbar to move out",
|
||||
"tooltip.immersive_hud.experienceMaxTime": "How long the experience bar can be displayed on screen in seconds",
|
||||
"tooltip.immersive_hud.experienceFadeIn": "How many seconds it takes for the experience bar to fade in",
|
||||
"tooltip.immersive_hud.experienceFadeOut": "How many seconds it takes for the experience bar to move out",
|
||||
"tooltip.immersive_hud.jumpMaxTime": "How long the horse jump bar can be displayed on screen in seconds",
|
||||
"tooltip.immersive_hud.jumpFadeIn": "How many seconds it takes for the horse jump bar to fade in",
|
||||
"tooltip.immersive_hud.jumpFadeOut": "How many seconds it takes for the horse jump bar to fade out",
|
||||
"tooltip.immersive_hud.healthMaxTime": "How long the health bar can be displayed on screen in seconds",
|
||||
"tooltip.immersive_hud.healthFadeIn": "How many seconds it takes for the health bar to fade in",
|
||||
"tooltip.immersive_hud.healthFadeOut": "How many seconds it takes for the health bar to fade out",
|
||||
"tooltip.immersive_hud.hungerMaxTime": "How long the hunger bar can be displayed on screen in seconds",
|
||||
"tooltip.immersive_hud.hungerFadeIn": "How many seconds it takes for the hunger bar to fade in",
|
||||
"tooltip.immersive_hud.hungerFadeOut": "How many seconds it takes for the hunger bar to fade out",
|
||||
"tooltip.immersive_hud.effectMaxTime": "How long potion icons can be displayed on screen in seconds",
|
||||
"tooltip.immersive_hud.effectFadeIn": "How many seconds it takes for potion icons to fade in",
|
||||
"tooltip.immersive_hud.effectFadeOut": "How many seconds it takes for potion icons to fade out",
|
||||
"tooltip.immersive_hud.crosshairTime": "How many seconds the crosshairs can be on screen",
|
||||
"tooltip.immersive_hud.handTime": "How many seconds the hands can be on screen",
|
||||
"tooltip.immersive_hud.minHealth": "When the percentage of health goes below this level, the health bar won't fade away",
|
||||
"tooltip.immersive_hud.minHunger": "When the hunger level goes below this level, the hunger bar won't fade away",
|
||||
"tooltip.immersive_hud.showArmor": "Whether or not the armor bar should display on the HUD"
|
||||
}
|
||||
@@ -20,6 +20,9 @@
|
||||
"entrypoints": {
|
||||
"main": [
|
||||
"markil3.immersive_hud.Main"
|
||||
],
|
||||
"modmenu": [
|
||||
"markil3.immersive_hud.Main"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
|
||||
Reference in New Issue
Block a user