Compare commits
4 Commits
v1.1-1.15-
...
v1.2-1.15-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70f534e033 | ||
|
|
50fad9acfd | ||
|
|
2403546896 | ||
|
|
7d67a0445a |
@@ -12,6 +12,6 @@ modmenu_version=1.8.4+build.20
|
||||
autoconfig_version=2.2.0
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.1
|
||||
mod_version = 1.2
|
||||
maven_group = markil3
|
||||
archives_base_name = immersive_hud
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
package markil3.immersive_hud;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
|
||||
|
||||
import static markil3.immersive_hud.Main.TICKS_PER_SECOND;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Configuration manager of this mod, which reads from and writes to this mod's
|
||||
* configuration file.
|
||||
@@ -88,6 +96,7 @@ public class ConfigManager
|
||||
private boolean showArmor = true;
|
||||
private double minHealth = 0.5;
|
||||
private int minHunger = 17;
|
||||
private Identifier[] ignoredItems = new Identifier[]{Registry.ITEM.getId(Items.FIREWORK_ROCKET)};
|
||||
|
||||
/**
|
||||
* Returns the instance of this class.
|
||||
@@ -248,6 +257,16 @@ public class ConfigManager
|
||||
return this.minHunger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a collection of items that won't cause hands and crosshairs to show when used.
|
||||
*
|
||||
* @return A set of ignored items.
|
||||
*/
|
||||
public Set<Item> getIgnoredItems()
|
||||
{
|
||||
return Arrays.stream(ignoredItems).map(Registry.ITEM::get).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the time that the hands are allowed to display.
|
||||
*
|
||||
@@ -319,6 +338,16 @@ public class ConfigManager
|
||||
{
|
||||
this.minHunger = MathHelper.clamp(boundary, 0, 20);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets which items won't cause the hands and crosshairs to show when used.
|
||||
*
|
||||
* @param items - A set of ignored items.
|
||||
*/
|
||||
public void setIgnoredItems(Item... items)
|
||||
{
|
||||
this.ignoredItems = Arrays.stream(items).map(Registry.ITEM::getId).toArray(Identifier[]::new);
|
||||
}
|
||||
/**
|
||||
* Saves changes to this mod's configuration.
|
||||
*/
|
||||
|
||||
@@ -49,6 +49,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Contains the logic for changing the HUD.
|
||||
@@ -250,6 +251,8 @@ public class TimerUtils
|
||||
ConfigManager.getInstance().getExperienceTime();
|
||||
ConfigManager.TimeValues jump =
|
||||
ConfigManager.getInstance().getJumpTime();
|
||||
ConfigManager.TimeValues healthTimes = ConfigManager.getInstance().getHealthTime();
|
||||
ConfigManager.TimeValues hungerTimes = ConfigManager.getInstance().getHungerTime();
|
||||
|
||||
float hotbarAlpha = Main.getAlpha(hotbarTime,
|
||||
hotbar.getMaxTime(),
|
||||
@@ -263,8 +266,21 @@ public class TimerUtils
|
||||
jump.getMaxTime(),
|
||||
jump.getFadeInTime(),
|
||||
jump.getFadeOutTime());
|
||||
float statusAlpha = Main.getAlpha(healthTime,
|
||||
healthTimes.getMaxTime(),
|
||||
healthTimes.getFadeInTime(),
|
||||
healthTimes.getFadeOutTime());
|
||||
statusAlpha = Math.max(statusAlpha, Main.getAlpha(hungerTime,
|
||||
hungerTimes.getMaxTime(),
|
||||
hungerTimes.getFadeInTime(),
|
||||
hungerTimes.getFadeOutTime()));
|
||||
/*
|
||||
* Draw it in its standard location until it is completely transparent, then move it
|
||||
* instantly.
|
||||
*/
|
||||
statusAlpha = (float) Math.ceil(statusAlpha);
|
||||
return 7 * (1 - Math.max(experienceAlpha,
|
||||
jumpAlpha)) + 22 * (1 - hotbarAlpha);
|
||||
jumpAlpha)) + 22 * (1 - hotbarAlpha) + 42 * (1 - statusAlpha);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -272,9 +288,8 @@ public class TimerUtils
|
||||
* view, and briefly brings the health and hunger into view if the held item
|
||||
* is food.
|
||||
*
|
||||
* @param hand - The hand being triggered
|
||||
* @param hand - The hand being triggered
|
||||
* @param clear - Whether the hand it being enabled or disabled.
|
||||
*
|
||||
* @since 0.1-1.16.4-fabric
|
||||
*/
|
||||
public static void onClick(Hand hand, boolean clear)
|
||||
@@ -289,6 +304,7 @@ public class TimerUtils
|
||||
LivingEntity entity;
|
||||
Item item;
|
||||
Iterator<ItemStack> hands;
|
||||
Set<Item> ignored;
|
||||
if (mc.getCameraEntity() instanceof LivingEntity)
|
||||
{
|
||||
entity = (LivingEntity) mc.getCameraEntity();
|
||||
@@ -314,6 +330,14 @@ public class TimerUtils
|
||||
.map(ItemStack::getItem)
|
||||
.orElse(null);
|
||||
}
|
||||
if (item != null)
|
||||
{
|
||||
ignored = ConfigManager.getInstance().getIgnoredItems();
|
||||
if (ignored.contains(item))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
crosshairTime = ConfigManager.getInstance().getCrosshairTime();
|
||||
if (hand == Hand.MAIN_HAND)
|
||||
{
|
||||
@@ -330,11 +354,11 @@ public class TimerUtils
|
||||
if (item.isFood())
|
||||
{
|
||||
healthTime = health.getMaxTime() - (healthTime > 0 ?
|
||||
health.getFadeInTime() :
|
||||
0);
|
||||
health.getFadeInTime() :
|
||||
0);
|
||||
hungerTime = hunger.getMaxTime() - (hungerTime > 0 ?
|
||||
hunger.getFadeInTime() :
|
||||
0);
|
||||
hunger.getFadeInTime() :
|
||||
0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -343,11 +367,9 @@ public class TimerUtils
|
||||
* Run whenever a hand is rendered in 1st person. This brings the player
|
||||
* hands into and out of view as needed.
|
||||
*
|
||||
* @param hand - The hand being rendered.
|
||||
* @param hand - The hand being rendered.
|
||||
* @param matrixStack - The rendering stack.
|
||||
*
|
||||
* @return If true, then don't render this hand at all.
|
||||
*
|
||||
* @since 0.1-1.16.4-fabric
|
||||
*/
|
||||
public static boolean onRenderHand(Hand hand,
|
||||
@@ -413,7 +435,6 @@ public class TimerUtils
|
||||
* needed.
|
||||
*
|
||||
* @return If true, then cancel drawing the crosshair.
|
||||
*
|
||||
* @since 0.1-1.16.4-fabric
|
||||
*/
|
||||
public static boolean drawCrosshair(float ticks)
|
||||
@@ -450,8 +471,8 @@ public class TimerUtils
|
||||
> 0)
|
||||
{
|
||||
setAlpha(Main.getAlpha(crosshairTime > 0 ?
|
||||
crosshairTime :
|
||||
CROSSHAIR_TIME, CROSSHAIR_TIME, 0, 0));
|
||||
crosshairTime :
|
||||
CROSSHAIR_TIME, CROSSHAIR_TIME, 0, 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -470,7 +491,6 @@ public class TimerUtils
|
||||
* as needed.
|
||||
*
|
||||
* @return If true, then cancel drawing the mount health bar.
|
||||
*
|
||||
* @since 0.1-1.16.4-fabric
|
||||
*/
|
||||
public static boolean drawMountHealth(float ticks)
|
||||
@@ -514,8 +534,8 @@ public class TimerUtils
|
||||
if (changed)
|
||||
{
|
||||
mountTime = healthTimes.getMaxTime() - (mountTime > 0 ?
|
||||
healthTimes.getFadeInTime() :
|
||||
0);
|
||||
healthTimes.getFadeInTime() :
|
||||
0);
|
||||
}
|
||||
else if (mountTime > 0)
|
||||
{
|
||||
@@ -602,7 +622,6 @@ public class TimerUtils
|
||||
* Obtains how transparent
|
||||
*
|
||||
* @param effectinstance
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static float getPotionAlpha(StatusEffectInstance effectinstance)
|
||||
@@ -614,7 +633,8 @@ public class TimerUtils
|
||||
if (effectinstance.getDuration() <= BLINK_TIME)
|
||||
{
|
||||
effectAlpha =
|
||||
MathHelper.sin(7000F / (effectinstance.getDuration() + 16F * (float) Math.PI)) * 50F / (effectinstance
|
||||
MathHelper.sin(7000F / (effectinstance
|
||||
.getDuration() + 16F * (float) Math.PI)) * 50F / (effectinstance
|
||||
.getDuration() + 100F) + 0.5F;
|
||||
}
|
||||
else if (effectinstance.getDuration() <= BLINK_TIME + potion.getFadeInTime())
|
||||
@@ -639,7 +659,6 @@ public class TimerUtils
|
||||
* needed.
|
||||
*
|
||||
* @return If true, then cancel drawing the armor bar.
|
||||
*
|
||||
* @since 0.1-1.16.4-fabric
|
||||
*/
|
||||
public static boolean drawArmor()
|
||||
@@ -667,7 +686,6 @@ public class TimerUtils
|
||||
* needed.
|
||||
*
|
||||
* @return If true, then cancel drawing the health.
|
||||
*
|
||||
* @since 0.1-1.16.4-fabric
|
||||
*/
|
||||
public static boolean drawHealth(float ticks)
|
||||
@@ -711,8 +729,8 @@ public class TimerUtils
|
||||
if (changed)
|
||||
{
|
||||
healthTime = healthTimes.getMaxTime() - (healthTime > 0 ?
|
||||
healthTimes.getFadeInTime() :
|
||||
0);
|
||||
healthTimes.getFadeInTime() :
|
||||
0);
|
||||
}
|
||||
else if (healthTime > 0)
|
||||
{
|
||||
@@ -743,7 +761,6 @@ public class TimerUtils
|
||||
* needed.
|
||||
*
|
||||
* @return If true, then cancel drawing the hunger bar.
|
||||
*
|
||||
* @since 0.1-1.16.4-fabric
|
||||
*/
|
||||
public static boolean drawHunger(float ticks)
|
||||
@@ -790,8 +807,8 @@ public class TimerUtils
|
||||
if (changed)
|
||||
{
|
||||
hungerTime = hungerTimes.getMaxTime() - (hungerTime > 0 ?
|
||||
hungerTimes.getFadeInTime() :
|
||||
0);
|
||||
hungerTimes.getFadeInTime() :
|
||||
0);
|
||||
}
|
||||
else if (hungerTime > 0)
|
||||
{
|
||||
@@ -822,7 +839,6 @@ public class TimerUtils
|
||||
* as needed.
|
||||
*
|
||||
* @return If true, then cancel drawing the jump bar.
|
||||
*
|
||||
* @since 0.1-1.16.4-fabric
|
||||
*/
|
||||
public static boolean drawJumpbar(float ticks)
|
||||
@@ -844,8 +860,8 @@ public class TimerUtils
|
||||
if (entity.method_3151() > 0)
|
||||
{
|
||||
jumpTime = jump.getMaxTime() - (jumpTime > 0 ?
|
||||
jump.getFadeInTime() :
|
||||
0);
|
||||
jump.getFadeInTime() :
|
||||
0);
|
||||
}
|
||||
else if (jumpTime > 0)
|
||||
{
|
||||
@@ -869,7 +885,6 @@ public class TimerUtils
|
||||
* as needed.
|
||||
*
|
||||
* @return If true, then cancel drawing the experience bar.
|
||||
*
|
||||
* @since 0.1-1.16.4-fabric
|
||||
*/
|
||||
public static boolean drawExperience(float ticks)
|
||||
@@ -898,8 +913,8 @@ public class TimerUtils
|
||||
if (changed)
|
||||
{
|
||||
experienceTime = experience.getMaxTime() - (experienceTime > 0 ?
|
||||
experience.getFadeInTime() :
|
||||
0);
|
||||
experience.getFadeInTime() :
|
||||
0);
|
||||
}
|
||||
else if (experienceTime > 0)
|
||||
{
|
||||
@@ -926,7 +941,6 @@ public class TimerUtils
|
||||
* or not to draw it.
|
||||
*
|
||||
* @return If true, then cancel drawing the hotbar.
|
||||
*
|
||||
* @see #recolorHotbar()
|
||||
* @since 0.1-1.16.4-fabric
|
||||
*/
|
||||
@@ -1035,7 +1049,7 @@ public class TimerUtils
|
||||
{
|
||||
if (entity.isUsingItem() && entity
|
||||
.getActiveHand() != null && entity.getActiveHand()
|
||||
.ordinal() == i)
|
||||
.ordinal() == i)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
@@ -1098,11 +1112,11 @@ public class TimerUtils
|
||||
if (item.isFood())
|
||||
{
|
||||
healthTime = health.getMaxTime() - (healthTime > 0 ?
|
||||
health.getFadeInTime() :
|
||||
0);
|
||||
health.getFadeInTime() :
|
||||
0);
|
||||
hungerTime = hunger.getMaxTime() - (hungerTime > 0 ?
|
||||
hunger.getFadeInTime() :
|
||||
0);
|
||||
hunger.getFadeInTime() :
|
||||
0);
|
||||
}
|
||||
if (i == 0)
|
||||
{
|
||||
@@ -1131,8 +1145,8 @@ public class TimerUtils
|
||||
if (changed)
|
||||
{
|
||||
hotbarTime = hotbar.getMaxTime() - (hotbarTime > 0 ?
|
||||
hotbar.getFadeInTime() :
|
||||
0);
|
||||
hotbar.getFadeInTime() :
|
||||
0);
|
||||
}
|
||||
else if (hotbarTime > 0)
|
||||
{
|
||||
@@ -1147,7 +1161,6 @@ public class TimerUtils
|
||||
* needed.
|
||||
*
|
||||
* @return If true, then cancel drawing the crosshair.
|
||||
*
|
||||
* @since 0.1-1.16.4-fabric
|
||||
*/
|
||||
public static void recolorHotbar()
|
||||
|
||||
@@ -329,7 +329,7 @@ public class HudHook
|
||||
@Inject(method = "renderStatusBars()V", at = @At(value = "INVOKE",
|
||||
target = "Lnet" +
|
||||
"/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V",
|
||||
ordinal = 1))
|
||||
ordinal = 1, shift = At.Shift.BY, by = 3))
|
||||
public void renderFood(CallbackInfo callbackInfo)
|
||||
{
|
||||
LOGGER.debug("Rendering food");
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
},
|
||||
"mixins": [
|
||||
{
|
||||
"config": "modid.mixins.json",
|
||||
"config": "immersive_hud.mixins.json",
|
||||
"environment": "client"
|
||||
}
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user