Skip to content

Commit b628613

Browse files
committed
Added Aura Node Visibility
Used the new Aura Node visibility condition to allow players to see the Aura Nodes if they are wearing Aetheric Goggles
1 parent f4bb521 commit b628613

File tree

4 files changed

+90
-6
lines changed

4 files changed

+90
-6
lines changed

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ archives_base_name=thaumaturge
1717
# Dependencies
1818
fabric_version=0.92.6+1.20.1
1919

20-
# AspectsLib (Version: 1.1.4)
21-
aspectslib_version=59aNoXMI
20+
# AspectsLib (Version: 1.1.5)
21+
aspectslib_version=OwxaPgrR

src/main/java/dev/overgrown/thaumaturge/ThaumaturgeClient.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import dev.overgrown.aspectslib.client.AspectsTooltipConfig;
44
import dev.overgrown.thaumaturge.client.keybind.KeybindManager;
5+
import dev.overgrown.thaumaturge.client.render.AuraNodeVisibility;
56
import dev.overgrown.thaumaturge.item.aetheric_goggles.overlay.AethericGogglesOverlay;
67
import dev.overgrown.thaumaturge.item.apophenia.predicate.ApopheniaModelProvider;
78
import dev.overgrown.thaumaturge.registry.ModEntities;
@@ -30,9 +31,12 @@ public void onInitializeClient() {
3031
// Register spell keybinds (original flow)
3132
KeybindManager.registerKeybinds();
3233

33-
// Overlay
34+
// Aetheric Goggles Overlay
3435
HudRenderCallback.EVENT.register(new AethericGogglesOverlay());
3536

37+
// Register Aura Node visibility
38+
AuraNodeVisibility.initialize();
39+
3640
// Handle presses: Primary=Lesser(self), Secondary=Advanced(targeted), Ternary=Greater(aoe)
3741
ClientTickEvents.END_CLIENT_TICK.register(client -> {
3842
if (client.player == null) return;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package dev.overgrown.thaumaturge.client.render;
2+
3+
import dev.overgrown.aspectslib.api.AspectsAPI;
4+
import dev.overgrown.thaumaturge.item.aetheric_goggles.AethericGogglesItem;
5+
6+
public class AuraNodeVisibility {
7+
8+
public static void initialize() {
9+
// Add condition to show aura nodes when wearing Aetheric Goggles
10+
AspectsAPI.addAuraNodeVisibilityCondition((player, hasAspects) -> {
11+
return AethericGogglesItem.isWearingGoggles(player);
12+
});
13+
}
14+
}

src/main/java/dev/overgrown/thaumaturge/item/aetheric_goggles/overlay/AethericGogglesOverlay.java

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import dev.overgrown.aspectslib.data.Aspect;
55
import dev.overgrown.aspectslib.data.AspectData;
66
import dev.overgrown.aspectslib.data.ModRegistries;
7+
import dev.overgrown.aspectslib.entity.aura_node.AuraNodeEntity;
78
import dev.overgrown.thaumaturge.block.vessel.VesselBlock;
89
import dev.overgrown.thaumaturge.block.vessel.entity.VesselBlockEntity;
910
import dev.overgrown.thaumaturge.item.aetheric_goggles.AethericGogglesItem;
@@ -12,16 +13,16 @@
1213
import net.minecraft.client.font.TextRenderer;
1314
import net.minecraft.client.gui.DrawContext;
1415
import net.minecraft.entity.Entity;
15-
import net.minecraft.entity.ItemEntity;
1616
import net.minecraft.entity.LivingEntity;
17+
import net.minecraft.entity.ItemEntity;
1718
import net.minecraft.item.ItemStack;
19+
import net.minecraft.text.Text;
1820
import net.minecraft.util.Formatting;
1921
import net.minecraft.util.Identifier;
2022
import net.minecraft.util.hit.BlockHitResult;
2123
import net.minecraft.util.hit.EntityHitResult;
2224
import net.minecraft.util.hit.HitResult;
2325
import net.minecraft.util.math.BlockPos;
24-
import net.minecraft.text.Text;
2526
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
2627

2728
import java.util.Map;
@@ -53,7 +54,7 @@ public void onHudRender(DrawContext drawContext, float tickDelta) {
5354
BlockHitResult blockHit = (BlockHitResult) hit;
5455
BlockPos pos = blockHit.getBlockPos();
5556
BlockState state = client.world.getBlockState(pos);
56-
57+
5758
if (state.getBlock() instanceof VesselBlock) {
5859
if (client.world.getBlockEntity(pos) instanceof VesselBlockEntity vessel) {
5960
Map<String, Integer> aspects = vessel.getAspects();
@@ -63,6 +64,15 @@ public void onHudRender(DrawContext drawContext, float tickDelta) {
6364
}
6465
}
6566
}
67+
} else if (hit.getType() == HitResult.Type.ENTITY) {
68+
EntityHitResult entityHit = (EntityHitResult) hit;
69+
Entity entity = entityHit.getEntity();
70+
71+
// Handle Aura Node entities specifically
72+
if (entity instanceof AuraNodeEntity auraNode) {
73+
renderAuraNodeAspects(drawContext, auraNode, x, y);
74+
return;
75+
}
6676
}
6777

6878
AspectData aspectData = getAspectDataForTarget(client, hit);
@@ -90,6 +100,62 @@ private AspectData getAspectDataForTarget(MinecraftClient client, HitResult hit)
90100
return null;
91101
}
92102

103+
private void renderAuraNodeAspects(DrawContext context, AuraNodeEntity auraNode, int centerX, int centerY) {
104+
TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
105+
boolean showNames = MinecraftClient.getInstance().options.sneakKey.isPressed();
106+
107+
// Get aspects from the aura node
108+
var aspects = auraNode.getAspects();
109+
if (aspects.isEmpty()) return;
110+
111+
// Calculate total width for centering
112+
int totalWidth = 0;
113+
for (var entry : aspects.entrySet()) {
114+
Aspect aspect = ModRegistries.ASPECTS.get(entry.getKey());
115+
if (aspect == null) continue;
116+
117+
int currentValue = entry.getValue().current;
118+
int textWidth = showNames ?
119+
textRenderer.getWidth(aspect.getTranslatedName()) :
120+
textRenderer.getWidth(currentValue + "/" + entry.getValue().original);
121+
122+
totalWidth += ASPECT_ICON_SIZE + textWidth + ASPECT_SPACING;
123+
}
124+
125+
// Start position for drawing
126+
int currentX = centerX - totalWidth / 2;
127+
128+
for (var entry : aspects.entrySet()) {
129+
Identifier aspectId = entry.getKey();
130+
Aspect aspect = ModRegistries.ASPECTS.get(aspectId);
131+
if (aspect == null) continue;
132+
133+
int currentValue = entry.getValue().current;
134+
int originalValue = entry.getValue().original;
135+
136+
Identifier texture = aspect.textureLocation();
137+
context.drawTexture(texture, currentX, centerY, 0, 0,
138+
ASPECT_ICON_SIZE, ASPECT_ICON_SIZE,
139+
ASPECT_ICON_SIZE, ASPECT_ICON_SIZE);
140+
141+
if (showNames) {
142+
Text aspectText = aspect.getTranslatedName().formatted(Formatting.WHITE);
143+
context.drawText(textRenderer, aspectText,
144+
currentX + ASPECT_TEXT_OFFSET,
145+
centerY + TEXT_Y_OFFSET,
146+
0xFFFFFF, false);
147+
currentX += ASPECT_ICON_SIZE + textRenderer.getWidth(aspectText) + ASPECT_SPACING;
148+
} else {
149+
String value = currentValue + "/" + originalValue;
150+
context.drawText(textRenderer, value,
151+
currentX + ASPECT_TEXT_OFFSET,
152+
centerY + TEXT_Y_OFFSET,
153+
0xFFFFFF, false);
154+
currentX += ASPECT_ICON_SIZE + textRenderer.getWidth(value) + ASPECT_SPACING;
155+
}
156+
}
157+
}
158+
93159
private void renderAspectData(DrawContext context, AspectData data, int centerX, int centerY) {
94160
TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
95161
boolean showNames = MinecraftClient.getInstance().options.sneakKey.isPressed();

0 commit comments

Comments
 (0)