Started work on actual flame implementation

This commit is contained in:
Aidan C. Brady 2014-07-17 20:06:51 -04:00
parent 2f4d545fb5
commit 9469fcb51a
7 changed files with 184 additions and 5 deletions

View file

@ -52,6 +52,7 @@ import mekanism.client.render.RenderTickHandler;
import mekanism.client.render.block.BasicRenderingHandler;
import mekanism.client.render.block.MachineRenderingHandler;
import mekanism.client.render.entity.RenderBalloon;
import mekanism.client.render.entity.RenderFlame;
import mekanism.client.render.entity.RenderObsidianTNTPrimed;
import mekanism.client.render.entity.RenderRobit;
import mekanism.client.render.item.ItemRenderingHandler;
@ -89,6 +90,7 @@ import mekanism.common.Mekanism;
import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.entity.EntityBabySkeleton;
import mekanism.common.entity.EntityBalloon;
import mekanism.common.entity.EntityFlame;
import mekanism.common.entity.EntityObsidianTNT;
import mekanism.common.entity.EntityRobit;
import mekanism.common.inventory.InventoryElectricChest;
@ -320,6 +322,7 @@ public class ClientProxy extends CommonProxy
RenderingRegistry.registerEntityRenderingHandler(EntityRobit.class, new RenderRobit());
RenderingRegistry.registerEntityRenderingHandler(EntityBalloon.class, new RenderBalloon());
RenderingRegistry.registerEntityRenderingHandler(EntityBabySkeleton.class, new RenderSkeleton());
RenderingRegistry.registerEntityRenderingHandler(EntityFlame.class, new RenderFlame());
//Register item handler
ItemRenderingHandler handler = new ItemRenderingHandler();

View file

@ -170,7 +170,7 @@ public class RenderTickHandler
{
for(EntityPlayer p : (List<EntityPlayer>)world.playerEntities)
{
if(!p.isSwingInProgress && p.getCurrentEquippedItem() != null && p.getCurrentEquippedItem().getItem() instanceof ItemFlamethrower)
if(!Mekanism.flamethrowerActive.contains(p.getCommandSenderName()) && !p.isSwingInProgress && p.getCurrentEquippedItem() != null && p.getCurrentEquippedItem().getItem() instanceof ItemFlamethrower)
{
if(((ItemFlamethrower)p.getCurrentEquippedItem().getItem()).getGas(p.getCurrentEquippedItem()) != null)
{

View file

@ -0,0 +1,98 @@
package mekanism.client.render.entity;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.entity.EntityFlame;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
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 size = alpha*8;
GL11.glPushMatrix();
MekanismRenderer.glowOn();
MekanismRenderer.blendOn();
GL11.glColor4f(1, 1, 1, 1-alpha);
GL11.glScalef(size, size, size);
bindTexture(getEntityTexture(entity));
GL11.glTranslatef((float)x, (float)y, (float)z);
GL11.glRotatef((entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTick) - 90F, 0.0F, 1.0F, 0.0F);
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;
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++)
{
GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F);
GL11.glNormal3f(0.0F, 0.0F, scale);
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(-8D, -2D, 0.0D, f2, f4);
tessellator.addVertexWithUV(8D, -2D, 0.0D, f3, f4);
tessellator.addVertexWithUV(8D, 2D, 0.0D, f3, f5);
tessellator.addVertexWithUV(-8D, 2D, 0.0D, f2, f5);
tessellator.draw();
}
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
MekanismRenderer.glowOff();
MekanismRenderer.blendOff();
GL11.glPopMatrix();
}
@Override
public void doRender(Entity entity, double x, double y, double z, float f, float partialTick)
{
doRender((EntityFlame)entity, x, y, z, f, partialTick);
}
@Override
protected ResourceLocation getEntityTexture(Entity entity)
{
return new ResourceLocation("mekanism:render/Flame.png");
}
}

View file

@ -1,6 +1,7 @@
package mekanism.common;
import mekanism.api.gas.GasStack;
import mekanism.common.entity.EntityFlame;
import mekanism.common.item.ItemFlamethrower;
import mekanism.common.item.ItemFreeRunners;
import mekanism.common.item.ItemGasMask;
@ -99,7 +100,7 @@ public class CommonPlayerTickHandler
if(isFlamethrowerOn(player))
{
//TODO spawn flame entities
player.worldObj.spawnEntityInWorld(new EntityFlame(player));
}
if(isJetpackOn(player))

View file

@ -51,6 +51,7 @@ import mekanism.common.block.BlockPlasticFence;
import mekanism.common.block.BlockSalt;
import mekanism.common.entity.EntityBabySkeleton;
import mekanism.common.entity.EntityBalloon;
import mekanism.common.entity.EntityFlame;
import mekanism.common.entity.EntityObsidianTNT;
import mekanism.common.entity.EntityRobit;
import mekanism.common.integration.MekanismHooks;
@ -1249,12 +1250,14 @@ public class Mekanism
EntityRegistry.registerGlobalEntityID(EntityRobit.class, "Robit", EntityRegistry.findGlobalUniqueEntityId());
EntityRegistry.registerGlobalEntityID(EntityBalloon.class, "Balloon", EntityRegistry.findGlobalUniqueEntityId());
EntityRegistry.registerGlobalEntityID(EntityBabySkeleton.class, "BabySkeleton", EntityRegistry.findGlobalUniqueEntityId());
EntityRegistry.registerGlobalEntityID(EntityFlame.class, "Flame", EntityRegistry.findGlobalUniqueEntityId());
//Registrations
EntityRegistry.registerModEntity(EntityObsidianTNT.class, "ObsidianTNT", 0, this, 40, 5, true);
EntityRegistry.registerModEntity(EntityRobit.class, "Robit", 1, this, 40, 2, true);
EntityRegistry.registerModEntity(EntityBalloon.class, "Balloon", 2, this, 40, 1, true);
EntityRegistry.registerModEntity(EntityObsidianTNT.class, "ObsidianTNT", 0, this, 64, 5, true);
EntityRegistry.registerModEntity(EntityRobit.class, "Robit", 1, this, 64, 2, true);
EntityRegistry.registerModEntity(EntityBalloon.class, "Balloon", 2, this, 64, 1, true);
EntityRegistry.registerModEntity(EntityBabySkeleton.class, "BabySkeleton", 3, this, 64, 5, true);
EntityRegistry.registerModEntity(EntityFlame.class, "Flame", 4, this, 64, 5, true);
//Tile entities
GameRegistry.registerTileEntity(TileEntityBoundingBlock.class, "BoundingBlock");

View file

@ -0,0 +1,74 @@
package mekanism.common.entity;
import mekanism.api.Pos3D;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
public class EntityFlame extends Entity
{
public EntityFlame(World world)
{
super(world);
}
public EntityFlame(EntityPlayer player)
{
super(player.worldObj);
Pos3D playerPos = new Pos3D(player);
Pos3D flameVec = new Pos3D(0.8, 0.8, 0.8);
flameVec.multiply(new Pos3D(player.getLook(90)));
flameVec.rotateYaw(15);
Pos3D mergedVec = playerPos.clone().translate(flameVec);
setPosition(mergedVec.xPos, mergedVec.yPos, mergedVec.zPos);
Pos3D motion = new Pos3D(8, 8, 8);
motion.multiply(new Pos3D(player.getLookVec()));
motionX = motion.xPos;
motionY = motion.yPos;
motionZ = motion.zPos;
}
@Override
public void onUpdate()
{
prevPosX = posX;
prevPosY = posY;
prevPosZ = posZ;
prevRotationPitch = rotationPitch;
prevRotationYaw = rotationYaw;
posX += motionX;
posY += motionY;
posZ += motionZ;
if(ticksExisted > 100)
{
setDead();
return;
}
}
@Override
protected void entityInit()
{
}
@Override
protected void readEntityFromNBT(NBTTagCompound nbtTags)
{
}
@Override
protected void writeEntityToNBT(NBTTagCompound nbtTags)
{
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB