Compare commits

..

25 Commits

Author SHA1 Message Date
Markil3
47675e4412 Fixes a crash on some computers where the configuration file can't always be made. 2021-04-01 18:18:17 -06:00
Markil3
5219932076 Changes:
+ Adds the ability to determine whether hands and crosshairs disappear or not. This can be changed in the mod configuration.
* Reduces the chance of the mod crashing the game for ordinary events (any errors will be reported to the console, though).
Bug Fixes
* Fixes crash when mounting boat or minecart (#1 thanks, @theFuzzyWarble!)
2021-04-01 13:09:55 -06:00
Markil3
bb18357bfe Adds the ability to always show hands and crosshairs.
Apparently, @rflambert doesn't want the hands to fade. It seemed like a good idea, so I added a configurable option to the main repo.
2021-03-26 11:00:18 -06:00
Markil3
5e3b714190 Catches any errors that occur when triggering events.
It is pretty annoying for the game to crash because of a GUI mod. This should reduce that.
2021-03-26 09:27:07 -06:00
Markil3
5059774b34 Fixes a ClassCastException (#1) 2021-03-25 17:15:36 -06:00
Markil3
ea97ade6cd Prepares the mod for 1.14 2021-03-02 22:08:39 -07:00
Markil3
c0da30efae Fixes the hand not moving correctly. 2021-03-02 18:04:39 -07:00
Markil3
bb9998a59b Locks this build out of 1.15.2
There is at least one change that doesn't work in 1.15.2. A new branch will be needed for this.
2021-03-02 18:04:15 -07:00
Markil3
656a548074 Prepares the mod for 1.15 2021-03-02 17:49:11 -07:00
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
11 changed files with 2159 additions and 867 deletions

View File

@@ -13,6 +13,10 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse' apply plugin: 'eclipse'
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
repositories {
maven { url "https://maven.shedaniel.me/" }
}
archivesBaseName = project.archives_base_name archivesBaseName = project.archives_base_name
version = project.mod_version + "-" + project.minecraft_version + "-forge" version = project.mod_version + "-" + project.minecraft_version + "-forge"
group = project.maven_group // http://maven.apache.org/guides/mini/guide-naming-conventions.html 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. // 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}" 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.. // 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:classifier"
// compile "some.group:artifact:version" // compile "some.group:artifact:version"

View File

@@ -4,11 +4,12 @@ org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false org.gradle.daemon=false
# Forge Properties # Forge Properties
minecraft_version=1.16.4 minecraft_version=1.14.2
mappings=20201028-1.16.3 mappings=20190621-1.14.2
forge_version=35.1.37 forge_version=26.0.63
# Mod Properties # Mod Properties
mod_version = 0.1 mod_version = 1.1.1
maven_group = markil3 maven_group = markil3
archives_base_name = immersive_hud archives_base_name = immersive_hud

View File

@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip

View File

@@ -0,0 +1,436 @@
package markil3.immersive_hud;
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
import com.electronwill.nightconfig.core.io.WritingMode;
import net.minecraft.client.Minecraft;
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.
*
* @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(Minecraft.getInstance().gameDir.toPath().toAbsolutePath().resolve(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.BooleanValue hideCrosshair;
private final ForgeConfigSpec.IntValue handTime;
private final ForgeConfigSpec.BooleanValue hideHands;
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.hideCrosshair =
configSpecBuilder.translation(
"immersive_hud.configGui.hideCrosshair.title")
.define("hideCrosshair", true);
this.handTime =
configSpecBuilder.translation(
"immersive_hud.configGui.handTime.title")
.defineInRange("handTime",
30 * TICKS_PER_SECOND,
0,
10 * 60 * TICKS_PER_SECOND);
this.hideHands =
configSpecBuilder.translation(
"immersive_hud.configGui.hideHands.title")
.define("hideHands", true);
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();
}
/**
* Checks whether the crosshairs should be hidden after a period of time.
*
* @return - Whether or not crosshairs will be hidden.
*/
public boolean hideCrosshair()
{
return this.hideCrosshair.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 hands should be hidden after a period of time.
*
* @return - Whether or not hands will be hidden.
*/
public boolean hideHands()
{
return this.hideHands.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 whether the crosshairs should be hidden after a period of time.
// *
// * @param hide - Whether or not crosshairs will be hidden.
// */
// public void hideCrosshair(boolean hide)
// {
// this.hideCrosshair.set(hide);
// }
//
// /**
// * 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);
// }
//
// /**
// * Sets whether hands should be hidden after a period of time.
// *
// * @param hide - Whether or not hands will be hidden.
// */
// public void hideHands(boolean hide)
// {
// this.hideHands.set(hide);
// }
//
// /**
// * 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 * Copyright (C) 2021 Markil 3
* <p> * <p>
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
@@ -16,30 +16,14 @@
*/ */
package markil3.immersive_hud; package markil3.immersive_hud;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.Minecraft; 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.Item;
import net.minecraft.item.ItemStack; 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.api.distmarker.Dist;
import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderHandEvent; import net.minecraftforge.client.event.RenderSpecificHandEvent;
import net.minecraftforge.event.entity.EntityMountEvent; import net.minecraftforge.event.entity.EntityMountEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
@@ -51,6 +35,8 @@ import org.apache.logging.log4j.Logger;
import java.util.Optional; import java.util.Optional;
import static markil3.immersive_hud.TimerUtils.resetAlpha;
/** /**
* Contains the logic for changing the HUD. * Contains the logic for changing the HUD.
* *
@@ -65,128 +51,6 @@ public class EventBus
*/ */
private static final Logger LOGGER = LogManager.getLogger(); 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 * 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 * view, and briefly brings the health and hunger into view if the held item
@@ -197,36 +61,25 @@ public class EventBus
@SubscribeEvent @SubscribeEvent
public static void onClick(final PlayerInteractEvent event) public static void onClick(final PlayerInteractEvent event)
{ {
DistExecutor.safeRunWhenOn(Dist.CLIENT, try
(DistExecutor.SafeSupplier<DistExecutor.SafeRunnable>) () -> new DistExecutor.SafeRunnable()
{ {
@Override DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
public void run()
{ {
Item item = Item item =
Optional.ofNullable(event.getItemStack()) Optional.ofNullable(event.getItemStack())
.map(ItemStack::getItem) .map(ItemStack::getItem)
.orElse(null); .orElse(null);
crosshairTime = VISUAL_TIME; TimerUtils.onClick(event.getHand(), item);
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;
}
}
}
}); });
} }
catch (Exception e)
{
LOGGER.error(
"Error in running markil3.immersive_hud.EventBus#onClick " +
"event",
e);
}
}
/** /**
* Run whenever the player mounts something. This brings the mount's health * Run whenever the player mounts something. This brings the mount's health
@@ -240,16 +93,21 @@ public class EventBus
@SubscribeEvent @SubscribeEvent
public static void onMount(final EntityMountEvent event) public static void onMount(final EntityMountEvent event)
{ {
DistExecutor.safeRunWhenOn(Dist.CLIENT, try
(DistExecutor.SafeSupplier<DistExecutor.SafeRunnable>) () -> new DistExecutor.SafeRunnable()
{ {
@Override DistExecutor.runWhenOn(Dist.CLIENT, () -> () ->
public void run()
{ {
mountTime = VISUAL_TIME; TimerUtils.resetMountHealth();
}
}); });
} }
catch (Exception e)
{
LOGGER.error(
"Error in running markil3.immersive_hud.EventBus#onMount " +
"event",
e);
}
}
/** /**
* Run whenever a hand is rendered in 1st person. This brings the player * Run whenever a hand is rendered in 1st person. This brings the player
@@ -258,55 +116,22 @@ public class EventBus
* @param event - event data * @param event - event data
*/ */
@SubscribeEvent @SubscribeEvent
public static void onRenderHand(final RenderHandEvent event) public static void onRenderHand(final RenderSpecificHandEvent event)
{ {
final int HAND_UP_TIME = 20; try
switch (event.getHand())
{ {
case OFF_HAND: if (TimerUtils.onRenderHand(event.getHand(),
if (mainHandTime > 0 && mainHandTime < HAND_UP_TIME) event.getPartialTicks()))
{
/*
* Undo the transformation of the previous hand
*/
event.getMatrixStack()
.translate(0,
1.0F * (HAND_UP_TIME - mainHandTime) / HAND_UP_TIME,
0);
}
if (offHandTime == 0)
{ {
event.setCanceled(true); 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);
} }
} catch (Exception e)
break;
case MAIN_HAND:
if (mainHandTime == 0)
{ {
event.setCanceled(true); LOGGER.error(
} "Error in running markil3.immersive_hud" +
else if (!mainHandLock && (mapLock & 0b10) == 0) ".EventBus#onRenderHand event",
{ e);
mainHandTime--;
if (mainHandTime < HAND_UP_TIME)
{
event.getMatrixStack()
.translate(0,
-1.0F * (HAND_UP_TIME - mainHandTime) / HAND_UP_TIME,
0);
}
}
break;
} }
} }
@@ -319,364 +144,85 @@ public class EventBus
@SubscribeEvent @SubscribeEvent
public static void onGUIDraw(final RenderGameOverlayEvent event) public static void onGUIDraw(final RenderGameOverlayEvent event)
{ {
/* try
* 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(); Minecraft mc = Minecraft.getInstance();
boolean changed = false; boolean fadeIn = false;
int hotbarSlot;
Item item, handItem = null;
switch (event.getType()) switch (event.getType())
{ {
case CROSSHAIRS: case CROSSHAIRS:
if (event instanceof RenderGameOverlayEvent.Pre) if (event instanceof RenderGameOverlayEvent.Pre)
{ {
if (mc.objectMouseOver != null && mc.objectMouseOver.getType() != RayTraceResult.Type.MISS) if (TimerUtils.drawCrosshair(event.getPartialTicks()))
{
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
{ {
event.setCanceled(true); event.setCanceled(true);
} }
if (crosshairTime > 0)
{
crosshairTime--;
}
} }
/*
* Reset the transparency.
*/
else if (event instanceof RenderGameOverlayEvent.Post) 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.getPartialTicks());
resetAlpha();
} }
break; break;
case HOTBAR: case HOTBAR:
if (event instanceof RenderGameOverlayEvent.Pre) if (event instanceof RenderGameOverlayEvent.Pre)
{ {
mainHandLock = offHandLock = false;
mapLock = 0;
event.setCanceled(true); 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, RenderUtils.renderHotbar(mc, mc.ingameGUI,
event.getMatrixStack(), event.getPartialTicks(), TimerUtils.hotbarTime);
event.getPartialTicks(), hotbarTime); }
} }
break; break;
case HEALTH: case HEALTH:
if (event instanceof RenderGameOverlayEvent.Pre) if (event instanceof RenderGameOverlayEvent.Pre)
{ {
/* if (TimerUtils.drawHealth(event.getPartialTicks()))
* Skip healthy bars that haven't updated in awhile.
*/
if (healthTime == 0 && health / maxHealth > CONST_BOUNDARY)
{ {
event.setCanceled(true); 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) else if (event instanceof RenderGameOverlayEvent.Post)
{ {
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.popMatrix();
resetAlpha();
} }
break; break;
case FOOD: case FOOD:
if (event instanceof RenderGameOverlayEvent.Pre) if (event instanceof RenderGameOverlayEvent.Pre)
{ {
/* if (TimerUtils.drawHunger(event.getPartialTicks()))
* Skip satisfied bars that haven't updated in awhile.
*/
if (hungerTime == 0 && hunger > HUNGER_BOUNDARY)
{ {
event.setCanceled(true); 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. * Reset the transparency.
*/ */
else if (event instanceof RenderGameOverlayEvent.Post) else if (event instanceof RenderGameOverlayEvent.Post)
{ {
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.popMatrix();
resetAlpha();
} }
break; break;
case ARMOR: case ARMOR:
if (event instanceof RenderGameOverlayEvent.Pre) if (event instanceof RenderGameOverlayEvent.Pre)
{ {
/* if (TimerUtils.drawArmor(event.getPartialTicks()))
* Renders armor along with health.
*/
if (healthTime > 0)
{
RenderSystem.color4f(1.0F,
1.0F,
1.0F,
RenderUtils.getAlpha(healthTime));
}
else
{ {
event.setCanceled(true); event.setCanceled(true);
} }
@@ -686,90 +232,74 @@ public class EventBus
*/ */
else if (event instanceof RenderGameOverlayEvent.Post) else if (event instanceof RenderGameOverlayEvent.Post)
{ {
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.popMatrix();
resetAlpha();
}
break;
case AIR:
if (event instanceof RenderGameOverlayEvent.Pre)
{
if (TimerUtils.drawAir(event.getPartialTicks()))
{
event.setCanceled(true);
}
}
/*
* Reset the transparency.
*/
else if (event instanceof RenderGameOverlayEvent.Post)
{
GlStateManager.popMatrix();
resetAlpha();
} }
break; break;
case HEALTHMOUNT: case HEALTHMOUNT:
if (event instanceof RenderGameOverlayEvent.Pre) if (event instanceof RenderGameOverlayEvent.Pre)
{ {
Entity tmp = mc.player.getRidingEntity(); if (TimerUtils.drawMountHealth(event.getPartialTicks()))
if (tmp == null)
{ {
mountHealth = -1; event.setCanceled(true);
mountMaxHealth = -1;
} }
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) else if (event instanceof RenderGameOverlayEvent.Post)
{ {
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.popMatrix();
resetAlpha();
} }
break; break;
case JUMPBAR: case JUMPBAR:
if (event instanceof RenderGameOverlayEvent.Pre) if (event instanceof RenderGameOverlayEvent.Pre)
{ {
event.setCanceled(true); event.setCanceled(true);
if (mc.player.getHorseJumpPower() > 0) if (!TimerUtils.drawJumpbar(event.getPartialTicks()))
{ {
jumpTime = VISUAL_TIME; RenderUtils.renderHorseJumpBar(mc,
mc.ingameGUI,
event.getPartialTicks(),
TimerUtils.jumpTime);
} }
else if (jumpTime > 0)
{
jumpTime--;
}
RenderUtils.renderHorseJumpBar(mc, mc.ingameGUI,
event.getMatrixStack(), jumpTime);
} }
break; break;
case EXPERIENCE: case EXPERIENCE:
if (event instanceof RenderGameOverlayEvent.Pre) if (event instanceof RenderGameOverlayEvent.Pre)
{ {
event.setCanceled(true); event.setCanceled(true);
if (experienceProgress != mc.player.experience) if (!TimerUtils.drawExperience(event.getPartialTicks()))
{ {
experienceProgress = mc.player.experience; RenderUtils.renderExperience(mc,
changed = true; mc.ingameGUI,
event.getPartialTicks(),
TimerUtils.experienceTime);
} }
if (changed)
{
experienceTime = VISUAL_TIME;
}
else if (experienceTime > 0)
{
experienceTime--;
}
RenderUtils.renderExperience(mc, mc.ingameGUI,
event.getMatrixStack(), experienceTime);
} }
break; break;
} }
} }
catch (Exception e)
{
LOGGER.error(
"Error in running markil3.immersive_hud.EventBus#onGUIDraw event",
e);
}
}
} }

View File

@@ -20,6 +20,8 @@ package markil3.immersive_hud;
import net.minecraftforge.fml.ExtensionPoint; import net.minecraftforge.fml.ExtensionPoint;
import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod; 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 net.minecraftforge.fml.network.FMLNetworkConstants;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
@@ -39,9 +41,25 @@ public class Main
* Class logger. * Class logger.
*/ */
private static final Logger LOGGER = LogManager.getLogger(); private static final Logger LOGGER = LogManager.getLogger();
public static final int TICKS_PER_SECOND = 20;
public Main() 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 //Make sure the mod being absent on the other network side does not
// cause the client to display the server as incompatible // cause the client to display the server as incompatible
ModLoadingContext.get() ModLoadingContext.get()
@@ -49,4 +67,34 @@ public class Main
.of(() -> FMLNetworkConstants.IGNORESERVERONLY, .of(() -> FMLNetworkConstants.IGNORESERVERONLY,
(a, b) -> true)); (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

@@ -1,33 +1,34 @@
/** /**
* Copyright (C) 2009-2021 Mojang Studios * Copyright (C) 2009-2021 Mojang Studios
* * <p>
* Players are free to create, build, and mod within Minecraft if the * Players are free to create, build, and mod within Minecraft if the branding
* branding usage guidelines are followed. Fan art, logos, videos, and screen * usage guidelines are followed. Fan art, logos, videos, and screen shots are
* shots are acceptable as long as they are not used to falsely represent * acceptable as long as they are not used to falsely represent Mojang Minecraft
* Mojang Minecraft assets. If you intend to use any portion of the name in * assets. If you intend to use any portion of the name in relation to
* relation to services, products, or distribution, you must adhere to the * services, products, or distribution, you must adhere to the following
* following requirements. * requirements.
* * <p>
* Mojang's terms of service and brand guidelines are designed to let you * Mojang's terms of service and brand guidelines are designed to let you know
* know in plain terms what you can and cannot do with your game, the Mojang * in plain terms what you can and cannot do with your game, the Mojang brand or
* brand or Mojang assets. * Mojang assets. https://account.mojang.com/documents/minecraft_eula
* https://account.mojang.com/documents/minecraft_eula
*/ */
package markil3.immersive_hud; package markil3.immersive_hud;
import com.mojang.blaze3d.matrix.MatrixStack; import com.google.common.collect.Lists;
import com.mojang.blaze3d.systems.RenderSystem; import com.google.common.collect.Ordering;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.AbstractGui; import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.gui.IngameGui; import net.minecraft.client.gui.IngameGui;
import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.gui.screen.inventory.ContainerScreen;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.AtlasTexture; 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.TextureManager; import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.settings.AttackIndicatorStatus; import net.minecraft.client.settings.AttackIndicatorStatus;
import net.minecraft.crash.CrashReport; import net.minecraft.crash.CrashReport;
import net.minecraft.crash.CrashReportCategory; import net.minecraft.crash.CrashReportCategory;
@@ -35,10 +36,17 @@ import net.minecraft.crash.ReportedException;
import net.minecraft.entity.LivingEntity; import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.potion.Effect;
import net.minecraft.potion.EffectInstance;
import net.minecraft.util.HandSide; import net.minecraft.util.HandSide;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.List;
/** /**
* Contains methods for rendering various HUD elements. Most of these methods * Contains methods for rendering various HUD elements. Most of these methods
* come from {@link IngameGui} and * come from {@link IngameGui} and
@@ -46,24 +54,159 @@ import net.minecraft.world.World;
* with some tweaks to make the mod work. * with some tweaks to make the mod work.
* *
* @author Mojang Studios * @author Mojang Studios
* @author Markil 3
* @version 0.1-1.16.4-forge * @version 0.1-1.16.4-forge
*/ */
public class RenderUtils public class RenderUtils
{ {
/** private static int getBlitOffset(IngameGui gui)
* 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)
{ {
return Math.min(renderTime / 20.0F, Field blitAccessField = null;
1.0F); int blitAccess = 0;
try
{
blitAccessField = AbstractGui.class.getDeclaredField("blitOffset");
}
catch (NoSuchFieldException e)
{
e.printStackTrace();
}
if (!blitAccessField.isAccessible())
{
blitAccessField.setAccessible(true);
}
try
{
blitAccess = (int) blitAccessField.get(gui);
}
catch (IllegalAccessException e)
{
e.printStackTrace();
}
return blitAccess;
}
private static boolean setBlitOffset(IngameGui gui, int value)
{
Field blitAccessField = null;
int blitAccess = 0;
try
{
blitAccessField = AbstractGui.class.getDeclaredField("blitOffset");
}
catch (NoSuchFieldException e)
{
e.printStackTrace();
return false;
}
if (!blitAccessField.isAccessible())
{
blitAccessField.setAccessible(true);
}
try
{
blitAccessField.set(gui, value);
return true;
}
catch (IllegalAccessException e)
{
e.printStackTrace();
return false;
}
}
public static void renderPotionIcons(Minecraft mc,
IngameGui gui,
float ticks)
{
int scaledWidth = mc.mainWindow.getScaledWidth();
int scaledHeight = mc.mainWindow.getScaledHeight();
Collection<EffectInstance> collection =
mc.player.getActivePotionEffects();
if (!collection.isEmpty())
{
GlStateManager.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.isShowIcon() || 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;
}
GlStateManager.color4f(1.0F, 1.0F, 1.0F, effectAlpha);
if (effectinstance.isAmbient())
{
gui.blit(k, l, 165, 166, 24, 24);
}
else
{
gui.blit(k, l, 141, 166, 24, 24);
}
float f_f = effectAlpha;
int k_f = k;
int l_f = l;
TextureAtlasSprite textureatlassprite =
potionspriteuploader.func_215288_a(effect);
list.add(() -> {
GlStateManager.color4f(1.0F, 1.0F, 1.0F, f_f);
gui.blit(k_f + 3, l_f + 3, getBlitOffset(gui), 18, 18, textureatlassprite);
});
effect.renderHUDEffect(effectinstance, gui,
k,
l,
getBlitOffset(gui),
effectAlpha);
}
}
mc.getTextureManager().bindTexture(AtlasTexture.LOCATION_EFFECTS_TEXTURE);
list.forEach(Runnable::run);
}
} }
/** /**
@@ -71,43 +214,47 @@ public class RenderUtils
* *
* @param mc - A Minecraft instance. * @param mc - A Minecraft instance.
* @param gui - The GUI. * @param gui - The GUI.
* @param matrixStack - The rendering transformation matrix stack. * @param ticks
* @param renderTime - How much time before this element becomes fully * @param renderTime - How much time before this element becomes fully
* transparent. * transparent.
* *
* @see IngameGui#renderHorseJumpBar(MatrixStack, int) * @see IngameGui#renderHorseJumpBar(int)
*/ */
public static void renderHorseJumpBar(Minecraft mc, public static void renderHorseJumpBar(Minecraft mc,
IngameGui gui, IngameGui gui,
MatrixStack matrixStack, float ticks, double renderTime)
int renderTime)
{ {
if (renderTime == 0) ConfigManager.TimeValues jump =
ConfigManager.getInstance().getJumpTime();
if (renderTime <= 0)
{ {
return; return;
} }
float alpha = getAlpha(renderTime); float alpha = Main.getAlpha(renderTime,
int scaledWidth = mc.getMainWindow().getScaledWidth(); jump.getMaxTime(),
int scaledHeight = mc.getMainWindow().getScaledHeight(); jump.getFadeInTime(),
jump.getFadeOutTime());
int scaledWidth = mc.mainWindow.getScaledWidth();
int scaledHeight = mc.mainWindow.getScaledHeight();
int xPosition = scaledWidth / 2 - 91; int xPosition = scaledWidth / 2 - 91;
mc.getProfiler().startSection("jumpBar"); mc.getProfiler().startSection("jumpBar");
RenderSystem.enableBlend(); GlStateManager.enableBlend();
RenderSystem.color4f(1.0F, 1.0F, 1.0F, alpha); GlStateManager.color4f(1.0F, 1.0F, 1.0F, alpha);
mc.getTextureManager().bindTexture(AbstractGui.GUI_ICONS_LOCATION); mc.getTextureManager().bindTexture(AbstractGui.GUI_ICONS_LOCATION);
float f = mc.player.getHorseJumpPower(); float f = mc.player.getHorseJumpPower();
int i = 182; int i = 182;
int j = (int) (f * 183.0F); 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); gui.blit(xPosition, k, 0, 84, 182, 5);
if (j > 0) if (j > 0)
{ {
gui.blit(matrixStack, xPosition, k, 0, 89, j, 5); gui.blit(xPosition, k, 0, 89, j, 5);
} }
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.disableBlend(); GlStateManager.disableBlend();
mc.getProfiler().endSection(); mc.getProfiler().endSection();
} }
@@ -116,92 +263,97 @@ public class RenderUtils
* *
* @param mc - A Minecraft instance. * @param mc - A Minecraft instance.
* @param gui - The GUI. * @param gui - The GUI.
* @param matrixStack - The rendering transformation matrix stack. * @param ticks
* @param renderTime - How much time before this element becomes fully * @param renderTime - How much time before this element becomes fully
* transparent. * transparent.
* *
* @see IngameGui#func_238454_b_(MatrixStack, int) * @see IngameGui#func_238454_b_(int)
*/ */
public static void renderExperience(Minecraft mc, public static void renderExperience(Minecraft mc,
IngameGui gui, IngameGui gui,
MatrixStack matrixStack, float ticks, double renderTime)
int renderTime)
{ {
if (renderTime == 0) ConfigManager.TimeValues experience =
ConfigManager.getInstance().getHealthTime();
ConfigManager.TimeValues hotbar =
ConfigManager.getInstance().getHotbarTime();
if (renderTime <= 0)
{ {
return; return;
} }
float alpha = getAlpha(renderTime); float alpha = Main.getAlpha(renderTime,
RenderSystem.color4f(1.0F, 1.0F, 1.0F, alpha); experience.getMaxTime(),
experience.getFadeInTime(),
experience.getFadeOutTime());
GlStateManager.color4f(1.0F, 1.0F, 1.0F, alpha);
if (mc.playerController.gameIsSurvivalOrAdventure()) if (mc.playerController.gameIsSurvivalOrAdventure())
{ {
int scaledWidth = mc.getMainWindow().getScaledWidth(); int scaledWidth = mc.mainWindow.getScaledWidth();
int scaledHeight = mc.getMainWindow().getScaledHeight(); int scaledHeight = mc.mainWindow.getScaledHeight();
int x = scaledWidth / 2 - 91; int x = scaledWidth / 2 - 91;
mc.getProfiler().startSection("expBar"); mc.getProfiler().startSection("expBar");
RenderSystem.enableBlend(); GlStateManager.enableBlend();
mc.getTextureManager().bindTexture(AbstractGui.GUI_ICONS_LOCATION); mc.getTextureManager().bindTexture(AbstractGui.GUI_ICONS_LOCATION);
int i = mc.player.xpBarCap(); int i = mc.player.xpBarCap();
if (i > 0) if (i > 0)
{ {
int j = 182; int j = 182;
int k = (int) (mc.player.experience * 183.0F); 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); gui.blit(x, l, 0, 64, 182, 5);
if (k > 0) if (k > 0)
{ {
gui.blit(matrixStack, x, l, 0, 69, k, 5); gui.blit(x, l, 0, 69, k, 5);
} }
} }
RenderSystem.disableBlend(); GlStateManager.disableBlend();
mc.getProfiler().endSection(); mc.getProfiler().endSection();
if (mc.player.experienceLevel > 0) if (mc.player.experienceLevel > 0)
{ {
mc.getProfiler().startSection("expLevel"); mc.getProfiler().startSection("expLevel");
RenderSystem.enableBlend(); GlStateManager.enableBlend();
String s = "" + mc.player.experienceLevel; String s = "" + mc.player.experienceLevel;
int i1 = (scaledWidth - gui.getFontRenderer() int i1 = (scaledWidth - gui.getFontRenderer()
.getStringWidth(s)) / 2; .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() gui.getFontRenderer()
.drawString(matrixStack, .drawString(s,
s,
(float) (i1 + 1), (float) (i1 + 1),
(float) j1, (float) j1,
0); 0);
gui.getFontRenderer() gui.getFontRenderer()
.drawString(matrixStack, .drawString(s,
s,
(float) (i1 - 1), (float) (i1 - 1),
(float) j1, (float) j1,
0); 0);
gui.getFontRenderer() gui.getFontRenderer()
.drawString(matrixStack, .drawString(s,
s,
(float) i1, (float) i1,
(float) (j1 + 1), (float) (j1 + 1),
0); 0);
gui.getFontRenderer() gui.getFontRenderer()
.drawString(matrixStack, .drawString(s,
s,
(float) i1, (float) i1,
(float) (j1 - 1), (float) (j1 - 1),
0); 0);
gui.getFontRenderer() gui.getFontRenderer()
.drawString(matrixStack, .drawString(s,
s,
(float) i1, (float) i1,
(float) j1, (float) j1,
8453920); 8453920);
RenderSystem.disableBlend(); GlStateManager.disableBlend();
mc.getProfiler().endSection(); mc.getProfiler().endSection();
} }
} }
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
} }
@@ -210,45 +362,50 @@ public class RenderUtils
* *
* @param mc - A Minecraft instance. * @param mc - A Minecraft instance.
* @param gui - The GUI. * @param gui - The GUI.
* @param matrixStack - The rendering transformation matrix stack.
* @param partialTicks * @param partialTicks
* @param renderTime - How much time before this element becomes fully * @param renderTime - How much time before this element becomes fully
* transparent. * transparent.
* *
* @see IngameGui#renderHotbar(float, MatrixStack) * @see IngameGui#renderHotbar(float)
*/ */
public static void renderHotbar(Minecraft mc, IngameGui gui, public static void renderHotbar(Minecraft mc,
MatrixStack matrixStack, IngameGui gui,
float partialTicks, int renderTime) float partialTicks,
double renderTime)
{ {
ConfigManager.TimeValues hotbar =
ConfigManager.getInstance().getHotbarTime();
final ResourceLocation WIDGETS_TEX_PATH = final ResourceLocation WIDGETS_TEX_PATH =
new ResourceLocation("textures/gui/widgets.png"); new ResourceLocation("textures/gui/widgets.png");
PlayerEntity playerentity = mc.player; PlayerEntity playerentity = mc.player;
if (renderTime == 0) if (renderTime <= 0)
{ {
return; return;
} }
float alpha = getAlpha(renderTime); float alpha = Main.getAlpha(renderTime,
hotbar.getMaxTime(),
hotbar.getFadeInTime(),
hotbar.getFadeOutTime());
int scaledWidth = mc.getMainWindow().getScaledWidth(); int scaledWidth = mc.mainWindow.getScaledWidth();
int scaledHeight = mc.getMainWindow().getScaledHeight(); int scaledHeight = mc.mainWindow.getScaledHeight();
if (playerentity != null) if (playerentity != null)
{ {
RenderSystem.color4f(1.0F, 1.0F, 1.0F, alpha); GlStateManager.color4f(1.0F, 1.0F, 1.0F, alpha);
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.getTextureManager().bindTexture(WIDGETS_TEX_PATH); mc.getTextureManager().bindTexture(WIDGETS_TEX_PATH);
ItemStack itemstack = playerentity.getHeldItemOffhand(); ItemStack itemstack = playerentity.getHeldItemOffhand();
HandSide handside = playerentity.getPrimaryHand().opposite(); HandSide handside = playerentity.getPrimaryHand().opposite();
int i = scaledWidth / 2; int i = scaledWidth / 2;
int j = gui.getBlitOffset(); int j = getBlitOffset(gui);
int k = 182; int k = 182;
int l = 91; int l = 91;
gui.setBlitOffset(-90); setBlitOffset(gui, -90);
gui.blit(matrixStack, i - 91, scaledHeight - 22, 0, 0, 182, 22); gui.blit(i - 91, scaledHeight - TimerUtils.getHotbarTranslation(), 0, 0, 182, 22);
gui.blit(matrixStack, gui.blit(i - 91 - 1 + playerentity.inventory.currentItem * 20,
i - 91 - 1 + playerentity.inventory.currentItem * 20, scaledHeight - (int) (22F * alpha) - 1,
scaledHeight - 22 - 1,
0, 0,
22, 22,
24, 24,
@@ -257,9 +414,8 @@ public class RenderUtils
{ {
if (handside == HandSide.LEFT) if (handside == HandSide.LEFT)
{ {
gui.blit(matrixStack, gui.blit(i - 91 - 29,
i - 91 - 29, scaledHeight - (int) (23 * alpha),
scaledHeight - 23,
24, 24,
22, 22,
29, 29,
@@ -267,26 +423,26 @@ public class RenderUtils
} }
else else
{ {
gui.blit(matrixStack, gui.blit(i + 91, scaledHeight - (int) (23 * alpha), 53, 22, 29, 24);
i + 91,
scaledHeight - 23,
53,
22,
29,
24);
} }
} }
gui.setBlitOffset(j); setBlitOffset(gui, j);
RenderSystem.enableRescaleNormal(); GlStateManager.enableRescaleNormal();
RenderSystem.enableBlend(); GlStateManager.enableBlend();
RenderSystem.defaultBlendFunc(); GlStateManager.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA,
GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA,
GlStateManager.SourceFactor.ONE,
GlStateManager.DestFactor.ZERO);
RenderHelper.enableGUIStandardItemLighting();
for (int i1 = 0; i1 < 9; ++i1) for (int i1 = 0; i1 < 9; ++i1)
{ {
int j1 = i - 90 + i1 * 20 + 2; int j1 = i - 90 + i1 * 20 + 2;
int k1 = scaledHeight - 16 - 3; int k1 = scaledHeight - (int) (16 * alpha) - 3;
renderHotbarItem(mc, alpha, j1, renderHotbarItem(mc,
alpha,
j1,
k1, k1,
partialTicks, partialTicks,
playerentity, playerentity,
@@ -295,10 +451,12 @@ public class RenderUtils
if (!itemstack.isEmpty()) if (!itemstack.isEmpty())
{ {
int i2 = scaledHeight - 16 - 3; int i2 = scaledHeight - (int) (16 * alpha) - 3;
if (handside == HandSide.LEFT) if (handside == HandSide.LEFT)
{ {
renderHotbarItem(mc, alpha, i - 91 - 26, renderHotbarItem(mc,
alpha,
i - 91 - 26,
i2, i2,
partialTicks, partialTicks,
playerentity, playerentity,
@@ -306,7 +464,9 @@ public class RenderUtils
} }
else else
{ {
renderHotbarItem(mc, alpha, i + 91 + 10, renderHotbarItem(mc,
alpha,
i + 91 + 10,
i2, i2,
partialTicks, partialTicks,
playerentity, playerentity,
@@ -329,20 +489,15 @@ public class RenderUtils
mc.getTextureManager() mc.getTextureManager()
.bindTexture(AbstractGui.GUI_ICONS_LOCATION); .bindTexture(AbstractGui.GUI_ICONS_LOCATION);
int l1 = (int) (f * 19.0F); int l1 = (int) (f * 19.0F);
RenderSystem.color4f(1.0F, 1.0F, 1.0F, alpha); GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
gui.blit(matrixStack, k2, j2, 0, 94, 18, 18); gui.blit(k2, j2, 0, 94, 18, 18);
gui.blit(matrixStack, gui.blit(k2, j2 + 18 - l1, 18, 112 - l1, 18, l1);
k2,
j2 + 18 - l1,
18,
112 - l1,
18,
l1);
} }
} }
RenderSystem.disableRescaleNormal(); RenderHelper.disableStandardItemLighting();
RenderSystem.disableBlend(); GlStateManager.disableRescaleNormal();
GlStateManager.disableBlend();
} }
} }
@@ -367,109 +522,99 @@ public class RenderUtils
{ {
if (!stack.isEmpty()) if (!stack.isEmpty())
{ {
GlStateManager.color4f(1.0F, 1.0F, 1.0F, alpha);
float f = (float) stack.getAnimationsToGo() - partialTicks; float f = (float) stack.getAnimationsToGo() - partialTicks;
RenderSystem.pushMatrix();
RenderSystem.color4f(1.0F, 1.0F, 1.0F, alpha);
if (f > 0.0F) if (f > 0.0F)
{ {
RenderSystem.pushMatrix(); GlStateManager.pushMatrix();
float f1 = 1.0F + f / 5.0F; float f1 = 1.0F + f / 5.0F;
RenderSystem.translatef((float) (x + 8), GlStateManager.translatef((float) (x + 8),
(float) (y + 12), (float) (y + 12),
0.0F); 0.0F);
RenderSystem.scalef(1.0F / f1, (f1 + 1.0F) / 2.0F, 1.0F); GlStateManager.scalef(1.0F / f1, (f1 + 1.0F) / 2.0F, 1.0F);
RenderSystem.translatef((float) (-(x + 8)), GlStateManager.translatef((float) (-(x + 8)),
(float) (-(y + 12)), (float) (-(y + 12)),
0.0F); 0.0F);
} }
renderItemAndEffectIntoGUI(mc, alpha, player, stack, x, y); renderItemAndEffectIntoGUI(mc, player, stack, x, y, alpha);
if (f > 0.0F) if (f > 0.0F)
{ {
RenderSystem.popMatrix(); GlStateManager.popMatrix();
} }
RenderSystem.popMatrix();
mc.getItemRenderer() mc.getItemRenderer()
.renderItemOverlays(mc.fontRenderer, stack, x, y); .renderItemOverlays(mc.fontRenderer, stack, x, y);
} }
} }
/** private static void renderItemAndEffectIntoGUI(Minecraft mc,
* Renders a single item on the HUD. LivingEntity entityIn,
* ItemStack itemIn,
* @param mc - A Minecraft instance.
* @param alpha - How transparent the item should be, on a scale from 0 to
* 1.
* @param ent - The player that the item is from.
* @param stack - The item to render.
* @param x - The x position of the item on the screen.
* @param y - The y position of the item on the screen
*
* @see net.minecraft.client.renderer.ItemRenderer#renderItemIntoGUI(LivingEntity,
* ItemStack, int, int)
*/
static void renderItemAndEffectIntoGUI(Minecraft mc,
float alpha,
PlayerEntity ent,
ItemStack stack,
int x, int x,
int y) int y,
float alpha)
{
if (!itemIn.isEmpty())
{
float zLevel = 50.0F;
try
{ {
TextureManager textureManager = mc.textureManager;
IBakedModel bakedmodel = mc.getItemRenderer() IBakedModel bakedmodel = mc.getItemRenderer()
.getItemModelWithOverrides(stack, .getItemModelWithOverrides(itemIn,
(World) null, (World) null,
(LivingEntity) null); entityIn);
if (!stack.isEmpty()) GlStateManager.pushMatrix();
mc.getTextureManager()
.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
mc.getTextureManager()
.getTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE)
.setBlurMipmap(false, false);
GlStateManager.enableRescaleNormal();
GlStateManager.enableAlphaTest();
GlStateManager.alphaFunc(516, 0.1F);
GlStateManager.enableBlend();
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA,
GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
GlStateManager.color4f(1.0F, 1.0F, 1.0F, alpha);
Method transformMethod = null;
try
{
transformMethod = ItemRenderer.class.getDeclaredMethod("setupGuiTransform", int.class, int.class, boolean.class);
}
catch (NoSuchMethodException e)
{ {
try try
{ {
RenderSystem.pushMatrix(); transformMethod = ItemRenderer.class.getDeclaredMethod("func_180452_a", int.class, int.class, boolean.class);
textureManager.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
textureManager.getTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE)
.setBlurMipmapDirect(false, false);
RenderSystem.enableRescaleNormal();
// RenderSystem.enableAlphaTest();
// RenderSystem.defaultAlphaFunc();
// RenderSystem.enableBlend();
// RenderSystem.blendFunc(GlStateManager.SourceFactor
// .SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
RenderSystem.color4f(1.0F, 1.0F, 1.0F, alpha);
RenderSystem.translatef((float) x, (float) y, 100.0F + 50F);
RenderSystem.translatef(8.0F, 8.0F, 0.0F);
RenderSystem.scalef(1.0F, -1.0F, 1.0F);
RenderSystem.scalef(16.0F, 16.0F, 16.0F);
MatrixStack matrixstack = new MatrixStack();
IRenderTypeBuffer.Impl irendertypebuffer$impl =
Minecraft.getInstance()
.getRenderTypeBuffers()
.getBufferSource();
boolean flag = !bakedmodel.isSideLit();
if (flag)
{
RenderHelper.setupGuiFlatDiffuseLighting();
} }
catch (NoSuchMethodException e1)
mc.getItemRenderer() {
.renderItem(stack, e.printStackTrace();
}
}
if (transformMethod != null)
{
if (!transformMethod.isAccessible())
{
transformMethod.setAccessible(true);
}
transformMethod.invoke(mc.getItemRenderer(), x, y, bakedmodel.isGui3d());
}
bakedmodel =
net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(
bakedmodel,
ItemCameraTransforms.TransformType.GUI, ItemCameraTransforms.TransformType.GUI,
false, false);
matrixstack, mc.getItemRenderer().renderItem(itemIn, bakedmodel);
irendertypebuffer$impl, GlStateManager.disableAlphaTest();
15728880, GlStateManager.disableRescaleNormal();
OverlayTexture.NO_OVERLAY, GlStateManager.disableLighting();
bakedmodel); GlStateManager.popMatrix();
irendertypebuffer$impl.finish(); mc.textureManager.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
RenderSystem.enableDepthTest(); mc.textureManager.getTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE)
if (flag) .restoreLastBlurMipmap();
{
RenderHelper.setupGui3DDiffuseLighting();
}
// RenderSystem.disableAlphaTest();
RenderSystem.disableRescaleNormal();
RenderSystem.popMatrix();
} }
catch (Throwable throwable) catch (Throwable throwable)
{ {
@@ -478,19 +623,19 @@ public class RenderUtils
CrashReportCategory crashreportcategory = CrashReportCategory crashreportcategory =
crashreport.makeCategory("Item being rendered"); crashreport.makeCategory("Item being rendered");
crashreportcategory.addDetail("Item Type", () -> { crashreportcategory.addDetail("Item Type", () -> {
return String.valueOf((Object) stack.getItem()); return String.valueOf((Object) itemIn.getItem());
}); });
crashreportcategory.addDetail("Registry Name", crashreportcategory.addDetail("Registry Name",
() -> String.valueOf(stack.getItem() () -> String.valueOf(itemIn.getItem()
.getRegistryName())); .getRegistryName()));
crashreportcategory.addDetail("Item Damage", () -> { crashreportcategory.addDetail("Item Damage", () -> {
return String.valueOf(stack.getDamage()); return String.valueOf(itemIn.getDamage());
}); });
crashreportcategory.addDetail("Item NBT", () -> { crashreportcategory.addDetail("Item NBT", () -> {
return String.valueOf((Object) stack.getTag()); return String.valueOf((Object) itemIn.getTag());
}); });
crashreportcategory.addDetail("Item Foil", () -> { crashreportcategory.addDetail("Item Foil", () -> {
return String.valueOf(stack.hasEffect()); return String.valueOf(itemIn.hasEffect());
}); });
throw new ReportedException(crashreport); throw new ReportedException(crashreport);
} }

File diff suppressed because it is too large Load Diff

View File

@@ -6,12 +6,12 @@
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml # The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
modLoader="javafml" #mandatory modLoader="javafml" #mandatory
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version # A version range to match for said mod loader - for regular FML @Mod it will be the forge version
loaderVersion="[35,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. loaderVersion="[26,)" #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. # 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. # 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 # 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 # A list of mods - how many allowed here is determined by the individual mod loader
[[mods]] #mandatory [[mods]] #mandatory
# The modid of the mod # The modid of the mod
@@ -23,43 +23,61 @@ version="${file.jarVersion}" #mandatory
# A display name for the mod # A display name for the mod
displayName="Immersive HUD" #mandatory 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/ # 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 # 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 # A file name (in the root of the mod JAR) containing a logo for display
logoFile="immersive_hud_logo.png" #optional logoFile="immersive_hud_logo.png" #optional
# A text field displayed in the mod UI # A text field displayed in the mod UI
credits="Minecraft Rendering Code (c) 2009-2021 Mojang Studios" #optional credits="Minecraft Rendering Code (c) 2009-2021 Mojang Studios" #optional
# A text field displayed in the mod UI # A text field displayed in the mod UI
authors="Markil 3" #optional authors="Markil 3"
# The description text for the mod (multi line!) (#mandatory) # The description text for the mod (multi line!) (#mandatory)
description=''' 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 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 F3 Menu. Honestly, anyone who uses this isn't in the need for immersion at the moment. * The hunger bar will only show up when your hunger level (not your saturation) changes, you are hungry, or when holding food.
* The chat. This will automatically fade away by itself. * The experience bar and level will only show upon gaining experience.
* The oxygen bar. This will disappear as soon as it is filled, anyway. * The health of your mount (i.e. your horse) will only show when its health changes.
* Boss health. It is helpful to have this available in a hectic situation. * The horse jump bar will only show when you are getting ready to jump.
* Sub-maximum health or hunger. In hectic battles, it can be convenient to see health at a glance. * 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. # 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 # the modid of the dependency
modId="forge" #mandatory modId="forge" #mandatory
# Does this dependency have to exist - if not, ordering below must be specified # Does this dependency have to exist - if not, ordering below must be specified
mandatory=true #mandatory mandatory=true #mandatory
# The version range of the dependency # The version range of the dependency
versionRange="[35,)" #mandatory versionRange="[26,)" #mandatory
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
ordering="NONE" ordering="NONE"
# Side this dependency is applied on - BOTH, CLIENT or SERVER # Side this dependency is applied on - BOTH, CLIENT or SERVER
side="CLIENT" 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 # Here's another dependency
[[dependencies.immersive_hud]] [[dependencies.immersive_hud]]
modId="minecraft" modId="minecraft"
mandatory=true mandatory=true
# This version range declares a minimum of the current minecraft version up to but not including the next major version versionRange="[1.14,1.15)"
versionRange="[1.16.4,1.17)"
ordering="NONE" ordering="NONE"
side="CLIENT" side="CLIENT"

View File

@@ -0,0 +1,53 @@
{
"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.hideCrosshair": "Hide Crosshair",
"option.immersive_hud.handTime": "Hand Display Time",
"option.immersive_hud.hideHands": "Hide Hands",
"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.hideCrosshair": "Whether or not the crosshairs should be hidden after a period of time",
"tooltip.immersive_hud.handTime": "How many seconds the hands can be on screen",
"tooltip.immersive_hud.hideHands": "Whether or not hands should be hidden after a period of time",
"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"
}

View File

@@ -1,7 +1,7 @@
{ {
"pack": { "pack": {
"description": "immersive_hud resources", "description": "immersive_hud resources",
"pack_format": 6, "pack_format": 4,
"_comment": "A pack_format of 6 requires json lang files and some texture changes from 1.16.2. Note: we require v6 pack meta for all mods." "_comment": "A pack_format of 4 requires json lang files and some texture changes from 1.16.2. Note: we require v6 pack meta for all mods."
} }
} }