package micdoodle8.mods.galacticraft.planets.mars.client.render.entity; import com.google.common.base.Function; import micdoodle8.mods.galacticraft.core.util.ClientUtil; import micdoodle8.mods.galacticraft.planets.GalacticraftPlanets; import micdoodle8.mods.galacticraft.planets.mars.client.render.item.ItemModelRocketT2; import micdoodle8.mods.galacticraft.planets.mars.entities.EntityTier2Rocket; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.culling.ICamera; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.client.FMLClientHandler; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; @SideOnly(Side.CLIENT) public class RenderTier2Rocket extends Render<EntityTier2Rocket> { private ItemModelRocketT2 rocketModel; public RenderTier2Rocket(RenderManager manager) { super(manager); this.shadowSize = 2F; } private void updateModel() { if (rocketModel == null) { Function<ResourceLocation, TextureAtlasSprite> textureGetter = new Function<ResourceLocation, TextureAtlasSprite>() { @Override public TextureAtlasSprite apply(ResourceLocation input) { return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(input.toString()); } }; ModelResourceLocation modelResourceLocation = new ModelResourceLocation(GalacticraftPlanets.TEXTURE_PREFIX + "rocket_t2", "inventory"); rocketModel = (ItemModelRocketT2) FMLClientHandler.instance().getClient().getRenderItem().getItemModelMesher().getModelManager().getModel(modelResourceLocation); } } @Override protected ResourceLocation getEntityTexture(EntityTier2Rocket par1Entity) { return new ResourceLocation("missing"); } @Override public void doRender(EntityTier2Rocket entity, double par2, double par4, double par6, float par8, float par9) { GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPushMatrix(); final float var24 = entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * par9 + 180; GL11.glTranslatef((float) par2, (float) par4 + entity.getRenderOffsetY(), (float) par6); GL11.glRotatef(180.0F - par8, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-var24, 0.0F, 0.0F, 1.0F); final float var28 = entity.rollAmplitude / 3 - par9; if (var28 > 0.0F) { final float i = entity.getLaunched() ? (5 - MathHelper.floor_double(entity.timeUntilLaunch / 85)) / 10F : 0.3F; GL11.glRotatef(MathHelper.sin(var28) * var28 * i * par9, 1.0F, 0.0F, 0.0F); GL11.glRotatef(MathHelper.sin(var28) * var28 * i * par9, 1.0F, 0.0F, 1.0F); } updateModel(); RenderHelper.disableStandardItemLighting(); this.bindTexture(TextureMap.locationBlocksTexture); if (Minecraft.isAmbientOcclusionEnabled()) { GlStateManager.shadeModel(GL11.GL_SMOOTH); } else { GlStateManager.shadeModel(GL11.GL_FLAT); } GL11.glScalef(-1.0F, -1.0F, 1.0F); GL11.glScalef(0.8F, 0.8F, 0.8F); ClientUtil.drawBakedModel(rocketModel); GL11.glPopMatrix(); RenderHelper.enableStandardItemLighting(); } @Override public boolean shouldRender(EntityTier2Rocket rocket, ICamera camera, double camX, double camY, double camZ) { AxisAlignedBB axisalignedbb = rocket.getEntityBoundingBox().expand(0.5D, 0, 0.5D); return rocket.isInRangeToRender3d(camX, camY, camZ) && camera.isBoundingBoxInFrustum(axisalignedbb); } }