Skip to content

Commit 01c2863

Browse files
committed
Feat : Update Constellation Nodes
1 parent 9860314 commit 01c2863

File tree

1 file changed

+61
-93
lines changed

1 file changed

+61
-93
lines changed

src/main/java/com/ghostipedia/cosmiccore/common/reflection/ui/BargainConstellationScreen.java

Lines changed: 61 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import com.ghostipedia.cosmiccore.client.renderer.BackgroundRenderer;
44
import com.ghostipedia.cosmiccore.client.renderer.ChainRenderer;
55
import com.ghostipedia.cosmiccore.client.renderer.SoulAuraRenderer;
6-
import com.ghostipedia.cosmiccore.common.reflection.ReflectionConstants;
6+
import com.ghostipedia.cosmiccore.client.renderer.SoulCoreRenderer;
7+
import com.ghostipedia.cosmiccore.client.renderer.SoulThreadsRenderer;
78
import com.ghostipedia.cosmiccore.common.reflection.ReflectionLang;
89
import com.ghostipedia.cosmiccore.common.reflection.bargain.Bargain;
910
import com.ghostipedia.cosmiccore.common.reflection.bargain.BargainRegistry;
@@ -16,6 +17,8 @@
1617
import net.minecraftforge.api.distmarker.Dist;
1718
import net.minecraftforge.api.distmarker.OnlyIn;
1819

20+
import com.mojang.blaze3d.systems.RenderSystem;
21+
1922
import java.util.ArrayList;
2023
import java.util.List;
2124
import java.util.Random;
@@ -390,19 +393,13 @@ private void renderSoulOrb(GuiGraphics graphics, float partialTick) {
390393
int centerX = width / 2 + (int) viewOffsetX;
391394
int centerY = height / 2 + (int) viewOffsetY;
392395

393-
int[] rgb = getSoulColor();
394-
395-
// Smooth animation with partialTick for 60fps fluidity
396396
float smoothBreath = soulBreath + (0.03f * partialTick);
397397
float smoothPulse = soulPulse + (0.08f * partialTick);
398398
float breath = (float) Math.sin(smoothBreath) * 0.05f + 1f;
399399
float pulse = (float) Math.sin(smoothPulse) * 0.08f + 1f;
400400
int baseRadius = (int) (30 * zoom);
401401
int radius = (int) (baseRadius * breath * pulse);
402402

403-
int alpha = (int) (fadeAlpha * 255);
404-
405-
// Render ethereal flame aura BEHIND the soul orb
406403
int auraRadius = (int) (baseRadius * 1.8f * zoom);
407404
SoulAuraRenderer.render(
408405
graphics.pose(),
@@ -412,63 +409,21 @@ private void renderSoulOrb(GuiGraphics graphics, float partialTick) {
412409
fadeAlpha * 0.8f,
413410
width, height);
414411

415-
// Outer glow - use 4px steps
416-
for (int r = radius + 30; r > radius; r -= 4) {
417-
float glowProgress = (float) (r - radius) / 30f;
418-
int glowAlpha = (int) ((1f - glowProgress) * 35 * fadeAlpha);
419-
int color = (glowAlpha << 24) | (rgb[0] << 16) | (rgb[1] << 8) | rgb[2];
420-
drawCircleFast(graphics, centerX, centerY, r, color);
421-
}
422-
423-
// Core - use 3px steps
424-
for (int r = radius; r > 0; r -= 3) {
425-
float coreProgress = (float) r / radius;
426-
int coreAlpha = (int) (alpha * (0.6f + 0.4f * coreProgress));
427-
int lr = Math.min(255, rgb[0] + (int) ((255 - rgb[0]) * (1f - coreProgress) * 0.3f));
428-
int lg = Math.min(255, rgb[1] + (int) ((255 - rgb[1]) * (1f - coreProgress) * 0.3f));
429-
int lb = Math.min(255, rgb[2] + (int) ((255 - rgb[2]) * (1f - coreProgress) * 0.3f));
430-
int color = (coreAlpha << 24) | (lr << 16) | (lg << 8) | lb;
431-
drawCircleFast(graphics, centerX, centerY, r, color);
432-
}
433-
}
434-
435-
private void drawCircle(GuiGraphics graphics, int cx, int cy, int radius, int color) {
436-
for (int y = -radius; y <= radius; y++) {
437-
int halfWidth = (int) Math.sqrt(radius * radius - y * y);
438-
graphics.fill(cx - halfWidth, cy + y, cx + halfWidth + 1, cy + y + 1, color);
439-
}
440-
}
441-
442-
private void drawCircleFast(GuiGraphics graphics, int cx, int cy, int radius, int color) {
443-
if (radius <= 0) return;
444-
445-
// For small radii, use precise 1px drawing
446-
if (radius <= 6) {
447-
drawCircle(graphics, cx, cy, radius, color);
448-
return;
449-
}
450-
451-
// Use 2px bands for good quality
452-
int bandSize = 2;
453-
454-
for (int y = -radius; y <= radius; y += bandSize) {
455-
int halfWidth = (int) Math.sqrt(radius * radius - y * y);
456-
int bandEnd = Math.min(y + bandSize, radius + 1);
457-
graphics.fill(cx - halfWidth, cy + y, cx + halfWidth + 1, cy + bandEnd, color);
458-
}
459-
}
460-
461-
private int[] getSoulColor() {
462-
int tier = ReflectionConstants.getSoulColorTier(erosion);
463-
return switch (tier) {
464-
case 0 -> new int[] { 220, 220, 235 };
465-
case 1 -> new int[] { 180, 200, 255 };
466-
case 2 -> new int[] { 140, 120, 220 };
467-
case 3 -> new int[] { 180, 80, 160 };
468-
case 4 -> new int[] { 160, 50, 50 };
469-
case 5 -> new int[] { 80, 30, 30 };
470-
default -> new int[] { 20, 10, 30 };
471-
};
412+
graphics.flush();
413+
SoulCoreRenderer.render(
414+
graphics.pose(),
415+
centerX, centerY,
416+
radius,
417+
erosion,
418+
fadeAlpha,
419+
width, height);
420+
SoulThreadsRenderer.render(
421+
graphics.pose(),
422+
centerX, centerY,
423+
radius,
424+
erosion,
425+
fadeAlpha,
426+
width, height);
472427
}
473428

474429
private void renderDetailPanel(GuiGraphics graphics, int mouseX, int mouseY, float smoothPanelSlide) {
@@ -911,6 +866,9 @@ public boolean isPauseScreen() {
911866

912867
private static class BargainNode {
913868

869+
private static final ResourceLocation NODE_TEXTURE = new ResourceLocation("cosmiccore",
870+
"textures/item/reflection_mirror.png");
871+
914872
final Bargain bargain;
915873
final int centerX, centerY;
916874
final float orbitRadius;
@@ -1017,48 +975,65 @@ int[] getColor() {
1017975
void render(GuiGraphics graphics, net.minecraft.client.gui.Font font, float fadeAlpha,
1018976
boolean hovered, boolean selected, int ticks, float zoom, float partialTick) {
1019977
int[] rgb = getColor();
1020-
float radius = getRadius(zoom);
1021978

1022-
// Pulse effect for active/hovered - smooth with partialTick
1023979
float pulse = 1f;
1024980
if (state == NodeState.ACTIVE || hovered || selected) {
1025981
float smoothPulse = pulsePhase + (0.1f * partialTick);
1026982
pulse = 1f + (float) Math.sin(smoothPulse) * 0.15f;
1027983
}
1028-
int renderRadius = (int) (radius * pulse);
1029984

1030-
// Alpha based on state
1031985
float stateAlpha = switch (state) {
1032986
case ACTIVE -> 1f;
1033987
case AVAILABLE -> hovered ? 0.9f : 0.5f;
1034988
case SCARRED -> 0.3f;
1035989
};
1036990

1037-
int alpha = (int) (fadeAlpha * stateAlpha * 255);
1038-
1039-
// Outer glow - only 3 bands instead of 8 for performance
1040-
if (state == NodeState.ACTIVE || hovered || selected) {
1041-
for (int r = renderRadius + 8; r > renderRadius; r -= 3) {
1042-
float glowProgress = (float) (r - renderRadius) / 8f;
1043-
int glowAlpha = (int) ((1f - glowProgress) * 60 * fadeAlpha * stateAlpha);
1044-
int color = (glowAlpha << 24) | (rgb[0] << 16) | (rgb[1] << 8) | rgb[2];
1045-
drawNodeCircle(graphics, (int) screenX, (int) screenY, r, color);
991+
int sx = (int) screenX;
992+
int sy = (int) screenY;
993+
994+
// Colored glow halo behind the texture
995+
float glowIntensity = (state == NodeState.ACTIVE || hovered || selected) ? 0.4f : 0.15f;
996+
int glowRadius = (int) (12 * zoom * pulse);
997+
for (int r = glowRadius; r > 0; r -= 2) {
998+
float t = (float) r / glowRadius;
999+
int glowAlpha = (int) (fadeAlpha * stateAlpha * glowIntensity * (1f - t * t) * 255);
1000+
if (glowAlpha <= 0) continue;
1001+
int color = (glowAlpha << 24) | (rgb[0] << 16) | (rgb[1] << 8) | rgb[2];
1002+
for (int y = -r; y <= r; y += 2) {
1003+
int halfW = (int) Math.sqrt(r * r - y * y);
1004+
int bandEnd = Math.min(y + 2, r + 1);
1005+
graphics.fill(sx - halfW, sy + y, sx + halfW + 1, sy + bandEnd, color);
10461006
}
10471007
}
10481008

1049-
// Core
1050-
int coreColor = (alpha << 24) | (rgb[0] << 16) | (rgb[1] << 8) | rgb[2];
1051-
drawNodeCircle(graphics, (int) screenX, (int) screenY, renderRadius, coreColor);
1052-
1053-
// Selection ring - only 8 points instead of 12, smooth with partialTick
1009+
// Mirror texture, tinted to bargain color
1010+
int texSize = (int) (16 * zoom * pulse);
1011+
int halfTex = texSize / 2;
1012+
float tintR = rgb[0] / 255f;
1013+
float tintG = rgb[1] / 255f;
1014+
float tintB = rgb[2] / 255f;
1015+
float tintA = fadeAlpha * stateAlpha;
1016+
1017+
// Brighten the tint so the texture isn't too dark
1018+
float brighten = (state == NodeState.ACTIVE || hovered) ? 0.5f : 0.3f;
1019+
tintR = Math.min(1f, tintR + brighten);
1020+
tintG = Math.min(1f, tintG + brighten);
1021+
tintB = Math.min(1f, tintB + brighten);
1022+
1023+
RenderSystem.setShaderColor(tintR, tintG, tintB, tintA);
1024+
graphics.blit(NODE_TEXTURE, sx - halfTex, sy - halfTex, 0, 0, texSize, texSize, texSize, texSize);
1025+
RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
1026+
1027+
// Selection ring
10541028
if (selected) {
10551029
int ringAlpha = (int) (fadeAlpha * 200);
10561030
int ringColor = (ringAlpha << 24) | 0xFFFFFF;
10571031
float smoothTicks = ticks + partialTick;
10581032
for (int i = 0; i < 8; i++) {
10591033
float angle = (float) (2 * Math.PI * i / 8) + smoothTicks * 0.05f;
1060-
int rx = (int) (screenX + Math.cos(angle) * (renderRadius + 5));
1061-
int ry = (int) (screenY + Math.sin(angle) * (renderRadius + 5));
1034+
int ringDist = halfTex + 4;
1035+
int rx = (int) (screenX + Math.cos(angle) * ringDist);
1036+
int ry = (int) (screenY + Math.sin(angle) * ringDist);
10621037
graphics.fill(rx, ry, rx + 2, ry + 2, ringColor);
10631038
}
10641039
}
@@ -1070,19 +1045,12 @@ void render(GuiGraphics graphics, net.minecraft.client.gui.Font font, float fade
10701045
Random crackRandom = new Random(bargain.getId().hashCode());
10711046
for (int i = 0; i < 3; i++) {
10721047
float crackAngle = crackRandom.nextFloat() * (float) Math.PI * 2;
1073-
int cx = (int) (screenX + Math.cos(crackAngle) * radius * 0.5f);
1074-
int cy = (int) (screenY + Math.sin(crackAngle) * radius * 0.5f);
1048+
int cx = (int) (screenX + Math.cos(crackAngle) * halfTex * 0.6f);
1049+
int cy = (int) (screenY + Math.sin(crackAngle) * halfTex * 0.6f);
10751050
graphics.fill(cx - 1, cy - 1, cx + 2, cy + 2, crackColor);
10761051
}
10771052
}
10781053
}
1079-
1080-
private void drawNodeCircle(GuiGraphics graphics, int cx, int cy, int radius, int color) {
1081-
for (int y = -radius; y <= radius; y++) {
1082-
int halfWidth = (int) Math.sqrt(radius * radius - y * y);
1083-
graphics.fill(cx - halfWidth, cy + y, cx + halfWidth + 1, cy + y + 1, color);
1084-
}
1085-
}
10861054
}
10871055

10881056
private static class StarParticle {

0 commit comments

Comments
 (0)