mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-27 23:45:38 +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,7 +2,6 @@ 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.EntityAbilityBeam;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -24,7 +23,7 @@ import java.util.List;
|
||||
* Design inspired by LouisXIV's energy rendering system.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderAbilityBeam extends RenderAbilityProjectile {
|
||||
public class RenderAbilityBeam extends RenderEnergyAbility {
|
||||
|
||||
@Override
|
||||
public void doRender(Entity entity, double x, double y, double z, float yaw, float partialTicks) {
|
||||
@@ -117,7 +116,7 @@ public class RenderAbilityBeam extends RenderAbilityProjectile {
|
||||
|
||||
// Render lightning during charging if enabled
|
||||
if (beam.hasLightningEffect()) {
|
||||
renderAttachedLightning(beam, scale);
|
||||
renderAttachedLightning(beam, 0.6f * 0.5f, scale);
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
@@ -545,7 +544,7 @@ public class RenderAbilityBeam extends RenderAbilityProjectile {
|
||||
|
||||
// Render lightning BEFORE rotation so it crackles in all directions (only on head)
|
||||
if (beam.hasLightningEffect()) {
|
||||
renderAttachedLightning(beam, scale);
|
||||
renderAttachedLightning(beam, 0.6f * 0.5f, scale);
|
||||
}
|
||||
|
||||
// Rotation
|
||||
@@ -579,31 +578,4 @@ public class RenderAbilityBeam extends RenderAbilityProjectile {
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render fading lightning arcs attached to the beam head (in local space).
|
||||
*/
|
||||
private void renderAttachedLightning(EntityAbilityBeam beam, float headScale) {
|
||||
AttachedLightningRenderer.LightningState state = getLightningState(beam);
|
||||
|
||||
float density = beam.getLightningDensity();
|
||||
// Lightning radius extends outward from inner surface (innerScale = 0.6)
|
||||
float innerRadius = 0.6f * headScale * 0.5f;
|
||||
float radius = innerRadius + beam.getLightningRadius() * headScale;
|
||||
int outerColor = beam.getOuterColor();
|
||||
int innerColor = beam.getInnerColor();
|
||||
int fadeTime = beam.getLightningFadeTime();
|
||||
|
||||
state.update(density, radius, outerColor, innerColor, fadeTime);
|
||||
state.render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or create the lightning state for an entity.
|
||||
*/
|
||||
private AttachedLightningRenderer.LightningState getLightningState(EntityAbilityBeam beam) {
|
||||
if (beam.lightningState == null) {
|
||||
beam.lightningState = new AttachedLightningRenderer.LightningState();
|
||||
}
|
||||
return (AttachedLightningRenderer.LightningState) beam.lightningState;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ 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.EntityAbilityDisc;
|
||||
import net.minecraft.entity.Entity;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -14,7 +13,7 @@ import org.lwjgl.opengl.GL11;
|
||||
* Design inspired by LouisXIV's energy rendering system.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderAbilityDisc extends RenderAbilityProjectile {
|
||||
public class RenderAbilityDisc extends RenderEnergyAbility {
|
||||
|
||||
@Override
|
||||
public void doRender(Entity entity, double x, double y, double z, float yaw, float partialTicks) {
|
||||
@@ -37,7 +36,7 @@ public class RenderAbilityDisc extends RenderAbilityProjectile {
|
||||
|
||||
// Render lightning BEFORE rotation so it crackles in all directions
|
||||
if (disc.hasLightningEffect()) {
|
||||
renderAttachedLightning(disc, radius * scale);
|
||||
renderAttachedLightning(disc, 0.6f * 0.5f, radius * scale);
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
@@ -76,34 +75,6 @@ public class RenderAbilityDisc extends RenderAbilityProjectile {
|
||||
restoreRenderState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render fading lightning arcs attached to the disc (in local space).
|
||||
*/
|
||||
private void renderAttachedLightning(EntityAbilityDisc disc, float discSize) {
|
||||
AttachedLightningRenderer.LightningState state = getLightningState(disc);
|
||||
|
||||
float density = disc.getLightningDensity();
|
||||
// Lightning radius extends outward from inner surface (innerScale = 0.6)
|
||||
float innerRadius = 0.6f * discSize * 0.5f;
|
||||
float radius = innerRadius + disc.getLightningRadius() * discSize;
|
||||
int outerColor = disc.getOuterColor();
|
||||
int innerColor = disc.getInnerColor();
|
||||
int fadeTime = disc.getLightningFadeTime();
|
||||
|
||||
state.update(density, radius, outerColor, innerColor, fadeTime);
|
||||
state.render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or create the lightning state for an entity.
|
||||
*/
|
||||
private AttachedLightningRenderer.LightningState getLightningState(EntityAbilityDisc disc) {
|
||||
if (disc.lightningState == null) {
|
||||
disc.lightningState = new AttachedLightningRenderer.LightningState();
|
||||
}
|
||||
return (AttachedLightningRenderer.LightningState) disc.lightningState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a flat square (thin cube) centered at origin.
|
||||
* The square lies flat on the XZ plane with thin Y height.
|
||||
|
||||
@@ -3,7 +3,6 @@ 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.EntityAbilityBeam;
|
||||
import kamkeel.npcs.entity.EntityAbilityLaser;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -15,7 +14,7 @@ import org.lwjgl.opengl.GL11;
|
||||
* Design inspired by LouisXIV's energy rendering system.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderAbilityLaser extends RenderAbilityProjectile {
|
||||
public class RenderAbilityLaser extends RenderEnergyAbility {
|
||||
|
||||
@Override
|
||||
public void doRender(Entity entity, double x, double y, double z, float yaw, float partialTicks) {
|
||||
@@ -147,7 +146,7 @@ public class RenderAbilityLaser extends RenderAbilityProjectile {
|
||||
|
||||
// Render lightning during charging if enabled
|
||||
if (laser.hasLightningEffect()) {
|
||||
renderAttachedLightning(laser, scale);
|
||||
renderAttachedLightning(laser, 0.6f * 0.5f, scale);
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
@@ -170,7 +169,7 @@ public class RenderAbilityLaser extends RenderAbilityProjectile {
|
||||
|
||||
// Render inner core
|
||||
GL11.glScalef(innerScale, innerScale, innerScale);
|
||||
renderCube(innerColor, 1.0f, 0.5f);
|
||||
renderCube(innerColor, laser.getInnerAlpha(), 0.5f);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopMatrix();
|
||||
@@ -215,31 +214,6 @@ public class RenderAbilityLaser extends RenderAbilityProjectile {
|
||||
}
|
||||
|
||||
|
||||
private void renderAttachedLightning(EntityAbilityLaser laser, float headScale) {
|
||||
AttachedLightningRenderer.LightningState state = getLightningState(laser);
|
||||
|
||||
float density = laser.getLightningDensity();
|
||||
// Lightning radius extends outward from inner surface (innerScale = 0.6)
|
||||
float innerRadius = 0.6f * headScale * 0.5f;
|
||||
float radius = innerRadius + laser.getLightningRadius() * headScale;
|
||||
int outerColor = laser.getOuterColor();
|
||||
int innerColor = laser.getInnerColor();
|
||||
int fadeTime = laser.getLightningFadeTime();
|
||||
|
||||
state.update(density, radius, outerColor, innerColor, fadeTime);
|
||||
state.render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or create the main lightning state for the laser.
|
||||
*/
|
||||
private AttachedLightningRenderer.LightningState getLightningState(EntityAbilityLaser laser) {
|
||||
if (laser.lightningState == null) {
|
||||
laser.lightningState = new AttachedLightningRenderer.LightningState();
|
||||
}
|
||||
return (AttachedLightningRenderer.LightningState) laser.lightningState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or create the tip lightning state for the laser.
|
||||
* Stored as a secondary object in lightningState2.
|
||||
|
||||
@@ -2,7 +2,6 @@ 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.EntityAbilityOrb;
|
||||
import net.minecraft.entity.Entity;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -12,7 +11,7 @@ import org.lwjgl.opengl.GL11;
|
||||
* Minecraft-style blocky appearance using Tessellator.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderAbilityOrb extends RenderAbilityProjectile {
|
||||
public class RenderAbilityOrb extends RenderEnergyAbility {
|
||||
|
||||
private static final int LIGHTNING_FADE_TICKS = 6;
|
||||
|
||||
@@ -35,7 +34,7 @@ public class RenderAbilityOrb extends RenderAbilityProjectile {
|
||||
|
||||
// Render lightning BEFORE rotation so it crackles in all directions
|
||||
if (orb.hasLightningEffect()) {
|
||||
renderAttachedLightning(orb, scale);
|
||||
renderAttachedLightning(orb, 0.6f * 0.5f, scale);
|
||||
}
|
||||
|
||||
// Use entity's interpolated rotation for smooth spinning
|
||||
@@ -63,7 +62,7 @@ public class RenderAbilityOrb extends RenderAbilityProjectile {
|
||||
|
||||
// Render inner cube (solid)
|
||||
GL11.glScalef(innerScale, innerScale, innerScale);
|
||||
renderCube(orb.getInnerColor(), 1.0f, 0.5f);
|
||||
renderCube(orb.getInnerColor(), orb.getInnerAlpha(), 0.5f);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopMatrix();
|
||||
@@ -71,36 +70,4 @@ public class RenderAbilityOrb extends RenderAbilityProjectile {
|
||||
restoreRenderState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render fading lightning arcs attached to the orb (in local space).
|
||||
* Arcs persist for a few ticks and fade out, while staying attached to the orb.
|
||||
*/
|
||||
private void renderAttachedLightning(EntityAbilityOrb orb, float orbScale) {
|
||||
// Get or create the lightning state for this entity
|
||||
AttachedLightningRenderer.LightningState state = getLightningState(orb);
|
||||
|
||||
float density = orb.getLightningDensity();
|
||||
// Lightning radius extends outward from inner surface (innerScale = 0.6)
|
||||
float innerRadius = 0.6f * orbScale * 0.5f; // Half size of inner cube
|
||||
float radius = innerRadius + orb.getLightningRadius() * orbScale;
|
||||
int outerColor = orb.getOuterColor();
|
||||
int innerColor = orb.getInnerColor();
|
||||
int fadeTime = orb.getLightningFadeTime();
|
||||
|
||||
// Update: age existing arcs, spawn new ones based on density
|
||||
state.update(density, radius, outerColor, innerColor, fadeTime);
|
||||
|
||||
// Render all active arcs in local space (they move with the orb)
|
||||
state.render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or create the lightning state for an entity.
|
||||
*/
|
||||
private AttachedLightningRenderer.LightningState getLightningState(EntityAbilityOrb orb) {
|
||||
if (orb.lightningState == null) {
|
||||
orb.lightningState = new AttachedLightningRenderer.LightningState();
|
||||
}
|
||||
return (AttachedLightningRenderer.LightningState) orb.lightningState;
|
||||
}
|
||||
}
|
||||
+38
-2
@@ -2,6 +2,8 @@ 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.EntityEnergyAbility;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
@@ -17,11 +19,11 @@ import org.lwjgl.opengl.GL12;
|
||||
* Design inspired by LouisXIV's energy rendering system.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class RenderAbilityProjectile extends Render {
|
||||
public abstract class RenderEnergyAbility extends Render {
|
||||
|
||||
protected static final ResourceLocation WHITE_TEXTURE = new ResourceLocation("customnpcs", "textures/entity/white.png");
|
||||
|
||||
public RenderAbilityProjectile() {
|
||||
public RenderEnergyAbility() {
|
||||
this.shadowSize = 0.0f;
|
||||
}
|
||||
|
||||
@@ -252,6 +254,40 @@ public abstract class RenderAbilityProjectile extends Render {
|
||||
tess.draw();
|
||||
}
|
||||
|
||||
// ==================== SHARED LIGHTNING ====================
|
||||
|
||||
/**
|
||||
* Get or create the lightning state for an energy entity.
|
||||
* Uses the lightningState field on EntityEnergyAbility (stored as Object
|
||||
* to avoid client class loading on server).
|
||||
*/
|
||||
protected AttachedLightningRenderer.LightningState getLightningState(EntityEnergyAbility entity) {
|
||||
if (entity.lightningState == null) {
|
||||
entity.lightningState = new AttachedLightningRenderer.LightningState();
|
||||
}
|
||||
return (AttachedLightningRenderer.LightningState) entity.lightningState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render attached lightning arcs around an energy entity.
|
||||
* @param entity the energy entity
|
||||
* @param innerScale multiplier for inner radius (e.g. 0.3f for projectiles, 0.95f for dome)
|
||||
* @param baseSize the entity's current render size/scale
|
||||
*/
|
||||
protected void renderAttachedLightning(EntityEnergyAbility entity, float innerScale, float baseSize) {
|
||||
AttachedLightningRenderer.LightningState state = getLightningState(entity);
|
||||
|
||||
float density = entity.getLightningDensity();
|
||||
float innerRadius = innerScale * baseSize;
|
||||
float radius = innerRadius + entity.getLightningRadius() * baseSize;
|
||||
int outerColor = entity.getOuterColor();
|
||||
int innerColor = entity.getInnerColor();
|
||||
int fadeTime = entity.getLightningFadeTime();
|
||||
|
||||
state.update(density, radius, outerColor, innerColor, fadeTime);
|
||||
state.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(Entity entity) {
|
||||
return WHITE_TEXTURE;
|
||||
@@ -0,0 +1,23 @@
|
||||
package kamkeel.npcs.client.renderer;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.entity.EntityEnergyBarrier;
|
||||
|
||||
/**
|
||||
* Intermediate renderer base for energy barrier entities (Dome, Panel).
|
||||
* Provides shared hit flash alpha computation.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class RenderEnergyBarrier extends RenderEnergyAbility {
|
||||
|
||||
/**
|
||||
* Compute the alpha boost from a hit flash effect.
|
||||
* Flash value decays from 4 to 0, producing alpha from 0.3 to 0.
|
||||
*/
|
||||
protected float computeFlashAlpha(EntityEnergyBarrier barrier) {
|
||||
byte flash = barrier.getHitFlash();
|
||||
if (flash <= 0) return 0.0f;
|
||||
return flash / 4.0f * 0.3f;
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -2,7 +2,6 @@ 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.EntityEnergyPanel;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -14,7 +13,7 @@ import org.lwjgl.opengl.GL11;
|
||||
* Voxel-blocky style with inner/outer layers.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderEnergyPanel extends RenderAbilityProjectile {
|
||||
public class RenderEnergyPanel extends RenderEnergyBarrier {
|
||||
|
||||
@Override
|
||||
public void doRender(Entity entity, double x, double y, double z, float yaw, float partialTicks) {
|
||||
@@ -30,19 +29,16 @@ public class RenderEnergyPanel extends RenderAbilityProjectile {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x, y, z);
|
||||
|
||||
// Lightning BEFORE rotation for uniform spread (like Orb pattern)
|
||||
if (panel.hasLightningEffect()) {
|
||||
renderAttachedLightning(panel, 0.9f, Math.max(width, height) * 0.5f);
|
||||
}
|
||||
|
||||
// Rotate panel to face the correct direction
|
||||
GL11.glRotatef(-panelYaw, 0.0f, 1.0f, 0.0f);
|
||||
|
||||
// Lightning (before rotation for uniform spread)
|
||||
if (panel.hasLightningEffect()) {
|
||||
renderAttachedLightning(panel, Math.max(width, height) * 0.5f);
|
||||
}
|
||||
|
||||
// Hit flash
|
||||
float flashAlpha = 0.0f;
|
||||
if (panel.getHitFlash() > 0) {
|
||||
flashAlpha = panel.getHitFlash() / 4.0f * 0.3f;
|
||||
}
|
||||
float flashAlpha = computeFlashAlpha(panel);
|
||||
|
||||
// Subtle pulsing
|
||||
float pulseTime = entity.ticksExisted + partialTicks;
|
||||
@@ -65,9 +61,8 @@ public class RenderEnergyPanel extends RenderAbilityProjectile {
|
||||
GL11.glDepthMask(true);
|
||||
}
|
||||
|
||||
// Render inner panel (more opaque core)
|
||||
float innerAlpha = (0.6f + 0.3f * healthPercent);
|
||||
renderPanel(panel.getInnerColor(), innerAlpha + flashAlpha,
|
||||
// Render inner panel (uses configurable innerAlpha for semi-transparency)
|
||||
renderPanel(panel.getInnerColor(), panel.getInnerAlpha(),
|
||||
width * 0.5f * innerScale, height * 0.5f * innerScale, panelThickness);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
@@ -79,93 +74,59 @@ public class RenderEnergyPanel extends RenderAbilityProjectile {
|
||||
/**
|
||||
* Render a flat panel (thin box) centered at origin.
|
||||
* Panel faces along the Z axis (width on X, height on Y).
|
||||
* All 6 faces batched into a single draw call.
|
||||
*/
|
||||
private void renderPanel(int color, float alpha, float halfWidth, float halfHeight, float halfThickness) {
|
||||
float[] rgb = extractRGB(color);
|
||||
float r = rgb[0], g = rgb[1], b = rgb[2];
|
||||
|
||||
Tessellator tess = Tessellator.instance;
|
||||
|
||||
// Front face (z+)
|
||||
tess.startDrawingQuads();
|
||||
tess.setColorRGBA_F(r, g, b, alpha);
|
||||
|
||||
// Front face (z+)
|
||||
tess.setNormal(0, 0, 1);
|
||||
tess.addVertex(-halfWidth, -halfHeight, halfThickness);
|
||||
tess.addVertex(halfWidth, -halfHeight, halfThickness);
|
||||
tess.addVertex(halfWidth, halfHeight, halfThickness);
|
||||
tess.addVertex(-halfWidth, halfHeight, halfThickness);
|
||||
tess.draw();
|
||||
|
||||
// Back face (z-)
|
||||
tess.startDrawingQuads();
|
||||
tess.setColorRGBA_F(r, g, b, alpha);
|
||||
tess.setNormal(0, 0, -1);
|
||||
tess.addVertex(halfWidth, -halfHeight, -halfThickness);
|
||||
tess.addVertex(-halfWidth, -halfHeight, -halfThickness);
|
||||
tess.addVertex(-halfWidth, halfHeight, -halfThickness);
|
||||
tess.addVertex(halfWidth, halfHeight, -halfThickness);
|
||||
tess.draw();
|
||||
|
||||
// Top edge (y+)
|
||||
tess.startDrawingQuads();
|
||||
tess.setColorRGBA_F(r, g, b, alpha);
|
||||
tess.setNormal(0, 1, 0);
|
||||
tess.addVertex(-halfWidth, halfHeight, halfThickness);
|
||||
tess.addVertex(halfWidth, halfHeight, halfThickness);
|
||||
tess.addVertex(halfWidth, halfHeight, -halfThickness);
|
||||
tess.addVertex(-halfWidth, halfHeight, -halfThickness);
|
||||
tess.draw();
|
||||
|
||||
// Bottom edge (y-)
|
||||
tess.startDrawingQuads();
|
||||
tess.setColorRGBA_F(r, g, b, alpha);
|
||||
tess.setNormal(0, -1, 0);
|
||||
tess.addVertex(-halfWidth, -halfHeight, -halfThickness);
|
||||
tess.addVertex(halfWidth, -halfHeight, -halfThickness);
|
||||
tess.addVertex(halfWidth, -halfHeight, halfThickness);
|
||||
tess.addVertex(-halfWidth, -halfHeight, halfThickness);
|
||||
tess.draw();
|
||||
|
||||
// Right edge (x+)
|
||||
tess.startDrawingQuads();
|
||||
tess.setColorRGBA_F(r, g, b, alpha);
|
||||
tess.setNormal(1, 0, 0);
|
||||
tess.addVertex(halfWidth, -halfHeight, halfThickness);
|
||||
tess.addVertex(halfWidth, -halfHeight, -halfThickness);
|
||||
tess.addVertex(halfWidth, halfHeight, -halfThickness);
|
||||
tess.addVertex(halfWidth, halfHeight, halfThickness);
|
||||
tess.draw();
|
||||
|
||||
// Left edge (x-)
|
||||
tess.startDrawingQuads();
|
||||
tess.setColorRGBA_F(r, g, b, alpha);
|
||||
tess.setNormal(-1, 0, 0);
|
||||
tess.addVertex(-halfWidth, -halfHeight, -halfThickness);
|
||||
tess.addVertex(-halfWidth, -halfHeight, halfThickness);
|
||||
tess.addVertex(-halfWidth, halfHeight, halfThickness);
|
||||
tess.addVertex(-halfWidth, halfHeight, -halfThickness);
|
||||
|
||||
tess.draw();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render lightning arcs on the panel surface.
|
||||
*/
|
||||
private void renderAttachedLightning(EntityEnergyPanel panel, float size) {
|
||||
AttachedLightningRenderer.LightningState state = getLightningState(panel);
|
||||
float density = panel.getLightningDensity();
|
||||
float radius = size + panel.getLightningRadius();
|
||||
int outerColor = panel.getOuterColor();
|
||||
int innerColor = panel.getInnerColor();
|
||||
int fadeTime = panel.getLightningFadeTime();
|
||||
|
||||
state.update(density, radius, outerColor, innerColor, fadeTime);
|
||||
state.render();
|
||||
}
|
||||
|
||||
private AttachedLightningRenderer.LightningState getLightningState(EntityEnergyPanel panel) {
|
||||
if (panel.lightningState == null) {
|
||||
panel.lightningState = new AttachedLightningRenderer.LightningState();
|
||||
}
|
||||
return (AttachedLightningRenderer.LightningState) panel.lightningState;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ 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.EntityEnergySlicer;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -14,28 +13,27 @@ import org.lwjgl.opengl.GL11;
|
||||
* Inner solid core with outer translucent glow.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderEnergySlicer extends RenderAbilityProjectile {
|
||||
public class RenderEnergySlicer extends RenderEnergyAbility {
|
||||
|
||||
@Override
|
||||
public void doRender(Entity entity, double x, double y, double z, float yaw, float partialTicks) {
|
||||
EntityEnergySlicer slicer = (EntityEnergySlicer) entity;
|
||||
|
||||
float size = slicer.getInterpolatedSize(partialTicks);
|
||||
float width = slicer.getSliceWidth();
|
||||
float thickness = slicer.getSliceThickness();
|
||||
|
||||
// Scale with interpolated size for charging grow effect
|
||||
float sizeRatio = size > 0.01f ? size / Math.max(0.01f, slicer.getSliceWidth()) : 0.01f;
|
||||
if (sizeRatio > 1.0f) sizeRatio = 1.0f;
|
||||
// During charging, width/thickness grow from 0.01 to target via updateCharging().
|
||||
// Use current dimensions directly - no separate sizeRatio needed.
|
||||
if (width <= 0.01f) return;
|
||||
|
||||
setupRenderState();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x, y, z);
|
||||
|
||||
// Lightning before rotation
|
||||
// Lightning BEFORE rotation for uniform spread (like Orb pattern)
|
||||
if (slicer.hasLightningEffect()) {
|
||||
renderAttachedLightning(slicer, width * 0.5f * sizeRatio);
|
||||
renderAttachedLightning(slicer, 0.7f, width * 0.5f);
|
||||
}
|
||||
|
||||
// Orient perpendicular to travel direction
|
||||
@@ -44,9 +42,6 @@ public class RenderEnergySlicer extends RenderAbilityProjectile {
|
||||
GL11.glRotatef(travelYaw, 0.0f, 1.0f, 0.0f);
|
||||
GL11.glRotatef(travelPitch, 1.0f, 0.0f, 0.0f);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(sizeRatio, sizeRatio, sizeRatio);
|
||||
|
||||
float innerScale = 0.7f;
|
||||
|
||||
// Render outer blade (translucent glow)
|
||||
@@ -58,12 +53,11 @@ public class RenderEnergySlicer extends RenderAbilityProjectile {
|
||||
GL11.glDepthMask(true);
|
||||
}
|
||||
|
||||
// Render inner blade (solid core)
|
||||
// Render inner blade (solid core, alpha 1.0 like Orb pattern)
|
||||
renderBlade(slicer.getInnerColor(), 1.0f,
|
||||
width * 0.5f * innerScale, thickness, 0.03f);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
restoreRenderState();
|
||||
}
|
||||
@@ -71,93 +65,61 @@ public class RenderEnergySlicer extends RenderAbilityProjectile {
|
||||
/**
|
||||
* Render a thin wide blade shape.
|
||||
* The blade extends along X (width), thin on Y (thickness), and very thin on Z (depth).
|
||||
* All 6 faces batched into a single draw call.
|
||||
*/
|
||||
private void renderBlade(int color, float alpha, float halfWidth, float halfHeight, float halfDepth) {
|
||||
float[] rgb = extractRGB(color);
|
||||
float r = rgb[0], g = rgb[1], b = rgb[2];
|
||||
|
||||
Tessellator tess = Tessellator.instance;
|
||||
tess.startDrawingQuads();
|
||||
|
||||
// Front face (z+)
|
||||
tess.startDrawingQuads();
|
||||
tess.setColorRGBA_F(r, g, b, alpha);
|
||||
tess.setNormal(0, 0, 1);
|
||||
tess.addVertex(-halfWidth, -halfHeight, halfDepth);
|
||||
tess.addVertex(halfWidth, -halfHeight, halfDepth);
|
||||
tess.addVertex(halfWidth, halfHeight, halfDepth);
|
||||
tess.addVertex(-halfWidth, halfHeight, halfDepth);
|
||||
tess.draw();
|
||||
|
||||
// Back face (z-)
|
||||
tess.startDrawingQuads();
|
||||
tess.setColorRGBA_F(r, g, b, alpha);
|
||||
tess.setNormal(0, 0, -1);
|
||||
tess.addVertex(halfWidth, -halfHeight, -halfDepth);
|
||||
tess.addVertex(-halfWidth, -halfHeight, -halfDepth);
|
||||
tess.addVertex(-halfWidth, halfHeight, -halfDepth);
|
||||
tess.addVertex(halfWidth, halfHeight, -halfDepth);
|
||||
tess.draw();
|
||||
|
||||
// Top edge (y+)
|
||||
tess.startDrawingQuads();
|
||||
tess.setColorRGBA_F(r, g, b, alpha * 0.8f);
|
||||
tess.setNormal(0, 1, 0);
|
||||
tess.addVertex(-halfWidth, halfHeight, halfDepth);
|
||||
tess.addVertex(halfWidth, halfHeight, halfDepth);
|
||||
tess.addVertex(halfWidth, halfHeight, -halfDepth);
|
||||
tess.addVertex(-halfWidth, halfHeight, -halfDepth);
|
||||
tess.draw();
|
||||
|
||||
// Bottom edge (y-)
|
||||
tess.startDrawingQuads();
|
||||
tess.setColorRGBA_F(r, g, b, alpha * 0.8f);
|
||||
tess.setNormal(0, -1, 0);
|
||||
tess.addVertex(-halfWidth, -halfHeight, -halfDepth);
|
||||
tess.addVertex(halfWidth, -halfHeight, -halfDepth);
|
||||
tess.addVertex(halfWidth, -halfHeight, halfDepth);
|
||||
tess.addVertex(-halfWidth, -halfHeight, halfDepth);
|
||||
tess.draw();
|
||||
|
||||
// Right edge (x+)
|
||||
tess.startDrawingQuads();
|
||||
tess.setColorRGBA_F(r, g, b, alpha * 0.6f);
|
||||
tess.setNormal(1, 0, 0);
|
||||
tess.addVertex(halfWidth, -halfHeight, halfDepth);
|
||||
tess.addVertex(halfWidth, -halfHeight, -halfDepth);
|
||||
tess.addVertex(halfWidth, halfHeight, -halfDepth);
|
||||
tess.addVertex(halfWidth, halfHeight, halfDepth);
|
||||
tess.draw();
|
||||
|
||||
// Left edge (x-)
|
||||
tess.startDrawingQuads();
|
||||
tess.setColorRGBA_F(r, g, b, alpha * 0.6f);
|
||||
tess.setNormal(-1, 0, 0);
|
||||
tess.addVertex(-halfWidth, -halfHeight, -halfDepth);
|
||||
tess.addVertex(-halfWidth, -halfHeight, halfDepth);
|
||||
tess.addVertex(-halfWidth, halfHeight, halfDepth);
|
||||
tess.addVertex(-halfWidth, halfHeight, -halfDepth);
|
||||
|
||||
tess.draw();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render lightning arcs on the slicer.
|
||||
*/
|
||||
private void renderAttachedLightning(EntityEnergySlicer slicer, float size) {
|
||||
AttachedLightningRenderer.LightningState state = getLightningState(slicer);
|
||||
float density = slicer.getLightningDensity();
|
||||
float radius = size + slicer.getLightningRadius();
|
||||
int outerColor = slicer.getOuterColor();
|
||||
int innerColor = slicer.getInnerColor();
|
||||
int fadeTime = slicer.getLightningFadeTime();
|
||||
|
||||
state.update(density, radius, outerColor, innerColor, fadeTime);
|
||||
state.render();
|
||||
}
|
||||
|
||||
private AttachedLightningRenderer.LightningState getLightningState(EntityEnergySlicer slicer) {
|
||||
if (slicer.lightningState == null) {
|
||||
slicer.lightningState = new AttachedLightningRenderer.LightningState();
|
||||
}
|
||||
return (AttachedLightningRenderer.LightningState) slicer.lightningState;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user