From cfc308b04267de3be88ae7fda4c423f1de38b17d Mon Sep 17 00:00:00 2001 From: "Aidan C. Brady" Date: Fri, 18 Jul 2014 01:34:56 -0400 Subject: [PATCH] Flames now render how I want them to! Tomorrow I add logic, such as the burning of entities and the smelting of blocks. --- .../mekanism/client/ClientTickHandler.java | 2 - .../client/render/entity/RenderFlame.java | 26 ++--------- .../mekanism/common/entity/EntityFlame.java | 42 +++++++++++++++--- .../assets/mekanism/render/Flame.png | Bin 1274 -> 1294 bytes 4 files changed, 39 insertions(+), 31 deletions(-) diff --git a/src/main/java/mekanism/client/ClientTickHandler.java b/src/main/java/mekanism/client/ClientTickHandler.java index 77e2a2490..f75e7f9a8 100644 --- a/src/main/java/mekanism/client/ClientTickHandler.java +++ b/src/main/java/mekanism/client/ClientTickHandler.java @@ -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()); diff --git a/src/main/java/mekanism/client/render/entity/RenderFlame.java b/src/main/java/mekanism/client/render/entity/RenderFlame.java index 74e0bd80d..e3cd32b13 100644 --- a/src/main/java/mekanism/client/render/entity/RenderFlame.java +++ b/src/main/java/mekanism/client/render/entity/RenderFlame.java @@ -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++) { diff --git a/src/main/java/mekanism/common/entity/EntityFlame.java b/src/main/java/mekanism/common/entity/EntityFlame.java index 41af3c91e..87e8b7143 100644 --- a/src/main/java/mekanism/common/entity/EntityFlame.java +++ b/src/main/java/mekanism/common/entity/EntityFlame.java @@ -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) + { + + } } diff --git a/src/main/resources/assets/mekanism/render/Flame.png b/src/main/resources/assets/mekanism/render/Flame.png index f5483bbc5f8164aa5e70336b751857d4eb1bfccf..f98623d2b517205809e891fb38eea2e7a4bee66f 100644 GIT binary patch delta 282 zcmeyx*~g{W8Q|y6%O%Cdz`(%k>ERLtq!mDzgAGU)S5d>Z({dxF<-4Ijp&4yxV}s+^^>XH}eGNm;XDXm-il-dbt0J+P{y}--=7GoqZ`m zxUBAb&AlvrYrmH{p?X{9KHv4LFyH3=^YX8k|Iml1JA|7XvQ(mDRlhtl3{ zWOx3TbZ?cJ-<%w^2bT*@S!m{~X$4QbR`Xo0f1`fg1s)M8)ojicfm4~D*B<%6knNt WTlCd>X;Gke89ZJ6T-G@yGywpi+jAoT delta 262 zcmV+h0r~!p3i=5liBL{Q4GJ0x0000DNk~Le0000O0000O2nGNE0N{5$_^~1X1AoOy zL_t(Y4ee074Z<)GeL;$A6eb`uu!DDCmDE`UQPZ&l3((M~Afk>7bMNd+5z*6}CF^|e zz5DoKLdd*nK#8$L!>6<4SL7$!oHm?dwN87GuX<|9?>@-rh6S&&g`F-gidl{u(8q-N z9zf1&_Go}dQ4v%AD7onQ?uUein_E*fA8NacG?9Vx7!+VbYm5_g5gk_b-CJaWQ@_>f z@b%kbgMLr!GCMe&Z(g(Pmwx3$Z#9P1wLQ24?tnYs4!8sEz@HuX0*r^26?ShNssI20 M07*qoM6N<$f^VO6KL7v#