Flames now render how I want them to! Tomorrow I add logic, such as the burning of entities and the smelting of blocks.
This commit is contained in:
parent
9469fcb51a
commit
cfc308b042
4 changed files with 39 additions and 31 deletions
|
@ -361,8 +361,6 @@ public class ClientTickHandler
|
|||
|
||||
if(isFlamethrowerOn(mc.thePlayer) != Mekanism.flamethrowerActive.contains(mc.thePlayer.getCommandSenderName()))
|
||||
{
|
||||
ItemFlamethrower flamethrower = (ItemFlamethrower)mc.thePlayer.getCurrentEquippedItem().getItem();
|
||||
|
||||
if(isFlamethrowerOn(mc.thePlayer))
|
||||
{
|
||||
Mekanism.flamethrowerActive.add(mc.thePlayer.getCommandSenderName());
|
||||
|
|
|
@ -18,14 +18,13 @@ public class RenderFlame extends Render
|
|||
{
|
||||
public void doRender(EntityFlame entity, double x, double y, double z, float f, float partialTick)
|
||||
{
|
||||
float alpha = (float)entity.ticksExisted/100F;
|
||||
float alpha = (float)(entity.ticksExisted+partialTick)/(float)EntityFlame.LIFESPAN;
|
||||
float size = alpha*8;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
MekanismRenderer.glowOn();
|
||||
MekanismRenderer.blendOn();
|
||||
GL11.glColor4f(1, 1, 1, 1-alpha);
|
||||
GL11.glScalef(size, size, size);
|
||||
|
||||
bindTexture(getEntityTexture(entity));
|
||||
|
||||
|
@ -34,37 +33,18 @@ public class RenderFlame extends Render
|
|||
GL11.glRotatef(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTick, 0.0F, 0.0F, 1.0F);
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
int i = 0;
|
||||
float f2 = 0.0F;
|
||||
float f3 = 0.5F;
|
||||
float f4 = (float)(0 + i * 10) / 32F;
|
||||
float f5 = (float)(5 + i * 10) / 32F;
|
||||
float f6 = 0.0F;
|
||||
float f7 = 0.15625F;
|
||||
float f8 = (float)(5 + i * 10) / 32F;
|
||||
float f9 = (float)(10 + i * 10) / 32F;
|
||||
float scale = 0.05625F;
|
||||
float scale = 0.05625F*(0.8F+alpha);
|
||||
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glRotatef(45F, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glScalef(scale, scale, scale);
|
||||
GL11.glTranslatef(-4F, 0.0F, 0.0F);
|
||||
|
||||
GL11.glNormal3f(scale, 0.0F, 0.0F);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV(-7D, -2D, -2D, f6, f8);
|
||||
tessellator.addVertexWithUV(-7D, -2D, 2D, f7, f8);
|
||||
tessellator.addVertexWithUV(-7D, 2D, 2D, f7, f9);
|
||||
tessellator.addVertexWithUV(-7D, 2D, -2D, f6, f9);
|
||||
tessellator.draw();
|
||||
|
||||
GL11.glNormal3f(-scale, 0.0F, 0.0F);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV(-7D, 2D, -2D, f6, f8);
|
||||
tessellator.addVertexWithUV(-7D, 2D, 2D, f7, f8);
|
||||
tessellator.addVertexWithUV(-7D, -2D, 2D, f7, f9);
|
||||
tessellator.addVertexWithUV(-7D, -2D, -2D, f6, f9);
|
||||
tessellator.draw();
|
||||
|
||||
for(int j = 0; j < 4; j++)
|
||||
{
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
package mekanism.common.entity;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import mekanism.api.Pos3D;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
|
||||
|
||||
public class EntityFlame extends Entity
|
||||
public class EntityFlame extends Entity implements IEntityAdditionalSpawnData
|
||||
{
|
||||
public static final int LIFESPAN = 60;
|
||||
|
||||
public EntityFlame(World world)
|
||||
{
|
||||
super(world);
|
||||
|
@ -17,29 +22,42 @@ public class EntityFlame extends Entity
|
|||
{
|
||||
super(player.worldObj);
|
||||
|
||||
Pos3D playerPos = new Pos3D(player);
|
||||
Pos3D flameVec = new Pos3D(0.8, 0.8, 0.8);
|
||||
Pos3D playerPos = new Pos3D(player).translate(0, 1.6, 0);
|
||||
Pos3D flameVec = new Pos3D(1, 1, 1);
|
||||
|
||||
flameVec.multiply(new Pos3D(player.getLook(90)));
|
||||
flameVec.rotateYaw(15);
|
||||
flameVec.rotateYaw(6);
|
||||
|
||||
Pos3D mergedVec = playerPos.clone().translate(flameVec);
|
||||
setPosition(mergedVec.xPos, mergedVec.yPos, mergedVec.zPos);
|
||||
|
||||
Pos3D motion = new Pos3D(8, 8, 8);
|
||||
Pos3D motion = new Pos3D(0.2, 0.2, 0.2);
|
||||
motion.multiply(new Pos3D(player.getLookVec()));
|
||||
|
||||
setHeading(motion);
|
||||
|
||||
motionX = motion.xPos;
|
||||
motionY = motion.yPos;
|
||||
motionZ = motion.zPos;
|
||||
}
|
||||
|
||||
public void setHeading(Pos3D motion)
|
||||
{
|
||||
float d = MathHelper.sqrt_double((motion.xPos * motion.xPos) + (motion.zPos * motion.zPos));
|
||||
|
||||
prevRotationYaw = rotationYaw = (float)(Math.atan2(motion.xPos, motion.zPos) * 180.0D / Math.PI);
|
||||
prevRotationPitch = rotationPitch = (float)(Math.atan2(motion.yPos, d) * 180.0D / Math.PI);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
ticksExisted++;
|
||||
|
||||
prevPosX = posX;
|
||||
prevPosY = posY;
|
||||
prevPosZ = posZ;
|
||||
|
||||
prevRotationPitch = rotationPitch;
|
||||
prevRotationYaw = rotationYaw;
|
||||
|
||||
|
@ -47,7 +65,7 @@ public class EntityFlame extends Entity
|
|||
posY += motionY;
|
||||
posZ += motionZ;
|
||||
|
||||
if(ticksExisted > 100)
|
||||
if(ticksExisted > LIFESPAN)
|
||||
{
|
||||
setDead();
|
||||
return;
|
||||
|
@ -71,4 +89,16 @@ public class EntityFlame extends Entity
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSpawnData(ByteBuf dataStream)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSpawnData(ByteBuf dataStream)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.3 KiB |
Loading…
Add table
Reference in a new issue