Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Commit

Permalink
Minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkKronicle committed Oct 14, 2022
1 parent c6d52b6 commit 8f4062c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 21 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ minecraft_version=1.19.2
yarn_mappings=1.19.2+build.1
loader_version=0.14.9
# Mod Properties
mod_version=2.2.1
mod_version=2.2.2
maven_group=io.github.darkkronicle
archives_base_name=KronHUD
# Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,26 +162,18 @@ public void setBounds(float scale) {
int scaledX = floatToInt(x.getValue().floatValue(), client.getWindow().getScaledWidth(), 0) - offsetTrueWidth();
int scaledY = floatToInt(y.getValue().floatValue(), client.getWindow().getScaledHeight(), 0) - offsetTrueHeight();
if (scaledX < 0) {
setX(offsetTrueWidth());
return;
scaledX = 0;
}
if (scaledY < 0) {
setY(offsetTrueHeight());
return;
scaledY = 0;
}
int trueWidth = (int) (getWidth() * getScale());
if (trueWidth < client.getWindow().getScaledWidth() && scaledX + trueWidth > client.getWindow().getScaledWidth()) {
scaledX = client.getWindow().getScaledWidth() - trueWidth;
setX(scaledX + offsetTrueWidth());
// It calls this method when updated
return;
}
int trueHeight = (int) (getHeight() * getScale());
if (trueHeight < client.getWindow().getScaledHeight() && scaledY + trueHeight > client.getWindow().getScaledHeight()) {
scaledY = client.getWindow().getScaledHeight() - trueHeight;
setY(scaledY + offsetTrueHeight());
// It calls this method when updated
return;
}
truePosition = new DrawPosition(scaledX, scaledY);
renderPosition = truePosition.divide(getScale());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@ public class PotionsHud extends TextHudEntry implements DynamicallyPositionable
private final KronBoolean iconsOnly = new KronBoolean("iconsonly", ID.getPath(), false);

public PotionsHud() {
super(60, 200, false);
super(50, 200, false);
}

private int calculateWidth(List<StatusEffectInstance> effects) {
if (order.getValue().isXAxis()) {
if (iconsOnly.getValue()) {
return 20 * effects.size() + 2;
}
return 60 * effects.size() + 2;
return 50 * effects.size() + 2;
} else {
if (iconsOnly.getValue()) {
return 20;
}
return 60;
return 50;
}
}

Expand Down Expand Up @@ -96,7 +96,7 @@ private void renderEffects(MatrixStack matrices, List<StatusEffectInstance> effe
StatusEffectInstance effect = effects.get(direction.getDirection() == -1 ? i : effects.size() - i - 1);
if (direction.isXAxis()) {
renderPotion(matrices, effect, x + lastPos + 1, y + 1);
lastPos += (iconsOnly.getValue() ? 20 : 60);
lastPos += (iconsOnly.getValue() ? 20 : 50);
} else {
renderPotion(matrices, effect, x + 1, y + 1 + lastPos);
lastPos += 20;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import net.minecraft.util.Util;
import net.minecraft.util.math.MathHelper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
Expand All @@ -34,7 +35,7 @@ public class BossBarHud extends TextHudEntry implements DynamicallyPositionable
return boss;
});

private Map<UUID, ClientBossBar> bossBars;
private Map<UUID, ClientBossBar> bossBars = new HashMap<>();
private final KronBoolean text = new KronBoolean("text", ID.getPath(), true);
private final KronBoolean bar = new KronBoolean("bar", ID.getPath(), true);
// TODO custom color
Expand All @@ -47,7 +48,7 @@ public BossBarHud() {
public void setBossBars() {
int prevLength = bossBars.size();
bossBars = ((AccessorBossBarHud) client.inGameHud.getBossBarHud()).getBossBars();
if (bossBars.size() != prevLength) {
if (bossBars != null && bossBars.size() != prevLength) {
if (bossBars.size() == 0) {
// Just leave it alone, it's not rendering anyways
return;
Expand All @@ -60,7 +61,7 @@ public void setBossBars() {
@Override
public void renderComponent(MatrixStack matrices, float delta) {
setBossBars();
if (this.bossBars.isEmpty()) {
if (bossBars == null || this.bossBars.isEmpty()) {
return;
}
DrawPosition scaledPos = getPos();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import io.github.darkkronicle.darkkore.util.render.RenderUtil;
import io.github.darkkronicle.kronhud.config.*;
import io.github.darkkronicle.kronhud.gui.AbstractHudEntry;
import io.github.darkkronicle.kronhud.gui.component.DynamicallyPositionable;
import io.github.darkkronicle.kronhud.gui.layout.AnchorPoint;
import io.github.darkkronicle.kronhud.util.ColorUtil;
import io.github.darkkronicle.kronhud.util.DrawPosition;
import io.github.darkkronicle.kronhud.util.Rectangle;
Expand All @@ -15,6 +17,7 @@
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.option.AttackIndicator;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Identifier;
Expand All @@ -26,7 +29,7 @@

import java.util.List;

public class CrosshairHud extends AbstractHudEntry {
public class CrosshairHud extends AbstractHudEntry implements DynamicallyPositionable {
public static final Identifier ID = new Identifier("kronhud", "crosshairhud");

private final KronOptionList<Crosshair> type = new KronOptionList<>("type", ID.getPath(), Crosshair.CROSS);
Expand All @@ -38,7 +41,7 @@ public class CrosshairHud extends AbstractHudEntry {
private final KronExtendedColor attackIndicatorForegroundColor = new KronExtendedColor("attackindicatorfg", ID.getPath(), new ExtendedColor(ColorUtil.WHITE, ExtendedColor.ChromaOptions.getDefault()));

public CrosshairHud() {
super(17, 17);
super(15, 15);
}

@Override
Expand Down Expand Up @@ -83,7 +86,9 @@ public void render(MatrixStack matrices, float delta) {
matrixStack.pop();
RenderSystem.applyModelViewMatrix();
} else if (type.getValue() == Crosshair.TEXTURE) {
client.getTextureManager().bindTexture(DrawableHelper.GUI_ICONS_TEXTURE);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderTexture(0, DrawableHelper.GUI_ICONS_TEXTURE);

// Draw crosshair
RenderSystem.setShaderColor(
Expand Down Expand Up @@ -181,6 +186,11 @@ public List<KronConfig<?>> getConfigurationOptions() {
return options;
}

@Override
public AnchorPoint getAnchor() {
return AnchorPoint.MIDDLE_MIDDLE;
}

@AllArgsConstructor
public enum Crosshair implements OptionListEntry<Crosshair> {
CROSS("cross"),
Expand Down

0 comments on commit 8f4062c

Please sign in to comment.