2013-08-27 00:49:32 +02:00
|
|
|
package mekanism.client.render;
|
2013-05-14 17:34:26 +02:00
|
|
|
|
|
|
|
import java.util.EnumSet;
|
2013-12-05 01:14:27 +01:00
|
|
|
import java.util.Random;
|
2013-05-14 17:34:26 +02:00
|
|
|
|
2013-12-01 05:19:24 +01:00
|
|
|
import mekanism.api.Object3D;
|
2013-05-28 06:29:29 +02:00
|
|
|
import mekanism.common.Mekanism;
|
2013-05-14 17:34:26 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.gui.FontRenderer;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.util.MathHelper;
|
|
|
|
import net.minecraft.util.MovingObjectPosition;
|
|
|
|
import net.minecraft.world.World;
|
2013-12-05 01:14:27 +01:00
|
|
|
import universalelectricity.core.vector.Vector3;
|
2013-05-14 17:34:26 +02:00
|
|
|
import cpw.mods.fml.client.FMLClientHandler;
|
|
|
|
import cpw.mods.fml.common.ITickHandler;
|
|
|
|
import cpw.mods.fml.common.TickType;
|
2013-05-29 17:35:30 +02:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2013-05-14 17:34:26 +02:00
|
|
|
|
2013-05-29 17:35:30 +02:00
|
|
|
@SideOnly(Side.CLIENT)
|
2013-05-14 17:34:26 +02:00
|
|
|
public class RenderTickHandler implements ITickHandler
|
|
|
|
{
|
2013-12-05 01:14:27 +01:00
|
|
|
public Random rand = new Random();
|
|
|
|
|
2013-05-14 17:34:26 +02:00
|
|
|
@Override
|
2013-12-05 01:14:27 +01:00
|
|
|
public void tickStart(EnumSet<TickType> type, Object... tickData) {}
|
2013-05-14 17:34:26 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void tickEnd(EnumSet<TickType> type, Object... tickData)
|
|
|
|
{
|
2013-05-23 19:30:12 +02:00
|
|
|
float partialTick = (Float)tickData[0];
|
2013-05-14 17:34:26 +02:00
|
|
|
Minecraft mc = FMLClientHandler.instance().getClient();
|
|
|
|
|
2013-05-23 19:30:12 +02:00
|
|
|
if(mc.thePlayer != null && mc.theWorld != null)
|
2013-05-14 17:34:26 +02:00
|
|
|
{
|
|
|
|
EntityPlayer player = mc.thePlayer;
|
2013-05-23 19:30:12 +02:00
|
|
|
World world = mc.thePlayer.worldObj;
|
2013-05-14 17:34:26 +02:00
|
|
|
|
|
|
|
FontRenderer font = mc.fontRenderer;
|
|
|
|
|
|
|
|
MovingObjectPosition pos = player.rayTrace(40.0D, 1.0F);
|
|
|
|
|
|
|
|
if(pos != null)
|
|
|
|
{
|
|
|
|
int x = MathHelper.floor_double(pos.blockX);
|
|
|
|
int y = MathHelper.floor_double(pos.blockY);
|
|
|
|
int z = MathHelper.floor_double(pos.blockZ);
|
|
|
|
|
|
|
|
Object3D obj = new Object3D(x, y, z);
|
|
|
|
|
2013-05-28 06:29:29 +02:00
|
|
|
if(Mekanism.debug && mc.currentScreen == null && !mc.gameSettings.showDebugInfo)
|
2013-05-14 17:34:26 +02:00
|
|
|
{
|
2013-05-23 19:30:12 +02:00
|
|
|
String tileDisplay = "";
|
|
|
|
|
|
|
|
if(obj.getTileEntity(world) != null)
|
2013-05-14 17:34:26 +02:00
|
|
|
{
|
2013-05-23 19:30:12 +02:00
|
|
|
if(obj.getTileEntity(world).getClass() != null)
|
|
|
|
{
|
|
|
|
tileDisplay = obj.getTileEntity(world).getClass().getSimpleName();
|
|
|
|
}
|
2013-05-14 17:34:26 +02:00
|
|
|
}
|
|
|
|
|
2013-05-23 19:30:12 +02:00
|
|
|
font.drawStringWithShadow("Block ID: " + obj.getBlockId(world), 1, 1, 0x404040);
|
|
|
|
font.drawStringWithShadow("Metadata: " + obj.getMetadata(world), 1, 10, 0x404040);
|
|
|
|
font.drawStringWithShadow("TileEntity: " + tileDisplay, 1, 19, 0x404040);
|
|
|
|
font.drawStringWithShadow("Side: " + pos.sideHit, 1, 28, 0x404040);
|
|
|
|
}
|
2013-05-14 17:34:26 +02:00
|
|
|
}
|
2013-12-05 01:14:27 +01:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2013-05-14 17:34:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public EnumSet<TickType> ticks()
|
|
|
|
{
|
|
|
|
return EnumSet.of(TickType.RENDER);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getLabel()
|
|
|
|
{
|
|
|
|
return "MekanismRender";
|
|
|
|
}
|
2013-05-23 19:30:12 +02:00
|
|
|
}
|