Search in sources :

Example 31 with RenderManager

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

the class YeetHandler method render.

@InvokeEvent
public void render(RenderEntitiesEvent event) {
    for (Yeet yeet : yeets) {
        RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
        FontRenderer fontrenderer = renderManager.getFontRenderer();
        float f = 1.6F;
        float f1 = 0.016666668F * f;
        GlStateManager.pushMatrix();
        EntityPlayerSP entity = Minecraft.getMinecraft().thePlayer;
        float partialTicks = event.getPartialTicks();
        double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double) partialTicks;
        double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double) partialTicks;
        double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double) partialTicks;
        EntityPlayer sender = yeet.sender;
        if (sender == null)
            continue;
        double e0 = yeet.sender.lastTickPosX + (yeet.sender.posX - yeet.sender.lastTickPosX) * (double) partialTicks;
        double e1 = yeet.sender.lastTickPosY + (yeet.sender.posY - yeet.sender.lastTickPosY) * (double) partialTicks;
        double e2 = yeet.sender.lastTickPosZ + (yeet.sender.posZ - yeet.sender.lastTickPosZ) * (double) partialTicks;
        GlStateManager.translate(e0 - d0, e1 - d1, e2 - d2);
        GlStateManager.translate(0, 3, 0);
        GL11.glNormal3f(0.0F, 1.0F, 0.0F);
        GlStateManager.rotate(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
        // Nametag x rotations should flip in front-facing 3rd person
        int xMultiplier = 1;
        if (Minecraft.getMinecraft() != null && Minecraft.getMinecraft().gameSettings != null && Minecraft.getMinecraft().gameSettings.thirdPersonView == 2) {
            xMultiplier = -1;
        }
        GlStateManager.rotate(renderManager.playerViewX * xMultiplier, 1.0F, 0.0F, 0.0F);
        GlStateManager.scale(-f1, -f1, f1);
        GlStateManager.disableLighting();
        GlStateManager.depthMask(false);
        GlStateManager.disableDepth();
        GlStateManager.enableBlend();
        GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
        Tessellator tessellator = Tessellator.getInstance();
        WorldRenderer worldrenderer = tessellator.getWorldRenderer();
        int i = 0;
        String string = "YEET";
        int j = fontrenderer.getStringWidth(string) / 2;
        GlStateManager.disableTexture2D();
        GlStateManager.scale(4, 4, 4);
        worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
        worldrenderer.pos(-j - 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
        worldrenderer.pos(-j - 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
        worldrenderer.pos(j + 1, 8 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
        worldrenderer.pos(j + 1, -1 + i, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
        tessellator.draw();
        GlStateManager.enableTexture2D();
        fontrenderer.drawString(string, -j, 0, 16777215, true);
        GlStateManager.enableLighting();
        GlStateManager.disableBlend();
        GlStateManager.depthMask(true);
        GlStateManager.enableDepth();
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        GlStateManager.popMatrix();
    }
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) EntityPlayer(net.minecraft.entity.player.EntityPlayer) FontRenderer(net.minecraft.client.gui.FontRenderer) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) RenderManager(net.minecraft.client.renderer.entity.RenderManager) WorldRenderer(net.minecraft.client.renderer.WorldRenderer) InvokeEvent(cc.hyperium.event.InvokeEvent)

Example 32 with RenderManager

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

the class DragonCompanion method renderPlayer.

@InvokeEvent
public void renderPlayer(RenderPlayerEvent event) {
    if (Minecraft.getMinecraft().theWorld == null || !isPurchasedBy(event.getEntity().getUniqueID()))
        return;
    HyperiumPurchase packageIfReady = PurchaseApi.getInstance().getPackageIfReady(event.getEntity().getUniqueID());
    if (packageIfReady == null || packageIfReady.getCachedSettings().getCurrentCompanion() != EnumPurchaseType.DRAGON_COMPANION)
        return;
    scale = .1F;
    AbstractClientPlayer player = event.getEntity();
    CustomDragon customDragon = dragonHashMap.computeIfAbsent(event.getEntity(), player1 -> {
        EntityDragon dragon = new EntityDragon(player1.getEntityWorld());
        dragon.setSilent(true);
        return new CustomDragon(dragon, new AnimationState());
    });
    Entity entity = customDragon.dragon;
    RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
    // Manage pos here
    float partialTicks = event.getPartialTicks();
    double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialTicks;
    double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialTicks;
    double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialTicks;
    GlStateManager.pushMatrix();
    EntityDragon entityDragon = customDragon.dragon;
    AnimationState animationState = customDragon.animationState;
    AnimationPoint current = animationState.getCurrent(player);
    entityDragon.posX = current.x / scale;
    entityDragon.posY = current.y / scale;
    entityDragon.posZ = current.z / scale;
    GlStateManager.translate(-((IMixinRenderManager) renderManager).getPosX(), -((IMixinRenderManager) renderManager).getPosY(), -((IMixinRenderManager) renderManager).getPosZ());
    GlStateManager.translate(d0 * scale, d1 * scale, d2 * scale);
    GlStateManager.scale(scale, scale, scale);
    renderManager.renderEntitySimple(entity, event.getPartialTicks());
    GlStateManager.popMatrix();
// render
}
Also used : AbstractClientPlayer(net.minecraft.client.entity.AbstractClientPlayer) EntityDragon(net.minecraft.entity.boss.EntityDragon) Entity(net.minecraft.entity.Entity) HyperiumPurchase(cc.hyperium.purchases.HyperiumPurchase) IMixinRenderManager(cc.hyperium.mixinsimp.client.renderer.entity.IMixinRenderManager) RenderManager(net.minecraft.client.renderer.entity.RenderManager) IMixinRenderManager(cc.hyperium.mixinsimp.client.renderer.entity.IMixinRenderManager) InvokeEvent(cc.hyperium.event.InvokeEvent)

Example 33 with RenderManager

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

the class TileEntityPresentRenderer method renderNameTag.

private void renderNameTag(String owner, boolean isOwner, boolean lookingAt) {
    FontRenderer fontRen = Minecraft.getMinecraft().fontRenderer;
    RenderManager renMan = RenderManager.instance;
    int boxColor = 0;
    int boxAlpha = (lookingAt ? 128 : 48);
    int textColor = ((isOwner ? 0xFFFF55 : 0xAAAAAA) + (lookingAt ? 0xFF000000 : 0x80000000));
    float f1 = 1 / 85.0f;
    GL11.glPushMatrix();
    GL11.glTranslatef(0.0F, 1.1F, 0.0F);
    GL11.glNormal3f(0.0F, 1.0F, 0.0F);
    GL11.glRotatef(-renMan.playerViewY, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(renMan.playerViewX, 1.0F, 0.0F, 0.0F);
    GL11.glScalef(-f1, -f1, f1);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDepthMask(false);
    GL11.glEnable(GL11.GL_BLEND);
    OpenGlHelper.glBlendFunc(770, 771, 1, 0);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();
    int j = fontRen.getStringWidth(owner) / 2;
    tessellator.setColorRGBA_I(boxColor, boxAlpha);
    tessellator.addVertex(-j - 2, -1, 0.0D);
    tessellator.addVertex(-j - 2, 9, 0.0D);
    tessellator.addVertex(j + 2, 9, 0.0D);
    tessellator.addVertex(j + 2, -1, 0.0D);
    tessellator.draw();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDepthMask(true);
    fontRen.drawString(owner, -fontRen.getStringWidth(owner) / 2, 0, textColor);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glPopMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) FontRenderer(net.minecraft.client.gui.FontRenderer) RenderManager(net.minecraft.client.renderer.entity.RenderManager)

Example 34 with RenderManager

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

the class Pathfinding method renderDebugText.

@SideOnly(Side.CLIENT)
private static void renderDebugText(@NotNull final Node n) {
    final String s1 = String.format("F: %.3f [%d]", n.getCost(), n.getCounterAdded());
    final String s2 = String.format("G: %.3f [%d]", n.getScore(), n.getCounterVisited());
    final FontRenderer fontrenderer = Minecraft.getMinecraft().fontRenderer;
    GlStateManager.pushAttrib();
    GlStateManager.pushMatrix();
    GlStateManager.translate(0.0F, 0.75F, 0.0F);
    GlStateManager.glNormal3f(0.0F, 1.0F, 0.0F);
    final RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
    GlStateManager.rotate(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
    GlStateManager.scale(-0.014F, -0.014F, 0.014F);
    GlStateManager.translate(0.0F, 18F, 0.0F);
    GlStateManager.depthMask(false);
    GlStateManager.disableDepth();
    GlStateManager.enableBlend();
    GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
    GlStateManager.disableTexture2D();
    final int i = Math.max(fontrenderer.getStringWidth(s1), fontrenderer.getStringWidth(s2)) / 2;
    final Tessellator tessellator = Tessellator.getInstance();
    final BufferBuilder vertexBuffer = tessellator.getBuffer();
    vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
    vertexBuffer.pos((double) (-i - 1), -5.0D, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
    vertexBuffer.pos((double) (-i - 1), 12.0D, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
    vertexBuffer.pos((double) (i + 1), 12.0D, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
    vertexBuffer.pos((double) (i + 1), -5.0D, 0.0D).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
    tessellator.draw();
    GlStateManager.enableTexture2D();
    GlStateManager.translate(0.0F, -5F, 0.0F);
    fontrenderer.drawString(s1, -fontrenderer.getStringWidth(s1) / 2, 0, 0xFFFFFFFF);
    GlStateManager.translate(0.0F, 8F, 0.0F);
    fontrenderer.drawString(s2, -fontrenderer.getStringWidth(s2) / 2, 0, 0xFFFFFFFF);
    GlStateManager.enableDepth();
    GlStateManager.depthMask(true);
    GlStateManager.translate(0.0F, -8F, 0.0F);
    fontrenderer.drawString(s1, -fontrenderer.getStringWidth(s1) / 2, 0, 0xFFFFFFFF);
    GlStateManager.translate(0.0F, 8F, 0.0F);
    fontrenderer.drawString(s2, -fontrenderer.getStringWidth(s2) / 2, 0, 0xFFFFFFFF);
    GlStateManager.popMatrix();
    GlStateManager.popAttrib();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) FontRenderer(net.minecraft.client.gui.FontRenderer) RenderManager(net.minecraft.client.renderer.entity.RenderManager) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 35 with RenderManager

use of net.minecraft.client.renderer.entity.RenderManager in project pnc-repressurized by TeamPneumatic.

the class RenderPressureChamber method render.

@Override
public void render(TileEntityPressureChamberValve te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    List<ItemStack> stacks = new ItemStackHandlerIterable(te.getStacksInChamber()).stream().filter(stack -> !stack.isEmpty()).collect(Collectors.toList());
    if (!stacks.isEmpty()) {
        x += te.multiBlockX - te.getPos().getX() + te.multiBlockSize / 2D;
        // Set to '+ 1' for normal y value.
        y += te.multiBlockY - te.getPos().getY() + 1.1;
        z += te.multiBlockZ - te.getPos().getZ() + te.multiBlockSize / 2D;
        GlStateManager.pushMatrix();
        GlStateManager.translate(x, y, z);
        RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
        boolean fancySetting = renderManager.options.fancyGraphics;
        renderManager.options.fancyGraphics = true;
        // render single item centered (looks best), multiple items arranged in a circle
        // around the centre of the chamber, radius dependent on chamber size
        float circleRadius = stacks.size() == 1 ? 0 : 0.33f * (te.multiBlockSize - 2);
        float degreesPerStack = 360f / stacks.size();
        // some gentle rotation and bobbing looks good here
        double ticks = ClientTickHandler.TICKS + partialTicks;
        float yBob = MathHelper.sin(((float) ticks / 10) % 360) * 0.01f;
        float yRot = (float) (ticks / 2) % 360;
        for (int i = 0; i < stacks.size(); i++) {
            GlStateManager.pushMatrix();
            GlStateManager.rotate(i * degreesPerStack, 0, 1, 0);
            GlStateManager.translate(circleRadius, yBob, 0);
            GlStateManager.rotate(yRot, 0, 1, 0);
            Minecraft.getMinecraft().getRenderItem().renderItem(stacks.get(i), ItemCameraTransforms.TransformType.GROUND);
            GlStateManager.popMatrix();
        }
        renderManager.options.fancyGraphics = fancySetting;
        GlStateManager.popMatrix();
    }
}
Also used : ClientTickHandler(me.desht.pneumaticcraft.client.ClientTickHandler) RenderManager(net.minecraft.client.renderer.entity.RenderManager) ItemStack(net.minecraft.item.ItemStack) TileEntityPressureChamberValve(me.desht.pneumaticcraft.common.tileentity.TileEntityPressureChamberValve) List(java.util.List) ItemStackHandlerIterable(me.desht.pneumaticcraft.common.util.ItemStackHandlerIterable) Minecraft(net.minecraft.client.Minecraft) MathHelper(net.minecraft.util.math.MathHelper) GlStateManager(net.minecraft.client.renderer.GlStateManager) TileEntitySpecialRenderer(net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer) ItemCameraTransforms(net.minecraft.client.renderer.block.model.ItemCameraTransforms) Collectors(java.util.stream.Collectors) ItemStackHandlerIterable(me.desht.pneumaticcraft.common.util.ItemStackHandlerIterable) ItemStack(net.minecraft.item.ItemStack) RenderManager(net.minecraft.client.renderer.entity.RenderManager)

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