ActuallyAdditions/src/main/java/ellpeck/actuallyadditions/gadget/RenderSpecial.java

62 lines
2 KiB
Java
Raw Normal View History

2015-03-30 18:42:14 +02:00
package ellpeck.actuallyadditions.gadget;
import ellpeck.actuallyadditions.blocks.render.ModelBaseAA;
import ellpeck.actuallyadditions.util.ModUtil;
import net.minecraft.client.Minecraft;
2015-03-31 20:37:55 +02:00
import net.minecraft.entity.player.EntityPlayer;
2015-03-30 18:42:14 +02:00
import net.minecraft.util.ResourceLocation;
2015-03-31 20:37:55 +02:00
import net.minecraft.util.Vec3;
2015-03-30 18:42:14 +02:00
import org.lwjgl.opengl.GL11;
public class RenderSpecial{
2015-03-31 20:37:55 +02:00
private double lastTimeForBobbing;
2015-03-30 18:42:14 +02:00
ModelBaseAA theModel;
ResourceLocation theTexture;
public RenderSpecial(ModelBaseAA model){
this.theModel = model;
2015-03-31 20:37:55 +02:00
this.theTexture = new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/blocks/models/special/" + this.theModel.getName() + ".png");
2015-03-30 18:42:14 +02:00
}
2015-03-31 20:37:55 +02:00
public void render(EntityPlayer player, float renderTick, float size, float offsetUp){
2015-07-07 12:32:25 +02:00
if(player.isInvisible() || player.getHideCape()) return;
2015-03-31 20:37:55 +02:00
int bobHeight = 70;
long theTime = Minecraft.getSystemTime();
long time = theTime/50;
2015-03-30 18:42:14 +02:00
2015-03-31 20:37:55 +02:00
if(time-bobHeight >= lastTimeForBobbing){
this.lastTimeForBobbing = time;
}
2015-03-30 18:42:14 +02:00
GL11.glPushMatrix();
2015-03-31 20:37:55 +02:00
if(player != Minecraft.getMinecraft().thePlayer){
Vec3 clientPos = Minecraft.getMinecraft().thePlayer.getPosition(renderTick);
Vec3 playerPos = player.getPosition(renderTick);
GL11.glTranslated(playerPos.xCoord-clientPos.xCoord, playerPos.yCoord-clientPos.yCoord+1.6225, playerPos.zCoord-clientPos.zCoord);
}
GL11.glTranslated(0F, offsetUp + 0.15D, 0F);
2015-03-31 20:37:55 +02:00
2015-03-30 18:42:14 +02:00
GL11.glRotatef(180F, 1.0F, 0.0F, 1.0F);
GL11.glScalef(size, size, size);
if(time-(bobHeight/2) >= lastTimeForBobbing){
2015-03-31 20:37:55 +02:00
GL11.glTranslated(0, ((double)time-this.lastTimeForBobbing)/100, 0);
}
else{
GL11.glTranslated(0, -((double)time-lastTimeForBobbing)/100+(double)bobHeight/100, 0);
}
2015-03-30 18:42:14 +02:00
GL11.glRotated((double)theTime/20, 0, 1, 0);
2015-03-30 18:42:14 +02:00
Minecraft.getMinecraft().renderEngine.bindTexture(theTexture);
theModel.render(0.0625F);
GL11.glPopMatrix();
}
}