Jetpack work!

This commit is contained in:
Aidan Brady 2013-12-04 19:14:27 -05:00
parent aca0692cec
commit 64f681c263
3 changed files with 64 additions and 8 deletions

View file

@ -30,6 +30,7 @@ import cpw.mods.fml.relauncher.SideOnly;
public class ClientPlayerTickHandler implements ITickHandler
{
public boolean lastTickUpdate = false;
public Minecraft mc = Minecraft.getMinecraft();
@Override
public void tickStart(EnumSet<TickType> type, Object... tickData) {}
@ -122,6 +123,12 @@ public class ClientPlayerTickHandler implements ITickHandler
{
Mekanism.proxy.registerSound(entry);
}
if(isJetpackOn(mc.thePlayer))
{
mc.thePlayer.motionY = Math.min(mc.thePlayer.motionY + 0.15D, 0.5D);
mc.thePlayer.fallDistance = 0.0F;
}
}
}
@ -132,13 +139,18 @@ public class ClientPlayerTickHandler implements ITickHandler
public static boolean isJetpackOn(EntityPlayer player)
{
if(player.inventory.armorInventory[2] != null)
ItemStack stack = player.inventory.armorInventory[2];
if(stack != null)
{
if(player.inventory.armorInventory[2].getItem() instanceof ItemJetpack)
if(stack.getItem() instanceof ItemJetpack)
{
if(Keyboard.isKeyDown(Keyboard.KEY_SPACE))
if(((ItemJetpack)stack.getItem()).getGas(stack) != null)
{
return true;
if(Keyboard.isKeyDown(Keyboard.KEY_SPACE))
{
return true;
}
}
}
}

View file

@ -167,7 +167,11 @@ public class ModelJetpack extends ModelBase
Fueltuberight.render(size);
Fueltubeleft.render(size);
Packmid.render(size);
MekanismRenderer.glowOn();
Packcore.render(size);
MekanismRenderer.glowOff();
WingsupportL.render(size);
WingsupportR.render(size);
Packtoprear.render(size);

View file

@ -1,6 +1,7 @@
package mekanism.client.render;
import java.util.EnumSet;
import java.util.Random;
import mekanism.api.Object3D;
import mekanism.common.Mekanism;
@ -10,6 +11,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import universalelectricity.core.vector.Vector3;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;
@ -19,11 +21,10 @@ import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderTickHandler implements ITickHandler
{
public Random rand = new Random();
@Override
public void tickStart(EnumSet<TickType> type, Object... tickData)
{
}
public void tickStart(EnumSet<TickType> type, Object... tickData) {}
@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData)
@ -66,6 +67,45 @@ public class RenderTickHandler implements ITickHandler
font.drawStringWithShadow("Side: " + pos.sideHit, 1, 28, 0x404040);
}
}
for(EntityPlayer p : Mekanism.jetpackOn)
{
if(p.getDistance(player.posX, player.posY, player.posZ) > 40)
{
continue;
}
float random = (rand.nextFloat()-0.5F)*0.1F;
Vector3 vLeft = new Vector3();
vLeft.z -= 0.54;
vLeft.x -= 0.43;
vLeft.rotate(p.renderYawOffset);
vLeft.y -= 0.55;
Vector3 vRight = new Vector3();
vRight.z -= 0.54;
vRight.x += 0.43;
vRight.rotate(p.renderYawOffset);
vRight.y -= 0.55;
Vector3 rLeft = vLeft.clone().scale(random);
Vector3 rRight = vRight.clone().scale(random);
Vector3 mLeft = Vector3.translate(vLeft.clone().scale(0.2), new Vector3(p.motionX, p.motionY, p.motionZ));
Vector3 mRight = Vector3.translate(vRight.clone().scale(0.2), new Vector3(p.motionX, p.motionY, p.motionZ));
mLeft.translate(rLeft);
mRight.translate(rRight);
Vector3 v = new Vector3(p).translate(vLeft);
world.spawnParticle("flame", v.x, v.y, v.z, mLeft.x, mLeft.y, mLeft.z);
world.spawnParticle("smoke", v.x, v.y, v.z, mLeft.x, mLeft.y, mLeft.z);
v = new Vector3(p).translate(vRight);
world.spawnParticle("flame", v.x, v.y, v.z, mRight.x, mRight.y, mRight.z);
world.spawnParticle("smoke", v.x, v.y, v.z, mRight.x, mRight.y, mRight.z);
}
}
}