mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-28 17:05:59 +00:00
Create Barrier Abilities + Heavy Refactoring
This commit is contained in:
1 parent
d1f2c9695c
commit
c07e9e7006
53 files changed
+1890
-1460
No files matched your search
@@ -2,19 +2,18 @@ package kamkeel.npcs.client.renderer;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.client.renderer.lightning.AttachedLightningRenderer;
|
||||
import kamkeel.npcs.entity.EntityEnergyDome;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.Entity;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
* Renders the Energy Dome entity as a translucent blocky hemisphere.
|
||||
* Built from cube panels forming a dome shape - voxel-blocky aesthetic.
|
||||
* Inner layer more opaque, outer layer translucent glow.
|
||||
* Renders the Dome entity as a translucent sphere.
|
||||
* Inner layer solid, outer layer translucent glow.
|
||||
* Optional skybox texture rendered on the interior surface.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderEnergyDome extends RenderAbilityProjectile {
|
||||
public class RenderEnergyDome extends RenderEnergyBarrier {
|
||||
|
||||
@Override
|
||||
public void doRender(Entity entity, double x, double y, double z, float yaw, float partialTicks) {
|
||||
@@ -27,31 +26,32 @@ public class RenderEnergyDome extends RenderAbilityProjectile {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x, y, z);
|
||||
|
||||
// Lightning
|
||||
// Lightning BEFORE any rotation (uniform spread)
|
||||
if (dome.hasLightningEffect()) {
|
||||
renderAttachedLightning(dome, radius);
|
||||
renderAttachedLightning(dome, 0.95f, radius);
|
||||
}
|
||||
|
||||
// Hit flash effect
|
||||
float flashAlpha = 0.0f;
|
||||
if (dome.getHitFlash() > 0) {
|
||||
flashAlpha = dome.getHitFlash() / 4.0f * 0.3f;
|
||||
}
|
||||
float flashAlpha = computeFlashAlpha(dome);
|
||||
|
||||
float innerScale = 0.95f;
|
||||
|
||||
// Render outer dome (translucent)
|
||||
// Render outer dome (translucent glow)
|
||||
if (dome.isOuterColorEnabled()) {
|
||||
float outerScale = 1.0f + dome.getOuterColorWidth() * 0.1f;
|
||||
float outerAlpha = dome.getOuterColorAlpha() * healthPercent;
|
||||
GL11.glDepthMask(false);
|
||||
renderBlockyDome(dome.getOuterColor(), outerAlpha + flashAlpha, radius * outerScale, 8);
|
||||
renderSphere(dome.getOuterColor(), outerAlpha + flashAlpha, radius * outerScale, 8);
|
||||
GL11.glDepthMask(true);
|
||||
}
|
||||
|
||||
// Render inner dome (more opaque)
|
||||
float innerAlpha = (0.5f + 0.3f * healthPercent);
|
||||
renderBlockyDome(dome.getInnerColor(), innerAlpha + flashAlpha, radius * innerScale, 8);
|
||||
// TODO: Skybox Feature
|
||||
// if (dome.isSkyboxEnabled() && !dome.getSkyboxTexture().isEmpty()) {
|
||||
// renderSkyboxSphere(dome.getSkyboxTexture(), radius, radius * 0.94f, 32, x, y, z);
|
||||
// }
|
||||
|
||||
// Render inner dome
|
||||
renderSphere(dome.getInnerColor(), dome.getInnerAlpha(), radius * innerScale, 8);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
@@ -59,19 +59,19 @@ public class RenderEnergyDome extends RenderAbilityProjectile {
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a dome made of blocky quad panels - voxel style.
|
||||
* Uses latitude/longitude segments to form a hemisphere of flat panels.
|
||||
* Render a sphere made of quad panels.
|
||||
* Uses latitude/longitude segments to form a full sphere.
|
||||
*/
|
||||
private void renderBlockyDome(int color, float alpha, float radius, int segments) {
|
||||
private void renderSphere(int color, float alpha, float radius, int segments) {
|
||||
float[] rgb = extractRGB(color);
|
||||
float r = rgb[0], g = rgb[1], b = rgb[2];
|
||||
|
||||
Tessellator tess = Tessellator.instance;
|
||||
int latSegments = segments / 2; // Half sphere
|
||||
tess.startDrawingQuads();
|
||||
tess.setColorRGBA_F(rgb[0], rgb[1], rgb[2], alpha);
|
||||
|
||||
for (int lat = 0; lat < latSegments; lat++) {
|
||||
float theta1 = (float) (Math.PI * 0.5 * lat / latSegments);
|
||||
float theta2 = (float) (Math.PI * 0.5 * (lat + 1) / latSegments);
|
||||
for (int lat = 0; lat < segments; lat++) {
|
||||
float theta1 = (float) (Math.PI * lat / segments - Math.PI * 0.5);
|
||||
float theta2 = (float) (Math.PI * (lat + 1) / segments - Math.PI * 0.5);
|
||||
|
||||
float y1 = (float) Math.sin(theta1) * radius;
|
||||
float y2 = (float) Math.sin(theta2) * radius;
|
||||
@@ -91,63 +91,22 @@ public class RenderEnergyDome extends RenderAbilityProjectile {
|
||||
float x4 = (float) Math.cos(phi1) * r2;
|
||||
float z4 = (float) Math.sin(phi1) * r2;
|
||||
|
||||
// Normal pointing outward
|
||||
float nx = (x1 + x2 + x3 + x4) * 0.25f;
|
||||
float ny = (y1 + y1 + y2 + y2) * 0.25f;
|
||||
float nz = (z1 + z2 + z3 + z4) * 0.25f;
|
||||
float nLen = (float) Math.sqrt(nx * nx + ny * ny + nz * nz);
|
||||
if (nLen > 0) { nx /= nLen; ny /= nLen; nz /= nLen; }
|
||||
|
||||
tess.startDrawingQuads();
|
||||
tess.setColorRGBA_F(r, g, b, alpha);
|
||||
tess.setNormal(nx, ny, nz);
|
||||
tess.addVertex(x1, y1, z1);
|
||||
tess.addVertex(x2, y1, z2);
|
||||
tess.addVertex(x3, y2, z3);
|
||||
tess.addVertex(x4, y2, z4);
|
||||
tess.draw();
|
||||
}
|
||||
}
|
||||
|
||||
// Bottom ring (ground level circle)
|
||||
tess.startDrawingQuads();
|
||||
tess.setColorRGBA_F(r, g, b, alpha * 0.5f);
|
||||
tess.setNormal(0, -1, 0);
|
||||
for (int lon = 0; lon < segments; lon++) {
|
||||
float phi1 = (float) (2 * Math.PI * lon / segments);
|
||||
float phi2 = (float) (2 * Math.PI * (lon + 1) / segments);
|
||||
float x1 = (float) Math.cos(phi1) * radius;
|
||||
float z1 = (float) Math.sin(phi1) * radius;
|
||||
float x2 = (float) Math.cos(phi2) * radius;
|
||||
float z2 = (float) Math.sin(phi2) * radius;
|
||||
|
||||
tess.addVertex(0, 0, 0);
|
||||
tess.addVertex(x1, 0, z1);
|
||||
tess.addVertex(x2, 0, z2);
|
||||
tess.addVertex(0, 0, 0);
|
||||
}
|
||||
tess.draw();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render lightning arcs on the dome surface.
|
||||
*/
|
||||
private void renderAttachedLightning(EntityEnergyDome dome, float radius) {
|
||||
AttachedLightningRenderer.LightningState state = getLightningState(dome);
|
||||
float density = dome.getLightningDensity();
|
||||
float lightningRadius = radius + dome.getLightningRadius();
|
||||
int outerColor = dome.getOuterColor();
|
||||
int innerColor = dome.getInnerColor();
|
||||
int fadeTime = dome.getLightningFadeTime();
|
||||
|
||||
state.update(density, lightningRadius, outerColor, innerColor, fadeTime);
|
||||
state.render();
|
||||
}
|
||||
|
||||
private AttachedLightningRenderer.LightningState getLightningState(EntityEnergyDome dome) {
|
||||
if (dome.lightningState == null) {
|
||||
dome.lightningState = new AttachedLightningRenderer.LightningState();
|
||||
}
|
||||
return (AttachedLightningRenderer.LightningState) dome.lightningState;
|
||||
}
|
||||
// TODO: Skybox Feature — renderSkyboxSphere method removed
|
||||
}
|
||||
Reference in new issue
Block a user