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:
Aidan C. Brady committed 2014-07-18 01:34:56 -04:00
1 parent 9469fcb51a
commit cfc308b042
4 files changed
+39 -31

No files matched your search

@@ -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)
{
}
}