added a config to move the aura cache bar

Closes #88
This commit is contained in:
Ellpeck 2020-03-11 23:32:37 +01:00
parent 02a1322b78
commit c0cc6166c1
2 changed files with 9 additions and 2 deletions

View file

@ -45,6 +45,7 @@ public final class ModConfig {
public ForgeConfigSpec.ConfigValue<Boolean> respectVanillaParticleSettings;
public ForgeConfigSpec.ConfigValue<Double> excessParticleAmount;
public ForgeConfigSpec.ConfigValue<Integer> auraBarLocation;
public ForgeConfigSpec.ConfigValue<Integer> cacheBarLocation;
public ForgeConfigSpec.ConfigValue<Boolean> debugText;
public ForgeConfigSpec.ConfigValue<Boolean> debugWorld;
@ -148,6 +149,10 @@ public final class ModConfig {
.comment("The location of the aura bar, where 0 is top left, 1 is top right, 2 is bottom left and 3 is bottom right")
.translation("config." + NaturesAura.MOD_ID + ".auraBarLocation")
.defineInRange("auraBarLocation", 0, 0, 3);
this.cacheBarLocation = builder
.comment("The location of the aura cache bar, where 0 is to the left of the hotbar and 1 is to the right of the hotbar")
.translation("config." + NaturesAura.MOD_ID + ".cacheBarLocation")
.defineInRange("cacheBarLocation", 0, 0, 1);
this.debugText = builder
.comment("If debug information about Aura around the player should be displayed in the F3 debug menu if the player is in creative mode")
.translation("config." + NaturesAura.MOD_ID + ".debugText")

View file

@ -294,7 +294,9 @@ public class ClientEvents {
if (!heldCache.isEmpty()) {
IAuraContainer container = heldCache.getCapability(NaturesAuraAPI.capAuraContainer, null).orElse(null);
int width = MathHelper.ceil(container.getStoredAura() / (float) container.getMaxAura() * 80);
int x = res.getScaledWidth() / 2 - 173 - (mc.player.getHeldItemOffhand().isEmpty() ? 0 : 29);
int conf = ModConfig.instance.cacheBarLocation.get();
int x = res.getScaledWidth() / 2 + (conf == 0 ? -173 - (mc.player.getHeldItemOffhand().isEmpty() ? 0 : 29) : 93);
int y = res.getScaledHeight() - 8;
RenderSystem.pushMatrix();
@ -310,7 +312,7 @@ public class ClientEvents {
float scale = 0.75F;
RenderSystem.scalef(scale, scale, scale);
String s = heldCache.getDisplayName().getFormattedText();
mc.fontRenderer.drawStringWithShadow(s, (x + 80) / scale - mc.fontRenderer.getStringWidth(s), (y - 7) / scale, color);
mc.fontRenderer.drawStringWithShadow(s, conf == 1 ? x / scale : (x + 80) / scale - mc.fontRenderer.getStringWidth(s), (y - 7) / scale, color);
RenderSystem.color4f(1F, 1F, 1F, 1);
RenderSystem.popMatrix();