Skip to content

Commit

Permalink
made code more readable in mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
legoraft committed Oct 26, 2023
1 parent 513b90e commit 14678da
Showing 1 changed file with 22 additions and 29 deletions.
51 changes: 22 additions & 29 deletions src/client/java/com/armorhud/mixin/client/armorHudMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@
public abstract class armorHudMixin {

@Shadow @Final private MinecraftClient client;

@Shadow private int scaledWidth;

@Shadow private int scaledHeight;

@Shadow protected abstract LivingEntity getRiddenEntity();

@Shadow protected abstract void renderHotbarItem(DrawContext context, int x, int y, float f, PlayerEntity player, ItemStack stack, int seed);

int armorHeight;
Expand All @@ -51,46 +47,43 @@ private void renderArmor(DrawContext context, float tickDelta) {
}

private void moveArmor() {

// Moves armorhud up if player uses double hotbar
if (config.DOUBLE_HOTBAR) {
armorHeight = this.scaledHeight - 76;
} else {
armorHeight = this.scaledHeight - 55;
}
armorHeight = this.scaledHeight - (config.DOUBLE_HOTBAR ? 76 : 55);

// Moves armorhud up if player is underwater
if (client.player.getAir() < client.player.getMaxAir() || client.player.isSubmergedInWater() && !client.player.isCreative()) {
armorHeight -= 10;
}

// Moves armorhud down if player is in creative
if (client.player.isCreative()) {
armorHeight += 16;
}
armorHeight += (client.player.isCreative() ? 16 : 0);

// Moves armorhud up if player is on mount
if (client.player.hasVehicle() && getRiddenEntity() != null) {
if (getRiddenEntity().isAlive()) {
if (getRiddenEntity().getMaxHealth() > 21) {
if (config.BETTER_MOUNT_HUD) {
armorHeight -= 20;
} else {
if (client.player.isCreative()) {
armorHeight -= 26;
} else {
armorHeight -= 10;
}
}
moveArmorHorse();
}
}

private void moveArmorHorse() {

if (getRiddenEntity().isAlive()) {
if (getRiddenEntity().getMaxHealth() > 21) {
if (config.BETTER_MOUNT_HUD && !client.player.isCreative()) {
armorHeight -= 20;
} else {
armorHeight -= (client.player.isCreative() ? 26 : 10);
}
else {
if (config.BETTER_MOUNT_HUD) {
armorHeight -= 10;
} else if (client.player.isCreative()) {
armorHeight -= 16;
}
}
else {
if (config.BETTER_MOUNT_HUD && !client.player.isCreative()) {
armorHeight -= 10;
} else if (client.player.isCreative()) {
armorHeight -= 16;
}
}
}

}

}

0 comments on commit 14678da

Please sign in to comment.