Java tutorial
/* * The MIT License (MIT) * * Copyright (c) 2014 * * See LICENSE for full License */ package kihira.tails.client.model.wings; import kihira.tails.client.model.ModelPartBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import org.lwjgl.opengl.GL11; public class ModelMetalWings extends ModelPartBase { ModelRenderer wing; public ModelMetalWings() { textureWidth = 64; textureHeight = 32; wing = new ModelRenderer(this, 0, 0); wing.addBox(0F, 0F, 0.5F, 20, 29, 1); wing.setTextureSize(32, 32); wing.mirror = true; } @Override public void render(EntityLivingBase theEntity, int subtype, float partialTicks) { GL11.glTranslatef(0, -7F * SCALE, 1F * SCALE * 2); GL11.glRotatef(90, 0, 1, 0); GL11.glRotatef(90, 0, 0, 1); boolean isFlying = theEntity instanceof EntityPlayer && ((EntityPlayer) theEntity).capabilities.isFlying && theEntity.isAirBorne || theEntity.fallDistance > 0F; float timestep = getAnimationTime(isFlying ? 500 : 6000, theEntity); float angle = (float) Math.sin(timestep) * (isFlying ? 20F : 6F); GL11.glTranslatef(0F, -0.5F * SCALE, 0F); GL11.glPushMatrix(); GL11.glTranslatef(0F, 0F, 2F * SCALE); GL11.glRotatef(30F - angle, 1F, 0F, 0F); GL11.glTranslatef(0F, 0F, -1F * SCALE); wing.render(SCALE); GL11.glPopMatrix(); GL11.glPushMatrix(); GL11.glTranslatef(0F, 0F, -2F * SCALE); GL11.glRotatef(-30F + angle, 1F, 0F, 0F); GL11.glTranslatef(0F, 0F, -1F * SCALE); wing.render(SCALE); GL11.glTranslatef(0F, 0F, 1F * SCALE); GL11.glPopMatrix(); } }