Using TC LBolt renderer(very nice).

This commit is contained in:
fewizz committed 2016-07-30 21:11:53 +03:00
1 parent a37234c719
commit 5cc45ee0cb
4 files changed
+29 -160

No files matched your search

@@ -1,117 +0,0 @@
package emt.client.renderer;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.ResourceLocation;
import static org.lwjgl.opengl.GL11.*;
import java.util.Random;
import emt.entity.EntityEnergyBall;
import emt.util.EMTRandomHelper.Bolt;
import emt.util.EMTRandomHelper.Point;
public class RenderEnergyBall extends Render {
@Override
public void doRender(Entity entity, double x, double y, double z, float p1, float p2) {
EntityEnergyBall ball = (EntityEnergyBall) entity;
if (ball.shootingEntity == null) {
if (ball.worldObj.isRemote) {
Tessellator tess = Tessellator.instance;
glPushMatrix();
glDisable(GL_LIGHTING);
glDisable(GL_FOG);
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
glTranslated(x, y, z);
/*******************************************/
for (int i = 0; i < ball.bolts.length; i++) {
Bolt bolt = ball.bolts[i];
glPushMatrix();
glRotatef(bolt.angleZ, 0, 0, 1);
glRotatef(bolt.angleY, 0, 1, 0);
glLineWidth(2);
tess.startDrawing(GL_LINE_STRIP);
for (Point point : bolt.points) {
tess.setColorRGBA(point.r & 0xff, point.g & 0xff, point.b & 0xff, 255);
tess.addVertex((point.x / 10), (point.y / 10), (point.z / 10));
}
tess.draw();
glPopMatrix();
}
/*******************************************/
if (ball.inTile) {
/** Horizontal **/
for (int i = 0; i < ball.bolts.length; i++) {
Bolt bolt = ball.bolts[i];
glPushMatrix();
glRotatef(bolt.angleY, 0, 1, 0);
glLineWidth(2);
tess.startDrawing(GL_LINE_STRIP);
tess.setColorRGBA(255, 255, 255, 255);
float lenRat = ball.ticksAlive <= 40 ? ball.ticksAlive / 40f : (60 - ball.ticksAlive) / 20f;
for (Point point : bolt.points) {
tess.addVertex(point.x * lenRat, (point.y / 3f) * (ball.ticksAlive / 60f), point.z * lenRat);
}
tess.draw();
glPopMatrix();
}
/****************/
if (ball.entityPositions != null) {
for (int i = 0; i < ball.entityPositions.length; i++) {
Point pos = ball.entityPositions[i];
double trX = pos.x - entity.posX;
double trY = pos.y - entity.posY;
double trZ = pos.z - entity.posZ;
for(int e = 0; e < ball.MAX_COUNT_OF_BOLTS; e++) {
Bolt bolt = ball.entityBolts[i][e];
glPushMatrix();
glTranslated(trX, trY, trZ);
glRotatef(bolt.angleZ, 0, 0, 1);
glRotatef(bolt.angleY, 0, 1, 0);
glLineWidth(2);
tess.startDrawing(GL_LINE_STRIP);
for (Point point : bolt.points) {
tess.setColorRGBA(point.r & 0xff, point.g & 0xff, point.b & 0xff, 255);
tess.addVertex(point.x / 4 , point.y / 4, point.z / 4);
}
tess.draw();
glPopMatrix();
}
}
}
}
glPopMatrix();
glEnable(GL_FOG);
glEnable(GL_TEXTURE_2D);
}
}
}
@Override
protected ResourceLocation getEntityTexture(Entity entity) {
return null;
}
}
+10 -39
View File
@@ -24,19 +24,13 @@ import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import thaumcraft.common.Thaumcraft;
public class EntityEnergyBall extends Entity implements IProjectile, IEntityAdditionalSpawnData {
public static final int RADIUS = 8;
public static final float LENGTH = 16f;
public static final float DIST = 1f;
public static final float HEIGHT = 8f;
public static final int MAX_TICKS_IN_TILE = 60;
public static final int MAX_COUNT_OF_BOLTS = 25;
public EntityLivingBase shootingEntity;
public Bolt[] bolts = new Bolt[MAX_COUNT_OF_BOLTS];
public Point[] entityPositions;
public Bolt[][] entityBolts;
public boolean inTile = false;
public int ticksAlive = 1; /** Pls, don't ask me why 1 =) **/
@@ -72,10 +66,6 @@ public class EntityEnergyBall extends Entity implements IProjectile, IEntityAddi
this.setPosition(this.posX, this.posY, this.posZ);
this.yOffset = 0.0F;
this.motionX = this.motionY = this.motionZ = 0.0D;
for (int i = 0; i < bolts.length; i++) {
bolts[i] = new Bolt(DIST, LENGTH, HEIGHT);
}
}
@Override
@@ -127,35 +117,16 @@ public class EntityEnergyBall extends Entity implements IProjectile, IEntityAddi
/** Closer - Harder */
entity.attackEntityFrom(DamageSource.magic, (float) (RADIUS - hyp));
entity.performHurtAnimation();
if(worldObj.isRemote)
Thaumcraft.proxy.bolt(worldObj, this, entity);
}
}
}
}
}
}
if(worldObj.isRemote) {
entityBolts = new Bolt[entities.size()][MAX_COUNT_OF_BOLTS];
}
entityPositions = new Point[entities.size()];
for (int i = 0; i < entities.size(); i++) {
Entity entity = entities.get(i);
entityPositions[i] = new Point(entity.posX, entity.posY, entity.posZ);
if (this.worldObj.isRemote) {
for (int e = 0; e < bolts.length; e++) {
float h = entity.height;
if(h < 4) {
h = 4;
}
entityBolts[i][e] = new Bolt(h / 10, h, h / 2);
}
}
}
/************************************************************************/
}
/** If not in Tile **/
@@ -207,12 +178,12 @@ public class EntityEnergyBall extends Entity implements IProjectile, IEntityAddi
/************************************************************************/
}
if (this.worldObj.isRemote) {
for (int i = 0; i < bolts.length; i++) {
bolts[i].regenerate();
}
for(int i = 0; i < 3 && worldObj.isRemote; i ++) {
float rndX = (float) ((((worldObj.rand.nextFloat() - 0.5f) * 2) * (RADIUS - 4)) + posX);
float rndY = (float) ((((worldObj.rand.nextFloat() - 0.5f) * 2) * (RADIUS - 4)) + posY);
float rndZ = (float) ((((worldObj.rand.nextFloat() - 0.5f) * 2) * (RADIUS - 4)) + posZ);
Thaumcraft.proxy.nodeBolt(worldObj, (float)posX, (float)posY, (float)posZ, rndX, rndY, rndZ);
}
}
protected float getMotionFactor() {
+17 -2
View File
@@ -2,14 +2,16 @@ package emt.proxy;
import org.lwjgl.input.Keyboard;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderFireball;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.entity.RenderSnowMan;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.RenderingRegistry;
import emt.client.EMTKeys;
import emt.client.renderer.RenderEnergyBall;
import emt.client.renderer.RenderLaser;
import emt.client.renderer.RenderShield;
import emt.entity.EntityArcher;
@@ -27,9 +29,22 @@ public class ClientProxy extends CommonProxy {
@Override
public void registerRenders() {
Render empty = new Render() {
@Override
public void doRender(Entity e, double x, double y, double z, float f1, float f2) {
}
@Override
protected ResourceLocation getEntityTexture(Entity e) {
return null;
}
};
RenderingRegistry.registerEntityRenderingHandler(EntityLaser.class, new RenderLaser());
RenderingRegistry.registerEntityRenderingHandler(EntityArcher.class, new RenderSnowMan());
RenderingRegistry.registerEntityRenderingHandler(EntityShield.class, new RenderShield());
RenderingRegistry.registerEntityRenderingHandler(EntityEnergyBall.class, new RenderEnergyBall());
RenderingRegistry.registerEntityRenderingHandler(EntityEnergyBall.class, empty);
}
}