/*
* This file is part of FalsePatternLib.
*
* Copyright (C) 2022-2025 FalsePattern
* All Rights Reserved
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* FalsePatternLib is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, only version 3 of the License.
*
* FalsePatternLib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with FalsePatternLib. If not, see
* This is useful for rendering things that are not part of the world mesh, but should be rendered as if they were. *
* It's good practice to make this call inside a {@link GL11#glPushMatrix() push}/{@link GL11#glPopMatrix() pop} matrix block. */ @StableAPI.Expose(since = "0.12.0") public static void setGLTranslationRelativeToPlayer() { val player = getMinecraft().thePlayer; val partialTick = partialTick(); val offsetX = (float) (player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTick); val offsetY = (float) (player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTick); val offsetZ = (float) (player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTick); GL11.glTranslatef(-offsetX, -offsetY, -offsetZ); } /** * Provides a texture icon with the given name and dimensions. *
* This is useful for rendering textures that are not part of the Minecraft texture atlas. * * @param iconName The icon name * @param width The icon width in pixels * @param height The icon height in pixels * * @return The full resolution texture icon. */ @StableAPI.Expose(since = "0.10.0") public static IIcon getFullTextureIcon(String iconName, int width, int height) { return new FullTextureIcon(iconName, width, height); } /** * Wraps the given icon as a clamped icon. *
* A clamped icon will clamp the coordinates given to {@link IIcon#getInterpolatedU(double)} and {@link IIcon#getInterpolatedV(double)} to the range of 0 to 16. *
* This is helpful when using {@link RenderBlocks} but having different bounds. * * @param icon The icon to clamp */ @StableAPI.Expose(since = "0.12.0") public static IIcon wrapAsClampedIcon(IIcon icon) { return new ClampedIcon(icon); } /** * Binds an empty texture. *
* When rendering without shaders, using {@link GL11#glDisable(int)} with {@link GL11#GL_TEXTURE_2D} * is sufficient to achieve the same effect. *
* However, when shaders are enabled, disabling textures using this method will have no effect. Therefore this method can be used as a workaround. */ @StableAPI.Expose(since = "1.3.0") public static void bindEmptyTexture() { getMinecraft().renderEngine.bindTexture(EMPTY_TEXTURE); } /** * Provides the partial tick between the last and next client tick, in the range of 0 to 1. *
* Sometimes referred to as 'subTick', it is used mostly for interpolation in rendering. * * @return The current partial tick */ @StableAPI.Expose public static float partialTick() { return MINECRAFT_TIMER.renderPartialTicks; } @StableAPI.Expose @SneakyThrows private static Timer getMinecraftTimer() { val timerField = ReflectionHelper.findField(Minecraft.class, "timer", "field_71428_T"); timerField.setAccessible(true); return (Timer) timerField.get(getMinecraft()); } }