Java Code Examples for net.minecraft.client.Minecraft#getRenderManager()

The following examples show how to use net.minecraft.client.Minecraft#getRenderManager() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProxyClient.java    From WearableBackpacks with MIT License 6 votes vote down vote up
@Override
public void init() {
	super.init();
	Minecraft mc = Minecraft.getMinecraft();
	
	if (BackpacksContent.BACKPACK != null) {
		mc.getBlockColors().registerBlockColorHandler(BLOCK_COLOR, MiscUtils.getBlockFromItem(BackpacksContent.BACKPACK));
		mc.getItemColors().registerItemColorHandler(ITEM_COLOR, BackpacksContent.BACKPACK);
		ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBackpack.class, new RendererBackpack.TileEntity());
	}
	
	RenderManager manager = mc.getRenderManager();
	Map<String, RenderPlayer> skinMap = manager.getSkinMap();
	for (RenderPlayer renderer : skinMap.values()) {
		renderer.addLayer(new RendererBackpack.Layer(renderer));
	}
}
 
Example 2
Source File: CrystalAuraModule.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
@Listener
public void onRender(EventRender3D event) {
    if (!this.render.getValue())
        return;

    final Minecraft mc = Minecraft.getMinecraft();

    for (PlaceLocation placeLocation : this.placeLocations) {
        if (placeLocation.alpha <= 0) {
            this.placeLocations.remove(placeLocation);
            continue;
        }

        placeLocation.update();

        if (placeLocation.placed) {
            final AxisAlignedBB bb = new AxisAlignedBB(
                    placeLocation.getX() - mc.getRenderManager().viewerPosX,
                    placeLocation.getY() - mc.getRenderManager().viewerPosY,
                    placeLocation.getZ() - mc.getRenderManager().viewerPosZ,
                    placeLocation.getX() + 1 - mc.getRenderManager().viewerPosX,
                    placeLocation.getY() + 1 - mc.getRenderManager().viewerPosY,
                    placeLocation.getZ() + 1 - mc.getRenderManager().viewerPosZ);

            RenderUtil.drawFilledBox(bb, ColorUtil.changeAlpha(0xAA9900EE, placeLocation.alpha / 2));
            RenderUtil.drawBoundingBox(bb, 1, ColorUtil.changeAlpha(0xAAAAAAAA, placeLocation.alpha));

            if (this.renderDamage.getValue()) {
                GlStateManager.pushMatrix();
                RenderUtil.glBillboardDistanceScaled((float) placeLocation.getX() + 0.5f, (float) placeLocation.getY() + 0.5f, (float) placeLocation.getZ() + 0.5f, mc.player, 1);
                final float damage = placeLocation.damage;
                final String damageText = (Math.floor(damage) == damage ? (int) damage : String.format("%.1f", damage)) + "";
                GlStateManager.disableDepth();
                GlStateManager.translate(-(mc.fontRenderer.getStringWidth(damageText) / 2.0d), 0, 0);
                mc.fontRenderer.drawStringWithShadow(damageText, 0, 0, 0xFFAAAAAA);
                GlStateManager.popMatrix();
            }
        }
    }
}
 
Example 3
Source File: RenderGlobalSchematic.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
public RenderGlobalSchematic(Minecraft mc)
{
    super(mc);

    this.mc = mc;
    this.renderManager = mc.getRenderManager();

    this.vboEnabled = OpenGlHelper.useVbo();

    if (this.vboEnabled)
    {
        this.renderContainer = new VboRenderListSchematic();
        this.renderChunkFactory = new RenderChunkFactoryVbo();
    }
    else
    {
        this.renderContainer = new RenderListSchematic();
        this.renderChunkFactory = new RenderChunkFactoryList();
    }

    BlockRendererDispatcher dispatcher = mc.getBlockRendererDispatcher();
    this.blockModelShapes = dispatcher.getBlockModelShapes();
    this.blockModelRenderer = new BlockModelRendererSchematic(mc.getBlockColors());
    this.fluidRenderer = ((IMixinBlockRendererDispatcher) dispatcher).getFluidRenderer();

    DataManager.getSchematicPlacementManager().addRebuildListener(this);
}
 
Example 4
Source File: RenderUtils.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Deprecated
private static void loadItemRenderer() {
    if (!hasInitRenderItem) {
        Minecraft minecraft = Minecraft.getInstance();
        uniformRenderItem = new net.minecraft.client.renderer.entity.ItemRenderer(minecraft.getRenderManager(), minecraft.getItemRenderer());
        hasInitRenderItem = true;
    }
}
 
Example 5
Source File: ProjectilesModule.java    From seppuku with GNU General Public License v3.0 4 votes vote down vote up
@Listener
public void onRender(EventRender3D event) {
    final Minecraft mc = Minecraft.getMinecraft();

    ThrowableType throwingType = this.getTypeFromCurrentItem(mc.player);

    if (throwingType == ThrowableType.NONE) {
        return;
    }

    FlightPath flightPath = new FlightPath(mc.player, throwingType);

    while (!flightPath.isCollided()) {
        flightPath.onUpdate();

        flightPoint.offer(new Vec3d(flightPath.position.x - mc.getRenderManager().viewerPosX,
                flightPath.position.y - mc.getRenderManager().viewerPosY,
                flightPath.position.z - mc.getRenderManager().viewerPosZ));
    }

    final boolean bobbing = mc.gameSettings.viewBobbing;
    mc.gameSettings.viewBobbing = false;
    mc.entityRenderer.setupCameraTransform(event.getPartialTicks(), 0);
    GlStateManager.pushMatrix();
    GlStateManager.disableTexture2D();
    GlStateManager.enableBlend();
    GlStateManager.disableAlpha();
    GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
    GlStateManager.shadeModel(GL_SMOOTH);
    glLineWidth(width.getValue());
    glEnable(GL_LINE_SMOOTH);
    glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
    GlStateManager.disableDepth();
    glEnable(GL32.GL_DEPTH_CLAMP);
    final Tessellator tessellator = Tessellator.getInstance();
    final BufferBuilder bufferbuilder = tessellator.getBuffer();

    while (!flightPoint.isEmpty()) {
        bufferbuilder.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_COLOR);
        Vec3d head = flightPoint.poll();
        bufferbuilder.pos(head.x, head.y, head.z).color(red.getValue() / 255.0f, green.getValue() / 255.0f, blue.getValue() / 255.0f, alpha.getValue() / 255.0f).endVertex();

        if (flightPoint.peek() != null) {
            Vec3d point = flightPoint.peek();
            bufferbuilder.pos(point.x, point.y, point.z).color(red.getValue() / 255.0f, green.getValue() / 255.0f, blue.getValue() / 255.0f, alpha.getValue() / 255.0f).endVertex();
        }

        tessellator.draw();
    }

    GlStateManager.shadeModel(GL_FLAT);
    glDisable(GL_LINE_SMOOTH);
    GlStateManager.enableDepth();
    glDisable(GL32.GL_DEPTH_CLAMP);
    GlStateManager.disableBlend();
    GlStateManager.enableAlpha();
    GlStateManager.enableTexture2D();
    GlStateManager.popMatrix();

    mc.gameSettings.viewBobbing = bobbing;
    mc.entityRenderer.setupCameraTransform(event.getPartialTicks(), 0);

    if (flightPath.collided) {
        final RayTraceResult hit = flightPath.target;
        AxisAlignedBB bb = null;

        if (hit.typeOfHit == RayTraceResult.Type.BLOCK) {
            final BlockPos blockpos = hit.getBlockPos();
            final IBlockState iblockstate = mc.world.getBlockState(blockpos);

            if (iblockstate.getMaterial() != Material.AIR && mc.world.getWorldBorder().contains(blockpos)) {
                final Vec3d interp = MathUtil.interpolateEntity(mc.player, mc.getRenderPartialTicks());
                bb = iblockstate.getSelectedBoundingBox(mc.world, blockpos).grow(0.0020000000949949026D).offset(-interp.x, -interp.y, -interp.z);
            }
        } else if (hit.typeOfHit == RayTraceResult.Type.ENTITY && hit.entityHit != null) {
            final AxisAlignedBB entityBB = hit.entityHit.getEntityBoundingBox();
            if (entityBB != null) {
                bb = new AxisAlignedBB(entityBB.minX - mc.getRenderManager().viewerPosX, entityBB.minY - mc.getRenderManager().viewerPosY, entityBB.minZ - mc.getRenderManager().viewerPosZ, entityBB.maxX - mc.getRenderManager().viewerPosX, entityBB.maxY - mc.getRenderManager().viewerPosY, entityBB.maxZ - mc.getRenderManager().viewerPosZ);
            }
        }

        if (bb != null) {
            RenderUtil.drawBoundingBox(bb, width.getValue(), red.getValue() / 255.0f, green.getValue() / 255.0f, blue.getValue() / 255.0f, alpha.getValue() / 255.0f);
        }
    }
}
 
Example 6
Source File: HolesModule.java    From seppuku with GNU General Public License v3.0 4 votes vote down vote up
@Listener
public void onRender(EventRender3D event) {
    final Minecraft mc = Minecraft.getMinecraft();

    for (Hole hole : this.holes) {
        final AxisAlignedBB bb = new AxisAlignedBB(
                hole.getX() - mc.getRenderManager().viewerPosX,
                hole.getY() - mc.getRenderManager().viewerPosY,
                hole.getZ() - mc.getRenderManager().viewerPosZ,
                hole.getX() + 1 - mc.getRenderManager().viewerPosX,
                hole.getY() + (hole.isTall() ? 2 : 1) - mc.getRenderManager().viewerPosY,
                hole.getZ() + 1 - mc.getRenderManager().viewerPosZ);

        camera.setPosition(mc.getRenderViewEntity().posX, mc.getRenderViewEntity().posY, mc.getRenderViewEntity().posZ);

        if (camera.isBoundingBoxInFrustum(new AxisAlignedBB(bb.minX + mc.getRenderManager().viewerPosX,
                bb.minY + mc.getRenderManager().viewerPosY,
                bb.minZ + mc.getRenderManager().viewerPosZ,
                bb.maxX + mc.getRenderManager().viewerPosX,
                bb.maxY + mc.getRenderManager().viewerPosY,
                bb.maxZ + mc.getRenderManager().viewerPosZ))) {
            GlStateManager.pushMatrix();
            GlStateManager.enableBlend();
            GlStateManager.disableDepth();
            GlStateManager.tryBlendFuncSeparate(770, 771, 0, 1);
            GlStateManager.disableTexture2D();
            GlStateManager.depthMask(false);
            glEnable(GL_LINE_SMOOTH);
            glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
            glLineWidth(1.5f);

            final double dist = mc.player.getDistance(hole.getX() + 0.5f, hole.getY() + 0.5f, hole.getZ() + 0.5f) * 0.75f;

            float alpha = MathUtil.clamp((float) (dist * 255.0f / (this.radius.getValue()) / 255.0f), 0.0f, 0.3f);

            RenderGlobal.renderFilledBox(bb, 0, 1, 0, this.fade.getValue() ? alpha : 0.25f);
            RenderGlobal.drawBoundingBox(bb.minX, bb.minY, bb.minZ, bb.maxX, bb.maxY, bb.maxZ, 0, 1, 0, this.fade.getValue() ? alpha : 0.25f);
            glDisable(GL_LINE_SMOOTH);
            GlStateManager.depthMask(true);
            GlStateManager.enableDepth();
            GlStateManager.enableTexture2D();
            GlStateManager.disableBlend();
            GlStateManager.popMatrix();
        }
    }
}
 
Example 7
Source File: StorageESPModule.java    From seppuku with GNU General Public License v3.0 4 votes vote down vote up
private AxisAlignedBB boundingBoxForEnt(TileEntity te) {
    final Minecraft mc = Minecraft.getMinecraft();

    if (te != null) {
        if (te instanceof TileEntityChest) {
            TileEntityChest chest = (TileEntityChest) te;
            if (chest.adjacentChestXNeg != null) {
                return new AxisAlignedBB(
                        te.getPos().getX() + 0.0625d - 1 - mc.getRenderManager().viewerPosX,
                        te.getPos().getY() - mc.getRenderManager().viewerPosY,
                        te.getPos().getZ() + 0.0625d - mc.getRenderManager().viewerPosZ,

                        te.getPos().getX() + 0.9375d - mc.getRenderManager().viewerPosX,
                        te.getPos().getY() + 0.875d - mc.getRenderManager().viewerPosY,
                        te.getPos().getZ() + 0.9375d - mc.getRenderManager().viewerPosZ);
            } else if (chest.adjacentChestZPos != null) {
                return new AxisAlignedBB(
                        te.getPos().getX() + 0.0625d - mc.getRenderManager().viewerPosX,
                        te.getPos().getY() - mc.getRenderManager().viewerPosY,
                        te.getPos().getZ() + 0.0625d - mc.getRenderManager().viewerPosZ,

                        te.getPos().getX() + 0.9375d - mc.getRenderManager().viewerPosX,
                        te.getPos().getY() + 0.875d - mc.getRenderManager().viewerPosY,
                        te.getPos().getZ() + 0.9375d + 1 - mc.getRenderManager().viewerPosZ);
            } else if (chest.adjacentChestXPos == null && chest.adjacentChestZPos == null && chest.adjacentChestZNeg == null && chest.adjacentChestXNeg == null) {
                return new AxisAlignedBB(
                        te.getPos().getX() + 0.0625d - mc.getRenderManager().viewerPosX,
                        te.getPos().getY() - mc.getRenderManager().viewerPosY,
                        te.getPos().getZ() + 0.0625d - mc.getRenderManager().viewerPosZ,

                        te.getPos().getX() + 0.9375d - mc.getRenderManager().viewerPosX,
                        te.getPos().getY() + 0.875d - mc.getRenderManager().viewerPosY,
                        te.getPos().getZ() + 0.9375d - mc.getRenderManager().viewerPosZ);
            }
        } else if (te instanceof TileEntityEnderChest) {
            return new AxisAlignedBB(
                    te.getPos().getX() + 0.0625d - mc.getRenderManager().viewerPosX,
                    te.getPos().getY() - mc.getRenderManager().viewerPosY,
                    te.getPos().getZ() + 0.0625d - mc.getRenderManager().viewerPosZ,

                    te.getPos().getX() + 0.9375d - mc.getRenderManager().viewerPosX,
                    te.getPos().getY() + 0.875d - mc.getRenderManager().viewerPosY,
                    te.getPos().getZ() + 0.9375d - mc.getRenderManager().viewerPosZ);
        } else {
            return new AxisAlignedBB(
                    te.getPos().getX() - mc.getRenderManager().viewerPosX,
                    te.getPos().getY() - mc.getRenderManager().viewerPosY,
                    te.getPos().getZ() - mc.getRenderManager().viewerPosZ,

                    te.getPos().getX() + 1 - mc.getRenderManager().viewerPosX,
                    te.getPos().getY() + 1 - mc.getRenderManager().viewerPosY,
                    te.getPos().getZ() + 1 - mc.getRenderManager().viewerPosZ);
        }
    }

    return null;
}