Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Madis0 committed Jun 4, 2024
1 parent 69cadd8 commit af2bbef
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ org.gradle.jvmargs=-Xmx1G

# Dependencies
fabric_api_version=0.99.4+1.21
modmenu_version=10.0.0-beta.1
modmenu_version=11.0.0-beta.1
cloth_config_version=14.0.126
exordium_version=1.2.1-1.20.2
8 changes: 3 additions & 5 deletions src/main/java/io/github/madis0/OneBarElements.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.github.madis0;

import com.mojang.blaze3d.systems.RenderSystem;
//import dev.tr7zw.exordium.ExordiumModBase;
import me.shedaniel.autoconfig.AutoConfig;
import net.fabricmc.loader.api.FabricLoader;
Expand All @@ -10,7 +9,6 @@
import net.minecraft.client.render.RenderLayer;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.passive.AbstractHorseEntity;
import net.minecraft.entity.passive.CamelEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.AnimalArmorItem;
Expand Down Expand Up @@ -96,7 +94,7 @@ private void armorBar(){
var bootsLength = leggingsLength + gap + playerProperties.leggingsMaxArmor;

var totalLength = bootsLength + playerProperties.bootsMaxArmor;
var elytraDurability = playerProperties.getArmorElementDurability(client.player, EquipmentSlot.CHEST, 8); //8 aka same full width as Diamond/Netherite
var elytraDurability = playerProperties.getArmorElementDurability(Objects.requireNonNull(client.player), EquipmentSlot.CHEST, 8); //8 aka same full width as Diamond/Netherite

if (!config.armor.showSegmentedArmorBar)
renderBar(clientProperties.baseStartW, clientProperties.baseStartH - 1, clientProperties.baseRelativeEndW(playerProperties.armor, playerProperties.maxArmor), clientProperties.baseStartH, config.armor.armorColor);
Expand All @@ -118,7 +116,7 @@ private void armorDurabilityBar(){
var bootsLength = leggingsLength + gap + playerProperties.leggingsMaxArmor;
var totalLength = bootsLength + playerProperties.bootsMaxArmor;

var helmetDurability = playerProperties.getArmorElementDurability(client.player, EquipmentSlot.HEAD, playerProperties.helmetArmor);
var helmetDurability = playerProperties.getArmorElementDurability(Objects.requireNonNull(client.player), EquipmentSlot.HEAD, playerProperties.helmetArmor);
var chestplateDurability = playerProperties.getArmorElementDurability(client.player, EquipmentSlot.CHEST, playerProperties.chestplateArmor);
var elytraDurability = playerProperties.getArmorElementDurability(client.player, EquipmentSlot.CHEST, 8); //8 aka same full width as Diamond/Netherite
var leggingsDurability = playerProperties.getArmorElementDurability(client.player, EquipmentSlot.LEGS, playerProperties.leggingsArmor);
Expand Down Expand Up @@ -289,7 +287,7 @@ private void barText(){
if(config.textSettings.showText) { // Separated if because order matters
if (playerProperties.hasResistance && config.goodThings.showResistance)
value += plus + Calculations.emojiOrText("text.onebar.resistanceEmoji","text.onebar.resistance", false, playerProperties.resistancePercent);
if(PlayerProperties.getMobHead(client.player) != null && config.armor.showMobHeads)
if(PlayerProperties.getMobHead(Objects.requireNonNull(client.player)) != null && config.armor.showMobHeads)
value += plus + PlayerProperties.getMobHead(client.player);
if(playerProperties.hasGoldenArmorItem && config.armor.showMobHeads)
value += plus + Calculations.emojiOrText("text.onebar.mobHeadPiglinEmoji","text.onebar.mobHeadPiglin", false, (Object) null);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/io/github/madis0/PlayerProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

public class PlayerProperties {
Difficulty difficulty;
private final MinecraftClient client = MinecraftClient.getInstance();

public final boolean hasResistance;
public final boolean hasRegeneration;
Expand Down Expand Up @@ -318,7 +317,7 @@ public PlayerProperties(){

if(playerEntity.hasStatusEffect(StatusEffects.LEVITATION)){
var effect = playerEntity.getStatusEffect(StatusEffects.LEVITATION);
var estHeight = (effect.getAmplifier() + 1) * 0.9 * ((float) effect.getDuration() / 20);
var estHeight = (Objects.requireNonNull(effect).getAmplifier() + 1) * 0.9 * ((float) effect.getDuration() / 20);
levitationResultYRaw = playerEntity.getY() + estHeight;
levitationFallHeightRaw = getFallingHeightEstimate(playerEntity, levitationResultYRaw - belowBlockYRaw);

Expand All @@ -340,11 +339,12 @@ public PlayerProperties(){
lapisLazuli = playerEntity.getInventory().count(Items.LAPIS_LAZULI) +
(playerEntity.getInventory().count(Items.LAPIS_BLOCK) * 9);

MinecraftClient client = MinecraftClient.getInstance();
if(client.currentScreen instanceof EnchantmentScreen){
lapisLazuli += ((EnchantmentScreen) client.currentScreen).getScreenHandler().getLapisCount();
}

if (client.currentScreen != null && client.currentScreen instanceof HandledScreen<?>){
if (client.currentScreen instanceof HandledScreen<?>){
var pickedUpItemInInventory = ((HandledScreen<?>) client.currentScreen).getScreenHandler().getCursorStack();
if(pickedUpItemInInventory.isOf(Items.LAPIS_BLOCK)) lapisLazuli += pickedUpItemInInventory.getCount() * 9;
if(pickedUpItemInInventory.isOf(Items.LAPIS_LAZULI)) lapisLazuli += pickedUpItemInInventory.getCount();
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/io/github/madis0/mixin/InGameHudMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.render.RenderTickCounter;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.JumpingMount;
import net.minecraft.entity.LivingEntity;
Expand All @@ -31,8 +32,8 @@ public abstract class InGameHudMixin {
private boolean showOneBar = false;

@Inject(at = @At("TAIL"), method = "render")
public void render(DrawContext drawContext, float tickDelta, CallbackInfo ci) {
oneBarElements = new OneBarElements(drawContext);
public void render(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) {
oneBarElements = new OneBarElements(context);
showOneBar = config.showOneBar; // This var exists because it also shows whether oneBarElements is initialized

boolean barsVisible = !client.options.hudHidden && Objects.requireNonNull(client.interactionManager).hasStatusBars();
Expand All @@ -47,7 +48,7 @@ private void hideHudCompat(DrawContext context, CallbackInfo ci){
if(config.otherBars.compatibilityMode) genericCancel(ci);
}
@Inject(method = "renderExperienceLevel", at = @At(value = "TAIL"), cancellable = true)
private void hideXpLevelCompat(DrawContext context, float x, CallbackInfo ci){
private void hideXpLevelCompat(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci){
if(config.otherBars.compatibilityMode) genericCancel(ci);
}
@Inject(method = "renderExperienceBar", at = @At(value = "TAIL"), cancellable = true)
Expand All @@ -66,7 +67,7 @@ private void hideHud(DrawContext context, CallbackInfo ci){
if(!config.otherBars.compatibilityMode) genericCancel(ci);
}
@Inject(method = "renderExperienceLevel", at = @At(value = "HEAD"), cancellable = true)
private void hideXpLevel(DrawContext context, float x, CallbackInfo ci){
private void hideXpLevel(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci){
if(!config.otherBars.compatibilityMode) genericCancel(ci);
}
@Inject(method = "renderExperienceBar", at = @At(value = "HEAD"), cancellable = true)
Expand Down

0 comments on commit af2bbef

Please sign in to comment.