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

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Bawnorton committed May 18, 2023
1 parent 7bbde1b commit 57d6403
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ yarn_mappings=1.19.4+build.2
loader_version=0.14.19

# Mod Properties
mod_version=1.2.0
mod_version=1.2.1
maven_group=com.bawnorton.randoassistant
archives_base_name=randoassistant

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private static void drawBlock(MatrixStack matrices, Block block, int x, int y) {
VertexConsumerProvider.Immediate vertexConsumers = client.getBufferBuilders().getEntityVertexConsumers();
client.getBlockRenderManager().renderBlockAsEntity(state, matrices, vertexConsumers, LightmapTextureManager.MAX_LIGHT_COORDINATE, OverlayTexture.DEFAULT_UV);

RenderSystem.setShaderLights(new Vector3f(1.5f, 0.5f, 0), new Vector3f(0, 1, 0));
RenderSystem.setShaderLights(new Vector3f(1, -0.5f, 0), new Vector3f(0, -1, 0));
vertexConsumers.draw();
DiffuseLighting.enableGuiDepthLighting();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,23 @@ public class LootBookStatsWidget {
private int y;

private final ToggleButtonWidget backButton;
private final String blockCount;
private final String entityCount;
private final String otherCount;
private final String totalCount;


private final int totalBlocks = Tracker.getInstance().getTotalBlocksCount();
private final int totalEntities = Tracker.getInstance().getTotalEntitiesCount();
private final int totalOther = Tracker.getInstance().getTotalOtherCount();
private final int totalTotal = Tracker.getInstance().getTotalCount();

private final int discoveredBlocks = Math.min(Tracker.getInstance().getDiscoveredBlocksCount(), totalBlocks);
private final int discoveredEntities = Math.min(Tracker.getInstance().getDiscoveredEntitiesCount(), totalEntities);
private final int discoveredOther = Math.min(Tracker.getInstance().getDiscoveredOtherCount(), totalOther);
private final int discoveredTotal = Math.min(Tracker.getInstance().getDiscoveredCount(), totalTotal);

private final String blockCount = discoveredBlocks + "/" + totalBlocks;
private final String entityCount = discoveredEntities + "/" + totalEntities;
private final String otherCount = discoveredOther + "/" + totalOther;
private final String totalCount = discoveredTotal + "/" + totalTotal;


public LootBookStatsWidget(MinecraftClient client, int x, int y) {
this.client = client;
Expand All @@ -28,11 +41,6 @@ public LootBookStatsWidget(MinecraftClient client, int x, int y) {
backButton = new ToggleButtonWidget(x + 10, y + 10, 16, 16, false);
backButton.setTextureUV(206, 41, 0, 18, LootBookWidget.TEXTURE);
backButton.setTooltip(Tooltip.of(Text.of("Exit")));

blockCount = Tracker.getInstance().getDiscoveredBlocksCount() + "/" + Tracker.getInstance().getTotalBlocksCount();
entityCount = Tracker.getInstance().getDiscoveredEntitiesCount() + "/" + Tracker.getInstance().getTotalEntitiesCount();
otherCount = Tracker.getInstance().getDiscoveredOtherCount() + "/" + Tracker.getInstance().getTotalOtherCount();
totalCount = Tracker.getInstance().getDiscoveredCount() + "/" + Tracker.getInstance().getTotalCount();
}

public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
Expand All @@ -47,6 +55,19 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
client.textRenderer.draw(matrices, Text.of(otherCount), x + 135 - MinecraftClient.getInstance().textRenderer.getWidth(otherCount), y + 85, 0xFFFFFF);
client.textRenderer.draw(matrices, Text.of("Total:"), x + 20, y + 100, 0xDDDDDD);
client.textRenderer.draw(matrices, Text.of(totalCount), x + 135 - MinecraftClient.getInstance().textRenderer.getWidth(totalCount), y + 100, 0xFFFFFF);
Text tooltip = null;
if (mouseX >= x + 20 && mouseY >= y + 55 && mouseX <= x + 135 && mouseY <= y + 55 + 9) {
tooltip = Text.of(String.format("Blocks: %.1f", (float) discoveredBlocks / totalBlocks * 100) + "%");
} else if (mouseX >= x + 20 && mouseY >= y + 70 && mouseX <= x + 135 && mouseY <= y + 70 + 9) {
tooltip = Text.of(String.format("Entities: %.1f", (float) discoveredEntities / totalEntities * 100) + "%");
} else if (mouseX >= x + 20 && mouseY >= y + 85 && mouseX <= x + 135 && mouseY <= y + 85 + 9) {
tooltip = Text.of(String.format("Other: %.1f", (float) discoveredOther / totalOther * 100) + "%");
} else if (mouseX >= x + 20 && mouseY >= y + 100 && mouseX <= x + 135 && mouseY <= y + 100 + 9) {
tooltip = Text.of(String.format("Total: %.1f", (float) discoveredTotal / totalTotal * 100) + "%");
}
if (tooltip != null && client.currentScreen != null) {
client.currentScreen.renderTooltip(matrices, tooltip, mouseX, mouseY);
}
}

public boolean mouseClicked(double mouseX, double mouseY, int button) {
Expand Down

0 comments on commit 57d6403

Please sign in to comment.