Compare commits

..

16 Commits

Author SHA1 Message Date
Markil3
637766ce46 Gets ready for release 1.0 2021-03-02 12:31:50 -07:00
Markil3
170c0f9065 Makes the Cloth API optional. 2021-03-02 12:31:08 -07:00
Markil3
45c63cf6fb Updates the mods.toml file to be more accurate. 2021-03-02 11:44:25 -07:00
Markil3
756113dc62 Tweaks potions some more 2021-03-02 10:35:00 -07:00
Markil3
ea626c9913 Adjusts the health and hunger to always show under wither, poison, and hunger. 2021-03-02 10:34:03 -07:00
Markil3
1c26eec9a4 Removes ConfigScreen
It was unused.
2021-03-02 10:09:23 -07:00
Markil3
def048a43a Made the Forge mod options more consistent with the Fabric options. 2021-03-02 09:55:32 -07:00
Markil3
98bc4d7cfc Fixes potions blinking. 2021-03-02 09:44:15 -07:00
Markil3
5d8e1d222a Enables the configuration of timing values, via the cloth API. 2021-03-01 12:17:33 -07:00
Markil3
ea80abfcc0 Set getAlpha to use custom fade times.
This is in preparation for configurable times.
2021-02-27 13:48:48 -07:00
Markil3
0c1196bbd2 Causes things to fade in as well as out. 2021-02-27 13:40:45 -07:00
Markil3
c7680888c1 Makes the hotbar and experience/jump bars move in and out.
Its a nice effect.
2021-02-27 12:23:21 -07:00
Markil3
2deb8aa2b3 Fixes a bug that prevented air from showing up if health wasn't. 2021-02-27 11:10:53 -07:00
Markil3
8fffdf110f Makes potion icons fade over time. 2021-02-27 11:00:20 -07:00
Markil3
7912a1b87c Moves most of the timer logic to its own class. 2021-02-27 09:36:50 -07:00
Markil3
2a0b4446bc Moved most of the timer logic to their own methods.
Not only does this make onGUIDraw a little more managable, but it also makes it more similar to the Fabric implementation.
2021-02-27 08:41:53 -07:00
10 changed files with 1962 additions and 627 deletions

View File

@@ -13,6 +13,10 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
repositories {
maven { url "https://maven.shedaniel.me/" }
}
archivesBaseName = project.archives_base_name
version = project.mod_version + "-" + project.minecraft_version + "-forge"
group = project.maven_group // http://maven.apache.org/guides/mini/guide-naming-conventions.html
@@ -96,6 +100,7 @@ dependencies {
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft "net.minecraftforge:forge:${project.minecraft_version}-${project.forge_version}"
compile(fg.deobf("me.shedaniel.cloth:cloth-config-forge:${project.cloth_version}"))
// You may put jars on which you depend on in ./libs or you may define them like so..
// compile "some.group:artifact:version:classifier"
// compile "some.group:artifact:version"

View File

@@ -8,7 +8,9 @@ minecraft_version=1.16.4
mappings=20201028-1.16.3
forge_version=35.1.37
cloth_version=4.11.14
# Mod Properties
mod_version = 0.1
mod_version = 1.0
maven_group = markil3
archives_base_name = immersive_hud

View File

@@ -0,0 +1,386 @@
package markil3.immersive_hud;
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
import com.electronwill.nightconfig.core.io.WritingMode;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.fml.common.Mod;
import org.apache.commons.lang3.tuple.Pair;
import java.nio.file.Path;
import java.nio.file.Paths;
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
*/
public class ConfigManager
{
/**
* The only instance of this class
*/
private static final ConfigManager INSTANCE;
/**
* The {@link ForgeConfigSpec} instance for this mod's configuration
*/
private static final ForgeConfigSpec SPEC;
/**
* {@link Path} to the configuration file of this mod
*/
private static final Path CONFIG_PATH =
Paths.get("config",
Main.class.getAnnotation(Mod.class).value() + ".toml");
static
{
Pair<ConfigManager, ForgeConfigSpec> specPair =
new ForgeConfigSpec.Builder().configure(ConfigManager::new);
INSTANCE = specPair.getLeft();
SPEC = specPair.getRight();
CommentedFileConfig config = CommentedFileConfig.builder(CONFIG_PATH)
.sync()
.autoreload()
.writingMode(WritingMode.REPLACE)
.build();
config.load();
config.save();
SPEC.setConfig(config);
}
public static class TimeValues
{
private static final int SHOW_TIME = 6 * TICKS_PER_SECOND;
private static final int FADE_IN = TICKS_PER_SECOND / 4;
private static final int FADE_OUT = TICKS_PER_SECOND / 2;
private final String name;
private final ForgeConfigSpec.IntValue maxTime;
private final ForgeConfigSpec.IntValue fadeIn;
private final ForgeConfigSpec.IntValue fadeOut;
TimeValues(String name, ForgeConfigSpec.Builder configSpecBuilder)
{
final int MAX_TIME = 10 * 60 * TICKS_PER_SECOND;
this.name = name;
this.maxTime =
configSpecBuilder.translation("immersive_hud.configGui." + name + "Time.title")
.defineInRange(name + "Time.maxTime",
SHOW_TIME,
0,
MAX_TIME);
this.fadeIn =
configSpecBuilder.translation("immersive_hud.configGui." + name + "FadeIn.title")
.defineInRange(name + "Time.fadeIn",
FADE_IN,
0,
MAX_TIME);
this.fadeOut =
configSpecBuilder.translation("immersive_hud.configGui." + name + "FadeOut.title")
.defineInRange(name + "Time.fadeOut",
FADE_OUT,
0,
MAX_TIME);
}
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.get();
}
/**
* Obtains the time that the hotbar takes to fade in.
*
* @return The hotbar fade in time.
*/
public int getFadeInTime()
{
return this.fadeIn.get();
}
/**
* Obtains the time that the hotbar takes to fade out.
*
* @return The hotbar fade out time.
*/
public int getFadeOutTime()
{
return this.fadeOut.get();
}
public void setMaxTime(int time)
{
this.maxTime.set(time);
}
public void setFadeInTime(int time)
{
this.fadeIn.set(time);
}
public void setFadeOutTime(int time)
{
this.fadeOut.set(time);
}
}
private final TimeValues hotbarTime;
private final TimeValues experienceTime;
private final TimeValues jumpTime;
private final TimeValues healthTime;
private final TimeValues hungerTime;
private final TimeValues effectTime;
private final ForgeConfigSpec.IntValue crosshairTime;
private final ForgeConfigSpec.IntValue handTime;
private final ForgeConfigSpec.BooleanValue showArmor;
private final ForgeConfigSpec.DoubleValue minHealth;
private final ForgeConfigSpec.IntValue minHunger;
/**
* Implementation of Singleton design pattern, which allows only one
* instance of this class to be created.
*/
private ConfigManager(ForgeConfigSpec.Builder configSpecBuilder)
{
// Comments are not added because there was no way to translate
// descriptions from translate keys here
this.hotbarTime = new TimeValues("hotbar", configSpecBuilder);
this.experienceTime = new TimeValues("experience", configSpecBuilder);
this.jumpTime = new TimeValues("jump", configSpecBuilder);
this.healthTime = new TimeValues("health", configSpecBuilder);
this.hungerTime = new TimeValues("hunger", configSpecBuilder);
this.effectTime = new TimeValues("effect", configSpecBuilder);
this.crosshairTime =
configSpecBuilder.translation(
"immersive_hud.configGui.crosshairTime.title")
.defineInRange("crosshairTime",
6 * TICKS_PER_SECOND,
0,
10 * 60 * TICKS_PER_SECOND);
this.handTime =
configSpecBuilder.translation(
"immersive_hud.configGui.handTime.title")
.defineInRange("handTime",
30 * TICKS_PER_SECOND,
0,
10 * 60 * TICKS_PER_SECOND);
this.showArmor = configSpecBuilder.translation(
"immersive_hud.configGui.showArmor.title")
.define("showArmor", true);
this.minHealth = configSpecBuilder.translation(
"immersive_hud.configGui.minHealth.title")
.defineInRange("minHealth", 0.5, 0.0, 1.0);
this.minHunger = configSpecBuilder.translation(
"immersive_hud.configGui.minHunger.title")
.defineInRange("minHunger", 17, 0, 20);
}
/**
* Returns the instance of this class.
*
* @return the instance of this class
*/
public static ConfigManager getInstance()
{
return INSTANCE;
}
// 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 getExperenceTime()
{
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.get();
}
/**
* Obtains the time that the hands are allowed to display.
*
* @return The hand display time values.
*/
public int getHandTime()
{
return this.handTime.get();
}
/**
* Checks whether the armor bar should render.
*
* @return Whether or not armor shows on the HUD.
*/
public boolean shouldShowArmor()
{
return this.showArmor.get();
}
/**
* 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.get();
}
/**
* 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.get();
}
/**
* Sets the time that the hands are allowed to display.
*
* @param time - The hand display time values.
*/
public void setCrosshairTime(int time)
{
this.crosshairTime.set(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.set(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.set(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.set(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.set(MathHelper.clamp(boundary, 0, 20));
}
/**
* Saves changes to this mod's configuration.
*/
public void save()
{
SPEC.save();
}
}

View File

@@ -1,4 +1,4 @@
/**
/*
* Copyright (C) 2021 Markil 3
* <p>
* This program is free software: you can redistribute it and/or modify it under
@@ -16,27 +16,9 @@
*/
package markil3.immersive_hud;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.BowItem;
import net.minecraft.item.CrossbowItem;
import net.minecraft.item.EggItem;
import net.minecraft.item.EnderPearlItem;
import net.minecraft.item.FilledMapItem;
import net.minecraft.item.FishingRodItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ShieldItem;
import net.minecraft.item.ShootableItem;
import net.minecraft.item.SnowballItem;
import net.minecraft.item.ThrowablePotionItem;
import net.minecraft.item.TridentItem;
import net.minecraft.potion.Effects;
import net.minecraft.util.Hand;
import net.minecraft.util.math.RayTraceResult;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderHandEvent;
@@ -51,6 +33,8 @@ import org.apache.logging.log4j.Logger;
import java.util.Optional;
import static markil3.immersive_hud.TimerUtils.resetAlpha;
/**
* Contains the logic for changing the HUD.
*
@@ -65,128 +49,6 @@ public class EventBus
*/
private static final Logger LOGGER = LogManager.getLogger();
/**
* The number of ticks that the hand will be onscreen. Every tick is 1/20th
* of a second.
*/
static final int HAND_TIME = 10 * 20;
/**
* The number of ticks most elements will be onscreen. Every tick is 1/20th
* of a second.
*/
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.
*/
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;
/**
* How many more ticks the crosshair will be onscreen. Every tick is 1/20th
* of a second.
*/
private static int crosshairTime;
/**
* If true, then the hand (and crosshairs) will be locked onto the screen
* without disappearing until this flag is updated.
*/
private static boolean mainHandLock, offHandLock;
/**
* A bitmask that will lock the corresponding hand without necessarily
* showing the crosshairs. The first bit will be the main hand, and the
* second will be the offhand.
*/
private static int mapLock;
/**
* How many more ticks the hotbar will be onscreen. Every tick is 1/20th of
* a second.
*/
private static int hotbarTime;
/**
* The last hotbar slot that was selected. This is used to check for a
* change in the hotbar slot.
*/
private static int selectedHotbarSlot = -1;
/**
* The last item that was in this hand. This is used to check for a change
* in what was equipped.
*/
private static Item mainHandItem = null, offHandItem = null;
/**
* How many more ticks the health bar will be onscreen. Every tick is 1/20th
* of a second.
*/
private static int healthTime;
/**
* Records what the health was previously. Used to check for a change in the
* health.
* <p>
* Note that the display of the armor is linked to this.
*/
private static float health = -1;
/**
* Records what the maximum health was previously. Used to check for a
* change in the health.
*/
private static float maxHealth = -1;
/**
* How many more ticks the hunger bar will be onscreen. Every tick is 1/20th
* of a second.
*/
private static int hungerTime;
/**
* Records what the hunger level was previously. Used to check for a change
* in hunger.
*/
private static int hunger = -1;
/**
* Records whether or not there was food poisoning. Used to check for a
* change in hunger.
*/
private static boolean isFoodPoisoned = false;
/**
* How many more ticks the mount's health bar will be onscreen. Every tick
* is 1/20th of a second.
*/
private static int mountTime;
/**
* Records what the health of the mount was previously. Used to check for a
* change in the health.
*/
private static float mountHealth = -1;
/**
* Records what the maximum health of the mount was previously. Used to
* check for a change in the health.
*/
private static float mountMaxHealth = -1;
/**
* How many more ticks the mount's jump bar will be onscreen. Every tick is
* 1/20th of a second.
*/
private static int jumpTime;
/**
* How many more ticks the experience bar will be onscreen. Every tick is
* 1/20th of a second.
*/
private static int experienceTime;
/**
* Records what the experience was previously. Used to check for a change in
* the health.
*/
private static float experienceProgress = -1;
/**
* Run whenever the player clicks a mouse button. This brings the hands into
* view, and briefly brings the health and hunger into view if the held item
@@ -207,23 +69,7 @@ public class EventBus
Optional.ofNullable(event.getItemStack())
.map(ItemStack::getItem)
.orElse(null);
crosshairTime = VISUAL_TIME;
if (event.getHand() == Hand.MAIN_HAND)
{
mainHandTime = HAND_TIME;
}
else
{
offHandTime = HAND_TIME;
}
if (item != null)
{
if (item.isFood())
{
healthTime = HEALTH_TIME;
hungerTime = HEALTH_TIME;
}
}
TimerUtils.onClick(event.getHand(), item);
}
});
}
@@ -246,7 +92,7 @@ public class EventBus
@Override
public void run()
{
mountTime = VISUAL_TIME;
TimerUtils.resetMountHealth();
}
});
}
@@ -260,54 +106,10 @@ public class EventBus
@SubscribeEvent
public static void onRenderHand(final RenderHandEvent event)
{
final int HAND_UP_TIME = 20;
switch (event.getHand())
{
case OFF_HAND:
if (mainHandTime > 0 && mainHandTime < HAND_UP_TIME)
{
/*
* Undo the transformation of the previous hand
*/
event.getMatrixStack()
.translate(0,
1.0F * (HAND_UP_TIME - mainHandTime) / HAND_UP_TIME,
0);
}
if (offHandTime == 0)
if (TimerUtils.onRenderHand(event.getHand(), event.getMatrixStack(), event.getPartialTicks()))
{
event.setCanceled(true);
}
else if (!offHandLock && (mapLock & 0b01) == 0)
{
offHandTime--;
if (offHandTime < HAND_UP_TIME)
{
event.getMatrixStack()
.translate(0,
-1.0F * (HAND_UP_TIME - offHandTime) / HAND_UP_TIME,
0);
}
}
break;
case MAIN_HAND:
if (mainHandTime == 0)
{
event.setCanceled(true);
}
else if (!mainHandLock && (mapLock & 0b10) == 0)
{
mainHandTime--;
if (mainHandTime < HAND_UP_TIME)
{
event.getMatrixStack()
.translate(0,
-1.0F * (HAND_UP_TIME - mainHandTime) / HAND_UP_TIME,
0);
}
}
break;
}
}
/**
@@ -319,364 +121,85 @@ public class EventBus
@SubscribeEvent
public static void onGUIDraw(final RenderGameOverlayEvent event)
{
/*
* 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;
/*
* 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;
Minecraft mc = Minecraft.getInstance();
boolean changed = false;
int hotbarSlot;
Item item, handItem = null;
boolean fadeIn = false;
switch (event.getType())
{
case CROSSHAIRS:
if (event instanceof RenderGameOverlayEvent.Pre)
{
if (mc.objectMouseOver != null && mc.objectMouseOver.getType() != RayTraceResult.Type.MISS)
{
if (mc.objectMouseOver.getType() == RayTraceResult.Type.ENTITY)
{
if (mc.objectMouseOver.hitInfo == null || mc.objectMouseOver.hitInfo != mc.player
.getRidingEntity())
{
changed = true;
}
}
else
{
changed = true;
}
}
if (changed || mainHandLock || offHandLock || crosshairTime > 0)
{
RenderSystem.color4f(1.0F,
1.0F,
1.0F,
RenderUtils.getAlpha(crosshairTime > 0 ?
crosshairTime :
VISUAL_TIME));
}
else
if (TimerUtils.drawCrosshair(event.getPartialTicks()))
{
event.setCanceled(true);
}
if (crosshairTime > 0)
{
crosshairTime--;
}
}
/*
* Reset the transparency.
*/
else if (event instanceof RenderGameOverlayEvent.Post)
{
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
resetAlpha();
}
break;
case POTION_ICONS:
if (event instanceof RenderGameOverlayEvent.Pre)
{
TimerUtils.updatePotions(mc.player);
event.setCanceled(true);
RenderUtils.renderPotionIcons(mc,
mc.ingameGUI,
event.getMatrixStack(), event.getPartialTicks());
resetAlpha();
}
break;
case HOTBAR:
if (event instanceof RenderGameOverlayEvent.Pre)
{
mainHandLock = offHandLock = false;
mapLock = 0;
event.setCanceled(true);
for (int i = 0, l = Hand.values().length; i < l; i++)
if (!TimerUtils.drawHotbar(event.getPartialTicks()))
{
item =
Optional.ofNullable(mc.player.getHeldItem(Hand.values()[i]))
.map(ItemStack::getItem)
.orElse(null);
if (item != null)
{
if (item instanceof ShootableItem)
{
/*
* Enables the crosshairs and lock the hand
* whenever the bow is drawn.
*/
if (item instanceof BowItem)
{
if (mc.player.isHandActive() && mc.player.getActiveHand()
.ordinal() == i)
{
switch (i)
{
case 0:
mainHandLock = true;
break;
case 1:
offHandLock = true;
break;
}
}
}
/*
* Enables the crosshairs and lock the hand
* whenever a loaded crossbow is equipped.
*/
else if (item instanceof CrossbowItem)
{
if (CrossbowItem.isCharged(mc.player.getHeldItem(
Hand.values()[i])))
{
switch (i)
{
case 0:
mainHandLock = true;
break;
case 1:
offHandLock = true;
break;
}
}
}
/*
* We don't know how modded items behave
* exactly, so we keep it safe and enable the
* crosshairs at all times for any shootable
* items.
*/
else
{
switch (i)
{
case 0:
mainHandLock = true;
break;
case 1:
offHandLock = true;
break;
}
}
}
/**
* Items that have the crosshairs enabled for as long
* as the item is actively being used.
*/
else if (item instanceof TridentItem || item instanceof ShieldItem)
{
if (mc.player.isHandActive() && mc.player.getActiveHand()
.ordinal() == i)
{
switch (i)
{
case 0:
mainHandLock = true;
break;
case 1:
offHandLock = true;
break;
}
}
}
/**
* Items that have the crosshairs enabled for as long
* as the item is being held at all.
*/
else if (item instanceof ThrowablePotionItem || item instanceof SnowballItem || item instanceof EggItem || item instanceof EnderPearlItem || item instanceof FishingRodItem)
{
switch (i)
{
case 0:
mainHandLock = true;
break;
case 1:
offHandLock = true;
break;
}
}
/**
* Maps get special treatment. The hand is locked,
* but the crosshairs are not enabled.
*/
else if (item instanceof FilledMapItem)
{
mapLock = mapLock | (2 - i);
}
}
/*
* Checks for a change in the item
*/
if (i == 0)
{
handItem = mainHandItem;
}
else if (i == 1)
{
handItem = offHandItem;
}
if (item != handItem)
{
changed = true;
/*
* Briefly shows the health and hunger bar whenever
* food is switched to.
*/
if (item.isFood())
{
healthTime = HEALTH_TIME;
hungerTime = HEALTH_TIME;
}
if (i == 0)
{
mainHandItem = item;
mainHandTime = HAND_TIME;
}
else if (i == 1)
{
offHandItem = item;
offHandTime = HAND_TIME;
}
}
}
/*
* Checks for a change in what slot is used.
*/
hotbarSlot = mc.player.inventory.currentItem;
if (selectedHotbarSlot != hotbarSlot)
{
selectedHotbarSlot = hotbarSlot;
mainHandTime = HAND_TIME;
changed = true;
}
if (changed)
{
hotbarTime = VISUAL_TIME;
}
else if (hotbarTime > 0)
{
hotbarTime--;
}
RenderUtils.renderHotbar(mc, mc.ingameGUI,
event.getMatrixStack(),
event.getPartialTicks(), hotbarTime);
event.getPartialTicks(), TimerUtils.hotbarTime);
}
}
break;
case HEALTH:
if (event instanceof RenderGameOverlayEvent.Pre)
{
/*
* Skip healthy bars that haven't updated in awhile.
*/
if (healthTime == 0 && health / maxHealth > CONST_BOUNDARY)
if (TimerUtils.drawHealth(event.getMatrixStack(), event.getPartialTicks()))
{
event.setCanceled(true);
}
/**
* Checks for a change in current or max health.
*/
if (health != mc.player.getHealth())
{
health = mc.player.getHealth();
changed = true;
}
if (maxHealth != mc.player.getMaxHealth())
{
maxHealth = mc.player.getMaxHealth();
changed = true;
}
if (changed)
{
healthTime = HEALTH_TIME;
}
else if (healthTime > 0)
{
healthTime--;
}
/*
* Only makes a change if the player is healthy. Otherwise,
* the bar is shown.
*/
if (health / maxHealth > CONST_BOUNDARY)
{
RenderSystem.color4f(1.0F,
1.0F,
1.0F,
RenderUtils.getAlpha(healthTime));
}
}
/*
* Reset the transparency.
*/
else if (event instanceof RenderGameOverlayEvent.Post)
{
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
event.getMatrixStack().pop();
resetAlpha();
}
break;
case FOOD:
if (event instanceof RenderGameOverlayEvent.Pre)
{
/*
* Skip satisfied bars that haven't updated in awhile.
*/
if (hungerTime == 0 && hunger > HUNGER_BOUNDARY)
if (TimerUtils.drawHunger(event.getMatrixStack(), event.getPartialTicks()))
{
event.setCanceled(true);
}
if (hunger != mc.player.getFoodStats().getFoodLevel())
{
hunger = mc.player.getFoodStats().getFoodLevel();
changed = true;
}
if (isFoodPoisoned != mc.player.isPotionActive(Effects.HUNGER))
{
isFoodPoisoned =
mc.player.isPotionActive(Effects.HUNGER);
changed = true;
}
if (hunger <= HUNGER_BOUNDARY)
{
changed = true;
}
if (changed)
{
hungerTime = HEALTH_TIME;
RenderSystem.color4f(1.0F,
1.0F,
1.0F,
RenderUtils.getAlpha(hungerTime));
}
else if (hungerTime > 0)
{
hungerTime--;
}
/*
* Only makes a change if the player is satisfied. Otherwise,
* the bar is shown.
*/
}
/*
* Reset the transparency.
*/
else if (event instanceof RenderGameOverlayEvent.Post)
{
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
event.getMatrixStack().pop();
resetAlpha();
}
break;
case ARMOR:
if (event instanceof RenderGameOverlayEvent.Pre)
{
/*
* Renders armor along with health.
*/
if (healthTime > 0)
{
RenderSystem.color4f(1.0F,
1.0F,
1.0F,
RenderUtils.getAlpha(healthTime));
}
else
if (TimerUtils.drawArmor(event.getMatrixStack(), event.getPartialTicks()))
{
event.setCanceled(true);
}
@@ -686,88 +209,61 @@ public class EventBus
*/
else if (event instanceof RenderGameOverlayEvent.Post)
{
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
event.getMatrixStack().pop();
resetAlpha();
}
break;
case AIR:
if (event instanceof RenderGameOverlayEvent.Pre)
{
if (TimerUtils.drawAir(event.getMatrixStack(), event.getPartialTicks()))
{
event.setCanceled(true);
}
}
/*
* Reset the transparency.
*/
else if (event instanceof RenderGameOverlayEvent.Post)
{
event.getMatrixStack().pop();
resetAlpha();
}
break;
case HEALTHMOUNT:
if (event instanceof RenderGameOverlayEvent.Pre)
{
Entity tmp = mc.player.getRidingEntity();
if (tmp == null)
if (TimerUtils.drawMountHealth(event.getMatrixStack(), event.getPartialTicks()))
{
mountHealth = -1;
mountMaxHealth = -1;
event.setCanceled(true);
}
else
{
LivingEntity mount = (LivingEntity) tmp;
if (mountHealth != mount.getHealth())
{
mountHealth = mount.getHealth();
changed = true;
}
if (mountMaxHealth != mount.getMaxHealth())
{
mountMaxHealth = mount.getMaxHealth();
changed = true;
}
}
if (changed)
{
mountTime = VISUAL_TIME;
}
else if (mountTime > 0)
{
mountTime--;
}
/*
* Renders it along with health.
*/
RenderSystem.color4f(1.0F,
1.0F,
1.0F,
RenderUtils.getAlpha(mountTime));
}
else if (event instanceof RenderGameOverlayEvent.Post)
{
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
event.getMatrixStack().pop();
resetAlpha();
}
break;
case JUMPBAR:
if (event instanceof RenderGameOverlayEvent.Pre)
{
event.setCanceled(true);
if (mc.player.getHorseJumpPower() > 0)
if (!TimerUtils.drawJumpbar(event.getPartialTicks()))
{
jumpTime = VISUAL_TIME;
}
else if (jumpTime > 0)
{
jumpTime--;
}
RenderUtils.renderHorseJumpBar(mc, mc.ingameGUI,
event.getMatrixStack(), jumpTime);
event.getMatrixStack(), event.getPartialTicks(), TimerUtils.jumpTime);
}
}
break;
case EXPERIENCE:
if (event instanceof RenderGameOverlayEvent.Pre)
{
event.setCanceled(true);
if (experienceProgress != mc.player.experience)
if (!TimerUtils.drawExperience(event.getPartialTicks()))
{
experienceProgress = mc.player.experience;
changed = true;
}
if (changed)
{
experienceTime = VISUAL_TIME;
}
else if (experienceTime > 0)
{
experienceTime--;
}
RenderUtils.renderExperience(mc, mc.ingameGUI,
event.getMatrixStack(), experienceTime);
event.getMatrixStack(), event.getPartialTicks(), TimerUtils.experienceTime);
}
}
break;
}

View File

@@ -17,9 +17,14 @@
*/
package markil3.immersive_hud;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.fml.ExtensionPoint;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.VersionChecker;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.network.FMLNetworkConstants;
import org.apache.commons.lang3.tuple.Pair;
@@ -39,9 +44,25 @@ public class Main
* Class logger.
*/
private static final Logger LOGGER = LogManager.getLogger();
public static final int TICKS_PER_SECOND = 20;
public Main()
{
FMLJavaModLoadingContext.get()
.getModEventBus()
.addListener(this::setup);
try
{
if (Class.forName("me.shedaniel.clothconfig2.api.ConfigBuilder") != null)
{
ModMenu.setupScreen();
}
}
catch (ClassNotFoundException e)
{
// Do nothing
}
//Make sure the mod being absent on the other network side does not
// cause the client to display the server as incompatible
ModLoadingContext.get()
@@ -49,4 +70,34 @@ public class Main
.of(() -> FMLNetworkConstants.IGNORESERVERONLY,
(a, b) -> true));
}
private void setup(final FMLClientSetupEvent event)
{
}
/**
* A utility method to handle the transparency timing. It will (for the most
* part), make
*
* @param renderTime - How many seconds until the element entirely
* disappears.
* @param maxTime - How many seconds the element can appear.
*
* @return The proper transparency to render something.
*/
static float getAlpha(double renderTime,
double maxTime,
double fadeInTime,
double fadeOutTime)
{
if (renderTime <= fadeOutTime)
{
return (float) (renderTime / fadeOutTime);
}
else if (renderTime > maxTime - fadeInTime)
{
return (float) ((maxTime - renderTime) / fadeInTime);
}
return 1F;
}
}

View File

@@ -0,0 +1,176 @@
package markil3.immersive_hud;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.fml.ExtensionPoint;
import net.minecraftforge.fml.ModLoadingContext;
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;
import static markil3.immersive_hud.Main.TICKS_PER_SECOND;
public class ModMenu
{
static 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 TranslationTextComponent(
"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 TranslationTextComponent(
"tooltip.immersive_hud." + value.getName() +
"MaxTime"))
.setSaveConsumer(val -> value.setMaxTime((int) (val * TICKS_PER_SECOND)))
.build();
DoubleListEntry fadeIn =
entryBuilder.startDoubleField(new TranslationTextComponent(
"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 TranslationTextComponent(
"tooltip.immersive_hud." + value.getName() +
"FadeIn"))
.setSaveConsumer(val -> value.setFadeInTime((int) (val * TICKS_PER_SECOND)))
.build();
DoubleListEntry fadeOut =
entryBuilder.startDoubleField(new TranslationTextComponent(
"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 TranslationTextComponent(
"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);
}
static void setupScreen()
{
ModLoadingContext.get()
.registerExtensionPoint(ExtensionPoint.CONFIGGUIFACTORY,
() -> (mc, screen) -> {
ConfigCategory general;
ConfigEntryBuilder entryBuilder;
final ConfigBuilder builder = ConfigBuilder.create()
.setParentScreen(screen)
.setTitle(new TranslationTextComponent(
"immersive_hud.configGui.title"))
.setSavingRunnable(() -> {
ConfigManager.getInstance().save();
});
general =
builder.getOrCreateCategory(new TranslationTextComponent(
"category.immersive_hud.general"));
entryBuilder = builder.entryBuilder();
startTimeField(entryBuilder,
general,
ConfigManager.getInstance()
.getHotbarTime());
startTimeField(entryBuilder,
general,
ConfigManager.getInstance()
.getExperenceTime());
startTimeField(entryBuilder,
general,
ConfigManager.getInstance().getJumpTime());
startTimeField(entryBuilder,
general,
ConfigManager.getInstance()
.getHealthTime());
startTimeField(entryBuilder,
general,
ConfigManager.getInstance()
.getHungerTime());
startTimeField(entryBuilder,
general,
ConfigManager.getInstance()
.getPotionTime());
general.addEntry(entryBuilder.startDoubleField(new TranslationTextComponent(
"option.immersive_hud" +
".crosshairTime"),
(float) ConfigManager.getInstance()
.getCrosshairTime() / TICKS_PER_SECOND)
.setDefaultValue(6)
.setTooltip(new TranslationTextComponent(
"tooltip.immersive_hud" +
".crosshairTime"))
.setSaveConsumer(val -> ConfigManager.getInstance()
.setCrosshairTime((int) (val * TICKS_PER_SECOND)))
.build());
general.addEntry(entryBuilder.startDoubleField(new TranslationTextComponent(
"option.immersive_hud.handTime"),
(float) ConfigManager.getInstance()
.getHandTime() / TICKS_PER_SECOND)
.setDefaultValue(30)
.setTooltip(new TranslationTextComponent(
"tooltip.immersive_hud.handTime"))
.setSaveConsumer(val -> ConfigManager.getInstance()
.setHandTime((int) (val * TICKS_PER_SECOND)))
.build());
general.addEntry(entryBuilder.startDoubleField(new TranslationTextComponent(
"option.immersive_hud.minHealth"),
ConfigManager.getInstance()
.getMinHealth())
.setDefaultValue(0.5)
.setTooltip(new TranslationTextComponent(
"tooltip.immersive_hud.minHealth"))
.setSaveConsumer(val -> ConfigManager.getInstance()
.setMinHealth(
val))
.build());
general.addEntry(entryBuilder.startIntField(new TranslationTextComponent(
"option.immersive_hud.minHunger"),
ConfigManager.getInstance()
.getMinHunger())
.setDefaultValue(17)
.setTooltip(new TranslationTextComponent(
"tooltip.immersive_hud.minHunger"))
.setSaveConsumer(val -> ConfigManager.getInstance()
.setMinHunger(
val))
.build());
general.addEntry(entryBuilder.startBooleanToggle(new TranslationTextComponent(
"option.immersive_hud.showArmor"),
ConfigManager.getInstance()
.shouldShowArmor())
.setDefaultValue(true)
.setTooltip(new TranslationTextComponent(
"tooltip.immersive_hud.showArmor"))
.setSaveConsumer(val -> ConfigManager.getInstance()
.shouldShowArmor(
val))
.build());
return builder.build();
});
}
}

View File

@@ -1,32 +1,36 @@
/**
* Copyright (C) 2009-2021 Mojang Studios
*
* Players are free to create, build, and mod within Minecraft if the
* branding usage guidelines are followed. Fan art, logos, videos, and screen
* shots are acceptable as long as they are not used to falsely represent
* Mojang Minecraft assets. If you intend to use any portion of the name in
* relation to services, products, or distribution, you must adhere to the
* following requirements.
*
* Mojang's terms of service and brand guidelines are designed to let you
* know in plain terms what you can and cannot do with your game, the Mojang
* brand or Mojang assets.
* https://account.mojang.com/documents/minecraft_eula
* <p>
* Players are free to create, build, and mod within Minecraft if the branding
* usage guidelines are followed. Fan art, logos, videos, and screen shots are
* acceptable as long as they are not used to falsely represent Mojang Minecraft
* assets. If you intend to use any portion of the name in relation to
* services, products, or distribution, you must adhere to the following
* requirements.
* <p>
* Mojang's terms of service and brand guidelines are designed to let you know
* in plain terms what you can and cannot do with your game, the Mojang brand or
* Mojang assets. https://account.mojang.com/documents/minecraft_eula
*/
package markil3.immersive_hud;
import com.google.common.collect.Lists;
import com.google.common.collect.Ordering;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.gui.IngameGui;
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.client.renderer.texture.PotionSpriteUploader;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.settings.AttackIndicatorStatus;
import net.minecraft.crash.CrashReport;
@@ -35,10 +39,16 @@ import net.minecraft.crash.ReportedException;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Effect;
import net.minecraft.potion.EffectInstance;
import net.minecraft.util.HandSide;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import java.util.Collection;
import java.util.List;
/**
* Contains methods for rendering various HUD elements. Most of these methods
* come from {@link IngameGui} and
@@ -46,24 +56,104 @@ import net.minecraft.world.World;
* with some tweaks to make the mod work.
*
* @author Mojang Studios
* @author Markil 3
* @version 0.1-1.16.4-forge
*/
public class RenderUtils
{
/**
* A utility method to handle the transparency timing. It will (for the most
* part), make
*
* @param renderTime - How many ticks until the element entirely
* disappears.
*
* @author Markil 3
*/
static float getAlpha(int renderTime)
public static void renderPotionIcons(Minecraft mc,
IngameGui gui,
MatrixStack matrixStack, float ticks)
{
return Math.min(renderTime / 20.0F,
1.0F);
int scaledWidth = mc.getMainWindow().getScaledWidth();
int scaledHeight = mc.getMainWindow().getScaledHeight();
Collection<EffectInstance> collection =
mc.player.getActivePotionEffects();
if (!collection.isEmpty())
{
RenderSystem.enableBlend();
int i = 0;
int j = 0;
PotionSpriteUploader potionspriteuploader =
mc.getPotionSpriteUploader();
List<Runnable> list =
Lists.newArrayListWithExpectedSize(collection.size());
mc.getTextureManager()
.bindTexture(ContainerScreen.INVENTORY_BACKGROUND);
for (EffectInstance effectinstance : Ordering.natural()
.reverse()
.sortedCopy(collection))
{
Effect effect = effectinstance.getPotion();
float effectAlpha = TimerUtils.getPotionAlpha(mc.player, effectinstance, ticks);
if (!effectinstance.shouldRenderHUD() || effectAlpha < 0.01F)
{
continue;
}
// Rebind in case previous renderHUDEffect changed texture
mc.getTextureManager()
.bindTexture(ContainerScreen.INVENTORY_BACKGROUND);
if (effectinstance.isShowIcon())
{
int k = scaledWidth;
int l = 1;
if (mc.isDemo())
{
l += 15;
}
if (effect.isBeneficial())
{
++i;
k = k - 25 * i;
}
else
{
++j;
k = k - 25 * j;
l += 26;
}
RenderSystem.color4f(1.0F, 1.0F, 1.0F, effectAlpha);
if (effectinstance.isAmbient())
{
gui.blit(matrixStack, k, l, 165, 166, 24, 24);
}
else
{
gui.blit(matrixStack, k, l, 141, 166, 24, 24);
}
TextureAtlasSprite textureatlassprite =
potionspriteuploader.getSprite(effect);
int j1 = k;
int k1 = l;
float f1 = effectAlpha;
list.add(() -> {
mc.getTextureManager()
.bindTexture(textureatlassprite.getAtlasTexture()
.getTextureLocation());
RenderSystem.color4f(1.0F, 1.0F, 1.0F, f1);
gui.blit(matrixStack,
j1 + 3,
k1 + 3,
gui.getBlitOffset(),
18,
18,
textureatlassprite);
});
effectinstance.renderHUDEffect(gui,
matrixStack,
k,
l,
gui.getBlitOffset(),
effectAlpha);
}
}
list.forEach(Runnable::run);
}
}
/**
@@ -72,6 +162,7 @@ public class RenderUtils
* @param mc - A Minecraft instance.
* @param gui - The GUI.
* @param matrixStack - The rendering transformation matrix stack.
* @param ticks
* @param renderTime - How much time before this element becomes fully
* transparent.
*
@@ -80,14 +171,15 @@ public class RenderUtils
public static void renderHorseJumpBar(Minecraft mc,
IngameGui gui,
MatrixStack matrixStack,
int renderTime)
float ticks, double renderTime)
{
if (renderTime == 0)
ConfigManager.TimeValues jump = ConfigManager.getInstance().getJumpTime();
if (renderTime <= 0)
{
return;
}
float alpha = getAlpha(renderTime);
float alpha = Main.getAlpha(renderTime, jump.getMaxTime(), jump.getFadeInTime(), jump.getFadeOutTime());
int scaledWidth = mc.getMainWindow().getScaledWidth();
int scaledHeight = mc.getMainWindow().getScaledHeight();
int xPosition = scaledWidth / 2 - 91;
@@ -99,7 +191,7 @@ public class RenderUtils
float f = mc.player.getHorseJumpPower();
int i = 182;
int j = (int) (f * 183.0F);
int k = scaledHeight - 32 + 3;
int k = scaledHeight - TimerUtils.getJumpTranslation();
gui.blit(matrixStack, xPosition, k, 0, 84, 182, 5);
if (j > 0)
{
@@ -117,6 +209,7 @@ public class RenderUtils
* @param mc - A Minecraft instance.
* @param gui - The GUI.
* @param matrixStack - The rendering transformation matrix stack.
* @param ticks
* @param renderTime - How much time before this element becomes fully
* transparent.
*
@@ -125,14 +218,16 @@ public class RenderUtils
public static void renderExperience(Minecraft mc,
IngameGui gui,
MatrixStack matrixStack,
int renderTime)
float ticks, double renderTime)
{
if (renderTime == 0)
ConfigManager.TimeValues experience = ConfigManager.getInstance().getHealthTime();
ConfigManager.TimeValues hotbar = ConfigManager.getInstance().getHotbarTime();
if (renderTime <= 0)
{
return;
}
float alpha = getAlpha(renderTime);
float alpha = Main.getAlpha(renderTime, experience.getMaxTime(), experience.getFadeInTime(), experience.getFadeOutTime());
RenderSystem.color4f(1.0F, 1.0F, 1.0F, alpha);
if (mc.playerController.gameIsSurvivalOrAdventure())
@@ -149,7 +244,7 @@ public class RenderUtils
{
int j = 182;
int k = (int) (mc.player.experience * 183.0F);
int l = scaledHeight - 32 + 3;
int l = scaledHeight - TimerUtils.getExperienceTranslation();
gui.blit(matrixStack, x, l, 0, 64, 182, 5);
if (k > 0)
{
@@ -166,7 +261,7 @@ public class RenderUtils
String s = "" + mc.player.experienceLevel;
int i1 = (scaledWidth - gui.getFontRenderer()
.getStringWidth(s)) / 2;
int j1 = scaledHeight - 31 - 4;
int j1 = scaledHeight - (int) ((22F * Main.getAlpha(TimerUtils.hotbarTime, hotbar.getMaxTime(), hotbar.getFadeInTime(), hotbar.getFadeOutTime()) + 9F) * alpha) - (int) (4F * alpha);
gui.getFontRenderer()
.drawString(matrixStack,
s,
@@ -217,20 +312,23 @@ public class RenderUtils
*
* @see IngameGui#renderHotbar(float, MatrixStack)
*/
public static void renderHotbar(Minecraft mc, IngameGui gui,
public static void renderHotbar(Minecraft mc,
IngameGui gui,
MatrixStack matrixStack,
float partialTicks, int renderTime)
float partialTicks,
double renderTime)
{
ConfigManager.TimeValues hotbar = ConfigManager.getInstance().getHotbarTime();
final ResourceLocation WIDGETS_TEX_PATH =
new ResourceLocation("textures/gui/widgets.png");
PlayerEntity playerentity = mc.player;
if (renderTime == 0)
if (renderTime <= 0)
{
return;
}
float alpha = getAlpha(renderTime);
float alpha = Main.getAlpha(renderTime, hotbar.getMaxTime(), hotbar.getFadeInTime(), hotbar.getFadeOutTime());
int scaledWidth = mc.getMainWindow().getScaledWidth();
int scaledHeight = mc.getMainWindow().getScaledHeight();
@@ -245,10 +343,10 @@ public class RenderUtils
int k = 182;
int l = 91;
gui.setBlitOffset(-90);
gui.blit(matrixStack, i - 91, scaledHeight - 22, 0, 0, 182, 22);
gui.blit(matrixStack, i - 91, scaledHeight - TimerUtils.getHotbarTranslation(), 0, 0, 182, 22);
gui.blit(matrixStack,
i - 91 - 1 + playerentity.inventory.currentItem * 20,
scaledHeight - 22 - 1,
scaledHeight - (int) (22F * alpha) - 1,
0,
22,
24,
@@ -259,7 +357,7 @@ public class RenderUtils
{
gui.blit(matrixStack,
i - 91 - 29,
scaledHeight - 23,
scaledHeight - (int) (23F * alpha),
24,
22,
29,
@@ -269,7 +367,7 @@ public class RenderUtils
{
gui.blit(matrixStack,
i + 91,
scaledHeight - 23,
scaledHeight - (int) (23F * alpha),
53,
22,
29,
@@ -285,7 +383,7 @@ public class RenderUtils
for (int i1 = 0; i1 < 9; ++i1)
{
int j1 = i - 90 + i1 * 20 + 2;
int k1 = scaledHeight - 16 - 3;
int k1 = scaledHeight - (int) (16F * alpha) - 3;
renderHotbarItem(mc, alpha, j1,
k1,
partialTicks,
@@ -295,7 +393,7 @@ public class RenderUtils
if (!itemstack.isEmpty())
{
int i2 = scaledHeight - 16 - 3;
int i2 = scaledHeight - (int) (16F * alpha) - 3;
if (handside == HandSide.LEFT)
{
renderHotbarItem(mc, alpha, i - 91 - 26,

File diff suppressed because it is too large Load Diff

View File

@@ -9,9 +9,9 @@ modLoader="javafml" #mandatory
loaderVersion="[35,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
license="All rights reserved"
license="GPL-3.0-only"
# A URL to refer people to when problems occur with this mod
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
issueTrackerURL="https://github.com/Markil3/MinecraftImmersiveHUD/issues" #optional
# A list of mods - how many allowed here is determined by the individual mod loader
[[mods]] #mandatory
# The modid of the mod
@@ -23,28 +23,35 @@ version="${file.jarVersion}" #mandatory
# A display name for the mod
displayName="Immersive HUD" #mandatory
# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional
updateJSONURL="https://raw.githubusercontent.com/Markil3/MinecraftImmersiveHUD/master/update-forge.json" #optional
# A URL for the "homepage" for this mod, displayed in the mod UI
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional
displayURL="https://www.planetminecraft.com/mod/immersive-hud/" #optional
# A file name (in the root of the mod JAR) containing a logo for display
logoFile="immersive_hud_logo.png" #optional
# A text field displayed in the mod UI
credits="Minecraft Rendering Code (c) 2009-2021 Mojang Studios" #optional
# A text field displayed in the mod UI
authors="Markil 3" #optional
authors="Markil 3"
# The description text for the mod (multi line!) (#mandatory)
description='''
This mod aims to move the ingame HUD out of the way whenever possible. Whenever an element updates (i.e., health changes, you swap items, you look at something, etc.), the respective item will show up. However, once you've been able to see the information, it will fade away and allow you to enjoy your game without the clutter of unneeded HUD elements.
This Minecraft mod aims to move the ingame HUD out of the way whenever possible. Whenever an element updates
(i.e., health changes, you swap items, you look at something, etc.), the respective item will show
up. However, once you've been able to see the information, it will fade away and allow you to enjoy
your game without the clutter of unneeded HUD elements.
The following elements will only show up under certain conditions:
Note that the following elements are unaffected:
* The F3 Menu. Honestly, anyone who uses this isn't in the need for immersion at the moment.
* The chat. This will automatically fade away by itself.
* The oxygen bar. This will disappear as soon as it is filled, anyway.
* Boss health. It is helpful to have this available in a hectic situation.
* Sub-maximum health or hunger. In hectic battles, it can be convenient to see health at a glance.
* The health and armor bars will only show up when your health changes (i.e. after taking damage), when your health is low or when holding food.
* The hunger bar will only show up when your hunger level (not your saturation) changes, you are hungry, or when holding food.
* The experience bar and level will only show upon gaining experience.
* The health of your mount (i.e. your horse) will only show when its health changes.
* The horse jump bar will only show when you are getting ready to jump.
* The hotbar will only show when an item you are holding changes or you change which slot is selected.
* The crosshair will only show when you are looking at something or you are using a bow, crossbow, shield, or trident or holding a throwable item.
* The hands will show only when you use an item or are holding/using one of the above specified items, or a map.
* Potion icons will only show up when first applied or about to run out.
'''
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
[[dependencies.immersive_hud]] #optional
[[dependencies.immersive_hud]]
# the modid of the dependency
modId="forge" #mandatory
# Does this dependency have to exist - if not, ordering below must be specified
@@ -55,6 +62,18 @@ Note that the following elements are unaffected:
ordering="NONE"
# Side this dependency is applied on - BOTH, CLIENT or SERVER
side="CLIENT"
[[dependencies.immersive_hud]]
# the modid of the dependency
modId="cloth-config" #mandatory
# Does this dependency have to exist - if not, ordering below must be specified
mandatory=false #mandatory
# The version range of the dependency
versionRange="[4.11,)" #mandatory
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
ordering="BEFORE"
# Side this dependency is applied on - BOTH, CLIENT or SERVER
side="CLIENT"
# Here's another dependency
[[dependencies.immersive_hud]]
modId="minecraft"

View 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"
}