Search in sources :

Example 21 with RenderManager

use of net.minecraft.client.renderer.entity.RenderManager in project Galacticraft by micdoodle8.

the class GuiExtendedInventory method drawPlayerOnGui.

public static void drawPlayerOnGui(Minecraft mc, int x, int y, int scale, float mouseX) {
    GlStateManager.enableColorMaterial();
    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, 50.0F);
    GlStateManager.scale(-scale, scale, scale);
    GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
    float f2 = mc.thePlayer.renderYawOffset;
    float f3 = mc.thePlayer.rotationYaw;
    float f4 = mc.thePlayer.rotationPitch;
    float f5 = mc.thePlayer.rotationYawHead;
    mouseX -= 19;
    GlStateManager.rotate(135.0F, 0.0F, 1.0F, 0.0F);
    RenderHelper.enableStandardItemLighting();
    GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F);
    mc.thePlayer.renderYawOffset = GuiExtendedInventory.rotation;
    mc.thePlayer.rotationYaw = (float) Math.atan(mouseX / 40.0F) * 40.0F;
    mc.thePlayer.rotationYaw = GuiExtendedInventory.rotation;
    mc.thePlayer.rotationYawHead = mc.thePlayer.rotationYaw;
    mc.thePlayer.rotationPitch = (float) Math.sin(mc.getSystemTime() / 500.0F) * 3.0F;
    GlStateManager.translate(0.0F, (float) mc.thePlayer.getYOffset(), 0.0F);
    mc.getRenderManager().playerViewY = 180.0F;
    mc.getRenderManager().renderEntityWithPosYaw(mc.thePlayer, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F);
    RenderManager rendermanager = Minecraft.getMinecraft().getRenderManager();
    rendermanager.setPlayerViewY(180.0F);
    rendermanager.setRenderShadow(false);
    rendermanager.renderEntityWithPosYaw(mc.thePlayer, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F);
    rendermanager.setRenderShadow(true);
    mc.thePlayer.renderYawOffset = f2;
    mc.thePlayer.rotationYaw = f3;
    mc.thePlayer.rotationPitch = f4;
    mc.thePlayer.rotationYawHead = f5;
    GlStateManager.popMatrix();
    RenderHelper.disableStandardItemLighting();
    GlStateManager.disableRescaleNormal();
    GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
    GlStateManager.disableTexture2D();
    GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
}
Also used : RenderManager(net.minecraft.client.renderer.entity.RenderManager)

Example 22 with RenderManager

use of net.minecraft.client.renderer.entity.RenderManager in project Galacticraft by micdoodle8.

the class GuiSlimeling method drawSlimelingOnGui.

public static void drawSlimelingOnGui(EntitySlimeling slimeling, int x, int y, int scale, float mouseX, float mouseY) {
    GuiSlimeling.renderingOnGui = true;
    GlStateManager.enableColorMaterial();
    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, 50.0F);
    GlStateManager.scale(-scale / 2.0F, scale / 2.0F, scale / 2.0F);
    GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
    float f2 = slimeling.renderYawOffset;
    float f3 = slimeling.rotationYaw;
    float f4 = slimeling.rotationPitch;
    mouseX += 40;
    mouseY -= 20;
    GlStateManager.rotate(135.0F, 0.0F, 1.0F, 0.0F);
    RenderHelper.enableStandardItemLighting();
    GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(-((float) Math.atan(mouseY / 40.0F)) * 20.0F, 1.0F, 0.0F, 0.0F);
    slimeling.renderYawOffset = (float) Math.atan(mouseX / 40.0F) * 20.0F;
    slimeling.rotationYaw = (float) Math.atan(mouseX / 40.0F) * 40.0F;
    slimeling.rotationPitch = -((float) Math.atan(mouseY / 40.0F)) * 20.0F;
    slimeling.rotationYawHead = slimeling.rotationYaw;
    GlStateManager.translate(0.0F, (float) slimeling.getYOffset(), 0.0F);
    RenderManager rendermanager = Minecraft.getMinecraft().getRenderManager();
    rendermanager.setPlayerViewY(180.0F);
    rendermanager.setRenderShadow(false);
    rendermanager.renderEntityWithPosYaw(slimeling, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F);
    rendermanager.setRenderShadow(true);
    slimeling.renderYawOffset = f2;
    slimeling.rotationYaw = f3;
    slimeling.rotationPitch = f4;
    GlStateManager.popMatrix();
    RenderHelper.disableStandardItemLighting();
    GlStateManager.disableRescaleNormal();
    GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
    GlStateManager.disableTexture2D();
    GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
    GlStateManager.color(1.0F, 1.0F, 1.0F);
    GuiSlimeling.renderingOnGui = false;
}
Also used : RenderManager(net.minecraft.client.renderer.entity.RenderManager)

Example 23 with RenderManager

use of net.minecraft.client.renderer.entity.RenderManager in project Wurst-MC-1.12 by Wurst-Imperium.

the class TrajectoriesMod method onRender.

@Override
public void onRender(float partialTicks) {
    EntityPlayerSP player = WMinecraft.getPlayer();
    // check if player is holding item
    ItemStack stack = player.inventory.getCurrentItem();
    if (stack == null)
        return;
    // check if item is throwable
    if (!WItem.isThrowable(stack))
        return;
    boolean usingBow = stack.getItem() instanceof ItemBow;
    // calculate starting position
    double arrowPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * mc.timer.renderPartialTicks - WMath.cos((float) Math.toRadians(player.rotationYaw)) * 0.16F;
    double arrowPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * Minecraft.getMinecraft().timer.renderPartialTicks + player.getEyeHeight() - 0.1;
    double arrowPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * Minecraft.getMinecraft().timer.renderPartialTicks - WMath.sin((float) Math.toRadians(player.rotationYaw)) * 0.16F;
    // calculate starting motion
    float arrowMotionFactor = usingBow ? 1F : 0.4F;
    float yaw = (float) Math.toRadians(player.rotationYaw);
    float pitch = (float) Math.toRadians(player.rotationPitch);
    float arrowMotionX = -WMath.sin(yaw) * WMath.cos(pitch) * arrowMotionFactor;
    float arrowMotionY = -WMath.sin(pitch) * arrowMotionFactor;
    float arrowMotionZ = WMath.cos(yaw) * WMath.cos(pitch) * arrowMotionFactor;
    double arrowMotion = Math.sqrt(arrowMotionX * arrowMotionX + arrowMotionY * arrowMotionY + arrowMotionZ * arrowMotionZ);
    arrowMotionX /= arrowMotion;
    arrowMotionY /= arrowMotion;
    arrowMotionZ /= arrowMotion;
    if (usingBow) {
        float bowPower = (72000 - player.getItemInUseCount()) / 20F;
        bowPower = (bowPower * bowPower + bowPower * 2F) / 3F;
        if (bowPower > 1F || bowPower <= 0.1F)
            bowPower = 1F;
        bowPower *= 3F;
        arrowMotionX *= bowPower;
        arrowMotionY *= bowPower;
        arrowMotionZ *= bowPower;
    } else {
        arrowMotionX *= 1.5D;
        arrowMotionY *= 1.5D;
        arrowMotionZ *= 1.5D;
    }
    // GL settings
    GL11.glPushMatrix();
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDepthMask(false);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glLineWidth(2);
    RenderManager renderManager = mc.getRenderManager();
    // draw trajectory line
    double gravity = usingBow ? 0.05D : stack.getItem() instanceof ItemPotion ? 0.4D : stack.getItem() instanceof ItemFishingRod ? 0.15D : 0.03D;
    Vec3d playerVector = new Vec3d(player.posX, player.posY + player.getEyeHeight(), player.posZ);
    GL11.glColor4f(0, 1, 0, 0.75F);
    GL11.glBegin(GL11.GL_LINE_STRIP);
    for (int i = 0; i < 1000; i++) {
        GL11.glVertex3d(arrowPosX - renderManager.renderPosX, arrowPosY - renderManager.renderPosY, arrowPosZ - renderManager.renderPosZ);
        arrowPosX += arrowMotionX * 0.1;
        arrowPosY += arrowMotionY * 0.1;
        arrowPosZ += arrowMotionZ * 0.1;
        arrowMotionX *= 0.999D;
        arrowMotionY *= 0.999D;
        arrowMotionZ *= 0.999D;
        arrowMotionY -= gravity * 0.1;
        if (WMinecraft.getWorld().rayTraceBlocks(playerVector, new Vec3d(arrowPosX, arrowPosY, arrowPosZ)) != null)
            break;
    }
    GL11.glEnd();
    // draw end of trajectory line
    double renderX = arrowPosX - renderManager.renderPosX;
    double renderY = arrowPosY - renderManager.renderPosY;
    double renderZ = arrowPosZ - renderManager.renderPosZ;
    GL11.glPushMatrix();
    GL11.glTranslated(renderX - 0.5, renderY - 0.5, renderZ - 0.5);
    GL11.glColor4f(0F, 1F, 0F, 0.25F);
    RenderUtils.drawSolidBox();
    GL11.glColor4f(0, 1, 0, 0.75F);
    RenderUtils.drawOutlinedBox();
    GL11.glPopMatrix();
    // GL resets
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthMask(true);
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
    GL11.glPopMatrix();
}
Also used : ItemPotion(net.minecraft.item.ItemPotion) ItemFishingRod(net.minecraft.item.ItemFishingRod) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) ItemStack(net.minecraft.item.ItemStack) ItemBow(net.minecraft.item.ItemBow) RenderManager(net.minecraft.client.renderer.entity.RenderManager) Vec3d(net.minecraft.util.math.Vec3d)

Example 24 with RenderManager

use of net.minecraft.client.renderer.entity.RenderManager in project Tropicraft by Tropicraft.

the class GuiTropicsLoading method drawScreenEntity.

private void drawScreenEntity(Entity ent, float x, float y, float scale, float yaw, float pitch) {
    if (ent == null)
        return;
    GlStateManager.enableColorMaterial();
    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, 500.0F);
    GlStateManager.scale(-scale, scale, scale);
    GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
    float f, f1, f2, f3, f4;
    f = f1 = f2 = f3 = f4 = 0;
    if (ent instanceof EntityTropicraftWaterBase) {
        EntityTropicraftWaterBase fish = (EntityTropicraftWaterBase) ent;
        fish.swimYaw = -yaw;
        fish.swimPitch = pitch * 0.25f;
    }
    if (ent instanceof EntityLivingBase) {
        EntityLivingBase liv = (EntityLivingBase) ent;
        f = liv.renderYawOffset;
        f1 = liv.rotationYaw;
        f2 = liv.rotationPitch;
        f3 = liv.prevRotationYawHead;
        f4 = liv.rotationYawHead;
        liv.renderYawOffset = yaw;
        liv.rotationYaw = yaw;
        liv.rotationPitch = pitch;
        liv.rotationYawHead = ent.rotationYaw;
        liv.prevRotationYawHead = ent.rotationYaw;
    }
    GlStateManager.rotate(135.0F, 0.0F, 1.0F, 0.0F);
    // RenderHelper.enableGUIStandardItemLighting();
    RenderHelper.enableStandardItemLighting();
    GlStateManager.rotate(-135.0F, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(-((float) Math.atan((double) (pitch / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F);
    GlStateManager.translate(0.0F, 0.0F, 0.0F);
    RenderManager rendermanager = mc.getRenderManager();
    rendermanager.setPlayerViewY(180.0F);
    rendermanager.setRenderShadow(false);
    rendermanager.renderEntity(ent, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, false);
    rendermanager.setRenderShadow(true);
    if (ent instanceof EntityLivingBase) {
        EntityLivingBase liv = (EntityLivingBase) ent;
        liv.renderYawOffset = f;
        liv.rotationYaw = f1;
        liv.rotationPitch = f2;
        liv.prevRotationYawHead = f3;
        liv.rotationYawHead = f4;
    }
    GlStateManager.popMatrix();
    RenderHelper.disableStandardItemLighting();
    GlStateManager.disableRescaleNormal();
    GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
    GlStateManager.disableTexture2D();
    GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) RenderManager(net.minecraft.client.renderer.entity.RenderManager) EntityTropicraftWaterBase(net.tropicraft.core.common.entity.underdasea.atlantoku.EntityTropicraftWaterBase)

Example 25 with RenderManager

use of net.minecraft.client.renderer.entity.RenderManager in project DynamicSurroundings by OreCruncher.

the class LightLevelHUD method doRender.

@SubscribeEvent
public static void doRender(@Nonnull final RenderWorldLastEvent event) {
    if (!showHUD || nextCoord == 0)
        return;
    final EntityPlayer player = EnvironState.getPlayer();
    if (player == null)
        return;
    final RenderManager manager = Minecraft.getMinecraft().getRenderManager();
    final OpenGlState glState = OpenGlState.push();
    GlStateManager.enableTexture2D();
    GlStateManager.disableLighting();
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
    GlStateManager.enableDepth();
    GlStateManager.depthFunc(GL11.GL_LEQUAL);
    GlStateManager.depthMask(true);
    if (useOldRenderMethod())
        drawStringRender(player, manager);
    else
        textureRender(player, manager);
    OpenGlState.pop(glState);
}
Also used : OpenGlState(org.blockartistry.lib.gfx.OpenGlState) EntityPlayer(net.minecraft.entity.player.EntityPlayer) RenderManager(net.minecraft.client.renderer.entity.RenderManager) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

RenderManager (net.minecraft.client.renderer.entity.RenderManager)45 Tessellator (net.minecraft.client.renderer.Tessellator)8 FontRenderer (net.minecraft.client.gui.FontRenderer)7 InvokeEvent (cc.hyperium.event.InvokeEvent)4 Minecraft (net.minecraft.client.Minecraft)4 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)3 WorldRenderer (net.minecraft.client.renderer.WorldRenderer)3 Render (net.minecraft.client.renderer.entity.Render)3 EntityLivingBase (net.minecraft.entity.EntityLivingBase)3 EntityItem (net.minecraft.entity.item.EntityItem)3 Field (java.lang.reflect.Field)2 EntityJuicer (micdoodle8.mods.galacticraft.planets.venus.entities.EntityJuicer)2 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)2 RenderPlayer (net.minecraft.client.renderer.entity.RenderPlayer)2 TextureManager (net.minecraft.client.renderer.texture.TextureManager)2 Entity (net.minecraft.entity.Entity)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 ItemStack (net.minecraft.item.ItemStack)2 LayerBloodElytra (WayofTime.bloodmagic.client.render.LayerBloodElytra)1 IMixinThreadDownloadImageData (cc.hyperium.mixins.client.renderer.IMixinThreadDownloadImageData)1