From 8db4bb1bb997732b6b70c6369b7e6e07018aa98e Mon Sep 17 00:00:00 2001 From: zywl Date: Sun, 24 Dec 2023 15:48:30 +0000 Subject: [PATCH] AddAll Command Remove ViaVersionFix module Refactor ClientSpoof Remove UUID Spoofer (useless) Fixed Some Things --- .../net/ccbluex/liquidbounce/FDPClient.kt | 6 +- .../liquidbounce/config/FileManager.kt | 2 +- .../liquidbounce/config/core/ConfigManager.kt | 9 +- .../net/ccbluex/liquidbounce/event/Event.kt | 1 - .../liquidbounce/event/EventManager.kt | 7 +- .../command/commands/AddAllCommand.java | 55 + .../command/commands/AutoDisableCommand.kt | 11 + .../features/command/commands/BindCommand.kt | 5 + .../features/command/commands/BindsCommand.kt | 6 + .../command/commands/ConfigCommand.kt | 14 +- .../command/commands/FriendCommand.kt | 5 + .../features/command/commands/HelpCommand.kt | 5 + .../features/command/commands/HideCommand.kt | 5 + .../features/command/commands/MacroCommand.kt | 5 + .../command/commands/ModuleTriggerCommand.kt | 5 + .../features/command/commands/SayCommand.kt | 2 - .../features/command/commands/ThemeCommand.kt | 3 +- .../features/command/commands/TpCommand.kt | 5 + .../features/command/commands/UUIDCommand.kt | 48 - .../liquidbounce/features/module/Module.kt | 20 +- .../module/modules/client/ChatControl.kt | 1 + .../module/modules/client/ClientSpoof.java | 50 + .../module/modules/client/ClientSpoof.kt | 37 - .../features/module/modules/client/HUD.kt | 9 +- .../module/modules/client/HotbarSettings.kt | 13 +- .../module/modules/exploit/ViaVersionFix.java | 22 - .../features/module/modules/player/Refill.kt | 4 +- .../features/module/modules/world/Timer.kt | 25 +- .../handler/network/BungeeCordSpoof.kt | 3 +- .../handler/network/ClientSpoof.java | 136 - .../handler/network/ClientSpoofHandler.java | 102 + .../liquidbounce/handler/other/UUIDSpoofer.kt | 16 - .../injection/forge/TransformerLoader.java | 49 +- .../forge/mixins/gui/MixinGuiNewChat.java | 2 +- .../forge/mixins/gui/MixinGuiScreen.java | 38 +- .../forge/mixins/item/MixinItemStack.java | 54 + .../mixins/network/MixinC00Handshake.java | 12 +- .../implementations/IMixinItemStack.java | 10 - .../transformers/ForgeNetworkTransformer.java | 84 - .../transformers/OptimizeTransformer.java | 74 - .../ViaForgeSupportTransformer.java | 50 - .../ui/clickgui/fonts/api/FontRenderer.java | 16 +- .../clickgui/style/styles/classic/Module.java | 2 +- .../style/styles/classic/Setting.java | 2 +- .../liquidbounce/ui/client/gui/GuiInfo.kt | 2 + .../ccbluex/liquidbounce/ui/font/Fonts.java | 7 + .../liquidbounce/ui/font/GameFontRenderer.kt | 242 +- .../liquidbounce/utils/render/ColorUtils.kt | 10 + .../liquidbounce/utils/render/RenderUtil.java | 1679 +++++ .../utils/render/RenderUtils.java | 8 + .../utils/render/VertexUtils.java | 20 + .../liquidbounce/utils/render/VisualBase.java | 1499 +++++ .../utils/render/VisualUtils.java | 5901 +++++++++++++++++ .../shader/shaders/BackgroundShader.java | 43 + src/main/resources/mixins.fdpclient.json | 1 + 55 files changed, 9686 insertions(+), 756 deletions(-) create mode 100644 src/main/java/net/ccbluex/liquidbounce/features/command/commands/AddAllCommand.java delete mode 100644 src/main/java/net/ccbluex/liquidbounce/features/command/commands/UUIDCommand.kt create mode 100644 src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/ClientSpoof.java delete mode 100644 src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/ClientSpoof.kt delete mode 100644 src/main/java/net/ccbluex/liquidbounce/features/module/modules/exploit/ViaVersionFix.java delete mode 100644 src/main/java/net/ccbluex/liquidbounce/handler/network/ClientSpoof.java create mode 100644 src/main/java/net/ccbluex/liquidbounce/handler/network/ClientSpoofHandler.java delete mode 100644 src/main/java/net/ccbluex/liquidbounce/handler/other/UUIDSpoofer.kt create mode 100644 src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/item/MixinItemStack.java delete mode 100644 src/main/java/net/ccbluex/liquidbounce/injection/implementations/IMixinItemStack.java delete mode 100644 src/main/java/net/ccbluex/liquidbounce/injection/transformers/ForgeNetworkTransformer.java delete mode 100644 src/main/java/net/ccbluex/liquidbounce/injection/transformers/OptimizeTransformer.java delete mode 100644 src/main/java/net/ccbluex/liquidbounce/injection/transformers/ViaForgeSupportTransformer.java create mode 100644 src/main/java/net/ccbluex/liquidbounce/utils/render/RenderUtil.java create mode 100644 src/main/java/net/ccbluex/liquidbounce/utils/render/VertexUtils.java create mode 100644 src/main/java/net/ccbluex/liquidbounce/utils/render/VisualBase.java create mode 100644 src/main/java/net/ccbluex/liquidbounce/utils/render/VisualUtils.java create mode 100644 src/main/java/net/ccbluex/liquidbounce/utils/render/shader/shaders/BackgroundShader.java diff --git a/src/main/java/net/ccbluex/liquidbounce/FDPClient.kt b/src/main/java/net/ccbluex/liquidbounce/FDPClient.kt index 9e78dfbf9c..15989f89e7 100644 --- a/src/main/java/net/ccbluex/liquidbounce/FDPClient.kt +++ b/src/main/java/net/ccbluex/liquidbounce/FDPClient.kt @@ -17,7 +17,7 @@ import net.ccbluex.liquidbounce.handler.combat.CombatManager import net.ccbluex.liquidbounce.handler.discord.DiscordRPC import net.ccbluex.liquidbounce.handler.network.BungeeCordSpoof import net.ccbluex.liquidbounce.handler.network.ClientFixes -import net.ccbluex.liquidbounce.handler.network.ClientSpoof +import net.ccbluex.liquidbounce.handler.network.ClientSpoofHandler import net.ccbluex.liquidbounce.ui.client.gui.EnumLaunchFilter import net.ccbluex.liquidbounce.ui.client.gui.LaunchFilterInfo import net.ccbluex.liquidbounce.ui.client.gui.LaunchOption @@ -76,7 +76,6 @@ object FDPClient { lateinit var combatManager: CombatManager lateinit var macroManager: MacroManager lateinit var configManager: ConfigManager - lateinit var clientSpoof: ClientSpoof // Some UI things lateinit var hud: HUD @@ -126,7 +125,6 @@ object FDPClient { keyBindManager = KeyBindManager() combatManager = CombatManager() tipSoundManager = TipSoundManager() - clientSpoof = ClientSpoof() // Load language LanguageManager.switchLanguage(Minecraft.getMinecraft().gameSettings.language) @@ -140,7 +138,7 @@ object FDPClient { eventManager.registerListener(LocationCache()) eventManager.registerListener(macroManager) eventManager.registerListener(combatManager) - eventManager.registerListener(ClientSpoof()) + eventManager.registerListener(ClientSpoofHandler()) // Load client fonts Fonts.loadFonts() diff --git a/src/main/java/net/ccbluex/liquidbounce/config/FileManager.kt b/src/main/java/net/ccbluex/liquidbounce/config/FileManager.kt index 26db44ceaa..5aa61f0c33 100644 --- a/src/main/java/net/ccbluex/liquidbounce/config/FileManager.kt +++ b/src/main/java/net/ccbluex/liquidbounce/config/FileManager.kt @@ -28,7 +28,7 @@ class FileManager : MinecraftInstance() { val capesDir = File(dir, "capes") val themesDir = File(dir, "themes") val accountsConfig = AccountsConfig(File(dir, "accounts.json")) - var friendsConfig = FriendsConfig(File(dir, "friends.json")) + val friendsConfig = FriendsConfig(File(dir, "friends.json")) val xrayConfig = XRayConfig(File(dir, "xray-blocks.json")) val hudConfig = HudConfig(File(dir, "hud.json")) val specialConfig = SpecialConfig(File(dir, "special.json")) diff --git a/src/main/java/net/ccbluex/liquidbounce/config/core/ConfigManager.kt b/src/main/java/net/ccbluex/liquidbounce/config/core/ConfigManager.kt index 51d9f90d9e..1281cdcbdf 100644 --- a/src/main/java/net/ccbluex/liquidbounce/config/core/ConfigManager.kt +++ b/src/main/java/net/ccbluex/liquidbounce/config/core/ConfigManager.kt @@ -53,7 +53,7 @@ class ConfigManager { val json = if (configFile.exists()) { JsonParser().parse(configFile.reader(Charsets.UTF_8)).asJsonObject } else { - JsonObject() // 这样方便一点,虽然效率会低 + JsonObject() } for (section in sections) { @@ -239,13 +239,6 @@ class ConfigManager { } } -// fun toLegacy(name: String){ -// if(!LiquidBounce.fileManager.legacySettingsDir.exists()) -// LiquidBounce.fileManager.legacySettingsDir.mkdir() -// -// val jsonObject=JsonParser().parse() -// } - /** * Register [section] */ diff --git a/src/main/java/net/ccbluex/liquidbounce/event/Event.kt b/src/main/java/net/ccbluex/liquidbounce/event/Event.kt index 9c9a896d69..fffd318f59 100644 --- a/src/main/java/net/ccbluex/liquidbounce/event/Event.kt +++ b/src/main/java/net/ccbluex/liquidbounce/event/Event.kt @@ -6,7 +6,6 @@ package net.ccbluex.liquidbounce.event open class Event - open class CancellableEvent : Event() { /** diff --git a/src/main/java/net/ccbluex/liquidbounce/event/EventManager.kt b/src/main/java/net/ccbluex/liquidbounce/event/EventManager.kt index 53b9136d12..7dbf616efd 100644 --- a/src/main/java/net/ccbluex/liquidbounce/event/EventManager.kt +++ b/src/main/java/net/ccbluex/liquidbounce/event/EventManager.kt @@ -11,9 +11,6 @@ class EventManager : MinecraftInstance() { private val registry = HashMap, MutableList>() -// private val counter = HashMap, Int>() -// private var lastSyncTime = System.currentTimeMillis() - /** * Register [listener] */ @@ -89,8 +86,8 @@ class EventManager : MinecraftInstance() { throwable.printStackTrace() } } - }catch (e :Exception){ - e.printStackTrace(); + } catch (e :Exception) { + e.printStackTrace() } } } diff --git a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/AddAllCommand.java b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/AddAllCommand.java new file mode 100644 index 0000000000..8550646efa --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/AddAllCommand.java @@ -0,0 +1,55 @@ +/* + * FDPClient Hacked Client + * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. + * https://github.com/SkidderMC/FDPClient/ + */ +package net.ccbluex.liquidbounce.features.command.commands; + +import net.ccbluex.liquidbounce.FDPClient; +import net.ccbluex.liquidbounce.config.impl.FriendsConfig; +import net.ccbluex.liquidbounce.features.command.Command; +import net.ccbluex.liquidbounce.utils.render.ColorUtils; +import net.minecraft.scoreboard.ScorePlayerTeam; +import net.minecraft.util.EnumChatFormatting; + +import org.jetbrains.annotations.NotNull; + +import java.util.concurrent.atomic.AtomicInteger; + +public final class AddAllCommand extends Command { + + public AddAllCommand() {super("addall", new String[]{""});} + + @Override + public void execute(@NotNull String[] arguments) { + if (arguments.length == 2) { + final String tag = ColorUtils.translateAlternateColorCodes(arguments[1]); + final AtomicInteger count = new AtomicInteger(0); + final FriendsConfig config = FDPClient.fileManager.getFriendsConfig(); + final boolean presistent = arguments[0].contains(""); + + mc.thePlayer.sendQueue.getPlayerInfoMap() + .forEach(player -> { + final ScorePlayerTeam team = player.getPlayerTeam(); + + assert team != null; + + if (team != null) { + if (ColorUtils.stripColor(team.getColorPrefix()).contains(tag) + || ColorUtils.stripColor(team.getColorSuffix()).contains(tag)) { + final String name = player.getGameProfile().getName(); + + config.addFriend(name, String.valueOf(presistent)); + + count.incrementAndGet(); + } + } + }); + + alert("Were added " + EnumChatFormatting.WHITE + count.get() + EnumChatFormatting.GRAY + "§7 players."); + + } else { + alert(EnumChatFormatting.GRAY + "Sintax: .addall "); + } + } +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/AutoDisableCommand.kt b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/AutoDisableCommand.kt index 5a07fba941..467f237a4a 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/AutoDisableCommand.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/AutoDisableCommand.kt @@ -1,3 +1,8 @@ +/* + * FDPClient Hacked Client + * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. + * https://github.com/SkidderMC/FDPClient/ + */ package net.ccbluex.liquidbounce.features.command.commands import net.ccbluex.liquidbounce.FDPClient @@ -5,6 +10,12 @@ import net.ccbluex.liquidbounce.features.command.Command import net.ccbluex.liquidbounce.features.module.EnumAutoDisableType import net.ccbluex.liquidbounce.utils.misc.StringUtils +/** + * AutoDisable Command + * + * Allows you to manage the list of modules that are automatically disabled. + * It provides subcommands to add, remove, list and clear modules from the auto-disable list. + */ class AutoDisableCommand : Command("autodisable", arrayOf("ad")) { private val modes = EnumAutoDisableType.values().map { it.name.lowercase() }.toTypedArray() diff --git a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/BindCommand.kt b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/BindCommand.kt index 408993127d..a9f0a32b7d 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/BindCommand.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/BindCommand.kt @@ -11,6 +11,11 @@ import net.ccbluex.liquidbounce.ui.client.hud.element.elements.Notification import net.ccbluex.liquidbounce.ui.client.hud.element.elements.NotifyType import org.lwjgl.input.Keyboard +/** + * Bind Command + * + * Allows you to bind a key to a module, which means that the module will be activated when the key is pressed. + */ class BindCommand : Command("bind", emptyArray()) { /** * Execute commands with provided [args] diff --git a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/BindsCommand.kt b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/BindsCommand.kt index 81356f8f95..b902d0ecfa 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/BindsCommand.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/BindsCommand.kt @@ -10,6 +10,12 @@ import net.ccbluex.liquidbounce.features.command.Command import net.ccbluex.liquidbounce.utils.ClientUtils import org.lwjgl.input.Keyboard +/** + * Binds Command + * + * Allows you to manage the bindings of modules to keys. + * It provides subcommands to add, remove, list and clear bindings. + */ class BindsCommand : Command("binds", emptyArray()) { /** * Execute commands with provided [args] diff --git a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/ConfigCommand.kt b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/ConfigCommand.kt index 19010eeca0..f79a26215d 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/ConfigCommand.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/ConfigCommand.kt @@ -1,3 +1,8 @@ +/* + * FDPClient Hacked Client + * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. + * https://github.com/SkidderMC/FDPClient/ + */ package net.ccbluex.liquidbounce.features.command.commands import net.ccbluex.liquidbounce.FDPClient @@ -6,6 +11,13 @@ import java.awt.Desktop import java.io.File import java.nio.file.Files +/** + * Config Command + * + * Provides various subcommands related to the configuration, + * such as loading configuration from an external source or an API + * and listing available configurations. + */ class ConfigCommand : Command("config", arrayOf("cfg")) { override fun execute(args: Array) { if (args.size > 1) { @@ -80,7 +92,7 @@ class ConfigCommand : Command("config", arrayOf("cfg")) { } "save" -> { - FDPClient.configManager.save(true, true) + FDPClient.configManager.save(true, forceSave = true) alert("Saved config ${FDPClient.configManager.nowConfig}") } diff --git a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/FriendCommand.kt b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/FriendCommand.kt index b2d0aa7a65..fc1d8d332d 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/FriendCommand.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/FriendCommand.kt @@ -11,6 +11,11 @@ import net.ccbluex.liquidbounce.features.module.modules.other.AntiBot import net.ccbluex.liquidbounce.utils.misc.StringUtils import net.ccbluex.liquidbounce.utils.render.ColorUtils +/** + * Friend Command + * + * Provides subcommands related to managing friends, such as adding, removing, aliasing, listing, and clearing friends. + */ class FriendCommand : Command("friend", arrayOf("friends")) { /** * Execute commands with provided [args] diff --git a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/HelpCommand.kt b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/HelpCommand.kt index b2db8a4992..c6252ef58d 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/HelpCommand.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/HelpCommand.kt @@ -10,6 +10,11 @@ import net.ccbluex.liquidbounce.FDPClient import net.ccbluex.liquidbounce.features.command.Command import net.ccbluex.liquidbounce.utils.ClientUtils +/** + * Help Command + * + * Provides a help page for displaying other commands. + */ class HelpCommand : Command("help", emptyArray()) { /** * Execute commands with provided [args] diff --git a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/HideCommand.kt b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/HideCommand.kt index 49bcf60634..9782d8dad4 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/HideCommand.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/HideCommand.kt @@ -10,6 +10,11 @@ import net.ccbluex.liquidbounce.features.command.Command import net.ccbluex.liquidbounce.features.module.ModuleInfo import net.ccbluex.liquidbounce.utils.ClientUtils +/** + * Hide Command + * + * Allows you to hide specific modules. + */ class HideCommand : Command("hide", emptyArray()) { /** diff --git a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/MacroCommand.kt b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/MacroCommand.kt index 3d1129ff7f..9afde3a799 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/MacroCommand.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/MacroCommand.kt @@ -1,3 +1,8 @@ +/* + * FDPClient Hacked Client + * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. + * https://github.com/SkidderMC/FDPClient/ + */ package net.ccbluex.liquidbounce.features.command.commands import net.ccbluex.liquidbounce.FDPClient diff --git a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/ModuleTriggerCommand.kt b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/ModuleTriggerCommand.kt index 362907ea8b..573f66dfcd 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/ModuleTriggerCommand.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/ModuleTriggerCommand.kt @@ -1,3 +1,8 @@ +/* + * FDPClient Hacked Client + * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. + * https://github.com/SkidderMC/FDPClient/ + */ package net.ccbluex.liquidbounce.features.command.commands import net.ccbluex.liquidbounce.FDPClient diff --git a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/SayCommand.kt b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/SayCommand.kt index 31b9ccbd49..a1efb477cb 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/SayCommand.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/SayCommand.kt @@ -6,9 +6,7 @@ package net.ccbluex.liquidbounce.features.command.commands import net.ccbluex.liquidbounce.features.command.Command -import net.ccbluex.liquidbounce.utils.PacketUtils import net.ccbluex.liquidbounce.utils.misc.StringUtils -import net.minecraft.network.play.client.C01PacketChatMessage class SayCommand : Command("say", emptyArray()) { /** diff --git a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/ThemeCommand.kt b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/ThemeCommand.kt index cd3333b4f4..2c779763cc 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/ThemeCommand.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/ThemeCommand.kt @@ -3,13 +3,12 @@ * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. * https://github.com/SkidderMC/FDPClient/ */ - package net.ccbluex.liquidbounce.features.command.commands import net.ccbluex.liquidbounce.FDPClient import net.ccbluex.liquidbounce.features.command.Command -import net.ccbluex.liquidbounce.ui.client.hud.element.elements.Notification import net.ccbluex.liquidbounce.ui.client.hud.Config +import net.ccbluex.liquidbounce.ui.client.hud.element.elements.Notification import net.ccbluex.liquidbounce.ui.client.hud.element.elements.NotifyType import java.io.File import java.io.IOException diff --git a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/TpCommand.kt b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/TpCommand.kt index 1e95d459ca..e58fdb3688 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/TpCommand.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/TpCommand.kt @@ -1,3 +1,8 @@ +/* + * FDPClient Hacked Client + * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. + * https://github.com/SkidderMC/FDPClient/ + */ package net.ccbluex.liquidbounce.features.command.commands import net.ccbluex.liquidbounce.features.command.Command diff --git a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/UUIDCommand.kt b/src/main/java/net/ccbluex/liquidbounce/features/command/commands/UUIDCommand.kt deleted file mode 100644 index 018b53bbbd..0000000000 --- a/src/main/java/net/ccbluex/liquidbounce/features/command/commands/UUIDCommand.kt +++ /dev/null @@ -1,48 +0,0 @@ -/* - * FDPClient Hacked Client - * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. - * https://github.com/SkidderMC/FDPClient/ - */ -package net.ccbluex.liquidbounce.features.command.commands - -import net.ccbluex.liquidbounce.features.command.Command -import net.ccbluex.liquidbounce.features.module.modules.other.AntiBot -import net.ccbluex.liquidbounce.handler.other.UUIDSpoofer - -class UUIDCommand : Command("uuid", emptyArray()) { - - /** - * Execute commands with provided [args] - */ - override fun execute(args: Array) { - if (args.size == 2) { - val theName = args[1] - - if (theName.equals("reset", true)) { - UUIDSpoofer.spoofId = null - chat("§aSuccessfully resetted your UUID.") - return - } - - // Get target player data - val targetPlayer = mc.theWorld.playerEntities - .filter { !AntiBot.isBot(it) && it.name.equals(theName, true) } - .firstOrNull() - - if (targetPlayer == null) - UUIDSpoofer.spoofId = theName - else - UUIDSpoofer.spoofId = targetPlayer.gameProfile.id.toString() - chat("§aSuccessfully changed your UUID to §6${UUIDSpoofer.spoofId!!}§a. Make sure to turn on BungeeCordSpoof in server selection.") - return - } - - if (args.size == 1) { - chat("§6Session's UUID is §7${mc.session.playerID}§6.") - chat("§6Player's UUID is §7${mc.thePlayer.uniqueID}§6.") - } - - chatSyntax("uuid ") - } - -} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/Module.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/Module.kt index 16e707e7ea..e03eb0b088 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/Module.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/Module.kt @@ -22,13 +22,11 @@ import net.ccbluex.liquidbounce.utils.render.EaseUtils import net.ccbluex.liquidbounce.utils.render.Translate import net.ccbluex.liquidbounce.value.Value import org.lwjgl.input.Keyboard -import java.util.ArrayList open class Module : MinecraftInstance(), Listenable { // Module information val translate = Translate(0F,0F) val tab = Translate(0f , 0f) - var expanded: Boolean = false val animation: AnimationHelper var name: String private var suffix: String? = null @@ -147,8 +145,15 @@ open class Module : MinecraftInstance(), Listenable { } set(value) { if (slideAnimation == null || (slideAnimation != null && slideAnimation!!.to != value.toDouble())) { - slideAnimation = Animation(EaseUtils.EnumEasingType.valueOf(HUD.arraylistXAxisAnimTypeValue.get()), EaseUtils.EnumEasingOrder.valueOf(HUD.arraylistXAxisAnimOrderValue.get()), field.toDouble(), value.toDouble(), HUD.arraylistXAxisAnimSpeedValue.get() * 30L).start() + slideAnimation = Animation( + EaseUtils.EnumEasingType.valueOf(HUD.arraylistXAxisAnimTypeValue.get()), + EaseUtils.EnumEasingOrder.valueOf(HUD.arraylistXAxisAnimOrderValue.get()), + field.toDouble(), + value.toDouble(), + HUD.arraylistXAxisAnimSpeedValue.get() * 30L + ).start() } + field = value } var yPosAnimation: Animation? = null open var yPos = 0f @@ -163,8 +168,15 @@ open class Module : MinecraftInstance(), Listenable { } set(value) { if (yPosAnimation == null || (yPosAnimation != null && yPosAnimation!!.to != value.toDouble())) { - yPosAnimation = Animation(EaseUtils.EnumEasingType.valueOf(HUD.arraylistYAxisAnimTypeValue.get()), EaseUtils.EnumEasingOrder.valueOf(HUD.arraylistYAxisAnimOrderValue.get()), field.toDouble(), value.toDouble(), HUD.arraylistYAxisAnimSpeedValue.get() * 30L).start() + yPosAnimation = Animation( + EaseUtils.EnumEasingType.valueOf(HUD.arraylistYAxisAnimTypeValue.get()), + EaseUtils.EnumEasingOrder.valueOf(HUD.arraylistYAxisAnimOrderValue.get()), + field.toDouble(), + value.toDouble(), + HUD.arraylistYAxisAnimSpeedValue.get() * 30L + ).start() } + field = value } // Tag diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/ChatControl.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/ChatControl.kt index 6edc7df62c..f113659b2c 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/ChatControl.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/ChatControl.kt @@ -12,6 +12,7 @@ import net.ccbluex.liquidbounce.value.BoolValue @ModuleInfo(name = "ChatControl", category = ModuleCategory.CLIENT, defaultOn = true) object ChatControl : Module() { + val chatLimitValue = BoolValue("NoChatLimit", true) val chatClearValue = BoolValue("NoChatClear", true) val chatCombineValue = BoolValue("ChatCombine", true) diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/ClientSpoof.java b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/ClientSpoof.java new file mode 100644 index 0000000000..98357e485d --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/ClientSpoof.java @@ -0,0 +1,50 @@ +/* + * ZAVZ Hacked Client + */ +package net.ccbluex.liquidbounce.features.module.modules.client; + +import net.ccbluex.liquidbounce.features.module.Module; +import net.ccbluex.liquidbounce.features.module.ModuleCategory; +import net.ccbluex.liquidbounce.features.module.ModuleInfo; +import net.ccbluex.liquidbounce.features.module.modules.client.button.*; +import net.ccbluex.liquidbounce.value.ListValue; +import net.ccbluex.liquidbounce.value.TextValue; +import net.minecraft.client.gui.GuiButton; + +@ModuleInfo(name = "Spoofer", category = ModuleCategory.CLIENT, defaultOn = true) +public class ClientSpoof extends Module { + + public final ListValue modeValue = new ListValue("Payloads", new String[]{"Vanilla", "Fabric", "Lunar", "LabyMod", "Custom", "CheatBreaker", "PvPLounge"}, "Lunar"); + public final TextValue CustomClient = new TextValue("CustomClientSpoof", "CustomClient"); + public final ListValue buttonValue = new ListValue("Button", new String[]{"Better", "RGBRounded", "Wolfram", "Rounded", "Hyperium", "RGB", "Badlion", "Flat", "FLine", "Rise", "Vanilla"}, "FLine"); + @Override + public String getTag() { + return modeValue.get(); + } + + public AbstractButtonRenderer getButtonRenderer(GuiButton button) { + String lowerCaseButtonValue = buttonValue.get().toLowerCase(); + switch (lowerCaseButtonValue) { + case "better": + return new BetterButtonRenderer(button); + case "rounded": + return new RoundedButtonRenderer(button); + case "fline": + return new FLineButtonRenderer(button); + case "rise": + return new RiseButtonRenderer(button); + case "hyperium": + return new HyperiumButtonRenderer(button); + case "rgb": + return new RGBButtonRenderer(button); + case "badlion": + return new BadlionTwoButtonRenderer(button); + case "rgbrounded": + return new RGBRoundedButtonRenderer(button); + case "wolfram": + return new WolframButtonRenderer(button); + default: + return null; // vanilla or unknown + } + } +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/ClientSpoof.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/ClientSpoof.kt deleted file mode 100644 index 8fa3116eeb..0000000000 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/ClientSpoof.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * FDPClient Hacked Client - * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. - * https://github.com/SkidderMC/FDPClient/ - */ -package net.ccbluex.liquidbounce.features.module.modules.client - -import net.ccbluex.liquidbounce.features.module.Module -import net.ccbluex.liquidbounce.features.module.ModuleCategory -import net.ccbluex.liquidbounce.features.module.ModuleInfo -import net.ccbluex.liquidbounce.features.module.modules.client.button.* -import net.ccbluex.liquidbounce.value.BoolValue -import net.ccbluex.liquidbounce.value.ListValue -import net.minecraft.client.gui.GuiButton - -@ModuleInfo(name = "ClientSpoof", category = ModuleCategory.CLIENT, defaultOn = true) -object ClientSpoof : Module() { - - val modeValue = ListValue("Payloads", arrayOf("Vanilla", "Forge", "Lunar", "LabyMod", "CheatBreaker", "PvPLounge"), "LabyMod") - private val buttonValue = ListValue("Button", arrayOf("Better", "RGBRounded", "Wolfram", "Rounded", "Hyperium", "RGB", "Badlion", "Flat", "FLine", "Rise", "Vanilla"), "Hyperium") - val render = BoolValue("Render", true) - - fun getButtonRenderer(button: GuiButton): AbstractButtonRenderer? { - return when (ClientSpoof.buttonValue.get().lowercase()) { - "better" -> BetterButtonRenderer(button) - "rounded" -> RoundedButtonRenderer(button) - "fline" -> FLineButtonRenderer(button) - "rise" -> RiseButtonRenderer(button) - "hyperium" -> HyperiumButtonRenderer(button) - "rgb" -> RGBButtonRenderer(button) - "badlion" -> BadlionTwoButtonRenderer(button) - "rgbrounded" -> RGBRoundedButtonRenderer(button) - "wolfram" -> WolframButtonRenderer(button) - else -> null // vanilla or unknown - } - } -} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/HUD.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/HUD.kt index cd6d936165..455a17e72b 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/HUD.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/HUD.kt @@ -10,7 +10,6 @@ import net.ccbluex.liquidbounce.event.* import net.ccbluex.liquidbounce.features.module.Module import net.ccbluex.liquidbounce.features.module.ModuleCategory import net.ccbluex.liquidbounce.features.module.ModuleInfo -import net.ccbluex.liquidbounce.value.* import net.ccbluex.liquidbounce.ui.cape.GuiCapeManager.height import net.ccbluex.liquidbounce.ui.clickgui.ClickGUIModule.colorBlueValue import net.ccbluex.liquidbounce.ui.clickgui.ClickGUIModule.colorGreenValue @@ -19,6 +18,10 @@ import net.ccbluex.liquidbounce.ui.client.hud.designer.GuiHudDesigner import net.ccbluex.liquidbounce.utils.render.ColorUtils import net.ccbluex.liquidbounce.utils.render.ColorUtils.rainbow import net.ccbluex.liquidbounce.utils.render.EaseUtils +import net.ccbluex.liquidbounce.value.BoolValue +import net.ccbluex.liquidbounce.value.FloatValue +import net.ccbluex.liquidbounce.value.IntegerValue +import net.ccbluex.liquidbounce.value.ListValue import net.minecraft.client.gui.GuiChat import net.minecraft.client.renderer.GlStateManager import net.minecraft.util.MathHelper @@ -30,9 +33,10 @@ import java.util.* object HUD : Module() { val shadowValue = ListValue("TextShadowMode", arrayOf("LiquidBounce", "Outline", "Default", "Autumn"), "Default") private val clolormode = ListValue("ColorMode", arrayOf("Rainbow", "Light Rainbow", "Static", "Double Color", "Default"), "Light Rainbow") - val hueInterpolation = BoolValue("hueInterpolation", false) + val shadowAlpha = IntegerValue("Shadow Alpha", 150, 0, 155) val movingcolors = BoolValue("MovingColors", false) val inventoryParticle = BoolValue("InventoryParticle", false) + val hueInterpolation = BoolValue("hueInterpolation", false) private val blurValue = BoolValue("Blur", false) private val HealthValue = BoolValue("Health", true) private val waterMark = BoolValue("Watermark", true) @@ -147,5 +151,4 @@ object HUD : Module() { } return arrayOf(firstColor, secondColor) } - } diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/HotbarSettings.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/HotbarSettings.kt index 0ceef02126..0b34b7ddfd 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/HotbarSettings.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/client/HotbarSettings.kt @@ -10,8 +10,8 @@ import net.ccbluex.liquidbounce.event.Render2DEvent import net.ccbluex.liquidbounce.features.module.Module import net.ccbluex.liquidbounce.features.module.ModuleCategory import net.ccbluex.liquidbounce.features.module.ModuleInfo -import net.ccbluex.liquidbounce.ui.font.cf.FontLoaders import net.ccbluex.liquidbounce.ui.font.Fonts +import net.ccbluex.liquidbounce.ui.font.cf.FontLoaders import net.ccbluex.liquidbounce.utils.render.Animation import net.ccbluex.liquidbounce.utils.render.BlurUtils import net.ccbluex.liquidbounce.utils.render.ColorUtils.rainbow @@ -38,9 +38,10 @@ import kotlin.math.max @ModuleInfo(name = "Hotbar", category = ModuleCategory.CLIENT, array = false, defaultOn = true) object HotbarSettings : Module() { + val hotbarValue = ListValue("HotbarMode", arrayOf("Minecraft", "Rounded", "Full", "LB", "Rise", "Gradient", "Overflow", "Glow", "Glowing", "Dock", "Exhi", "BlueIce", "Win11", "Bread"), "Minecraft") private val hotbarAlphaValue = IntegerValue("HotbarAlpha", 70, 0, 255) - private val hotbarEaseValue = BoolValue("HotbarEase", true) + private val hotbarEaseValue = BoolValue("HotbarEase", false) private val BlurValue = BoolValue("Blur", false) private val BlurAmount = FloatValue("BlurAmount", 10F, 1F, 100F).displayable { BlurValue.get() } private val ItemCountValue = BoolValue("ItemColorCount", false) @@ -51,7 +52,7 @@ object HotbarSettings : Module() { @EventTarget fun onRender2D(event: Render2DEvent) { val sr = event.scaledResolution - val i = sr.getScaledWidth() / 2 + val i = sr.scaledWidth / 2 val entityplayer = mc.renderViewEntity as EntityPlayer val itemX = sr.scaledWidth / 2 - 91 + getHotbarEasePos(entityplayer.inventory.currentItem * 20) val posInv = (91 - i + itemX).toFloat() @@ -268,6 +269,7 @@ object HotbarSettings : Module() { } } } + @JvmStatic private fun HotbarTextOverlay(xPosition: Int, yPosition: Int, text: String?, index: Int) { val entityplayer = mc.renderViewEntity as EntityPlayer val stack = entityplayer.inventory.mainInventory[index] @@ -325,7 +327,9 @@ object HotbarSettings : Module() { } set(value) { var hotbarSpeed = hotbarAnimSpeedValue.get() - if(hotbarValue.get() == "Dock"){ hotbarSpeed = 4} + if (hotbarValue.get() == "Dock") { + hotbarSpeed = 4 + } if (easeAnimation == null || (easeAnimation != null && easeAnimation!!.to != value.toDouble())) { easeAnimation = Animation( EaseUtils.EnumEasingType.valueOf(hotbarAnimTypeValue.get()), @@ -335,6 +339,7 @@ object HotbarSettings : Module() { hotbarSpeed * 30L ).start() } + field = value } fun getHotbarEasePos(x: Int): Int { if (!hotbarEaseValue.get()) return x diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/exploit/ViaVersionFix.java b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/exploit/ViaVersionFix.java deleted file mode 100644 index c80756edff..0000000000 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/exploit/ViaVersionFix.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * FDPClient Hacked Client - * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. - * https://github.com/SkidderMC/FDPClient/ - */ -package net.ccbluex.liquidbounce.features.module.modules.exploit; - -import net.ccbluex.liquidbounce.FDPClient; -import net.ccbluex.liquidbounce.features.module.Module; -import net.ccbluex.liquidbounce.features.module.ModuleCategory; -import net.ccbluex.liquidbounce.features.module.ModuleInfo; -import net.ccbluex.liquidbounce.ui.client.hud.element.elements.Notification; -import net.ccbluex.liquidbounce.ui.client.hud.element.elements.NotifyType; - -@ModuleInfo(name = "ViaVersionFix", category = ModuleCategory.EXPLOIT) -public class ViaVersionFix extends Module { - - @Override - public void onEnable(){ - FDPClient.hud.addNotification(new Notification("WARNING","If you using this module in a low version server < 1.12.Server AntiCheat will detect this as a hack when you right click!", NotifyType.WARNING,4000,500)); - } -} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/player/Refill.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/player/Refill.kt index b95529deff..9305ae2a73 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/player/Refill.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/player/Refill.kt @@ -11,7 +11,7 @@ import net.ccbluex.liquidbounce.event.UpdateEvent import net.ccbluex.liquidbounce.features.module.Module import net.ccbluex.liquidbounce.features.module.ModuleCategory import net.ccbluex.liquidbounce.features.module.ModuleInfo -import net.ccbluex.liquidbounce.injection.implementations.IMixinItemStack +import net.ccbluex.liquidbounce.injection.forge.mixins.item.MixinItemStack import net.ccbluex.liquidbounce.utils.timer.MSTimer import net.ccbluex.liquidbounce.value.BoolValue import net.ccbluex.liquidbounce.value.IntegerValue @@ -58,7 +58,7 @@ object Refill : Module() { for (slot in 36..44) { val stack = mc.thePlayer.inventoryContainer.getSlot(slot).stack ?: continue if (stack.stackSize == stack.maxStackSize - || (System.currentTimeMillis() - (stack as IMixinItemStack).itemDelay) < itemDelayValue.get()) continue + || (System.currentTimeMillis() - (stack as MixinItemStack).itemDelay) < itemDelayValue.get()) continue when (modeValue.get()) { "Swap" -> { diff --git a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/Timer.kt b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/Timer.kt index 578414ed12..28caac8bc8 100644 --- a/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/Timer.kt +++ b/src/main/java/net/ccbluex/liquidbounce/features/module/modules/world/Timer.kt @@ -7,20 +7,21 @@ package net.ccbluex.liquidbounce.features.module.modules.world import net.ccbluex.liquidbounce.event.EventTarget import net.ccbluex.liquidbounce.event.UpdateEvent +import net.ccbluex.liquidbounce.event.WorldEvent import net.ccbluex.liquidbounce.features.module.EnumAutoDisableType import net.ccbluex.liquidbounce.features.module.Module import net.ccbluex.liquidbounce.features.module.ModuleCategory import net.ccbluex.liquidbounce.features.module.ModuleInfo import net.ccbluex.liquidbounce.utils.MovementUtils +import net.ccbluex.liquidbounce.utils.misc.RandomUtils import net.ccbluex.liquidbounce.value.BoolValue import net.ccbluex.liquidbounce.value.FloatValue -import net.ccbluex.liquidbounce.utils.misc.RandomUtils @ModuleInfo(name = "Timer", category = ModuleCategory.WORLD, autoDisable = EnumAutoDisableType.RESPAWN) object Timer : Module() { // private val minSpeedValue = FloatValue("Speed", 2F, 0.1F, 10F) - private val maxSpeedValue: FloatValue = object : FloatValue("Max-Timer", 2F, 0.1F, 10F) { + val maxSpeedValue: FloatValue = object : FloatValue("Max-Timer", 2F, 0.1F, 10F) { fun onChanged(oldValue: Int, newValue: Int) { val minTimer = minSpeedValue.get() if (minTimer > newValue) { @@ -37,18 +38,18 @@ object Timer : Module() { } } private val onMoveValue = BoolValue("OnMove", true) + private val autoDisableValue = BoolValue("AutoDisable", true) + val smart = BoolValue("Smart", false) override fun onDisable() { - if (mc.thePlayer == null) { - return - } - mc.timer.timerSpeed = 1F } @EventTarget fun onUpdate(event: UpdateEvent) { - if (MovementUtils.isMoving() || !onMoveValue.get()) { + if (mc.thePlayer == null || mc.theWorld == null) return + + if(MovementUtils.isMoving() || !onMoveValue.get()) { mc.timer.timerSpeed = RandomUtils.nextFloat(minSpeedValue.get(), maxSpeedValue.get()) return } @@ -56,6 +57,14 @@ object Timer : Module() { mc.timer.timerSpeed = 1F } + @EventTarget + fun onWorld(event: WorldEvent) { + if (event.worldClient != null) + return + + if (autoDisableValue.get()) state = false + } + override val tag: String? get() = "${RandomUtils.nextFloat(minSpeedValue.get(), maxSpeedValue.get()).toString()}" -} +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/handler/network/BungeeCordSpoof.kt b/src/main/java/net/ccbluex/liquidbounce/handler/network/BungeeCordSpoof.kt index 764599376a..bcd0079899 100644 --- a/src/main/java/net/ccbluex/liquidbounce/handler/network/BungeeCordSpoof.kt +++ b/src/main/java/net/ccbluex/liquidbounce/handler/network/BungeeCordSpoof.kt @@ -9,7 +9,6 @@ package net.ccbluex.liquidbounce.handler.network import net.ccbluex.liquidbounce.event.EventTarget import net.ccbluex.liquidbounce.event.Listenable import net.ccbluex.liquidbounce.event.PacketEvent -import net.ccbluex.liquidbounce.handler.other.UUIDSpoofer import net.ccbluex.liquidbounce.utils.MinecraftInstance import net.minecraft.network.EnumConnectionState import net.minecraft.network.handshake.client.C00Handshake @@ -20,7 +19,7 @@ class BungeeCordSpoof : MinecraftInstance(), Listenable { fun onPacket(event: PacketEvent) { val packet = event.packet if (packet is C00Handshake && enabled && packet.requestedState == EnumConnectionState.LOGIN) - packet.ip = "${packet.ip}\u0000${getRandomIpPart()}.${getRandomIpPart()}.${getRandomIpPart()}.${getRandomIpPart()}\u0000${UUIDSpoofer.getUUID()}" + packet.ip = "${packet.ip}\u0000${getRandomIpPart()}.${getRandomIpPart()}.${getRandomIpPart()}.${getRandomIpPart()}\u0000" } private fun getRandomIpPart(): String = RANDOM.nextInt(256).toString() diff --git a/src/main/java/net/ccbluex/liquidbounce/handler/network/ClientSpoof.java b/src/main/java/net/ccbluex/liquidbounce/handler/network/ClientSpoof.java deleted file mode 100644 index 084a64f0ef..0000000000 --- a/src/main/java/net/ccbluex/liquidbounce/handler/network/ClientSpoof.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * FDPClient Hacked Client - * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. - * https://github.com/SkidderMC/FDPClient/ - */ -package net.ccbluex.liquidbounce.handler.network; - -import io.netty.buffer.Unpooled; -import net.ccbluex.liquidbounce.FDPClient; -import net.ccbluex.liquidbounce.event.EventTarget; -import net.ccbluex.liquidbounce.event.Listenable; -import net.ccbluex.liquidbounce.event.PacketEvent; -import net.ccbluex.liquidbounce.utils.MinecraftInstance; -import net.minecraft.client.Minecraft; -import net.minecraft.network.Packet; -import net.minecraft.network.PacketBuffer; -import net.minecraft.network.play.client.C17PacketCustomPayload; -import net.minecraft.network.play.server.S3FPacketCustomPayload; - -public class ClientSpoof extends MinecraftInstance implements Listenable { - - public static final boolean enabled = true; - - @EventTarget - public void handle(final PacketEvent event) { - final Packet packet = event.getPacket(); - final net.ccbluex.liquidbounce.features.module.modules.client.ClientSpoof clientSpoof = FDPClient.moduleManager.getModule(net.ccbluex.liquidbounce.features.module.modules.client.ClientSpoof.class); - - if (enabled && !Minecraft.getMinecraft().isIntegratedServerRunning() && clientSpoof.getModeValue().equals("Vanilla")) { - try { - if (packet.getClass().getName().equals("net.minecraftforge.fml.common.network.internal.FMLProxyPacket")) - event.cancelEvent(); - - if (packet instanceof C17PacketCustomPayload) { - final C17PacketCustomPayload customPayload = (C17PacketCustomPayload) packet; - - if (!customPayload.getChannelName().startsWith("MC|")) - event.cancelEvent(); - else if (customPayload.getChannelName().equalsIgnoreCase("MC|Brand")) - customPayload.data = (new PacketBuffer(Unpooled.buffer()).writeString("vanilla")); - } - } catch (final Exception e) { - e.printStackTrace(); - } - } - - if (enabled && !Minecraft.getMinecraft().isIntegratedServerRunning() && clientSpoof.getModeValue().equals("LabyMod")) { - try { - - if (packet.getClass().getName().equals("net.minecraftforge.fml.common.network.internal.FMLProxyPacket")) - event.cancelEvent(); - - if (packet instanceof S3FPacketCustomPayload) { - final S3FPacketCustomPayload payload = (S3FPacketCustomPayload) packet; - if (payload.getChannelName().equals("REGISTER")) { - mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload("labymod3:main", this.getInfo())); - mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload("LMC", this.getInfo())); - - } - } - - } catch (final Exception e) { - e.printStackTrace(); - } - } - - if (enabled && !Minecraft.getMinecraft().isIntegratedServerRunning() && clientSpoof.getModeValue().equals("CheatBreaker")) { - try { - if (packet.getClass().getName().equals("net.minecraftforge.fml.common.network.internal.FMLProxyPacket")) - event.cancelEvent(); - - if (packet instanceof C17PacketCustomPayload) { - final C17PacketCustomPayload customPayload = (C17PacketCustomPayload) packet; - - if (!customPayload.getChannelName().startsWith("MC|")) - event.cancelEvent(); - else if (customPayload.getChannelName().equalsIgnoreCase("MC|Brand")) - customPayload.data = (new PacketBuffer(Unpooled.buffer()).writeString("CB")); - } - } catch (final Exception e) { - e.printStackTrace(); - } - } - - if (enabled && !Minecraft.getMinecraft().isIntegratedServerRunning() && clientSpoof.getModeValue().equals("PvPLounge")) { - try { - if (packet.getClass().getName().equals("net.minecraftforge.fml.common.network.internal.FMLProxyPacket")) - event.cancelEvent(); - - if (packet instanceof C17PacketCustomPayload) { - final C17PacketCustomPayload customPayload = (C17PacketCustomPayload) packet; - - if (!customPayload.getChannelName().startsWith("MC|")) - event.cancelEvent(); - else if (customPayload.getChannelName().equalsIgnoreCase("MC|Brand")) - customPayload.data = (new PacketBuffer(Unpooled.buffer()).writeString("PLC18")); - } - } catch (final Exception e) { - e.printStackTrace(); - } - } - } - - private PacketBuffer getInfo() { - return new PacketBuffer(Unpooled.buffer()) - .writeString("INFO") - .writeString("{ \n" + - " \"version\": \"3.9.25\",\n" + - " \"ccp\": { \n" + - " \"enabled\": true,\n" + - " \"version\": 2\n" + - " },\n" + - " \"shadow\":{ \n" + - " \"enabled\": true,\n" + - " \"version\": 1\n" + - " },\n" + - " \"addons\": [ \n" + - " { \n" + - " \"uuid\": \"null\",\n" + - " \"name\": \"null\"\n" + - " }\n" + - " ],\n" + - " \"mods\": [\n" + - " { \n" + - " \"hash\":\"sha256:null\",\n" + - " \"name\":\"null.jar\"\n" + - " }\n" + - " ]\n" + - "}"); - } - - @Override - public boolean handleEvents() { - return true; - } -} diff --git a/src/main/java/net/ccbluex/liquidbounce/handler/network/ClientSpoofHandler.java b/src/main/java/net/ccbluex/liquidbounce/handler/network/ClientSpoofHandler.java new file mode 100644 index 0000000000..0d35f15003 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/handler/network/ClientSpoofHandler.java @@ -0,0 +1,102 @@ +/* + * FDPClient Hacked Client + * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. + * https://github.com/SkidderMC/FDPClient/ + */ +package net.ccbluex.liquidbounce.handler.network; + +import net.ccbluex.liquidbounce.FDPClient; +import net.ccbluex.liquidbounce.event.EventTarget; +import net.ccbluex.liquidbounce.event.Listenable; +import net.ccbluex.liquidbounce.event.PacketEvent; +import net.ccbluex.liquidbounce.features.module.modules.client.ClientSpoof; +import net.ccbluex.liquidbounce.handler.protocol.ProtocolBase; +import net.ccbluex.liquidbounce.utils.MinecraftInstance; +import io.netty.buffer.Unpooled; +import net.ccbluex.liquidbounce.utils.PacketUtils; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; +import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; +import net.minecraft.network.play.client.C17PacketCustomPayload; +import net.raphimc.vialoader.util.VersionEnum; + +import java.util.Objects; + +public class ClientSpoofHandler extends MinecraftInstance implements Listenable { + @EventTarget + public void onPacket(PacketEvent event) { + final Packet packet = event.getPacket(); + final ClientSpoof clientSpoof = FDPClient.moduleManager.getModule(ClientSpoof.class); + + if (ProtocolBase.getManager().getTargetVersion().isNewerThan(VersionEnum.r1_9_3tor1_9_4)) { + if (packet instanceof C08PacketPlayerBlockPlacement) { + ((C08PacketPlayerBlockPlacement) packet).facingX = 0.5F; + ((C08PacketPlayerBlockPlacement) packet).facingY = 0.5F; + ((C08PacketPlayerBlockPlacement) packet).facingZ = 0.5F; + } + } + + if (!MinecraftInstance.mc.isIntegratedServerRunning()) { + if (packet instanceof C17PacketCustomPayload) { + if (((C17PacketCustomPayload) event.getPacket()).getChannelName().equalsIgnoreCase("MC|Brand")) { + if (Objects.requireNonNull(clientSpoof).modeValue.get().equals("Vanilla")) + PacketUtils.sendPacketNoEvent(new C17PacketCustomPayload("MC|Brand", (new PacketBuffer(Unpooled.buffer())).writeString("vanilla"))); + if (Objects.requireNonNull(clientSpoof).modeValue.get().equals("Fabric")) + PacketUtils.sendPacketNoEvent(new C17PacketCustomPayload("MC|Brand", (new PacketBuffer(Unpooled.buffer())).writeString("fabric"))); + if (Objects.requireNonNull(clientSpoof).modeValue.get().equals("LabyMod")) { + mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload("labymod3:main", this.getInfo())); + mc.getNetHandler().addToSendQueue(new C17PacketCustomPayload("LMC", this.getInfo())); + } + if (Objects.requireNonNull(clientSpoof).modeValue.get().equals("Custom")) { + try { + final C17PacketCustomPayload customPayload = (C17PacketCustomPayload) packet; + customPayload.data = (new PacketBuffer(Unpooled.buffer()).writeString(clientSpoof.CustomClient.get())); + } catch (final Exception e) { + e.printStackTrace(); + } + } + if (Objects.requireNonNull(clientSpoof).modeValue.get().equals("CheatBreaker")) + PacketUtils.sendPacketNoEvent(new C17PacketCustomPayload("MC|Brand", (new PacketBuffer(Unpooled.buffer())).writeString("CB"))); + if (Objects.requireNonNull(clientSpoof).modeValue.get().equals("PvPLounge")) + PacketUtils.sendPacketNoEvent(new C17PacketCustomPayload("MC|Brand", (new PacketBuffer(Unpooled.buffer())).writeString("PLC18"))); + if (Objects.requireNonNull(clientSpoof).modeValue.get().equals("Lunar")) + PacketUtils.sendPacketNoEvent(new C17PacketCustomPayload("MC|Brand", (new PacketBuffer(Unpooled.buffer())).writeString("lunarclient:v2.12.3-2351"))); + } + event.cancelEvent(); + } + } + } + + private PacketBuffer getInfo() { + return new PacketBuffer(Unpooled.buffer()) + .writeString("INFO") + .writeString("{ \n" + + " \"version\": \"3.9.25\",\n" + + " \"ccp\": { \n" + + " \"enabled\": true,\n" + + " \"version\": 2\n" + + " },\n" + + " \"shadow\":{ \n" + + " \"enabled\": true,\n" + + " \"version\": 1\n" + + " },\n" + + " \"addons\": [ \n" + + " { \n" + + " \"uuid\": \"null\",\n" + + " \"name\": \"null\"\n" + + " }\n" + + " ],\n" + + " \"mods\": [\n" + + " { \n" + + " \"hash\":\"sha256:null\",\n" + + " \"name\":\"null.jar\"\n" + + " }\n" + + " ]\n" + + "}"); + } + + @Override + public boolean handleEvents() { + return true; + } +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/handler/other/UUIDSpoofer.kt b/src/main/java/net/ccbluex/liquidbounce/handler/other/UUIDSpoofer.kt deleted file mode 100644 index 038a964a12..0000000000 --- a/src/main/java/net/ccbluex/liquidbounce/handler/other/UUIDSpoofer.kt +++ /dev/null @@ -1,16 +0,0 @@ -/* - * FDPClient Hacked Client - * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. - * https://github.com/SkidderMC/FDPClient/ - */ - -package net.ccbluex.liquidbounce.handler.other - -import net.ccbluex.liquidbounce.utils.MinecraftInstance - -object UUIDSpoofer : MinecraftInstance() { - var spoofId: String? = null - - @JvmStatic - fun getUUID(): String = (if (spoofId == null) mc.session.playerID else spoofId!!).replace("-", "") -} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/TransformerLoader.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/TransformerLoader.java index e3fe53e6ab..41961d8df4 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/forge/TransformerLoader.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/TransformerLoader.java @@ -5,10 +5,6 @@ */ package net.ccbluex.liquidbounce.injection.forge; -import net.ccbluex.liquidbounce.injection.transformers.ForgeNetworkTransformer; -import net.ccbluex.liquidbounce.injection.transformers.OptimizeTransformer; -import net.ccbluex.liquidbounce.injection.transformers.ViaForgeSupportTransformer; -import net.ccbluex.liquidbounce.handler.script.remapper.injection.transformers.AbstractJavaLinkerTransformer; import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin; import org.spongepowered.asm.launch.MixinBootstrap; import org.spongepowered.asm.mixin.MixinEnvironment; @@ -16,72 +12,41 @@ import java.util.Map; +/** + * The type Transformer loader. + */ @IFMLLoadingPlugin.MCVersion("1.8.9") public class TransformerLoader implements IFMLLoadingPlugin { + /** + * Instantiates a new Transformer loader. + */ public TransformerLoader() { MixinBootstrap.init(); Mixins.addConfiguration("mixins.fdpclient.json"); MixinEnvironment.getDefaultEnvironment().setSide(MixinEnvironment.Side.CLIENT); } - /** - * Return a list of classes that implements the IClassTransformer interface - * - * @return a list of classes that implements the IClassTransformer interface - */ @Override public String[] getASMTransformerClass() { - return new String[] {ForgeNetworkTransformer.class.getName(), AbstractJavaLinkerTransformer.class.getName(), ViaForgeSupportTransformer.class.getName(), OptimizeTransformer.class.getName()}; + return new String[0]; } - /** - * Return a class name that implements "ModContainer" for injection into the mod list - * The "getName" function should return a name that other mods can, if need be, - * depend on. - * Trivially, this modcontainer will be loaded before all regular mod containers, - * which means it will be forced to be "immutable" - not susceptible to normal - * sorting behaviour. - * All other mod behaviours are available however- this container can receive and handle - * normal loading events - */ @Override public String getModContainerClass() { return null; } - /** - * Return the class name of an implementor of "IFMLCallHook", that will be run, in the - * main thread, to perform any additional setup this coremod may require. It will be - * run prior to Minecraft starting, so it CANNOT operate on minecraft - * itself. The game will deliberately crash if this code is detected to trigger a - * minecraft class loading - */ @Override public String getSetupClass() { return null; } - /** - * Inject coremod data into this coremod - * This data includes: - * "mcLocation" : the location of the minecraft directory, - * "coremodList" : the list of coremods - * "coremodLocation" : the file this coremod loaded from, - * - * @param data - */ @Override public void injectData(Map data) { } - /** - * Return an optional access transformer class for this coremod. It will be injected post-deobf - * so ensure your ATs conform to the new srgnames scheme. - * - * @return the name of an access transformer class or null if none is provided - */ @Override public String getAccessTransformerClass() { return null; diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiNewChat.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiNewChat.java index c27d0a6b7e..1cdbd79fbb 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiNewChat.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiNewChat.java @@ -7,8 +7,8 @@ import com.mojang.realmsclient.gui.ChatFormatting; import net.ccbluex.liquidbounce.FDPClient; -import net.ccbluex.liquidbounce.features.module.modules.client.HUD; import net.ccbluex.liquidbounce.features.module.modules.client.ChatControl; +import net.ccbluex.liquidbounce.features.module.modules.client.HUD; import net.ccbluex.liquidbounce.ui.font.cf.CFontRenderer; import net.ccbluex.liquidbounce.ui.font.cf.FontLoaders; import net.ccbluex.liquidbounce.injection.access.StaticStorage; diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiScreen.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiScreen.java index 063a4e92e3..73ecfb7f77 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiScreen.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/gui/MixinGuiScreen.java @@ -10,14 +10,15 @@ import net.ccbluex.liquidbounce.ui.font.cf.FontLoaders; import net.ccbluex.liquidbounce.ui.client.GuiBackground; import net.ccbluex.liquidbounce.utils.particles.ParticleUtils; +import net.ccbluex.liquidbounce.utils.render.shader.shaders.BackgroundShader; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.*; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.event.ClickEvent; import net.minecraft.event.HoverEvent; import net.minecraft.util.ChatStyle; @@ -127,19 +128,38 @@ private void drawDefaultBackground(final CallbackInfo callbackInfo){ /** * @author CCBlueX */ - @Inject(method = "drawBackground", at = @At("RETURN")) + @Inject(method = "drawBackground", at = @At("HEAD"), cancellable = true) private void drawClientBackground(final CallbackInfo callbackInfo) { GlStateManager.disableLighting(); GlStateManager.disableFog(); + if(GuiBackground.Companion.getEnabled()) { - if (FDPClient.INSTANCE.getBackground() != null) { + if (FDPClient.INSTANCE.getBackground() == null) { + BackgroundShader.BACKGROUND_SHADER.startShader(); + + final Tessellator instance = Tessellator.getInstance(); + final WorldRenderer worldRenderer = instance.getWorldRenderer(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(0, height, 0.0D).endVertex(); + worldRenderer.pos(width, height, 0.0D).endVertex(); + worldRenderer.pos(width, 0, 0.0D).endVertex(); + worldRenderer.pos(0, 0, 0.0D).endVertex(); + instance.draw(); + + BackgroundShader.BACKGROUND_SHADER.stopShader(); + }else{ + final ScaledResolution scaledResolution = new ScaledResolution(mc); + final int width = scaledResolution.getScaledWidth(); + final int height = scaledResolution.getScaledHeight(); + mc.getTextureManager().bindTexture(FDPClient.INSTANCE.getBackground()); - Gui.drawModalRectWithCustomSizedTexture(0, 0, 0f, 0f, width, height, width, height); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + Gui.drawScaledCustomSizeModalRect(0, 0, 0.0F, 0.0F, width, height, width, height, width, height); } - GlStateManager.resetColor(); if (GuiBackground.Companion.getParticles()) - ParticleUtils.drawParticles(Mouse.getX() * width / mc.displayWidth, height - Mouse.getY() * height / mc.displayHeight - 1); + net.ccbluex.liquidbounce.utils.render.ParticleUtils.drawParticles(Mouse.getX() * width / mc.displayWidth, height - Mouse.getY() * height / mc.displayHeight - 1); + callbackInfo.cancel(); } } diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/item/MixinItemStack.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/item/MixinItemStack.java new file mode 100644 index 0000000000..28fb4049f0 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/item/MixinItemStack.java @@ -0,0 +1,54 @@ +package net.ccbluex.liquidbounce.injection.forge.mixins.item; + +import net.ccbluex.liquidbounce.injection.access.IItemStack; +import net.minecraft.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +/** + * The type Mixin item stack. + */ +@Mixin(ItemStack.class) +public class MixinItemStack implements IItemStack { + private long itemDelay; + private String cachedDisplayName; + + @Inject(method = "(Lnet/minecraft/item/Item;IILnet/minecraft/nbt/NBTTagCompound;)V", at = @At("RETURN")) + private void init(final CallbackInfo callbackInfo) { + this.itemDelay = System.currentTimeMillis(); + } + + @Override + public long getItemDelay() { + return itemDelay; + } + + @Redirect( + method = "getTooltip", + at = @At(value = "INVOKE", target = "Ljava/lang/Integer;toHexString(I)Ljava/lang/String;") + ) + private String fixHexColorString(int i) { + return String.format("%06X", i); + } + + @Inject(method = "getDisplayName", at = @At("HEAD"), cancellable = true) + private void returnCachedDisplayName(CallbackInfoReturnable cir) { + if (cachedDisplayName != null) { + cir.setReturnValue(cachedDisplayName); + } + } + + @Inject(method = "getDisplayName", at = @At("RETURN")) + private void cacheDisplayName(CallbackInfoReturnable cir) { + cachedDisplayName = cir.getReturnValue(); + } + + @Inject(method = "setStackDisplayName", at = @At("HEAD")) + private void resetCachedDisplayName(String displayName, CallbackInfoReturnable cir) { + cachedDisplayName = null; + } +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinC00Handshake.java b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinC00Handshake.java index 3d5dfb80d6..d34043d6f0 100644 --- a/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinC00Handshake.java +++ b/src/main/java/net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinC00Handshake.java @@ -5,7 +5,6 @@ */ package net.ccbluex.liquidbounce.injection.forge.mixins.network; -import net.ccbluex.liquidbounce.handler.network.ClientSpoof; import net.minecraft.client.Minecraft; import net.minecraft.network.EnumConnectionState; import net.minecraft.network.handshake.client.C00Handshake; @@ -17,8 +16,14 @@ @Mixin(C00Handshake.class) public class MixinC00Handshake { + /** + * The Port. + */ @Shadow public int port; + /** + * The Ip. + */ @Shadow public String ip; @Shadow @@ -26,11 +31,8 @@ public class MixinC00Handshake { @Shadow private EnumConnectionState requestedState; - /** - * @author CCBlueX - */ @ModifyConstant(method = "writePacketData", constant = @Constant(stringValue = "\u0000FML\u0000")) private String injectAntiForge(String constant) { - return ClientSpoof.enabled && !Minecraft.getMinecraft().isIntegratedServerRunning() ? "" : "\u0000FML\u0000"; + return !Minecraft.getMinecraft().isIntegratedServerRunning() ? "" : "\u0000FML\u0000"; } } \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/implementations/IMixinItemStack.java b/src/main/java/net/ccbluex/liquidbounce/injection/implementations/IMixinItemStack.java deleted file mode 100644 index aff7ba1f50..0000000000 --- a/src/main/java/net/ccbluex/liquidbounce/injection/implementations/IMixinItemStack.java +++ /dev/null @@ -1,10 +0,0 @@ -/* - * FDPClient Hacked Client - * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. - * https://github.com/SkidderMC/FDPClient/ - */ -package net.ccbluex.liquidbounce.injection.implementations; - -public interface IMixinItemStack { - long getItemDelay(); -} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/transformers/ForgeNetworkTransformer.java b/src/main/java/net/ccbluex/liquidbounce/injection/transformers/ForgeNetworkTransformer.java deleted file mode 100644 index 583a95696d..0000000000 --- a/src/main/java/net/ccbluex/liquidbounce/injection/transformers/ForgeNetworkTransformer.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * FDPClient Hacked Client - * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. - * https://github.com/SkidderMC/FDPClient/ - */ -package net.ccbluex.liquidbounce.injection.transformers; - -import net.ccbluex.liquidbounce.handler.network.ClientSpoof; -import net.ccbluex.liquidbounce.handler.script.remapper.injection.utils.ClassUtils; -import net.ccbluex.liquidbounce.handler.script.remapper.injection.utils.NodeUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.launchwrapper.IClassTransformer; -import org.objectweb.asm.tree.*; - -import static org.objectweb.asm.Opcodes.*; - -/** - * Transform bytecode of classes - */ -public class ForgeNetworkTransformer implements IClassTransformer { - - public static boolean returnMethod() { - return ClientSpoof.enabled && !Minecraft.getMinecraft().isIntegratedServerRunning(); - } - - /** - * Transform a class - * - * @param name of target class - * @param transformedName of target class - * @param basicClass bytecode of target class - * @return new bytecode - */ - @Override - public byte[] transform(String name, String transformedName, byte[] basicClass) { - if (name.equals("net.minecraftforge.fml.common.network.handshake.NetworkDispatcher")) { - try { - final ClassNode classNode = ClassUtils.INSTANCE.toClassNode(basicClass); - - classNode.methods.stream().filter(methodNode -> methodNode.name.equals("handleVanilla")).forEach(methodNode -> { - final LabelNode labelNode = new LabelNode(); - - methodNode.instructions.insertBefore(methodNode.instructions.getFirst(), NodeUtils.INSTANCE.toNodes( - new MethodInsnNode(INVOKESTATIC, "net/ccbluex/liquidbounce/injection/transformers/ForgeNetworkTransformer", "returnMethod", "()Z", false), - new JumpInsnNode(IFEQ, labelNode), - new InsnNode(ICONST_0), - new InsnNode(IRETURN), - labelNode - )); - }); - - return ClassUtils.INSTANCE.toBytes(classNode); - } catch (final Throwable throwable) { - throwable.printStackTrace(); - } - } - - if (name.equals("net.minecraftforge.fml.common.network.handshake.HandshakeMessageHandler")) { - try { - final ClassNode classNode = ClassUtils.INSTANCE.toClassNode(basicClass); - - classNode.methods.stream().filter(method -> method.name.equals("channelRead0")).forEach(methodNode -> { - final LabelNode labelNode = new LabelNode(); - - methodNode.instructions.insertBefore(methodNode.instructions.getFirst(), NodeUtils.INSTANCE.toNodes( - new MethodInsnNode(INVOKESTATIC, - "net/ccbluex/liquidbounce/injection/transformers/ForgeNetworkTransformer", - "returnMethod", "()Z", false - ), - new JumpInsnNode(IFEQ, labelNode), - new InsnNode(RETURN), - labelNode - )); - }); - - return ClassUtils.INSTANCE.toBytes(classNode); - } catch (final Throwable throwable) { - throwable.printStackTrace(); - } - } - - return basicClass; - } -} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/transformers/OptimizeTransformer.java b/src/main/java/net/ccbluex/liquidbounce/injection/transformers/OptimizeTransformer.java deleted file mode 100644 index 940bf32257..0000000000 --- a/src/main/java/net/ccbluex/liquidbounce/injection/transformers/OptimizeTransformer.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * FDPClient Hacked Client - * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. - * https://github.com/SkidderMC/FDPClient/ - */ -package net.ccbluex.liquidbounce.injection.transformers; - -import net.ccbluex.liquidbounce.utils.ASMUtils; -import net.minecraft.launchwrapper.IClassTransformer; -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.tree.AbstractInsnNode; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.MethodInsnNode; - -import java.util.HashMap; -import java.util.concurrent.atomic.AtomicBoolean; - -public class OptimizeTransformer implements IClassTransformer { - - private static final HashMap transformMap = new HashMap<>(); - - static { - addTransform("net.minecraft.util.EnumFacing", "cq", "facings"); - addTransform("net.minecraft.util.EnumChatFormatting", "a", "chatFormatting"); - addTransform("net.minecraft.util.EnumParticleTypes", "cy", "particleTypes"); - addTransform("net.minecraft.util.EnumWorldBlockLayer", "adf", "worldBlockLayers"); - } - - /** - * Add transform to transformMap - * @param mcpName the normal name look like in developing env - * @param notchName the obfuscated name in player env - * @param targetName the target method in [StaticStorage] - */ - private static void addTransform(final String mcpName, final String notchName, final String targetName) { - transformMap.put(mcpName, targetName); - transformMap.put(notchName, targetName); - } - - @Override - public byte[] transform(String name, String transformedName, byte[] basicClass) { - if(transformedName.startsWith("net.minecraft") && basicClass != null && !transformMap.containsKey(transformedName)) { - try { - final ClassNode classNode = ASMUtils.INSTANCE.toClassNode(basicClass); - AtomicBoolean changed = new AtomicBoolean(false); - - classNode.methods.forEach(methodNode -> { - for (int i = 0; i < methodNode.instructions.size(); ++i) { - final AbstractInsnNode abstractInsnNode = methodNode.instructions.get(i); - if (abstractInsnNode instanceof MethodInsnNode) { - MethodInsnNode min = (MethodInsnNode) abstractInsnNode; - if(min.getOpcode() == Opcodes.INVOKESTATIC && min.name.equals("values")) { - final String owner = min.owner.replaceAll("/", "."); - if (transformMap.containsKey(owner)) { - changed.set(true); - min.owner = "net/ccbluex/liquidbounce/injection/access/StaticStorage"; - min.name = transformMap.get(owner); - } - } - } - } - }); - - if (changed.get()) { - return ASMUtils.INSTANCE.toBytes(classNode); - } - }catch(final Throwable throwable) { - throwable.printStackTrace(); - } - } - - return basicClass; - } -} diff --git a/src/main/java/net/ccbluex/liquidbounce/injection/transformers/ViaForgeSupportTransformer.java b/src/main/java/net/ccbluex/liquidbounce/injection/transformers/ViaForgeSupportTransformer.java deleted file mode 100644 index 993bf2e489..0000000000 --- a/src/main/java/net/ccbluex/liquidbounce/injection/transformers/ViaForgeSupportTransformer.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * FDPClient Hacked Client - * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. - * https://github.com/SkidderMC/FDPClient/ - */ -package net.ccbluex.liquidbounce.injection.transformers; - -import net.ccbluex.liquidbounce.utils.ASMUtils; -import net.minecraft.launchwrapper.IClassTransformer; -import org.objectweb.asm.tree.AbstractInsnNode; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.MethodInsnNode; -import org.objectweb.asm.tree.TypeInsnNode; - -public class ViaForgeSupportTransformer implements IClassTransformer { - - private final byte[] target = null; - - @Override - public byte[] transform(String name, String transformedName, byte[] basicClass) { - if(name.equals("net.ccbluex.liquidbounce.injection.forge.mixins.network.MixinNetworkManager")) { - try { - final ClassNode classNode = ASMUtils.INSTANCE.toClassNode(basicClass); - - classNode.methods.stream().filter(methodNode -> methodNode.name.equals("createNetworkManagerAndConnect")).forEach(methodNode -> { - for(int i = 0; i < methodNode.instructions.size(); ++i) { - final AbstractInsnNode abstractInsnNode = methodNode.instructions.get(i); - if(abstractInsnNode instanceof TypeInsnNode) { - TypeInsnNode tin = (TypeInsnNode) abstractInsnNode; - if(tin.desc.equals("net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinNetworkManager$1")) { - ((TypeInsnNode) abstractInsnNode).desc = "net/minecraft/network/NetworkManager$5"; - } - } else if(abstractInsnNode instanceof MethodInsnNode) { - MethodInsnNode min = (MethodInsnNode) abstractInsnNode; - if(min.owner.equals("net/ccbluex/liquidbounce/injection/forge/mixins/network/MixinNetworkManager$1") && min.name.equals("")) { - min.owner = "net/minecraft/network/NetworkManager$5"; - } - } - } - }); - - return ASMUtils.INSTANCE.toBytes(classNode); - }catch(final Throwable throwable) { - throwable.printStackTrace(); - } - } - - return basicClass; - } -} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/fonts/api/FontRenderer.java b/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/fonts/api/FontRenderer.java index ec2c8d09ea..c247cb14ab 100644 --- a/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/fonts/api/FontRenderer.java +++ b/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/fonts/api/FontRenderer.java @@ -8,18 +8,18 @@ public interface FontRenderer { float drawString(CharSequence text, float x, float y, int color, boolean dropShadow); - String trimStringToWidth(CharSequence text, int width, boolean reverse); + String trimStringToWidth(CharSequence text, int width, boolean reverse); int stringWidth(CharSequence text); - int getHeight(); + int getHeight(); - //region default methods + //region default methods default float drawString(CharSequence text, float x, float y, int color) { return drawString(text, x, y, color, false); } default void drawString(CharSequence text, int x, int y, int color) { - drawString(text, x, y, color, false); - } + drawString(text, x, y, color, false); + } default String trimStringToWidth(CharSequence text, int width) { return trimStringToWidth(text, width, false); } @@ -27,11 +27,11 @@ default String trimStringToWidth(CharSequence text, int width) { default float drawCenteredString(CharSequence text, float x, float y, int color, boolean dropShadow) { return drawString(text, x - stringWidth(text) / 2.0F, y, color, dropShadow); } - default float getMiddleOfBox(float boxHeight) { + default float getMiddleOfBox(float boxHeight) { return boxHeight / 2f - getHeight() / 2f; } default void drawCenteredString(CharSequence text, float x, float y, int color) { - drawCenteredString(text, x, y, color, false); - } + drawCenteredString(text, x, y, color, false); + } } diff --git a/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/classic/Module.java b/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/classic/Module.java index 6611b159be..c973ff0333 100644 --- a/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/classic/Module.java +++ b/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/classic/Module.java @@ -8,8 +8,8 @@ import lombok.Getter; import net.ccbluex.liquidbounce.FDPClient; -import net.ccbluex.liquidbounce.ui.clickgui.ClickGUIModule; import net.ccbluex.liquidbounce.features.module.modules.client.HUD; +import net.ccbluex.liquidbounce.ui.clickgui.ClickGUIModule; import net.ccbluex.liquidbounce.ui.clickgui.fonts.impl.Fonts; import net.ccbluex.liquidbounce.utils.render.RenderUtils; import net.ccbluex.liquidbounce.utils.timer.TickTimer; diff --git a/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/classic/Setting.java b/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/classic/Setting.java index bd664f84ab..922bee7f04 100644 --- a/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/classic/Setting.java +++ b/src/main/java/net/ccbluex/liquidbounce/ui/clickgui/style/styles/classic/Setting.java @@ -6,8 +6,8 @@ package net.ccbluex.liquidbounce.ui.clickgui.style.styles.classic; import net.ccbluex.liquidbounce.FDPClient; -import net.ccbluex.liquidbounce.ui.clickgui.ClickGUIModule; import net.ccbluex.liquidbounce.features.module.modules.client.HUD; +import net.ccbluex.liquidbounce.ui.clickgui.ClickGUIModule; import net.ccbluex.liquidbounce.ui.clickgui.fonts.impl.Fonts; import net.ccbluex.liquidbounce.utils.MathUtils; import net.ccbluex.liquidbounce.utils.render.RenderUtils; diff --git a/src/main/java/net/ccbluex/liquidbounce/ui/client/gui/GuiInfo.kt b/src/main/java/net/ccbluex/liquidbounce/ui/client/gui/GuiInfo.kt index 9afd63e4ed..84ce5c48d8 100644 --- a/src/main/java/net/ccbluex/liquidbounce/ui/client/gui/GuiInfo.kt +++ b/src/main/java/net/ccbluex/liquidbounce/ui/client/gui/GuiInfo.kt @@ -8,6 +8,7 @@ package net.ccbluex.liquidbounce.ui.client.gui import net.ccbluex.liquidbounce.FDPClient import net.ccbluex.liquidbounce.features.command.CommandManager import net.ccbluex.liquidbounce.handler.combat.CombatManager +import net.ccbluex.liquidbounce.ui.client.GuiBackground import net.ccbluex.liquidbounce.ui.sound.TipSoundManager import net.ccbluex.liquidbounce.utils.misc.MiscUtils import net.ccbluex.liquidbounce.utils.render.RenderUtils @@ -46,6 +47,7 @@ class GuiInfo(private val prevGui: GuiScreen) : GuiScreen() { override fun actionPerformed(button: GuiButton) { when (button.id) { + 1 -> mc.displayGuiScreen(GuiBackground(this)) 2 -> BUTTON_VERSIONS 3 -> MiscUtils.showURL(FDPClient.CLIENT_WEBSITE) 5 -> { diff --git a/src/main/java/net/ccbluex/liquidbounce/ui/font/Fonts.java b/src/main/java/net/ccbluex/liquidbounce/ui/font/Fonts.java index a135335a07..ec58515956 100644 --- a/src/main/java/net/ccbluex/liquidbounce/ui/font/Fonts.java +++ b/src/main/java/net/ccbluex/liquidbounce/ui/font/Fonts.java @@ -49,6 +49,12 @@ public class Fonts { @FontDetails(fontName = "SF", fontSize = 35) public static GameFontRenderer fontSFUI35; + @FontDetails(fontName = "SF", fontSize = 15) + public static GameFontRenderer fontSFUI15; + + @FontDetails(fontName = "SF", fontSize = 17) + public static GameFontRenderer fontSFUI17; + @FontDetails(fontName = "SF", fontSize = 40) public static GameFontRenderer fontSFUI40; @@ -136,6 +142,7 @@ public static void loadFonts() { SFUI40 = new GameFontRenderer(getFont("SF.ttf", 20)); SFUI35 = new GameFontRenderer(getFont("SF.ttf", 18)); SFUI24 = new GameFontRenderer(getFont("SF.ttf", 10)); + fontSFUI15 = new GameFontRenderer(getFont("SF.ttf", 35)); fontSFUI35 = new GameFontRenderer(getFont("SF.ttf", 35)); fontSFUI40 = new GameFontRenderer(getFont("SF.ttf", 40)); fontBold180 = new GameFontRenderer(getFont("Roboto-Bold.ttf", 180)); diff --git a/src/main/java/net/ccbluex/liquidbounce/ui/font/GameFontRenderer.kt b/src/main/java/net/ccbluex/liquidbounce/ui/font/GameFontRenderer.kt index 3d840ac19d..38e24e7e9c 100644 --- a/src/main/java/net/ccbluex/liquidbounce/ui/font/GameFontRenderer.kt +++ b/src/main/java/net/ccbluex/liquidbounce/ui/font/GameFontRenderer.kt @@ -8,9 +8,9 @@ package net.ccbluex.liquidbounce.ui.font import net.ccbluex.liquidbounce.FDPClient import net.ccbluex.liquidbounce.event.TextEvent import net.ccbluex.liquidbounce.features.module.modules.client.HUD -import net.ccbluex.liquidbounce.ui.i18n.LanguageManager import net.ccbluex.liquidbounce.utils.render.ColorUtils import net.ccbluex.liquidbounce.utils.render.RenderUtils +import net.ccbluex.liquidbounce.utils.render.VisualBase import net.ccbluex.liquidbounce.utils.render.shader.shaders.RainbowFontShader import net.minecraft.client.Minecraft import net.minecraft.client.gui.FontRenderer @@ -39,28 +39,47 @@ class GameFontRenderer(font: Font) : FontRenderer(Minecraft.getMinecraft().gameS init { FONT_HEIGHT = height } - - private fun getColorIndex2(type: Char): Int { - return when (type) { - in '0'..'9' -> type - '0' - in 'a'..'f' -> type - 'a' + 10 - in 'k'..'o' -> type - 'k' + 16 - 'r' -> 21 - else -> -1 - } - } + fun drawStringWithColor(text: String, x: Float, y: Float, color: Int, shadow: Boolean) = drawString(text, x, y, color, shadow) fun drawString(s: String, x: Float, y: Float, color: Int) = drawString(s, x, y, color, false) + open fun getMiddleOfBox(boxHeight: Float): Float { + return boxHeight / 2f - height / 2f + } + override fun drawStringWithShadow(text: String, x: Float, y: Float, color: Int) = drawString(text, x, y, color, true) + fun drawBlurredString(text: String, x: Double, y: Double, blurRadius: Int, blurColor: Color, color: Int, shadow: Boolean) { + GlStateManager.resetColor() + VisualBase.drawBlurredShadow(x.toFloat(), y.toFloat(), getStringWidth(text).toFloat(), FONT_HEIGHT.toFloat(), blurRadius, blurColor) + drawString(text, x.toFloat(), y.toFloat(), color, shadow) + } + + fun drawBlurredStringWithShadow(text: String, x: Double, y: Double, blurRadius: Int, blurColor: Color, color: Int) { + GlStateManager.resetColor() + VisualBase.drawBlurredShadow(x.toFloat(), y.toFloat(), getStringWidth(text).toFloat(), FONT_HEIGHT.toFloat(), blurRadius, blurColor) + drawStringWithShadow(text, x.toFloat(), y.toFloat(), color) + } + + fun drawCenteredBlurredString(s: String, x: Float, y: Float, blurRadius: Int, blurColor: Color, color: Int, shadow: Boolean) { + GlStateManager.resetColor() + VisualBase.drawBlurredShadow(x, y, getStringWidth(s).toFloat() / 2f, FONT_HEIGHT.toFloat(), blurRadius, blurColor) + drawString(s, x - getStringWidth(s) / 2F, y, color, shadow) + } + + fun drawCenteredBlurredString(s: String, x: Float, y: Float, blurRadius: Int, blurColor: Color, color: Int) { + GlStateManager.resetColor() + VisualBase.drawBlurredShadow(x, y, getStringWidth(s).toFloat() / 2f, FONT_HEIGHT.toFloat(), blurRadius, blurColor) + drawStringWithShadow(s, x - getStringWidth(s) / 2F, y, color) + } + fun drawCenteredString(s: String, x: Float, y: Float, color: Int, shadow: Boolean) = drawString(s, x - getStringWidth(s) / 2F, y, color, shadow) - fun drawCenteredString(s: String, x: Float, y: Float, color: Int) = drawStringWithShadow(s, x - getStringWidth(s) / 2F, y, color) + fun drawCenteredString(s: String, x: Float, y: Float, color: Int) = + drawStringWithShadow(s, x - getStringWidth(s) / 2F, y, color) override fun drawString(text: String, x: Float, y: Float, color: Int, shadow: Boolean): Int { - val TranslatedCurrentText = LanguageManager.replace(text) - var currentText = TranslatedCurrentText + var currentText = text val event = TextEvent(currentText) FDPClient.eventManager.callEvent(event) @@ -71,15 +90,30 @@ class GameFontRenderer(font: Font) : FontRenderer(Minecraft.getMinecraft().gameS val rainbow = RainbowFontShader.INSTANCE.isInUse if (shadow) { - when { - HUD.shadowValue.get().equals("LiquidBounce", ignoreCase = true) -> drawText(currentText, x + 1f, currY + 1f, Color(0, 0, 0, 150).rgb, true) - HUD.shadowValue.get().equals("Default", ignoreCase = true) -> drawText(currentText, x + 0.5f, currY + 0.5f, Color(0, 0, 0, 130).rgb, true) - HUD.shadowValue.get().equals("Autumn", ignoreCase = true) -> drawText(currentText, x + 1f, currY + 1f, Color(20, 20, 20, 200).rgb, true) - HUD.shadowValue.get().equals("Outline", ignoreCase = true) -> { - drawText(currentText, x + 0.5f, currY + 0.5f, Color(0, 0, 0, 130).rgb, true) - drawText(currentText, x - 0.5f, currY - 0.5f, Color(0, 0, 0, 130).rgb, true) - drawText(currentText, x + 0.5f, currY - 0.5f, Color(0, 0, 0, 130).rgb, true) - drawText(currentText, x - 0.5f, currY + 0.5f, Color(0, 0, 0, 130).rgb, true) + GL20.glUseProgram(0) + + // Remove the "Custom" shadow option: + if (HUD.shadowValue.get().equals("Default", true)) { + drawText(currentText, x + 0.5f, currY + 0.5f, Color(0, 0, 0, HUD.shadowAlpha.get()).rgb, true) + } else if (HUD.shadowValue.get().equals("Hanabi", true)) { + val c = Color(color) + val r = 0.003921569f * c.red.toFloat() + val g = 0.003921569f * c.green.toFloat() + val b = 0.003921569f * c.blue.toFloat() + val a = 0.003921569f * c.alpha.toFloat() + this.drawText(currentText, x + .8f, currY + .8f, Color(r, g, b, a).darker().darker().darker().darker().rgb, true) + } else { + // Handle other shadow types without using HUD.customShadow: + when (HUD.shadowValue.get()) { + "LiquidBounce" -> drawText(currentText, x + 1f, currY + 1f, Color(0, 0, 0, 150).rgb, true) + "Default" -> drawText(currentText, x + 0.5f, currY + 0.5f, Color(0, 0, 0, 130).rgb, true) + "Autumn" -> drawText(currentText, x + 1f, currY + 1f, Color(20, 20, 20, 200).rgb, true) + "Outline" -> { + drawText(currentText, x + 0.5f, currY + 0.5f, Color(0, 0, 0, 130).rgb, true) + drawText(currentText, x - 0.5f, currY - 0.5f, Color(0, 0, 0, 130).rgb, true) + drawText(currentText, x + 0.5f, currY - 0.5f, Color(0, 0, 0, 130).rgb, true) + drawText(currentText, x - 0.5f, currY + 0.5f, Color(0, 0, 0, 130).rgb, true) + } } } } @@ -90,9 +124,10 @@ class GameFontRenderer(font: Font) : FontRenderer(Minecraft.getMinecraft().gameS private fun drawText(text: String?, x: Float, y: Float, color: Int, ignoreColor: Boolean, rainbow: Boolean = false): Int { if (text == null) return 0 - if (text.isEmpty()) + if (text.isNullOrEmpty()) return x.toInt() + GlStateManager.translate(x - 1.5, y + 0.5, 0.0) GlStateManager.enableAlpha() GlStateManager.enableBlend() @@ -133,7 +168,7 @@ class GameFontRenderer(font: Font) : FontRenderer(Minecraft.getMinecraft().gameS val words = part.substring(1) val type = part[0] - when (val colorIndex = getColorIndex2(type)) { + when (val colorIndex = getColorIndex(type)) { in 0..15 -> { if (!ignoreColor) { currentColor = ColorUtils.hexColors[colorIndex] or (alpha shl 24) @@ -160,7 +195,6 @@ class GameFontRenderer(font: Font) : FontRenderer(Minecraft.getMinecraft().gameS currentColor = currentColor or -16777216 - bold = false italic = false randomCase = false @@ -205,127 +239,11 @@ class GameFontRenderer(font: Font) : FontRenderer(Minecraft.getMinecraft().gameS return (x + getStringWidth(text)).toInt() } - private fun drawText(text: String?, x: Float, y: Float, colorHex: Int, ignoreColor: Boolean): Int { - if (text == null) - return 0 - if (text.isEmpty()) - return x.toInt() - - GlStateManager.translate(x - 1.5, y + 0.5, 0.0) - GlStateManager.enableAlpha() - GlStateManager.enableBlend() - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO) - GlStateManager.enableTexture2D() - - var hexColor = colorHex - if (hexColor and -67108864 == 0) { - hexColor = hexColor or -16777216 - } - - val alpha: Int = (hexColor shr 24 and 0xff) - - if (text.contains("§")) { - val parts = text.split("§") - - var currentFont = defaultFont - - var width = 0.0 - - // Color code states - var randomCase = false - var bold = false - var italic = false - var strikeThrough = false - var underline = false - - parts.forEachIndexed { index, part -> - if (part.isEmpty()) { - return@forEachIndexed - } - - if (index == 0) { - currentFont.drawString(part, width, 0.0, hexColor) - width += currentFont.getStringWidth(part) - } else { - val words = part.substring(1) - val type = part[0] - - when (val colorIndex = getColorIndex2(type)) { - in 0..15 -> { - if (!ignoreColor) { - hexColor = ColorUtils.hexColors[colorIndex] or (alpha shl 24) - } - - bold = false - italic = false - randomCase = false - underline = false - strikeThrough = false - } - 16 -> randomCase = true - 17 -> bold = true - 18 -> strikeThrough = true - 19 -> underline = true - 20 -> italic = true - 21 -> { - hexColor = colorHex - if (hexColor and -67108864 == 0) { - hexColor = hexColor or -16777216 - } - - bold = false - italic = false - randomCase = false - underline = false - strikeThrough = false - } - } - - currentFont = if (bold && italic) { - boldItalicFont - } else if (bold) { - boldFont - } else if (italic) { - italicFont - } else { - defaultFont - } - - currentFont.drawString(if (randomCase) ColorUtils.randomMagicText(words) else words, width, 0.0, hexColor) - - if (strikeThrough) { - RenderUtils.drawLine(width / 2.0 + 1, currentFont.height / 3.0, - (width + currentFont.getStringWidth(words)) / 2.0 + 1, currentFont.height / 3.0, - FONT_HEIGHT / 16F) - } - - if (underline) { - RenderUtils.drawLine(width / 2.0 + 1, currentFont.height / 2.0, - (width + currentFont.getStringWidth(words)) / 2.0 + 1, currentFont.height / 2.0, - FONT_HEIGHT / 16F) - } - - width += currentFont.getStringWidth(words) - } - } - } else { - defaultFont.drawString(text, 0.0, 0.0, hexColor) - } - - GlStateManager.translate(-(x - 1.5), -(y + 0.5), 0.0) - GlStateManager.resetColor() - GlStateManager.color(1f, 1f, 1f, 1f) - - return (x + getStringWidth(text)).toInt() - } - override fun getColorCode(charCode: Char) = - ColorUtils.hexColors[getColorIndex2(charCode)] + ColorUtils.hexColors[getColorIndex(charCode)] override fun getStringWidth(text: String): Int { - val TranslatedCurrentText = LanguageManager.replace(text) - var currentText = TranslatedCurrentText - + var currentText = text val event = TextEvent(currentText) FDPClient.eventManager.callEvent(event) @@ -340,16 +258,15 @@ class GameFontRenderer(font: Font) : FontRenderer(Minecraft.getMinecraft().gameS var italic = false parts.forEachIndexed { index, part -> - if (part.isEmpty()) { + if (part.isEmpty()) return@forEachIndexed - } if (index == 0) { width += currentFont.getStringWidth(part) } else { val words = part.substring(1) val type = part[0] - val colorIndex = getColorIndex2(type) + val colorIndex = getColorIndex(type) when { colorIndex < 16 -> { bold = false @@ -363,24 +280,22 @@ class GameFontRenderer(font: Font) : FontRenderer(Minecraft.getMinecraft().gameS } } - currentFont = if (bold && italic) { + currentFont = if (bold && italic) boldItalicFont - } else if (bold) { + else if (bold) boldFont - } else if (italic) { + else if (italic) italicFont - } else { + else defaultFont - } width += currentFont.getStringWidth(words) } } width / 2 - } else { + } else defaultFont.getStringWidth(currentText) / 2 - } } override fun getCharWidth(character: Char) = getStringWidth(character.toString()) @@ -389,17 +304,6 @@ class GameFontRenderer(font: Font) : FontRenderer(Minecraft.getMinecraft().gameS override fun bindTexture(location: ResourceLocation?) {} - - fun drawOutlineStringWithoutGL(s: String, x: Float, y: Float, color: Int,font: FontRenderer) { - - font.drawString(ColorUtils.stripColor(s), (x * 2 - 1).toInt(), (y * 2).toInt(), Color.BLACK.rgb) - font.drawString(ColorUtils.stripColor(s), (x * 2 + 1).toInt(), (y * 2).toInt(), Color.BLACK.rgb) - font.drawString(ColorUtils.stripColor(s), (x * 2).toInt(), (y * 2 - 1).toInt(), Color.BLACK.rgb) - font.drawString(ColorUtils.stripColor(s), (x * 2).toInt(), (y * 2 + 1).toInt(), Color.BLACK.rgb) - font.drawString(s, (x * 2).toInt(), (y * 2).toInt(), color) - } - - companion object { @JvmStatic fun getColorIndex(type: Char): Int { @@ -411,5 +315,13 @@ class GameFontRenderer(font: Font) : FontRenderer(Minecraft.getMinecraft().gameS else -> -1 } } + + fun drawOutlineStringWithoutGL(s: String, x: Float, y: Float, color: Int,fontRenderer: FontRenderer) { + fontRenderer.drawString(ColorUtils.stripColor(s), (x * 2 - 1).toInt(), (y * 2).toInt(), Color.BLACK.rgb) + fontRenderer.drawString(ColorUtils.stripColor(s), (x * 2 + 1).toInt(), (y * 2).toInt(), Color.BLACK.rgb) + fontRenderer.drawString(ColorUtils.stripColor(s), (x * 2).toInt(), (y * 2 - 1).toInt(), Color.BLACK.rgb) + fontRenderer.drawString(ColorUtils.stripColor(s), (x * 2).toInt(), (y * 2 + 1).toInt(), Color.BLACK.rgb) + fontRenderer.drawString(s, (x * 2).toInt(), (y * 2).toInt(), color) + } } } diff --git a/src/main/java/net/ccbluex/liquidbounce/utils/render/ColorUtils.kt b/src/main/java/net/ccbluex/liquidbounce/utils/render/ColorUtils.kt index 40bca37a31..8e18cd0fc8 100644 --- a/src/main/java/net/ccbluex/liquidbounce/utils/render/ColorUtils.kt +++ b/src/main/java/net/ccbluex/liquidbounce/utils/render/ColorUtils.kt @@ -9,6 +9,7 @@ import com.ibm.icu.text.NumberFormat import net.ccbluex.liquidbounce.features.module.modules.client.HUD import net.minecraft.client.renderer.GlStateManager import net.minecraft.util.ChatAllowedCharacters +import org.lwjgl.opengl.GL11 import java.awt.Color import java.util.* import java.util.regex.Pattern @@ -468,4 +469,13 @@ object ColorUtils { return Color(185, 185, 185, 190) } + @JvmStatic + fun glColor(color: Color) { + val red = color.red / 255f + val green = color.green / 255f + val blue = color.blue / 255f + val alpha = color.alpha / 255f + GL11.glColor4f(red, green, blue, alpha) + } + } diff --git a/src/main/java/net/ccbluex/liquidbounce/utils/render/RenderUtil.java b/src/main/java/net/ccbluex/liquidbounce/utils/render/RenderUtil.java new file mode 100644 index 0000000000..b9916408b9 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/utils/render/RenderUtil.java @@ -0,0 +1,1679 @@ +package net.ccbluex.liquidbounce.utils.render; + +import com.mojang.authlib.GameProfile; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.network.NetworkPlayerInfo; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.culling.Frustum; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.client.shader.Framebuffer; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.ARBShaderObjects; +import org.lwjgl.opengl.EXTFramebufferObject; +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.HashMap; +import java.util.Map; + +import static net.minecraft.client.renderer.GlStateManager.disableBlend; +import static net.minecraft.client.renderer.GlStateManager.enableTexture2D; +import static org.lwjgl.opengl.GL11.*; + +public enum RenderUtil { + INSTANCE; + + public static Minecraft mc = Minecraft.getMinecraft(); + private static Frustum frustrum; + private static final Map glCapMap = new HashMap<>(); + public static float delta; + + private RenderUtil() { + } + + public static void pre3D() { + GL11.glPushMatrix(); + GL11.glEnable((int)3042); + GL11.glBlendFunc((int)770, (int)771); + GL11.glShadeModel((int)7425); + GL11.glDisable((int)3553); + GL11.glEnable((int)2848); + GL11.glDisable((int)2929); + GL11.glDisable((int)2896); + GL11.glDepthMask((boolean)false); + GL11.glHint((int)3154, (int)4354); + } + + public static void render(int mode, Runnable render){ + glBegin(mode); + render.run(); + glEnd(); + } + + public static void setup2DRendering(Runnable f) { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glDisable(GL_TEXTURE_2D); + f.run(); + glEnable(GL_TEXTURE_2D); + GlStateManager.disableBlend(); + } + + public static Double interpolate(double oldValue, double newValue, double interpolationValue){ + return (oldValue + (newValue - oldValue) * interpolationValue); + } + + public static void setGlCap(final int cap, final boolean state) { + glCapMap.put(cap, glGetBoolean(cap)); + setGlState(cap, state); + } + + + public static void setGlState(final int cap, final boolean state) { + if (state) + glEnable(cap); + else + glDisable(cap); + } + + public static void post3D() { + GL11.glDepthMask((boolean)true); + GL11.glEnable((int)2929); + GL11.glDisable((int)2848); + GL11.glEnable((int)3553); + GL11.glDisable((int)3042); + GL11.glPopMatrix(); + GL11.glColor4f((float)1.0f, (float)1.0f, (float)1.0f, (float)1.0f); + if (!GL11.glIsEnabled((int)2896)) { + GL11.glEnable((int)2896); + } + } + + public static void drawArrow(double x, double y, int lineWidth, int color, double length) { + start2D(); + GL11.glPushMatrix(); + GL11.glLineWidth(lineWidth); + setColor(new Color(color)); + GL11.glBegin(GL_LINE_STRIP); + GL11.glVertex2d(x, y); + GL11.glVertex2d(x + 3, y + length); + GL11.glVertex2d(x + 3 * 2, y); + GL11.glEnd(); + GL11.glPopMatrix(); + stop2D(); + } + + public static void resetColor() { + GlStateManager.color(1, 1, 1, 1); + } + + public static double animate(double endPoint, double current, double speed) { + boolean shouldContinueAnimation = endPoint > current; + if (speed < 0.0D) { + speed = 0.0D; + } else if (speed > 1.0D) { + speed = 1.0D; + } + + double dif = Math.max(endPoint, current) - Math.min(endPoint, current); + double factor = dif * speed; + return current + (shouldContinueAnimation ? factor : -factor); + } + + public static void setColor(Color c) { + GL11.glColor4d(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 255f); + } + + public static void drawCheck(double x, double y, int lineWidth, int color) { + start2D(); + GlStateManager.enableBlend(); + GL11.glPushMatrix(); + GL11.glLineWidth((float)lineWidth); + setColor(new Color(color)); + GL11.glBegin(3); + GL11.glVertex2d(x, y); + GL11.glVertex2d(x + 2.0, y + 2.0); + GL11.glVertex2d(x + 5.0, y - 2.0); + GL11.glEnd(); + GL11.glPopMatrix(); + GlStateManager.disableBlend(); + stop2D(); + } + + public static int darker(int color, float factor) { + int r = (int)((float)(color >> 16 & 255) * factor); + int g = (int)((float)(color >> 8 & 255) * factor); + int b = (int)((float)(color & 255) * factor); + int a = color >> 24 & 255; + return (r & 255) << 16 | (g & 255) << 8 | b & 255 | (a & 255) << 24; + } + + public static void enableRender2D() { + GL11.glEnable(3042); + GL11.glDisable(2884); + GL11.glDisable(3553); + GL11.glEnable(2848); + GL11.glBlendFunc(770, 771); + GL11.glLineWidth(1.0f); + } + public static void disableRender2D() { + GL11.glDisable(3042); + GL11.glEnable(2884); + GL11.glEnable(3553); + GL11.glDisable(2848); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.shadeModel(7424); + GlStateManager.disableBlend(); + GlStateManager.enableTexture2D(); + } + + + + public static void drawGradientRect(double left, double top, double right, double bottom, boolean sideways, int startColor, int endColor) { + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glBegin(GL11.GL_QUADS); + color(startColor); + if (sideways) { + GL11.glVertex2d(left, top); + GL11.glVertex2d(left, bottom); + color(endColor); + GL11.glVertex2d(right, bottom); + GL11.glVertex2d(right, top); + } else { + GL11.glVertex2d(left, top); + color(endColor); + GL11.glVertex2d(left, bottom); + GL11.glVertex2d(right, bottom); + color(startColor); + GL11.glVertex2d(right, top); + } + GL11.glEnd(); + GL11.glDisable(GL11.GL_BLEND); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } + + public static void drawRDRect(float left, float top, float width, float height, int color) { + float f3 = (float) (color >> 24 & 255) / 255.0F; + float f = (float) (color >> 16 & 255) / 255.0F; + float f1 = (float) (color >> 8 & 255) / 255.0F; + float f2 = (float) (color & 255) / 255.0F; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.color(f, f1, f2, f3); + worldrenderer.begin(7, DefaultVertexFormats.POSITION); + worldrenderer.pos(left, top + height, 0.0D).endVertex(); + worldrenderer.pos(left + width, top + height, 0.0D).endVertex(); + worldrenderer.pos(left + width, top, 0.0D).endVertex(); + worldrenderer.pos(left, top, 0.0D).endVertex(); + tessellator.draw(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static int reAlpha(int color, float alpha) { + Color c = new Color(color); + float r = ((float) 1 / 255) * c.getRed(); + float g = ((float) 1 / 255) * c.getGreen(); + float b = ((float) 1 / 255) * c.getBlue(); + return new Color(r, g, b, alpha).getRGB(); + } + + public static Color blend(final Color color1, final Color color2, final double ratio) { + final float r = (float)ratio; + final float ir = 1.0f - r; + final float[] rgb1 = new float[3]; + final float[] rgb2 = new float[3]; + color1.getColorComponents(rgb1); + color2.getColorComponents(rgb2); + final Color color3 = new Color(rgb1[0] * r + rgb2[0] * ir, rgb1[1] * r + rgb2[1] * ir, rgb1[2] * r + rgb2[2] * ir); + return color3; + } + public static void doGlScissor(double mainx, double d, double e, double f) { + Minecraft mc = Minecraft.getMinecraft(); + int scaleFactor = 1; + int k = mc.gameSettings.guiScale; + if (k == 0) { + k = 1000; + } + while (scaleFactor < k && mc.displayWidth / (scaleFactor + 1) >= 320 && mc.displayHeight / (scaleFactor + 1) >= 240) { + ++scaleFactor; + } + GL11.glScissor((int) (mainx * scaleFactor), (int) (mc.displayHeight - (d + f) * scaleFactor), (int) (e * scaleFactor), (int) (f * scaleFactor)); + } + public static boolean isHovering(float x, float y, float width, float height, int mouseX, int mouseY) { + return (float)mouseX >= x && (float)mouseY >= y && (float)mouseX < x + width && (float)mouseY < y + height; + } + public static void scale(float x, float y, float scale, Runnable data) { + GL11.glPushMatrix(); + GL11.glTranslatef(x, y, 0.0F); + GL11.glScalef(scale, scale, 1.0F); + GL11.glTranslatef(-x, -y, 0.0F); + data.run(); + GL11.glPopMatrix(); + } + public static void start2D() { + glEnable(3042); + glDisable(3553); + glBlendFunc(770, 771); + glEnable(2848); + } + + public static void stop2D() { + glEnable(3553); + glDisable(3042); + glDisable(2848); + enableTexture2D(); + disableBlend(); + glColor4f(1, 1, 1, 1); + } + + public static double interpolate(double newPos, double oldPos) { + return oldPos + (newPos - oldPos) * (double)Minecraft.getMinecraft().timer.renderPartialTicks; + } + + public static boolean isInViewFrustrum(Entity entity) { + return RenderUtil.isInViewFrustrum(entity.getEntityBoundingBox()) || entity.ignoreFrustumCheck; + } + + public static void drawHorizontalLine(float x, float y, float x1, float thickness, int color) { + RenderUtil.drawRect2(x, y, x1, y + thickness, color); + } + + public static void drawRect2(double x, double y, double x2, double y2, int color) { + RenderUtil.drawRect(x, y, x2, y2, color); + } + + public static void drawVerticalLine(float x, float y, float y1, float thickness, int color) { + RenderUtil.drawRect2(x, y, x + thickness, y1, color); + } + + + public static void drawRect(float x, float y, double x1, float y1, Color color) { + RenderUtil.drawRect(x, y, x1, y1, color.getRGB()); + } + public static void drawHollowBox(float x, float y, float x1, float y1, float thickness, int color) { + RenderUtil.drawHorizontalLine(x, y, x1, thickness, color); + RenderUtil.drawHorizontalLine(x, y1, x1, thickness, color); + RenderUtil.drawVerticalLine(x, y, y1, thickness, color); + RenderUtil.drawVerticalLine(x1 - thickness, y, y1, thickness, color); + } + + + + public static void rectangle(double left, double top, double right, double bottom, int color) { + + double var5; + + if (left < right) { + var5 = left; + left = right; + right = var5; + } + + if (top < bottom) { + var5 = top; + top = bottom; + bottom = var5; + } + + float var11 = (float) (color >> 24 & 255) / 255.0F; + float var6 = (float) (color >> 16 & 255) / 255.0F; + float var7 = (float) (color >> 8 & 255) / 255.0F; + float var8 = (float) (color & 255) / 255.0F; + WorldRenderer BufferBuilder = Tessellator.getInstance().getWorldRenderer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.color(var6, var7, var8, var11); + BufferBuilder.begin(7, DefaultVertexFormats.POSITION); + BufferBuilder.pos(left, bottom, 0.0D).endVertex(); + BufferBuilder.pos(right, bottom, 0.0D).endVertex(); + BufferBuilder.pos(right, top, 0.0D).endVertex(); + BufferBuilder.pos(left, top, 0.0D).endVertex(); + Tessellator.getInstance().draw(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + } + + public static void rectangleBordered(double x, double y, double x1, double y1, double width, int internalColor, + int borderColor) { + rectangle(x + width, y + width, x1 - width, y1 - width, internalColor); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + rectangle(x + width, y, x1 - width, y + width, borderColor); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + rectangle(x, y, x + width, y1, borderColor); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + rectangle(x1 - width, y, x1, y1, borderColor); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + rectangle(x + width, y1 - width, x1 - width, y1, borderColor); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + } + + public static void drawBordered(double x2, double y2, double width, double height, double length, int innerColor, int outerColor) { + Gui.drawRect((int) x2, (int) y2, (int) (x2 + width), (int) y2 + (int) height, innerColor); + Gui.drawRect((int) (x2 - length), (int) y2, (int) x2, (int) y2 + (int) height, outerColor); + Gui.drawRect((int) (x2 - length), (int) y2 - (int) length, (int) x2 + (int) width, (int) y2, outerColor); + Gui.drawRect((int) (x2 + width), (int) y2 - (int) length, (int) x2 + (int) width + (int) length, (int) y2 + (int) height + (int) length, outerColor); + Gui.drawRect((int) (x2 - length), (int) y2 + (int) height, (int) x2 + (int) width, (int) y2 + (int) height + (int) length, outerColor); + } + + public static void drawImage(float x, float y, final int width, final int height, final ResourceLocation image, Color color) { + new ScaledResolution(Minecraft.getMinecraft()); + GL11.glDisable(2929); + GL11.glEnable(3042); + GL11.glDepthMask(false); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glColor4f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 1.0f); + Minecraft.getMinecraft().getTextureManager().bindTexture(image); + Gui.drawModalRectWithCustomSizedTexture((int) x, (int) y, 0.0f, 0.0f, width, height, (float) width, (float) height); + GL11.glDepthMask(true); + GL11.glDisable(3042); + GL11.glEnable(2929); + } + + public static void drawGradientSideways(double left, double top, double right, double bottom, int col1, int col2) { + float f = (float) (col1 >> 24 & 255) / 255.0f; + float f1 = (float) (col1 >> 16 & 255) / 255.0f; + float f2 = (float) (col1 >> 8 & 255) / 255.0f; + float f3 = (float) (col1 & 255) / 255.0f; + float f4 = (float) (col2 >> 24 & 255) / 255.0f; + float f5 = (float) (col2 >> 16 & 255) / 255.0f; + float f6 = (float) (col2 >> 8 & 255) / 255.0f; + float f7 = (float) (col2 & 255) / 255.0f; + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glBlendFunc(770, 771); + GL11.glEnable(2848); + GL11.glShadeModel(7425); + GL11.glPushMatrix(); + GL11.glBegin(7); + GL11.glColor4f(f1, f2, f3, f); + GL11.glVertex2d(left, top); + GL11.glVertex2d(left, bottom); + GL11.glColor4f(f5, f6, f7, f4); + GL11.glVertex2d(right, bottom); + GL11.glVertex2d(right, top); + GL11.glEnd(); + GL11.glPopMatrix(); + GL11.glEnable(3553); + GL11.glDisable(3042); + GL11.glDisable(2848); + GL11.glShadeModel(7424); + } + + public static void drawScaledCustomSizeModalCircle(int x, int y, float u, float v, int uWidth, int vHeight, int width, int height, float tileWidth, float tileHeight) { + float f = 1.0F / tileWidth; + float f1 = 1.0F / tileHeight; + GL11.glColor4f(1, 1, 1, 1); + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer bufferbuilder = tessellator.getWorldRenderer(); + bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX); + bufferbuilder.pos(x, y + height, 0.0D).tex(u * f, (v + (float) vHeight) * f1).endVertex(); + bufferbuilder.pos(x + width, y + height, 0.0D).tex((u + (float) uWidth) * f, (v + (float) vHeight) * f1).endVertex(); + bufferbuilder.pos(x + width, y, 0.0D).tex((u + (float) uWidth) * f, v * f1).endVertex(); + bufferbuilder.pos(x, y, 0.0D).tex(u * f, v * f1).endVertex(); + tessellator.draw(); + } + + public static void drawRoundedRect(float x, float y, float width, float height, float edgeRadius, int color, float borderWidth, int borderColor) { + if (color == 16777215) color = -65794; + if (borderColor == 16777215) borderColor = -65794; + + if (edgeRadius < 0.0F) { + edgeRadius = 0.0F; + } + + if (edgeRadius > width / 2.0F) { + edgeRadius = width / 2.0F; + } + + if (edgeRadius > height / 2.0F) { + edgeRadius = height / 2.0F; + } + + drawRDRect(x + edgeRadius, y + edgeRadius, width - edgeRadius * 2.0F, height - edgeRadius * 2.0F, color); + drawRDRect(x + edgeRadius, y, width - edgeRadius * 2.0F, edgeRadius, color); + drawRDRect(x + edgeRadius, y + height - edgeRadius, width - edgeRadius * 2.0F, edgeRadius, color); + drawRDRect(x, y + edgeRadius, edgeRadius, height - edgeRadius * 2.0F, color); + drawRDRect(x + width - edgeRadius, y + edgeRadius, edgeRadius, height - edgeRadius * 2.0F, color); + enableRender2D(); + color(color); + GL11.glBegin(6); + float centerX = x + edgeRadius; + float centerY = y + edgeRadius; + GL11.glVertex2d(centerX, centerY); + int vertices = (int) Math.min(Math.max(edgeRadius, 10.0F), 90.0F); + + int i; + double angleRadians; + for (i = 0; i < vertices + 1; ++i) { + angleRadians = 6.283185307179586D * (double) (i + 180) / (double) (vertices * 4); + GL11.glVertex2d((double) centerX + Math.sin(angleRadians) * (double) edgeRadius, (double) centerY + Math.cos(angleRadians) * (double) edgeRadius); + } + + GL11.glEnd(); + GL11.glBegin(6); + centerX = x + width - edgeRadius; + centerY = y + edgeRadius; + GL11.glVertex2d(centerX, centerY); + vertices = (int) Math.min(Math.max(edgeRadius, 10.0F), 90.0F); + + for (i = 0; i < vertices + 1; ++i) { + angleRadians = 6.283185307179586D * (double) (i + 90) / (double) (vertices * 4); + GL11.glVertex2d((double) centerX + Math.sin(angleRadians) * (double) edgeRadius, (double) centerY + Math.cos(angleRadians) * (double) edgeRadius); + } + + GL11.glEnd(); + GL11.glBegin(6); + centerX = x + edgeRadius; + centerY = y + height - edgeRadius; + GL11.glVertex2d(centerX, centerY); + vertices = (int) Math.min(Math.max(edgeRadius, 10.0F), 90.0F); + + for (i = 0; i < vertices + 1; ++i) { + angleRadians = 6.283185307179586D * (double) (i + 270) / (double) (vertices * 4); + GL11.glVertex2d((double) centerX + Math.sin(angleRadians) * (double) edgeRadius, (double) centerY + Math.cos(angleRadians) * (double) edgeRadius); + } + + GL11.glEnd(); + GL11.glBegin(6); + + centerX = x + width - edgeRadius; + centerY = y + height - edgeRadius; + GL11.glVertex2d(centerX, centerY); + vertices = (int) Math.min(Math.max(edgeRadius, 10.0F), 90.0F); + + for (i = 0; i < vertices + 1; ++i) { + angleRadians = 6.283185307179586D * (double) i / (double) (vertices * 4); + GL11.glVertex2d((double) centerX + Math.sin(angleRadians) * (double) edgeRadius, (double) centerY + Math.cos(angleRadians) * (double) edgeRadius); + } + + GL11.glEnd(); + color(borderColor); + GL11.glLineWidth(borderWidth); + GL11.glBegin(3); + centerX = x + edgeRadius; + centerY = y + edgeRadius; + vertices = (int) Math.min(Math.max(edgeRadius, 10.0F), 90.0F); + + for (i = vertices; i >= 0; --i) { + angleRadians = 6.283185307179586D * (double) (i + 180) / (double) (vertices * 4); + GL11.glVertex2d((double) centerX + Math.sin(angleRadians) * (double) edgeRadius, (double) centerY + Math.cos(angleRadians) * (double) edgeRadius); + } + + GL11.glVertex2d((x + edgeRadius), y); + GL11.glVertex2d((x + width - edgeRadius), y); + centerX = x + width - edgeRadius; + centerY = y + edgeRadius; + + for (i = vertices; i >= 0; --i) { + angleRadians = 6.283185307179586D * (double) (i + 90) / (double) (vertices * 4); + GL11.glVertex2d((double) centerX + Math.sin(angleRadians) * (double) edgeRadius, (double) centerY + Math.cos(angleRadians) * (double) edgeRadius); + } + + GL11.glVertex2d((x + width), (y + edgeRadius)); + GL11.glVertex2d((x + width), (y + height - edgeRadius)); + centerX = x + width - edgeRadius; + centerY = y + height - edgeRadius; + + for (i = vertices; i >= 0; --i) { + angleRadians = 6.283185307179586D * (double) i / (double) (vertices * 4); + GL11.glVertex2d((double) centerX + Math.sin(angleRadians) * (double) edgeRadius, (double) centerY + Math.cos(angleRadians) * (double) edgeRadius); + } + + GL11.glVertex2d((x + width - edgeRadius), (y + height)); + GL11.glVertex2d((x + edgeRadius), (y + height)); + + centerX = x + edgeRadius; + centerY = y + height - edgeRadius; + + for (i = vertices; i >= 0; --i) { + angleRadians = 6.283185307179586D * (double) (i + 270) / (double) (vertices * 4); + GL11.glVertex2d((double) centerX + Math.sin(angleRadians) * (double) edgeRadius, (double) centerY + Math.cos(angleRadians) * (double) edgeRadius); + } + + GL11.glVertex2d(x, y + height - edgeRadius); + GL11.glVertex2d(x, y + edgeRadius); + GL11.glEnd(); + disableRender2D(); + } + + + + public static void drawRect(double left, double top, double right, double bottom, int color) { + if (left < right) { + double i = left; + left = right; + right = i; + } + if (top < bottom) { + double j = top; + top = bottom; + bottom = j; + } + float f3 = (float)(color >> 24 & 255) / 255.0f; + float f = (float)(color >> 16 & 255) / 255.0f; + float f1 = (float)(color >> 8 & 255) / 255.0f; + float f2 = (float)(color & 255) / 255.0f; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.color(f, f1, f2, f3); + worldrenderer.begin(7, DefaultVertexFormats.POSITION); + worldrenderer.pos(left, bottom, 0.0).endVertex(); + worldrenderer.pos(right, bottom, 0.0).endVertex(); + worldrenderer.pos(right, top, 0.0).endVertex(); + worldrenderer.pos(left, top, 0.0).endVertex(); + tessellator.draw(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static boolean isInViewFrustrum(AxisAlignedBB bb) { + Entity current = Minecraft.getMinecraft().getRenderViewEntity(); + frustrum.setPosition(current.posX, current.posY, current.posZ); + return frustrum.isBoundingBoxInFrustum(bb); + } + + public static void drawBorderedRect(final float x, final double d, final float x2, final double e, final float l1, + final int col1, final int col2) { + Gui.drawRect((int) x, (int) d, (int) x2, (int) e, col2); + final float f = (col1 >> 24 & 0xFF) / 255.0f; + final float f2 = (col1 >> 16 & 0xFF) / 255.0f; + final float f3 = (col1 >> 8 & 0xFF) / 255.0f; + final float f4 = (col1 & 0xFF) / 255.0f; + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glBlendFunc(770, 771); + GL11.glEnable(2848); + GL11.glPushMatrix(); + GL11.glColor4f(f2, f3, f4, f); + GL11.glLineWidth(l1); + GL11.glBegin(1); + GL11.glVertex2d(x, d); + GL11.glVertex2d(x, e); + GL11.glVertex2d(x2, e); + GL11.glVertex2d(x2, d); + GL11.glVertex2d(x, d); + GL11.glVertex2d(x2, d); + GL11.glVertex2d(x, e); + GL11.glVertex2d(x2, e); + GL11.glEnd(); + GL11.glPopMatrix(); + GL11.glEnable(3553); + GL11.glDisable(3042); + GL11.glDisable(2848); + } + + public static void drawGradientRect(float left, float top, float right, float bottom, int startColor, int endColor) { + float f = (float) (startColor >> 24 & 255) / 255.0F; + float f1 = (float) (startColor >> 16 & 255) / 255.0F; + float f2 = (float) (startColor >> 8 & 255) / 255.0F; + float f3 = (float) (startColor & 255) / 255.0F; + float f4 = (float) (endColor >> 24 & 255) / 255.0F; + float f5 = (float) (endColor >> 16 & 255) / 255.0F; + float f6 = (float) (endColor >> 8 & 255) / 255.0F; + float f7 = (float) (endColor & 255) / 255.0F; + GlStateManager.disableTexture2D(); + GlStateManager.enableBlend(); + GlStateManager.disableAlpha(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.shadeModel(7425); + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR); + worldrenderer.pos(right, top, 0).color(f1, f2, f3, f).endVertex(); + worldrenderer.pos(left, top, 0).color(f1, f2, f3, f).endVertex(); + worldrenderer.pos(left, bottom, 0).color(f5, f6, f7, f4).endVertex(); + worldrenderer.pos(right, bottom, 0).color(f5, f6, f7, f4).endVertex(); + tessellator.draw(); + GlStateManager.shadeModel(7424); + GlStateManager.disableBlend(); + GlStateManager.enableAlpha(); + GlStateManager.enableTexture2D(); + } + + public static int getColor(int color) { + int r = color >> 16 & 0xFF; + int g = color >> 8 & 0xFF; + int b = color & 0xFF; + int a = (int) 255; + return (r & 0xFF) << 16 | (g & 0xFF) << 8 | b & 0xFF | (a & 0xFF) << 24; + } + public static void drawCheckeredBackground(float x, float y, float x2, float y2) { + RenderUtil.drawRect(x, y, x2, y2, RenderUtil.getColor(16777215)); + for(boolean offset = false; y < y2; ++y) { + for(float x1 = x + (float)((offset = !offset) ? 1 : 0); x1 < x2; x1 += 2.0F) { + if (x1 <= x2 - 1.0F) { + RenderUtil.drawRect(x1, y, x1 + 1.0F, y + 1.0F, RenderUtil.getColor(8421504)); + } + } + } + } + + public static double interpolatee(double current, double old, double scale) { + return old + (current - old) * scale; + } + + public static void pre() { + GL11.glDisable((int)2929); + GL11.glDisable((int)3553); + GL11.glEnable((int)3042); + GL11.glBlendFunc((int)770, (int)771); + } + + public static void post() { + GL11.glDisable((int)3042); + GL11.glEnable((int)3553); + GL11.glEnable((int)2929); + GL11.glColor3d((double)1.0, (double)1.0, (double)1.0); + } + + public static int rainbow(int delay) { + double rainbowState = Math.ceil((double)(System.currentTimeMillis() + (long)delay) / 20.0); + return Color.getHSBColor((float)((rainbowState %= 360.0) / 360.0), 0.5f, 0.7f).brighter().getRGB(); + } + + public static Color rainbowEffect(int delay) { + float hue = (float)(System.nanoTime() + (long)delay) / 2.0E10f % 1.0f; + Color color = new Color((int)Long.parseLong(Integer.toHexString(Color.HSBtoRGB(hue, 1.0f, 1.0f)), 16)); + return new Color((float)color.getRed() / 255.0f, (float)color.getGreen() / 255.0f, (float)color.getBlue() / 255.0f, (float)color.getAlpha() / 255.0f); + } + + public static void drawFullscreenImage(ResourceLocation image) { + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + GL11.glDisable((int)2929); + GL11.glDepthMask((boolean)false); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glColor4f((float)1.0f, (float)1.0f, (float)1.0f, (float)1.0f); + GL11.glDisable((int)3008); + Minecraft.getMinecraft().getTextureManager().bindTexture(image); + Gui.drawModalRectWithCustomSizedTexture(0, 0, 0.0f, 0.0f, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight()); + GL11.glDepthMask((boolean)true); + GL11.glEnable((int)2929); + GL11.glEnable((int)3008); + GL11.glColor4f((float)1.0f, (float)1.0f, (float)1.0f, (float)1.0f); + } + + public static void drawPlayerHead(String playerName, int x, int y, int width, int height) { + Minecraft.getMinecraft(); + for (EntityPlayer player : Minecraft.getMinecraft().theWorld.playerEntities) { + if (!playerName.equalsIgnoreCase(player.getName())) continue; + GameProfile profile = new GameProfile(player.getUniqueID(), player.getName()); + NetworkPlayerInfo networkplayerinfo1 = new NetworkPlayerInfo(profile); + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + GL11.glDisable((int)2929); + GL11.glEnable((int)3042); + GL11.glDepthMask((boolean)false); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glColor4f((float)1.0f, (float)1.0f, (float)1.0f, (float)1.0f); + Minecraft.getMinecraft().getTextureManager().bindTexture(networkplayerinfo1.getLocationSkin()); + Gui.drawModalRectWithCustomSizedTexture(x, y, 0.0f, 0.0f, width, height, width, height); + GL11.glDepthMask((boolean)true); + GL11.glDisable((int)3042); + GL11.glEnable((int)2929); + } + } + + public static double getAnimationState(double n, final double n2, final double n3) { + final float n4 = (float)(RenderUtil.delta * n3); + if (n < n2) { + if (n + n4 < n2) { + n += n4; + }else { + n = n2; + } + }else if (n - n4 > n2) { + n -= n4; + }else { + n = n2; + } + return n; + } + + public static void glColor(Color color) { + GL11.glColor4f((float)((float)color.getRed() / 255.0f), (float)((float)color.getGreen() / 255.0f), (float)((float)color.getBlue() / 255.0f), (float)((float)color.getAlpha() / 255.0f)); + } + + public static String getShaderCode(InputStreamReader file) { + String shaderSource = ""; + try { + String line; + BufferedReader reader = new BufferedReader(file); + while ((line = reader.readLine()) != null) { + shaderSource = String.valueOf(String.valueOf(shaderSource)) + line + "\n"; + } + reader.close(); + } + catch (IOException e) { + e.printStackTrace(); + System.exit(-1); + } + return shaderSource.toString(); + } + + public static void drawImage(ResourceLocation image, int x, int y, int width, int height) { + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + GL11.glDisable((int)2929); + GL11.glEnable((int)3042); + GL11.glDepthMask((boolean)false); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glColor4f((float)1.0f, (float)1.0f, (float)1.0f, (float)1.0f); + Minecraft.getMinecraft().getTextureManager().bindTexture(image); + Gui.drawModalRectWithCustomSizedTexture(x, y, 0.0f, 0.0f, width, height, width, height); + GL11.glDepthMask((boolean)true); + GL11.glDisable((int)3042); + GL11.glEnable((int)2929); + } + + public static void drawOutlinedRect(int x, int y, int width, int height, int lineSize, Color lineColor, Color backgroundColor) { + RenderUtil.drawRect((float)x, (float)y, (float)width, (float)height, backgroundColor.getRGB()); + RenderUtil.drawRect((float)x, (float)y, (float)width, (float)(y + lineSize), lineColor.getRGB()); + RenderUtil.drawRect((float)x, (float)(height - lineSize), (float)width, (float)height, lineColor.getRGB()); + RenderUtil.drawRect((float)x, (float)(y + lineSize), (float)(x + lineSize), (float)(height - lineSize), lineColor.getRGB()); + RenderUtil.drawRect((float)(width - lineSize), (float)(y + lineSize), (float)width, (float)(height - lineSize), lineColor.getRGB()); + } + + public static void drawImage(ResourceLocation image, int x, int y, int width, int height, Color color) { + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + GL11.glDisable((int)2929); + GL11.glEnable((int)3042); + GL11.glDepthMask((boolean)false); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glColor4f((float)((float)color.getRed() / 255.0f), (float)((float)color.getBlue() / 255.0f), (float)((float)color.getRed() / 255.0f), (float)1.0f); + Minecraft.getMinecraft().getTextureManager().bindTexture(image); + Gui.drawModalRectWithCustomSizedTexture(x, y, 0.0f, 0.0f, width, height, width, height); + GL11.glDepthMask((boolean)true); + GL11.glDisable((int)3042); + GL11.glEnable((int)2929); + } + + public static void doGlScissor(int x, int y, int width, int height) { + Minecraft mc = Minecraft.getMinecraft(); + ScaledResolution scale = new ScaledResolution(mc); + int scaleFactor = 1; + int k = mc.gameSettings.guiScale; + if (k == 0) { + k = 1000; + } + while (scaleFactor < k && mc.displayWidth / (scaleFactor + 1) >= 320 && mc.displayHeight / (scaleFactor + 1) >= 240) { + ++scaleFactor; + } + GL11.glScalef((float)0.5f, (float)0.5f, (float)0.5f); + GL11.glScissor((int)(x * scaleFactor), (int)(mc.displayHeight - (y + height) * scaleFactor), (int)(width * scaleFactor), (int)(height * scaleFactor)); + GL11.glScalef((float)2.0f, (float)2.0f, (float)2.0f); + } + + public static void doGlScissor2(int x, int y, int width, int height) { + RenderUtil.doGlScissor(x, y, width - x, height - y); + } + + public static void drawRect(float x1, float y1, float x2, float y2, int color) { + GL11.glPushMatrix(); + GL11.glEnable((int)3042); + GL11.glDisable((int)3553); + GL11.glBlendFunc((int)770, (int)771); + GL11.glEnable((int)2848); + GL11.glPushMatrix(); + RenderUtil.color(color); + GL11.glBegin((int)7); + GL11.glVertex2d((double)x2, (double)y1); + GL11.glVertex2d((double)x1, (double)y1); + GL11.glVertex2d((double)x1, (double)y2); + GL11.glVertex2d((double)x2, (double)y2); + GL11.glEnd(); + GL11.glPopMatrix(); + GL11.glEnable((int)3553); + GL11.glDisable((int)3042); + GL11.glDisable((int)2848); + GL11.glPopMatrix(); + } + + public static void color(int color) { + float f = (float)(color >> 24 & 255) / 255.0f; + float f1 = (float)(color >> 16 & 255) / 255.0f; + float f2 = (float)(color >> 8 & 255) / 255.0f; + float f3 = (float)(color & 255) / 255.0f; + GL11.glColor4f((float)f1, (float)f2, (float)f3, (float)f); + } + + public static int createShader(String shaderCode, int shaderType) throws Exception { + int shader = 0; + try { + shader = ARBShaderObjects.glCreateShaderObjectARB((int)shaderType); + if (shader == 0) { + return 0; + } + } + catch (Exception exc) { + ARBShaderObjects.glDeleteObjectARB((int)shader); + throw exc; + } + ARBShaderObjects.glShaderSourceARB((int)shader, (CharSequence)shaderCode); + ARBShaderObjects.glCompileShaderARB((int)shader); + if (ARBShaderObjects.glGetObjectParameteriARB((int)shader, (int)35713) == 0) { + throw new RuntimeException("Error creating shader:"); + } + return shader; + } + + public void drawCircle(int x, int y, float radius, int color) { + float alpha = (float)(color >> 24 & 255) / 255.0f; + float red = (float)(color >> 16 & 255) / 255.0f; + float green = (float)(color >> 8 & 255) / 255.0f; + float blue = (float)(color & 255) / 255.0f; + boolean blend = GL11.glIsEnabled((int)3042); + boolean line = GL11.glIsEnabled((int)2848); + boolean texture = GL11.glIsEnabled((int)3553); + if (!blend) { + GL11.glEnable((int)3042); + } + if (!line) { + GL11.glEnable((int)2848); + } + if (texture) { + GL11.glDisable((int)3553); + } + GL11.glBlendFunc((int)770, (int)771); + GL11.glColor4f((float)red, (float)green, (float)blue, (float)alpha); + GL11.glBegin((int)9); + for (int i = 0; i <= 360; ++i) { + GL11.glVertex2d((double)((double)x + Math.sin((double)i * 3.141526 / 180.0) * (double)radius), (double)((double)y + Math.cos((double)i * 3.141526 / 180.0) * (double)radius)); + } + GL11.glEnd(); + if (texture) { + GL11.glEnable((int)3553); + } + if (!line) { + GL11.glDisable((int)2848); + } + if (!blend) { + GL11.glDisable((int)3042); + } + } + + public static void outlineOne() { + GL11.glPushAttrib((int)1048575); + GL11.glDisable((int)3008); + GL11.glDisable((int)3553); + GL11.glDisable((int)2896); + GL11.glEnable((int)3042); + GL11.glBlendFunc((int)770, (int)771); + GL11.glLineWidth((float)4.0f); + GL11.glEnable((int)2848); + GL11.glEnable((int)2960); + GL11.glClear((int)1024); + GL11.glClearStencil((int)15); + GL11.glStencilFunc((int)512, (int)1, (int)15); + GL11.glStencilOp((int)7681, (int)7681, (int)7681); + GL11.glPolygonMode((int)1032, (int)6913); + } + + public static void outlineTwo() { + GL11.glStencilFunc((int)512, (int)0, (int)15); + GL11.glStencilOp((int)7681, (int)7681, (int)7681); + GL11.glPolygonMode((int)1032, (int)6914); + } + + public static void outlineThree() { + GL11.glStencilFunc((int)514, (int)1, (int)15); + GL11.glStencilOp((int)7680, (int)7680, (int)7680); + GL11.glPolygonMode((int)1032, (int)6913); + } + + public static void outlineFour() { + GL11.glDepthMask((boolean)false); + GL11.glDisable((int)2929); + GL11.glEnable((int)10754); + GL11.glPolygonOffset((float)1.0f, (float)-2000000.0f); + GL11.glColor4f((float)0.9529412f, (float)0.6117647f, (float)0.07058824f, (float)1.0f); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 240.0f); + } + + public static void outlineFive() { + GL11.glPolygonOffset((float)1.0f, (float)2000000.0f); + GL11.glDisable((int)10754); + GL11.glEnable((int)2929); + GL11.glDepthMask((boolean)true); + GL11.glDisable((int)2960); + GL11.glDisable((int)2848); + GL11.glHint((int)3154, (int)4352); + GL11.glEnable((int)3042); + GL11.glEnable((int)2896); + GL11.glEnable((int)3553); + GL11.glEnable((int)3008); + GL11.glPopAttrib(); + } + + public static void drawOutlinedBoundingBox(AxisAlignedBB aa) { + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldRenderer = tessellator.getWorldRenderer(); + worldRenderer.begin(3, DefaultVertexFormats.POSITION); + worldRenderer.pos(aa.minX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.minY, aa.minZ).endVertex(); + tessellator.draw(); + worldRenderer.begin(3, DefaultVertexFormats.POSITION); + worldRenderer.pos(aa.minX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.minZ).endVertex(); + tessellator.draw(); + worldRenderer.begin(1, DefaultVertexFormats.POSITION); + worldRenderer.pos(aa.minX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.maxZ).endVertex(); + tessellator.draw(); + } + + public static void drawBoundingBox(AxisAlignedBB aa) { + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldRenderer = tessellator.getWorldRenderer(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(aa.minX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.maxZ).endVertex(); + tessellator.draw(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(aa.maxX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.minX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.maxZ).endVertex(); + tessellator.draw(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(aa.minX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.minZ).endVertex(); + tessellator.draw(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(aa.minX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.minX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.minZ).endVertex(); + tessellator.draw(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(aa.minX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.minX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.minZ).endVertex(); + tessellator.draw(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(aa.minX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.minX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.maxZ).endVertex(); + tessellator.draw(); + } + + public static void drawOutlinedBlockESP(double x, double y, double z, float red, float green, float blue, float alpha, float lineWidth) { + GL11.glPushMatrix(); + GL11.glEnable((int)3042); + GL11.glBlendFunc((int)770, (int)771); + GL11.glDisable((int)3553); + GL11.glEnable((int)2848); + GL11.glDisable((int)2929); + GL11.glDepthMask((boolean)false); + GL11.glLineWidth((float)lineWidth); + GL11.glColor4f((float)red, (float)green, (float)blue, (float)alpha); + RenderUtil.drawOutlinedBoundingBox(new AxisAlignedBB(x, y, z, x + 1.0, y + 1.0, z + 1.0)); + GL11.glDisable((int)2848); + GL11.glEnable((int)3553); + GL11.glEnable((int)2929); + GL11.glDepthMask((boolean)true); + GL11.glDisable((int)3042); + GL11.glPopMatrix(); + } + + public static void drawBlockESP(double x, double y, double z, float red, float green, float blue, float alpha, float lineRed, float lineGreen, float lineBlue, float lineAlpha, float lineWidth) { + GL11.glPushMatrix(); + GL11.glEnable((int)3042); + GL11.glBlendFunc((int)770, (int)771); + GL11.glDisable((int)2896); + GL11.glDisable((int)3553); + GL11.glEnable((int)2848); + GL11.glDisable((int)2929); + GL11.glDepthMask((boolean)false); + GL11.glColor4f((float)red, (float)green, (float)blue, (float)alpha); + RenderUtil.drawBoundingBox(new AxisAlignedBB(x, y, z, x + 1.0, y + 1.0, z + 1.0)); + GL11.glLineWidth((float)lineWidth); + GL11.glColor4f((float)lineRed, (float)lineGreen, (float)lineBlue, (float)lineAlpha); + RenderUtil.drawOutlinedBoundingBox(new AxisAlignedBB(x, y, z, x + 1.0, y + 1.0, z + 1.0)); + GL11.glDisable((int)2848); + GL11.glEnable((int)3553); + GL11.glEnable((int)2896); + GL11.glEnable((int)2929); + GL11.glDepthMask((boolean)true); + GL11.glDisable((int)3042); + GL11.glPopMatrix(); + } + + public static void drawSolidBlockESP(double x, double y, double z, float red, float green, float blue, float alpha) { + GL11.glPushMatrix(); + GL11.glEnable((int)3042); + GL11.glBlendFunc((int)770, (int)771); + GL11.glDisable((int)3553); + GL11.glEnable((int)2848); + GL11.glDisable((int)2929); + GL11.glDepthMask((boolean)false); + GL11.glColor4f((float)red, (float)green, (float)blue, (float)alpha); + RenderUtil.drawBoundingBox(new AxisAlignedBB(x, y, z, x + 1.0, y + 1.0, z + 1.0)); + GL11.glDisable((int)2848); + GL11.glEnable((int)3553); + GL11.glEnable((int)2929); + GL11.glDepthMask((boolean)true); + GL11.glDisable((int)3042); + GL11.glPopMatrix(); + } + + public static void drawOutlinedEntityESP(double x, double y, double z, double width, double height, float red, float green, float blue, float alpha) { + GL11.glPushMatrix(); + GL11.glEnable((int)3042); + GL11.glBlendFunc((int)770, (int)771); + GL11.glDisable((int)3553); + GL11.glEnable((int)2848); + GL11.glDisable((int)2929); + GL11.glDepthMask((boolean)false); + GL11.glColor4f((float)red, (float)green, (float)blue, (float)alpha); + RenderUtil.drawOutlinedBoundingBox(new AxisAlignedBB(x - width, y, z - width, x + width, y + height, z + width)); + GL11.glDisable((int)2848); + GL11.glEnable((int)3553); + GL11.glEnable((int)2929); + GL11.glDepthMask((boolean)true); + GL11.glDisable((int)3042); + GL11.glPopMatrix(); + } + + public static void drawSolidEntityESP(double x, double y, double z, double width, double height, float red, float green, float blue, float alpha) { + GL11.glPushMatrix(); + GL11.glEnable((int)3042); + GL11.glBlendFunc((int)770, (int)771); + GL11.glDisable((int)3553); + GL11.glEnable((int)2848); + GL11.glDisable((int)2929); + GL11.glDepthMask((boolean)false); + GL11.glColor4f((float)red, (float)green, (float)blue, (float)alpha); + RenderUtil.drawBoundingBox(new AxisAlignedBB(x - width, y, z - width, x + width, y + height, z + width)); + GL11.glDisable((int)2848); + GL11.glEnable((int)3553); + GL11.glEnable((int)2929); + GL11.glDepthMask((boolean)true); + GL11.glDisable((int)3042); + GL11.glPopMatrix(); + } + + public static void drawEntityESP(double x, double y, double z, double width, double height, float red, float green, float blue, float alpha, float lineRed, float lineGreen, float lineBlue, float lineAlpha, float lineWdith) { + GL11.glPushMatrix(); + GL11.glEnable((int)3042); + GL11.glBlendFunc((int)770, (int)771); + GL11.glDisable((int)3553); + GL11.glEnable((int)2848); + GL11.glDisable((int)2929); + GL11.glDepthMask((boolean)false); + GL11.glColor4f((float)red, (float)green, (float)blue, (float)alpha); + RenderUtil.drawBoundingBox(new AxisAlignedBB(x - width, y, z - width, x + width, y + height, z + width)); + GL11.glLineWidth((float)lineWdith); + GL11.glColor4f((float)lineRed, (float)lineGreen, (float)lineBlue, (float)lineAlpha); + RenderUtil.drawOutlinedBoundingBox(new AxisAlignedBB(x - width, y, z - width, x + width, y + height, z + width)); + GL11.glDisable((int)2848); + GL11.glEnable((int)3553); + GL11.glEnable((int)2929); + GL11.glDepthMask((boolean)true); + GL11.glDisable((int)3042); + GL11.glPopMatrix(); + } + + public static void drawTracerLine(double x, double y, double z, float red, float green, float blue, float alpha, float lineWdith) { + GL11.glPushMatrix(); + GL11.glEnable((int)3042); + GL11.glEnable((int)2848); + GL11.glDisable((int)2929); + GL11.glDisable((int)3553); + GL11.glBlendFunc((int)770, (int)771); + GL11.glEnable((int)3042); + GL11.glLineWidth((float)lineWdith); + GL11.glColor4f((float)red, (float)green, (float)blue, (float)alpha); + GL11.glBegin((int)2); + Minecraft.getMinecraft(); + Minecraft.getMinecraft(); + GL11.glVertex3d((double)0.0, (double)(0.0 + (double)mc.thePlayer.getEyeHeight()), (double)0.0); + GL11.glVertex3d((double)x, (double)y, (double)z); + GL11.glEnd(); + GL11.glDisable((int)3042); + GL11.glEnable((int)3553); + GL11.glEnable((int)2929); + GL11.glDisable((int)2848); + GL11.glDisable((int)3042); + GL11.glPopMatrix(); + } + + public static void drawFilledBox(AxisAlignedBB mask) { + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldRenderer = tessellator.getWorldRenderer(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(mask.minX, mask.minY, mask.minZ).endVertex(); + worldRenderer.pos(mask.minX, mask.maxY, mask.minZ).endVertex(); + worldRenderer.pos(mask.maxX, mask.minY, mask.minZ).endVertex(); + worldRenderer.pos(mask.maxX, mask.maxY, mask.minZ).endVertex(); + worldRenderer.pos(mask.maxX, mask.minY, mask.maxZ).endVertex(); + worldRenderer.pos(mask.maxX, mask.maxY, mask.maxZ).endVertex(); + worldRenderer.pos(mask.minX, mask.minY, mask.maxZ).endVertex(); + worldRenderer.pos(mask.minX, mask.maxY, mask.maxZ).endVertex(); + tessellator.draw(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(mask.maxX, mask.maxY, mask.minZ).endVertex(); + worldRenderer.pos(mask.maxX, mask.minY, mask.minZ).endVertex(); + worldRenderer.pos(mask.minX, mask.maxY, mask.minZ).endVertex(); + worldRenderer.pos(mask.minX, mask.minY, mask.minZ).endVertex(); + worldRenderer.pos(mask.minX, mask.maxY, mask.maxZ).endVertex(); + worldRenderer.pos(mask.minX, mask.minY, mask.maxZ).endVertex(); + worldRenderer.pos(mask.maxX, mask.maxY, mask.maxZ).endVertex(); + worldRenderer.pos(mask.maxX, mask.minY, mask.maxZ).endVertex(); + tessellator.draw(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(mask.minX, mask.maxY, mask.minZ).endVertex(); + worldRenderer.pos(mask.maxX, mask.maxY, mask.minZ).endVertex(); + worldRenderer.pos(mask.maxX, mask.maxY, mask.maxZ).endVertex(); + worldRenderer.pos(mask.minX, mask.maxY, mask.maxZ).endVertex(); + worldRenderer.pos(mask.minX, mask.maxY, mask.minZ).endVertex(); + worldRenderer.pos(mask.minX, mask.maxY, mask.maxZ).endVertex(); + worldRenderer.pos(mask.maxX, mask.maxY, mask.maxZ).endVertex(); + worldRenderer.pos(mask.maxX, mask.maxY, mask.minZ).endVertex(); + tessellator.draw(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(mask.minX, mask.minY, mask.minZ).endVertex(); + worldRenderer.pos(mask.maxX, mask.minY, mask.minZ).endVertex(); + worldRenderer.pos(mask.maxX, mask.minY, mask.maxZ).endVertex(); + worldRenderer.pos(mask.minX, mask.minY, mask.maxZ).endVertex(); + worldRenderer.pos(mask.minX, mask.minY, mask.minZ).endVertex(); + worldRenderer.pos(mask.minX, mask.minY, mask.maxZ).endVertex(); + worldRenderer.pos(mask.maxX, mask.minY, mask.maxZ).endVertex(); + worldRenderer.pos(mask.maxX, mask.minY, mask.minZ).endVertex(); + tessellator.draw(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(mask.minX, mask.minY, mask.minZ).endVertex(); + worldRenderer.pos(mask.minX, mask.maxY, mask.minZ).endVertex(); + worldRenderer.pos(mask.minX, mask.minY, mask.maxZ).endVertex(); + worldRenderer.pos(mask.minX, mask.maxY, mask.maxZ).endVertex(); + worldRenderer.pos(mask.maxX, mask.minY, mask.maxZ).endVertex(); + worldRenderer.pos(mask.maxX, mask.maxY, mask.maxZ).endVertex(); + worldRenderer.pos(mask.maxX, mask.minY, mask.minZ).endVertex(); + worldRenderer.pos(mask.maxX, mask.maxY, mask.minZ).endVertex(); + tessellator.draw(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(mask.minX, mask.maxY, mask.maxZ).endVertex(); + worldRenderer.pos(mask.minX, mask.minY, mask.maxZ).endVertex(); + worldRenderer.pos(mask.minX, mask.maxY, mask.minZ).endVertex(); + worldRenderer.pos(mask.minX, mask.minY, mask.minZ).endVertex(); + worldRenderer.pos(mask.maxX, mask.maxY, mask.minZ).endVertex(); + worldRenderer.pos(mask.maxX, mask.minY, mask.minZ).endVertex(); + worldRenderer.pos(mask.maxX, mask.maxY, mask.maxZ).endVertex(); + worldRenderer.pos(mask.maxX, mask.minY, mask.maxZ).endVertex(); + tessellator.draw(); + } + + public static void checkSetupFBO() { + Framebuffer fbo = Minecraft.getMinecraft().getFramebuffer(); + if (fbo != null && fbo.depthBuffer > -1) { + EXTFramebufferObject.glDeleteRenderbuffersEXT((int)fbo.depthBuffer); + int stencil_depth_buffer_ID = EXTFramebufferObject.glGenRenderbuffersEXT(); + EXTFramebufferObject.glBindRenderbufferEXT((int)36161, (int)stencil_depth_buffer_ID); + EXTFramebufferObject.glRenderbufferStorageEXT((int)36161, (int)34041, (int)Minecraft.getMinecraft().displayWidth, (int)Minecraft.getMinecraft().displayHeight); + EXTFramebufferObject.glFramebufferRenderbufferEXT((int)36160, (int)36128, (int)36161, (int)stencil_depth_buffer_ID); + EXTFramebufferObject.glFramebufferRenderbufferEXT((int)36160, (int)36096, (int)36161, (int)stencil_depth_buffer_ID); + fbo.depthBuffer = -1; + } + } + public static void drawRoundedRect(float n, float n2, float n3, float n4, final int n5, final int n6) { + GL11.glDisable(2929); + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glBlendFunc(770, 771); + GL11.glDepthMask(true); + GL11.glEnable(2848); + GL11.glHint(3154, 4354); + GL11.glHint(3155, 4354); + GL11.glScalef(0.5f, 0.5f, 0.5f); + drawVLine(n *= 2.0f, (n2 *= 2.0f) + 1.0f, (n4 *= 2.0f) - 2.0f, n5); + drawVLine((n3 *= 2.0f) - 1.0f, n2 + 1.0f, n4 - 2.0f, n5); + drawHLine(n + 2.0f, n3 - 3.0f, n2, n5); + drawHLine(n + 2.0f, n3 - 3.0f, n4 - 1.0f, n5); + drawHLine(n + 1.0f, n + 1.0f, n2 + 1.0f, n5); + drawHLine(n3 - 2.0f, n3 - 2.0f, n2 + 1.0f, n5); + drawHLine(n3 - 2.0f, n3 - 2.0f, n4 - 2.0f, n5); + drawHLine(n + 1.0f, n + 1.0f, n4 - 2.0f, n5); + drawRect(n + 1.0f, n2 + 1.0f, n3 - 1.0f, n4 - 1.0f, n6); + GL11.glScalef(2.0f, 2.0f, 2.0f); + GL11.glEnable(3553); + GL11.glDisable(3042); + GL11.glEnable(2929); + GL11.glDisable(2848); + GL11.glHint(3154, 4352); + GL11.glHint(3155, 4352); + } +// public static void drawRoundedRect(float x, float y, float x2, float y2, float round, int color) { +// x = (float)((double)x + ((double)(round / 2.0f) + 0.5)); +// y = (float)((double)y + ((double)(round / 2.0f) + 0.5)); +// x2 = (float)((double)x2 - ((double)(round / 2.0f) + 0.5)); +// y2 = (float)((double)y2 - ((double)(round / 2.0f) + 0.5)); +// Gui.drawRect(x, y, x2, y2, color); +// Gui.circle(x2 - round / 2.0f, y + round / 2.0f, round, color); +// Gui.circle(x + round / 2.0f, y2 - round / 2.0f, round, color); +// Gui.circle(x + round / 2.0f, y + round / 2.0f, round, color); +// Gui.circle(x2 - round / 2.0f, y2 - round / 2.0f, round, color); +// Gui.drawRect(x - round / 2.0f - 0.5f, y + round / 2.0f, x2, y2 - round / 2.0f, color); +// Gui.drawRect(x, y + round / 2.0f, x2 + round / 2.0f + 0.5f, y2 - round / 2.0f, color); +// Gui.drawRect(x + round / 2.0f, y - round / 2.0f - 0.5f, x2 - round / 2.0f, y2 - round / 2.0f, color); +// Gui.drawRect(x + round / 2.0f, y, x2 - round / 2.0f, y2 + round / 2.0f + 0.5f, color); +// } + + public static void drawRoundedRect2(float var0, float var1, float var2, float var3, int var4, int var5) { + RenderUtil.enableGL2D(); + GL11.glScalef((float)0.5f, (float)0.5f, (float)0.5f); + RenderUtil.drawVLine(var0 *= 2.0f, (var1 *= 2.0f) + 1.0f, (var3 *= 2.0f) - 2.0f, var4); + RenderUtil.drawVLine((var2 *= 2.0f) - 1.0f, var1 + 1.0f, var3 - 2.0f, var4); + RenderUtil.drawHLine(var0 + 2.0f, var2 - 3.0f, var1, var4); + RenderUtil.drawHLine(var0 + 2.0f, var2 - 3.0f, var3 - 1.0f, var4); + RenderUtil.drawHLine(var0 + 1.0f, var0 + 1.0f, var1 + 1.0f, var4); + RenderUtil.drawHLine(var2 - 2.0f, var2 - 2.0f, var1 + 1.0f, var4); + RenderUtil.drawHLine(var2 - 2.0f, var2 - 2.0f, var3 - 2.0f, var4); + RenderUtil.drawHLine(var0 + 1.0f, var0 + 1.0f, var3 - 2.0f, var4); + RenderUtil.drawRect(var0 + 1.0f, var1 + 1.0f, var2 - 1.0f, var3 - 1.0f, var5); + GL11.glScalef((float)2.0f, (float)2.0f, (float)2.0f); + RenderUtil.disableGL2D(); + } + + public static void drawHLine(float x, float y, float x1, int y1) { + if (y < x) { + float var5 = x; + x = y; + y = var5; + } + RenderUtil.drawRect(x, x1, y + 1.0f, x1 + 1.0f, y1); + } + + public static void drawVLine(float x, float y, float x1, int y1) { + if (x1 < y) { + float var5 = y; + y = x1; + x1 = var5; + } + RenderUtil.drawRect(x, y + 1.0f, x + 1.0f, x1, y1); + } + + public static void drawRoundedRectBottem(float x, float y, float x2, float y2, float round, int color) { + x = (float)((double)x + ((double)(round / 2.0f) + 0.0)); + y = (float)((double)y + ((double)(round / 2.0f) + 0.0)); + x2 = (float)((double)x2 - ((double)(round / 2.0f) + 0.0)); + y2 = (float)((double)y2 - ((double)(round / 2.0f) + 0.0)); + RenderUtil.drawCircle(x + round / 2.0f, y2 - round / 2.0f, round, 180, 270, color); + RenderUtil.drawCircle(x2 - round / 2.0f, y2 - round / 2.0f, round, 270, 360, color); + drawRect(x - round / 2.0f, y, x2 + round / 2.0f, y2 - round / 2.0f + 0.0f, color); + drawRect(x + round / 2.0f, y2 - round / 2.0f + 0.0f, x2 - round / 2.0f, y2 + round / 2.0f + 0.0f, color); + } + + public static void drawCircle(float x, float y, float radius, int startPi, int endPi, int c) { + float f = (float)(c >> 24 & 255) / 255.0f; + float f1 = (float)(c >> 16 & 255) / 255.0f; + float f2 = (float)(c >> 8 & 255) / 255.0f; + float f3 = (float)(c & 255) / 255.0f; + GL11.glColor4f((float)f1, (float)f2, (float)f3, (float)f); + GlStateManager.enableAlpha(); + GlStateManager.enableBlend(); + GL11.glDisable((int)3553); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.alphaFunc(516, 0.001f); + Tessellator tess = Tessellator.getInstance(); + WorldRenderer render = tess.getWorldRenderer(); + for (double i = (double)startPi; i < (double)endPi; i += 1.0) { + double cs = i * 3.141592653589793 / 180.0; + double ps = (i - 1.0) * 3.141592653589793 / 180.0; + double[] outer = new double[]{Math.cos(cs) * (double)radius, (- Math.sin(cs)) * (double)radius, Math.cos(ps) * (double)radius, (- Math.sin(ps)) * (double)radius}; + render.begin(6, DefaultVertexFormats.POSITION); + render.pos((double)x + outer[2], (double)y + outer[3], 0.0).endVertex(); + render.pos((double)x + outer[0], (double)y + outer[1], 0.0).endVertex(); + render.pos(x, y, 0.0).endVertex(); + tess.draw(); + } + GlStateManager.color(0.0f, 0.0f, 0.0f); + GlStateManager.disableBlend(); + GlStateManager.alphaFunc(516, 0.1f); + GlStateManager.disableAlpha(); + GL11.glEnable((int)3553); + } + + public static void drawRect(float left, float top, float right, float bottom, Color color) { + float tessellator; + if (left < right) { + tessellator = left; + left = right; + right = tessellator; + } + if (top < bottom) { + tessellator = top; + top = bottom; + bottom = tessellator; + } + Tessellator tessellator1 = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator1.getWorldRenderer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.color((float)color.getRed() / 255.0f, (float)color.getGreen() / 255.0f, (float)color.getBlue() / 255.0f, (float)color.getAlpha() / 255.0f); + worldrenderer.begin(7, DefaultVertexFormats.POSITION); + worldrenderer.pos(left, bottom, 0.0).endVertex(); + worldrenderer.pos(right, bottom, 0.0).endVertex(); + worldrenderer.pos(right, top, 0.0).endVertex(); + worldrenderer.pos(left, top, 0.0).endVertex(); + tessellator1.draw(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static void drawCircle(float xx, float yy, float radius, Color col) { + int sections = 70; + double dAngle = 6.283185307179586 / (double)sections; + GL11.glPushMatrix(); + GL11.glEnable((int)3042); + GL11.glDisable((int)3553); + GL11.glBlendFunc((int)770, (int)771); + GL11.glEnable((int)2848); + GL11.glLineWidth((float)1.0f); + GL11.glShadeModel((int)7425); + GL11.glBegin((int)2); + for (int i = 0; i < sections; ++i) { + float x = (float)((double)radius * Math.cos((double)i * dAngle)); + float y = (float)((double)radius * Math.sin((double)i * dAngle)); + GL11.glColor4f((float)((float)col.getRed() / 255.0f), (float)((float)col.getGreen() / 255.0f), (float)((float)col.getBlue() / 255.0f), (float)((float)col.getAlpha() / 255.0f)); + GL11.glVertex2f((float)(xx + x), (float)(yy + y)); + } + GlStateManager.color(0.0f, 0.0f, 0.0f); + GL11.glEnd(); + GL11.glEnable((int)3553); + GL11.glDisable((int)3042); + GL11.glDisable((int)2848); + GL11.glPopMatrix(); + } + + public static void drawCircle(int x, int y, float radius, int startPi, int endPi, int c) { + float f = (float)(c >> 24 & 255) / 255.0f; + float f1 = (float)(c >> 16 & 255) / 255.0f; + float f2 = (float)(c >> 8 & 255) / 255.0f; + float f3 = (float)(c & 255) / 255.0f; + GL11.glColor4f((float)f1, (float)f2, (float)f3, (float)f); + GlStateManager.enableAlpha(); + GlStateManager.enableBlend(); + GL11.glDisable((int)3553); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.alphaFunc(516, 0.001f); + Tessellator tess = Tessellator.getInstance(); + WorldRenderer render = tess.getWorldRenderer(); + for (double i = (double)startPi; i < (double)endPi; i += 1.0) { + double cs = i * 3.141592653589793 / 180.0; + double ps = (i - 1.0) * 3.141592653589793 / 180.0; + double[] outer = new double[]{Math.cos(cs) * (double)radius, (- Math.sin(cs)) * (double)radius, Math.cos(ps) * (double)radius, (- Math.sin(ps)) * (double)radius}; + render.begin(6, DefaultVertexFormats.POSITION); + render.pos((double)x + outer[2], (double)y + outer[3], 0.0).endVertex(); + render.pos((double)x + outer[0], (double)y + outer[1], 0.0).endVertex(); + render.pos(x, y, 0.0).endVertex(); + tess.draw(); + } + GlStateManager.color(0.0f, 0.0f, 0.0f); + GlStateManager.disableBlend(); + GlStateManager.alphaFunc(516, 0.1f); + GlStateManager.disableAlpha(); + GL11.glEnable((int)3553); + } + + public static void drawRoundedRectTop(float x, float y, float x2, float y2, float round, int color) { + GlStateManager.disableBlend(); + x = (float)((double)x + ((double)(round / 2.0f) + 0.0)); + y = (float)((double)y + ((double)(round / 2.0f) + 0.0)); + x2 = (float)((double)x2 - ((double)(round / 2.0f) + 0.0)); + y2 = (float)((double)y2 - ((double)(round / 2.0f) + 0.0)); + RenderUtil.drawCircle((int)x2 - (int)round / 2, (int)y + (int)round / 2, round, 0, 90, color); + RenderUtil.drawCircle((int)x + (int)round / 2, (int)y + (int)round / 2, round, 90, 180, color); + RenderUtil.drawRect(x - round / 2.0f, y + round / 2.0f, x2, y2 + round / 2.0f, color); + RenderUtil.drawRect(x2 + round / 2.0f - round / 2.0f, y + round / 2.0f, x2 + round / 2.0f, y2 + round / 2.0f, color); + RenderUtil.drawRect(x + round / 2.0f, y - round / 2.0f, x2 - round / 2.0f, y + round / 2.0f, color); + GlStateManager.disableBlend(); + } + + public static void enableGL2D() { + GL11.glDisable((int)2929); + GL11.glEnable((int)3042); + GL11.glDisable((int)3553); + GL11.glBlendFunc((int)770, (int)771); + GL11.glDepthMask((boolean)true); + GL11.glEnable((int)2848); + GL11.glHint((int)3154, (int)4354); + GL11.glHint((int)3155, (int)4354); + } + + public static void disableGL2D() { + GL11.glEnable((int)3553); + GL11.glDisable((int)3042); + GL11.glEnable((int)2929); + GL11.glDisable((int)2848); + GL11.glHint((int)3154, (int)4352); + GL11.glHint((int)3155, (int)4352); + } + + public static void startDrawing() { + GL11.glEnable((int)3042); + GL11.glEnable((int)3042); + GL11.glBlendFunc((int)770, (int)771); + GL11.glEnable((int)2848); + GL11.glDisable((int)3553); + GL11.glDisable((int)2929); + Minecraft.getMinecraft().entityRenderer.setupCameraTransform(Minecraft.getMinecraft().timer.renderPartialTicks, 0); + } + + public static void stopDrawing() { + GL11.glDisable((int)3042); + GL11.glEnable((int)3553); + GL11.glDisable((int)2848); + GL11.glDisable((int)3042); + GL11.glEnable((int)2929); + } + + static { + frustrum = new Frustum(); + } + + public static boolean isHovering(final int n, final int n2, final float n3, final float n4, final float n5, final float n6) { + boolean b; + if (n > n3 && n < n5 && n2 > n4 && n2 < n6) { + b = true; + } + else { + b = false; + } + return b; + } + + public static void circle(final float n, final float n2, final float n3, final int n4) { + arc(n, n2, 0.0f, 360.0f, n3, n4); + } + + public static void circle(final float n, final float n2, final float n3, final Color color) { + arc(n, n2, 0.0f, 360.0f, n3, color); + } + + + public static void arc(final float n, final float n2, final float n3, final float n4, final float n5, final int n6) { + arcEllipse(n, n2, n3, n4, n5, n5, n6); + } + + public static void arc(final float n, final float n2, final float n3, final float n4, final float n5, final Color color) { + arcEllipse(n, n2, n3, n4, n5, n5, color); + } + + public static void arcEllipse(final float n, final float n2, float n3, float n4, final float n5, final float n6, final Color color) { + GlStateManager.color(0.0f, 0.0f, 0.0f); + GL11.glColor4f(0.0f, 0.0f, 0.0f, 0.0f); + if (n3 > n4) { + final float n7 = n4; + n4 = n3; + n3 = n7; + } + Tessellator.getInstance().getWorldRenderer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.color(color.getRed() / 255.0f, color.getGreen() / 255.0f, color.getBlue() / 255.0f, color.getAlpha() / 255.0f); + if (color.getAlpha() > 0.5f) { + GL11.glEnable(2848); + GL11.glLineWidth(2.0f); + GL11.glBegin(3); + float n8 = n4; + while (n8 >= n3) { + GL11.glVertex2f(n + (float)Math.cos(n8 * 3.141592653589793 / 180.0) * (n5 * 1.001f), n2 + (float)Math.sin(n8 * 3.141592653589793 / 180.0) * (n6 * 1.001f)); + n8 -= 4.0f; + } + GL11.glEnd(); + GL11.glDisable(2848); + } + GL11.glBegin(6); + float n9 = n4; + while (n9 >= n3) { + GL11.glVertex2f(n + (float)Math.cos(n9 * 3.141592653589793 / 180.0) * n5, n2 + (float)Math.sin(n9 * 3.141592653589793 / 180.0) * n6); + n9 -= 4.0f; + } + GL11.glEnd(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + + public static void arcEllipse(final float n, final float n2, float n3, float n4, final float n5, final float n6, final int n7) { + GlStateManager.color(0.0f, 0.0f, 0.0f); + GL11.glColor4f(0.0f, 0.0f, 0.0f, 0.0f); + if (n3 > n4) { + final float n8 = n4; + n4 = n3; + n3 = n8; + } + final float p_color_3_ = (n7 >> 24 & 0xFF) / 255.0f; + final float p_color_0_ = (n7 >> 16 & 0xFF) / 255.0f; + final float p_color_1_ = (n7 >> 8 & 0xFF) / 255.0f; + final float p_color_2_ = (n7 & 0xFF) / 255.0f; + Tessellator.getInstance().getWorldRenderer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.color(p_color_0_, p_color_1_, p_color_2_, p_color_3_); + if (p_color_3_ > 0.5f) { + GL11.glEnable(2848); + GL11.glLineWidth(2.0f); + GL11.glBegin(3); + float n9 = n4; + while (n9 >= n3) { + GL11.glVertex2f(n + (float)Math.cos(n9 * 3.141592653589793 / 180.0) * (n5 * 1.001f), n2 + (float)Math.sin(n9 * 3.141592653589793 / 180.0) * (n6 * 1.001f)); + n9 -= 4.0f; + } + GL11.glEnd(); + GL11.glDisable(2848); + } + GL11.glBegin(6); + float n10 = n4; + while (n10 >= n3) { + GL11.glVertex2f(n + (float)Math.cos(n10 * 3.141592653589793 / 180.0) * n5, n2 + (float)Math.sin(n10 * 3.141592653589793 / 180.0) * n6); + n10 -= 4.0f; + } + GL11.glEnd(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static void drawArc(float n, float n2, double n3, final int n4, final int n5, final double n6, final int n7) { + n3 *= 2.0; + n *= 2.0f; + n2 *= 2.0f; + final float n8 = (n4 >> 24 & 0xFF) / 255.0f; + final float n9 = (n4 >> 16 & 0xFF) / 255.0f; + final float n10 = (n4 >> 8 & 0xFF) / 255.0f; + final float n11 = (n4 & 0xFF) / 255.0f; + GL11.glDisable(2929); + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glBlendFunc(770, 771); + GL11.glDepthMask(true); + GL11.glEnable(2848); + GL11.glHint(3154, 4354); + GL11.glHint(3155, 4354); + GL11.glScalef(0.5f, 0.5f, 0.5f); + GL11.glLineWidth((float)n7); + GL11.glEnable(2848); + GL11.glColor4f(n9, n10, n11, n8); + GL11.glBegin(3); + int n12 = n5; + while (n12 <= n6) { + GL11.glVertex2d(n + Math.sin(n12 * 3.141592653589793 / 180.0) * n3, n2 + Math.cos(n12 * 3.141592653589793 / 180.0) * n3); + ++n12; + } + GL11.glEnd(); + GL11.glDisable(2848); + GL11.glScalef(2.0f, 2.0f, 2.0f); + GL11.glEnable(3553); + GL11.glDisable(3042); + GL11.glEnable(2929); + GL11.glDisable(2848); + GL11.glHint(3154, 4352); + GL11.glHint(3155, 4352); + } +} diff --git a/src/main/java/net/ccbluex/liquidbounce/utils/render/RenderUtils.java b/src/main/java/net/ccbluex/liquidbounce/utils/render/RenderUtils.java index 57bb846dc4..002fecc2f5 100644 --- a/src/main/java/net/ccbluex/liquidbounce/utils/render/RenderUtils.java +++ b/src/main/java/net/ccbluex/liquidbounce/utils/render/RenderUtils.java @@ -59,6 +59,14 @@ public final class RenderUtils extends MinecraftInstance { public static int deltaTime; + public static int width() { + return new ScaledResolution(Minecraft.getMinecraft()).getScaledWidth(); + } + + public static int height() { + return new ScaledResolution(Minecraft.getMinecraft()).getScaledHeight(); + } + private static final int[] DISPLAY_LISTS_2D = new int[4]; static { diff --git a/src/main/java/net/ccbluex/liquidbounce/utils/render/VertexUtils.java b/src/main/java/net/ccbluex/liquidbounce/utils/render/VertexUtils.java new file mode 100644 index 0000000000..54b9e8eb3b --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/utils/render/VertexUtils.java @@ -0,0 +1,20 @@ +package net.ccbluex.liquidbounce.utils.render; + +import org.lwjgl.opengl.GL11; + +import java.awt.*; + +public class VertexUtils { + public static void start(int mode) { + GL11.glBegin(mode); + } + + public static void add(double x, double y, Color color) { + GL11.glColor4f(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, color.getAlpha() / 255f); + GL11.glVertex2d(x, y); + } + + public static void end() { + GL11.glEnd(); + } +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/utils/render/VisualBase.java b/src/main/java/net/ccbluex/liquidbounce/utils/render/VisualBase.java new file mode 100644 index 0000000000..b672d819a9 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/utils/render/VisualBase.java @@ -0,0 +1,1499 @@ +package net.ccbluex.liquidbounce.utils.render; + + +import net.ccbluex.liquidbounce.utils.MinecraftInstance; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.client.shader.Framebuffer; +import net.minecraft.client.shader.ShaderGroup; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + +import java.awt.*; +import java.awt.image.BufferedImage; +import java.util.HashMap; + +import static org.lwjgl.opengl.GL11.*; + +public class VisualBase extends MinecraftInstance { + static RenderManager renderManager; + private static final HashMap shadowCache = new HashMap<>(); + protected static float zLevel; + private static ShaderGroup blurShader; + private static Framebuffer buffer; + private static int lastScale; + private static int lastScaleWidth; + private static int lastScaleHeight; + private static ResourceLocation shader; + + + public double fpsMultiplier() { + return (RenderUtils.deltaTime / 60.0) * 3; + } + + + public static void pushAttrib() + { + GL11.glPushAttrib(8256); + } + + public static void popAttrib() + { + GL11.glPopAttrib(); + } + + public static void pushMatrix() + { + GL11.glPushMatrix(); + } + + public static void popMatrix() + { + GL11.glPopMatrix(); + } + + public static void pushAttribAndMatrix() { + pushAttrib(); + pushMatrix(); + } + + public static void popAttribAndMatrix() { + popAttrib(); + popMatrix(); + } + + public static void circle(double x, double y, double radius, boolean filled, Color color) { + polygon(x, y, radius, 360.0, filled, color); + } + + public static void circle(double x, double y, double radius, boolean filled) { + polygon(x, y, radius, 360, filled); + } + + public static void circle(double x, double y, double radius, Color color) { + polygon(x, y, radius, 360, color); + } + + + public static void rescale(double factor) { + rescale(mc.displayWidth / factor, mc.displayHeight / factor); + } + + public static void rescaleMC() { + ScaledResolution resolution = new ScaledResolution(mc); + rescale(mc.displayWidth / resolution.getScaleFactor(),mc.displayHeight / resolution.getScaleFactor()); + } + + public static void rescale(double width, double height) { + GlStateManager.clear(256); + GlStateManager.matrixMode(5889); + GlStateManager.loadIdentity(); + GlStateManager.ortho(0.0D, width, height, 0.0D, 1000.0D, 3000.0D); + GlStateManager.matrixMode(5888); + GlStateManager.loadIdentity(); + GlStateManager.translate(0.0F, 0.0F, -2000.0F); + } + + public static void glColor(final Color color) { + final float red = color.getRed() / 255F; + final float green = color.getGreen() / 255F; + final float blue = color.getBlue() / 255F; + final float alpha = color.getAlpha() / 255F; + + GlStateManager.color(red, green, blue, alpha); + } + + public static void glColor(final Color color, final int alpha) { + glColor(color, alpha / 255F); + } + + public static void glColor(final Color color, final float alpha) { + final float red = color.getRed() / 255F; + final float green = color.getGreen() / 255F; + final float blue = color.getBlue() / 255F; + + GlStateManager.color(red, green, blue, alpha); + } + + public static void color(double red, double green, double blue, double alpha) { + GL11.glColor4d(red, green, blue, alpha); + } + + public static void color(int color) { + color(color, (float) (color >> 24 & 255) / 255.0F); + } + + public static void color(int color, float alpha) { + float r = (float) (color >> 16 & 255) / 255.0F; + float g = (float) (color >> 8 & 255) / 255.0F; + float b = (float) (color & 255) / 255.0F; + GlStateManager.color(r, g, b, alpha); + } + + public static void glColor(final int hex, final int alpha) { + final float red = (hex >> 16 & 0xFF) / 255F; + final float green = (hex >> 8 & 0xFF) / 255F; + final float blue = (hex & 0xFF) / 255F; + + GlStateManager.color(red, green, blue, alpha / 255F); + } + + public static void glColor(final int hex, final float alpha) { + final float red = (hex >> 16 & 0xFF) / 255F; + final float green = (hex >> 8 & 0xFF) / 255F; + final float blue = (hex & 0xFF) / 255F; + + GlStateManager.color(red, green, blue, alpha); + } + + + public static void inShaderFBO() { + try { + blurShader = new ShaderGroup(mc.getTextureManager(), mc.getResourceManager(), mc.getFramebuffer(), shader); + blurShader.createBindFramebuffers(mc.displayWidth, mc.displayHeight); + buffer = blurShader.mainFramebuffer; + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void drawBlurredShadow(float x, float y, float width, float height, int blurRadius, Color color) { + glPushMatrix(); + GlStateManager.alphaFunc(GL11.GL_GREATER, 0.01f); + + width = width + blurRadius * 2; + height = height + blurRadius * 2; + x = x - blurRadius; + y = y - blurRadius; + + float _X = x - 0.25f; + float _Y = y + 0.25f; + + int identifier = (int) (width * height + width + color.hashCode() * blurRadius + blurRadius); + + GL11.glEnable(GL11.GL_TEXTURE_2D); + glDisable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GlStateManager.enableBlend(); + + int texId = -1; + if (shadowCache.containsKey(identifier)) { + texId = shadowCache.get(identifier); + + GlStateManager.bindTexture(texId); + } else { + if (width <= 0) width = 1; + if (height <= 0) height = 1; + BufferedImage original = new BufferedImage((int) width, (int) height, BufferedImage.TYPE_INT_ARGB_PRE); + + Graphics g = original.getGraphics(); + g.setColor(color); + g.fillRect(blurRadius, blurRadius, (int) (width - blurRadius * 2), (int) (height - blurRadius * 2)); + g.dispose(); + + shadowCache.put(identifier, texId); + } + + GL11.glColor4f(1f, 1f, 1f, 1f); + + GL11.glBegin(GL11.GL_QUADS); + GL11.glTexCoord2f(0, 0); // top left + GL11.glVertex2f(_X, _Y); + + GL11.glTexCoord2f(0, 1); // bottom left + GL11.glVertex2f(_X, _Y + height); + + GL11.glTexCoord2f(1, 1); // bottom right + GL11.glVertex2f(_X + width, _Y + height); + + GL11.glTexCoord2f(1, 0); // top right + GL11.glVertex2f(_X + width, _Y); + GL11.glEnd(); + + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + GlStateManager.resetColor(); + + glEnable(GL_CULL_FACE); + glPopMatrix(); + } + + public static void drawGradientRected(float f, float sY, double width, double height, int colour1, int colour2) { + VisualUtils.drawGradientRect(f, sY, f + width, sY + height, colour1, colour2); + } + + public static void stop() { + GlStateManager.enableAlpha(); + GlStateManager.enableDepth(); + GL11.glEnable(2884); + GL11.glEnable(3553); + GL11.glDisable(3042); + color(Color.white); + } + + public static void vertex(double x, double y) { + GL11.glVertex2d(x, y); + } + + public static void begin(int glMode) { + GL11.glBegin(glMode); + } + + public static void end() { + GL11.glEnd(); + } + + public static void polygon(double x, double y, double sideLength, int amountOfSides, boolean filled) { + polygon(x, y, sideLength, amountOfSides, filled, null); + } + + public static void polygon(double x, double y, double sideLength, int amountOfSides, Color color) { + polygon(x, y, sideLength, amountOfSides, true, color); + } + + public static void polygon(double x, double y, double sideLength, int amountOfSides) { + polygon(x, y, sideLength, amountOfSides, true, null); + } + + + public static void polygon(double x, double y, double sideLength, double amountOfSides, boolean filled, Color color) { + sideLength /= 2.0; + start(); + if (color != null) { + setGLColor(color); + } + if (!filled) { + GL11.glLineWidth(2.0f); + } + GL11.glEnable(2848); + begin(filled ? 6 : 3); + for (double i = 0.0; i <= amountOfSides / 4.0; i += 1.0) { + double angle = i * 4.0 * (Math.PI * 2) / 360.0; + vertex(x + sideLength * Math.cos(angle) + sideLength, y + sideLength * Math.sin(angle) + sideLength); + } + end(); + GL11.glDisable(2848); + stop(); + } + + public static void start() { + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glDisable(3553); + GL11.glDisable(2884); + GlStateManager.disableAlpha(); + GlStateManager.disableDepth(); + } + + public static void glColor(int hex) { + float alpha = (float)(hex >> 24 & 0xFF) / 255.0f; + float red = (float)(hex >> 16 & 0xFF) / 255.0f; + float green = (float)(hex >> 8 & 0xFF) / 255.0f; + float blue = (float)(hex & 0xFF) / 255.0f; + GL11.glColor4f(red, green, blue, alpha); + } + + public static boolean isSliderHovered(float x1, float y1, float x2, float y2, int mouseX, int mouseY) { + return (float)mouseX >= x1 && (float)mouseX <= x2 && (float)mouseY >= y1 && (float)mouseY <= y2; + } + + public static Color getColorAlpha(int color, int alpha) { + Color color2 = new Color(new Color(color).getRed(), new Color(color).getGreen(), new Color(color).getBlue(), alpha); + return color2; + } + + public static void scissor(double x, double y, double width, double height) { + ScaledResolution sr = new ScaledResolution(mc); + double scale = sr.getScaleFactor(); + y = (double)sr.getScaledHeight() - y; + GL11.glScissor((int)(x *= scale), (int)((y *= scale) - (height *= scale)), (int)(width *= scale), (int)height); + } + + public static int rainbow(int delay) { + double rainbowState = Math.ceil((System.currentTimeMillis() + (long)delay) / 7L); + return Color.getHSBColor((float)((rainbowState %= 360.0) / 360.0), 0.9f, 1.0f).getRGB(); + } + + public static Color setAlpha(int color, int alpha) { + return new Color(new Color(color).getRed(), new Color(color).getGreen(), new Color(color).getBlue(), alpha); + } + + public static int getColor(int red, int green, int blue, int alpha) { + int color = MathHelper.clamp_int(alpha, 0, 255) << 24; + color |= MathHelper.clamp_int(red, 0, 255) << 16; + color |= MathHelper.clamp_int(green, 0, 255) << 8; + return color |= MathHelper.clamp_int(blue, 0, 255); + } + + public static void drawCircle(double x, double y, double radius, float startAngle, float endAngle, int color, float lineWidth) { + GlStateManager.pushMatrix(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.disableAlpha(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GL11.glEnable((int)2848); + GL11.glLineWidth((float)lineWidth); + GL11.glBegin((int)3); + for (int i = (int)((double)startAngle / 360.0 * 100.0); i <= (int)((double)endAngle / 360.0 * 100.0); ++i) { + double angle = Math.PI * 2 * (double)i / 100.0 + Math.toRadians(180.0); + if (color == 1337) { + + } else { + color(color); + } + GL11.glVertex2d((double)(x + Math.sin(angle) * radius), (double)(y + Math.cos(angle) * radius)); + } + GL11.glEnd(); + GlStateManager.disableBlend(); + GlStateManager.enableAlpha(); + GlStateManager.enableTexture2D(); + GL11.glDisable((int)2848); + GlStateManager.popMatrix(); + GlStateManager.resetColor(); + } + + + public static void drawTexturedModalRect(ResourceLocation location, double x, double y, int textureX, int textureY, double width, double height) { + boolean alpha_test = GL11.glIsEnabled((int)3008); + GL11.glEnable((int)3008); + Minecraft.getMinecraft().getTextureManager().bindTexture(location); + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer bufferbuilder = tessellator.getWorldRenderer(); + bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX); + bufferbuilder.pos(x, y + height, 0.0).tex((float)textureX * 0.00390625f, (float)((double)textureY + height) * 0.00390625f).endVertex(); + bufferbuilder.pos(x + width, y + height, 0.0).tex((float)((double)textureX + width) * 0.00390625f, (float)((double)textureY + height) * 0.00390625f).endVertex(); + bufferbuilder.pos(x + width, y, 0.0).tex((float)((double)textureX + width) * 0.00390625f, (float)textureY * 0.00390625f).endVertex(); + bufferbuilder.pos(x, y, 0.0).tex((float)textureX * 0.00390625f, (float)textureY * 0.00390625f).endVertex(); + tessellator.draw(); + if (alpha_test) { + GL11.glEnable((int)3008); + } else { + GL11.glDisable((int)3008); + } + } + + public static void drawTexturedRect(ResourceLocation location, double xStart, double yStart, double width, double height, double scale) { + GL11.glPushMatrix(); + GL11.glEnable((int)3042); + GL11.glScaled((double)scale, (double)scale, (double)scale); + drawTexturedModalRect(location, xStart / scale, yStart / scale, 0, 0, width, height); + GL11.glDisable((int)3042); + GL11.glPopMatrix(); + } + + public static float getRenderHurtTime(EntityLivingBase hurt) { + return (float)hurt.hurtTime - (hurt.hurtTime != 0 ? Minecraft.getMinecraft().timer.renderPartialTicks : 0.0f); + } + + public static float getHurtPercent(EntityLivingBase hurt) { + return getRenderHurtTime(hurt) / 10.0f; + } + + public static void drawRGBLineHorizontal(double x, double y, double width, float linewidth, float colors, boolean reverse) { + GlStateManager.shadeModel(7425); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GL11.glLineWidth(linewidth); + GL11.glBegin(3); + colors = (float)((double)colors * width); + double steps = width / (double)colors; + double cX = x; + double cX2 = x + steps; + if (reverse) { + for (float i = colors; i > 0.0f; i -= 1.0f) { + int argbColor = rainbow((int)(i * 10.0f)); + float a = (float)(argbColor >> 24 & 0xFF) / 255.0f; + float r = (float)(argbColor >> 16 & 0xFF) / 255.0f; + float g = (float)(argbColor >> 8 & 0xFF) / 255.0f; + float b = (float)(argbColor & 0xFF) / 255.0f; + GlStateManager.color(r, g, b, a); + GL11.glVertex2d(cX, y); + GL11.glVertex2d(cX2, y); + cX = cX2; + cX2 += steps; + } + } else { + int i = 0; + while ((float)i < colors) { + int argbColor = rainbow(i * 10); + float a = (float)(argbColor >> 24 & 0xFF) / 255.0f; + float r = (float)(argbColor >> 16 & 0xFF) / 255.0f; + float g = (float)(argbColor >> 8 & 0xFF) / 255.0f; + float b = (float)(argbColor & 0xFF) / 255.0f; + GlStateManager.color(r, g, b, a); + GL11.glVertex2d(cX, y); + GL11.glVertex2d(cX2, y); + cX = cX2; + cX2 += steps; + ++i; + } + } + GL11.glEnd(); + GlStateManager.shadeModel(7424); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static void drawRoundedRect3(double x, double y, double width, double height, double cornerRadius, boolean leftTop, boolean rightTop, boolean rightBottom, boolean leftBottom, Color color) { + int i; + GL11.glPushMatrix(); + GL11.glDisable(3553); + GL11.glEnable(2848); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + setGLColor(color); + GL11.glBegin(9); + double cornerX = x + width - cornerRadius; + double cornerY = y + height - cornerRadius; + if (rightBottom) { + for (i = 0; i <= 90; i += 30) { + GL11.glVertex2d(cornerX + Math.sin((double)i * Math.PI / 180.0) * cornerRadius, cornerY + Math.cos((double)i * Math.PI / 180.0) * cornerRadius); + } + } else { + GL11.glVertex2d(x + width, y + height); + } + if (rightTop) { + cornerX = x + width - cornerRadius; + cornerY = y + cornerRadius; + for (i = 90; i <= 180; i += 30) { + GL11.glVertex2d(cornerX + Math.sin((double)i * Math.PI / 180.0) * cornerRadius, cornerY + Math.cos((double)i * Math.PI / 180.0) * cornerRadius); + } + } else { + GL11.glVertex2d(x + width, y); + } + if (leftTop) { + cornerX = x + cornerRadius; + cornerY = y + cornerRadius; + for (i = 180; i <= 270; i += 30) { + GL11.glVertex2d(cornerX + Math.sin((double)i * Math.PI / 180.0) * cornerRadius, cornerY + Math.cos((double)i * Math.PI / 180.0) * cornerRadius); + } + } else { + GL11.glVertex2d(x, y); + } + if (leftBottom) { + cornerX = x + cornerRadius; + cornerY = y + height - cornerRadius; + for (i = 270; i <= 360; i += 30) { + GL11.glVertex2d(cornerX + Math.sin((double)i * Math.PI / 180.0) * cornerRadius, cornerY + Math.cos((double)i * Math.PI / 180.0) * cornerRadius); + } + } else { + GL11.glVertex2d(x, y + height); + } + GL11.glEnd(); + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + GL11.glDisable(2848); + GL11.glEnable(3553); + GL11.glPopMatrix(); + setGLColor(Color.white); + } + + public static void drawRoundedRect2Alpha(double x, double y, double width, double height, double cornerRadius, Color color) { + int i; + GL11.glPushMatrix(); + GL11.glDisable(3553); + GL11.glEnable(3042); + color(color); + GL11.glBegin(9); + double cornerX = x + width - cornerRadius; + double cornerY = y + height - cornerRadius; + for (i = 0; i <= 90; i += 30) { + GL11.glVertex2d(cornerX + Math.sin((double)i * Math.PI / 180.0) * cornerRadius, cornerY + Math.cos((double)i * Math.PI / 180.0) * cornerRadius); + } + cornerX = x + width - cornerRadius; + cornerY = y + cornerRadius; + for (i = 90; i <= 180; i += 30) { + GL11.glVertex2d(cornerX + Math.sin((double)i * Math.PI / 180.0) * cornerRadius, cornerY + Math.cos((double)i * Math.PI / 180.0) * cornerRadius); + } + cornerX = x + cornerRadius; + cornerY = y + cornerRadius; + for (i = 180; i <= 270; i += 30) { + GL11.glVertex2d(cornerX + Math.sin((double)i * Math.PI / 180.0) * cornerRadius, cornerY + Math.cos((double)i * Math.PI / 180.0) * cornerRadius); + } + cornerX = x + cornerRadius; + cornerY = y + height - cornerRadius; + for (i = 270; i <= 360; i += 30) { + GL11.glVertex2d(cornerX + Math.sin((double)i * Math.PI / 180.0) * cornerRadius, cornerY + Math.cos((double)i * Math.PI / 180.0) * cornerRadius); + } + GL11.glEnd(); + color(1.0f, 1.0f, 1.0f, 1.0f); + GL11.glDisable(3042); + GL11.glEnable(3553); + GL11.glPopMatrix(); + } + + public static void drawRoundedRectSmooth(double x, double y, double width, double height, double cornerRadius, Color color) { + int i; + GL11.glPushMatrix(); + GL11.glDisable(3008); + GL11.glEnable(2881); + GL11.glDisable(3553); + GL11.glEnable(3042); + color(color); + GL11.glBegin(9); + double cornerX = x + width - cornerRadius; + double cornerY = y + height - cornerRadius; + for (i = 0; i <= 90; i += 30) { + GL11.glVertex2d(cornerX + Math.sin((double)i * Math.PI / 180.0) * cornerRadius, cornerY + Math.cos((double)i * Math.PI / 180.0) * cornerRadius); + } + cornerX = x + width - cornerRadius; + cornerY = y + cornerRadius; + for (i = 90; i <= 180; i += 30) { + GL11.glVertex2d(cornerX + Math.sin((double)i * Math.PI / 180.0) * cornerRadius, cornerY + Math.cos((double)i * Math.PI / 180.0) * cornerRadius); + } + cornerX = x + cornerRadius; + cornerY = y + cornerRadius; + for (i = 180; i <= 270; i += 30) { + GL11.glVertex2d(cornerX + Math.sin((double)i * Math.PI / 180.0) * cornerRadius, cornerY + Math.cos((double)i * Math.PI / 180.0) * cornerRadius); + } + cornerX = x + cornerRadius; + cornerY = y + height - cornerRadius; + for (i = 270; i <= 360; i += 30) { + GL11.glVertex2d(cornerX + Math.sin((double)i * Math.PI / 180.0) * cornerRadius, cornerY + Math.cos((double)i * Math.PI / 180.0) * cornerRadius); + } + GL11.glEnd(); + color(1.0f, 1.0f, 1.0f, 1.0f); + GL11.glDisable(2881); + GL11.glDisable(3042); + GL11.glEnable(3553); + GL11.glPopMatrix(); + } + + public static double interpolate(double current, double old, double scale) { + return old + (current - old) * scale; + } + + public static void drawImage(int x, int y, int width, int height, ResourceLocation resourceLocation) { + GlStateManager.enableAlpha(); + mc.getTextureManager().bindTexture(resourceLocation); + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + Gui.drawModalRectWithCustomSizedTexture(x, y, 0.0f, 0.0f, width, height, width, height); + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + } + + public void drawHorizontalGradientRect(double x, double y, double width, double height, Color right, Color left) { + pushAttribAndMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glBegin(GL11.GL_QUADS); + + ColorUtils.glColor(right); + GL11.glVertex2d(x, y + height); + + ColorUtils.glColor(left); + GL11.glVertex2d(x + width, y + height); + + ColorUtils.glColor(left); + GL11.glVertex2d(x + width, y); + + ColorUtils.glColor(right); + GL11.glVertex2d(x, y); + + GL11.glEnd(); + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glDisable(GL11.GL_BLEND); + popAttribAndMatrix(); + } + + public void renderSkinHead(EntityLivingBase player, double x, double y, int size, Color color) { + if (!(player instanceof EntityPlayer)) + return; + + try { + GL11.glPushMatrix(); + mc.getTextureManager().bindTexture(((AbstractClientPlayer) player).getLocationSkin()); + GL11.glColor4f(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, color.getAlpha() / 255f); + + Gui.drawScaledCustomSizeModalRect((int) x, (int) y, 8, 8, 8, 8, size, size, 64, 64); + GL11.glPopMatrix(); + } catch (Exception ignored) { + } + } + + public static void drawRect(double x, double y, double x2, double y2, int color) { + GlStateManager.color(1, 1, 1, 1); + RenderUtil.drawRect(x, y, x2, y2, color); + } + public static void preRenderShade() { + GlStateManager.pushMatrix(); + GlStateManager.disableAlpha(); + GlStateManager.disableTexture2D(); + GlStateManager.enableBlend(); + GlStateManager.shadeModel(GL11.GL_SMOOTH); + GL11.glEnable(GL11.GL_LINE_SMOOTH); + GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); + GlStateManager.disableCull(); + } + + public static void postRenderShade() { + GlStateManager.enableAlpha(); + GlStateManager.enableTexture2D(); + GlStateManager.shadeModel(GL11.GL_FLAT); + GL11.glDisable(GL11.GL_LINE_SMOOTH); + GlStateManager.enableCull(); + GlStateManager.popMatrix(); + } + + public static void startScissorBox() { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_SCISSOR_TEST); + } + + public static void drawScissorBox(double x, double y, double width, double height) { + width = Math.max(width, 0.1); + + ScaledResolution sr = new ScaledResolution(mc); + double scale = sr.getScaleFactor(); + + y = sr.getScaledHeight() - y; + + x *= scale; + y *= scale; + width *= scale; + height *= scale; + + GL11.glScissor((int) x, (int) (y - height), (int) width, (int) height); + } + + public static void endScissorBox() { + GL11.glDisable(GL11.GL_SCISSOR_TEST); + GL11.glPopMatrix(); + } + + public static void drawCircleArc(double x, double y, double width, double height, Color color) { + drawArc(x + width / 2f, y + height / 2f, width / 2f, 0, 360f, color); + } + + public static double ticks = 0; + public static long lastFrame = 0; + + public static void drawCircle(float x, float y, float radius, int color) { + float alpha = (color >> 24 & 0xFF) / 255.0F; + float red = (color >> 16 & 0xFF) / 255.0F; + float green = (color >> 8 & 0xFF) / 255.0F; + float blue = (color & 0xFF) / 255.0F; + + glColor4f(red, green, blue, alpha); + glEnable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_LINE_SMOOTH); + glPushMatrix(); + glLineWidth(1F); + glBegin(GL_POLYGON); + for(int i = 0; i <= 360; i++) + glVertex2d(x + Math.sin(i * Math.PI / 180.0D) * radius, y + Math.cos(i * Math.PI / 180.0D) * radius); + glEnd(); + glPopMatrix(); + glEnable(GL_TEXTURE_2D); + glDisable(GL_LINE_SMOOTH); + glColor4f(1F, 1F, 1F, 1F); + } + + public static void drawCircle(Entity entity, double rad, int color, boolean shade) { + ticks += .004 * (System.currentTimeMillis() - lastFrame); + + lastFrame = System.currentTimeMillis(); + + GL11.glPushMatrix(); + GL11.glDisable(3553); + GL11.glEnable(2848); + GL11.glEnable(2832); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glHint(3154, 4354); + GL11.glHint(3155, 4354); + GL11.glHint(3153, 4354); + GL11.glDisable(2929); + GL11.glDepthMask(false); + if (shade) GL11.glShadeModel(GL11.GL_SMOOTH); + GlStateManager.disableCull(); + + Color c = new Color(color); + + double x = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) + * Minecraft.getMinecraft().timer.renderPartialTicks - renderManager.renderPosX; + double y = (entity.lastTickPosY + (entity.posY - entity.lastTickPosY) + * Minecraft.getMinecraft().timer.renderPartialTicks - renderManager.renderPosY) + Math.sin(ticks) + 1; + double z = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) + * Minecraft.getMinecraft().timer.renderPartialTicks - renderManager.renderPosZ; + + GL11.glBegin(GL11.GL_TRIANGLE_STRIP); + + double TAU = Math.PI * 2.D; + for (float i = 0; i < TAU; i += TAU / 64.F) { + + double vecX = x + rad * Math.cos(i); + double vecZ = z + rad * Math.sin(i); + + if (shade) { + GL11.glColor4f(c.getRed() / 255.F, + c.getGreen() / 255.F, + c.getBlue() / 255.F, + 0.05F + ); + + GL11.glVertex3d(vecX, y - Math.sin(ticks + 1) / 2.7f, vecZ); + } + + GL11.glColor4f(c.getRed() / 255.F, + c.getGreen() / 255.F, + c.getBlue() / 255.F, + 0.56F + ); + + GL11.glVertex3d(vecX, y, vecZ); + } + + GL11.glColor4f(1, 1, 1, 1); + GL11.glEnd(); + if (shade) GL11.glShadeModel(GL11.GL_FLAT); + GL11.glDepthMask(true); + GL11.glEnable(2929); + GlStateManager.enableCull(); + GL11.glDisable(2848); + GL11.glEnable(2832); + GL11.glEnable(3553); + GL11.glPopMatrix(); + + pushAttribAndMatrix(); + GL11.glPushMatrix(); + mc.entityRenderer.disableLightmap(); + GL11.glDisable(3553); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glDisable(2929); + GL11.glEnable(2848); + GL11.glDepthMask(false); + GL11.glPushMatrix(); + GL11.glLineWidth(2); + ColorUtils.INSTANCE.glColor(new Color(color)); + GL11.glBegin(1); + for (int i = 0; i <= 90; ++i) { + ColorUtils.INSTANCE.glColor(new Color(color)); + GL11.glVertex3d(x + rad * Math.cos((double) i * (Math.PI * 2) / 45), y, z + rad * Math.sin((double) i * (Math.PI * 2) / 45)); + } + GL11.glEnd(); + GL11.glPopMatrix(); + GL11.glDepthMask(true); + GL11.glDisable(2848); + GL11.glEnable(2929); + GL11.glDisable(3042); + GL11.glEnable(3553); + mc.entityRenderer.enableLightmap(); + GL11.glPopMatrix(); + popAttribAndMatrix(); + } + + public static void drawRoundedRectNew(double x, double y, double width, double height, double cornerRadius, Color color) { + drawRect(x, y + cornerRadius, x + cornerRadius, y + height - cornerRadius, color.getRGB()); + drawRect(x + cornerRadius, y, x + width - cornerRadius, y + height, color.getRGB()); + drawRect(x + width - cornerRadius, y + cornerRadius, x + width, y + height - cornerRadius, color.getRGB()); + drawArc(x + cornerRadius, y + cornerRadius, cornerRadius, 0, 90, color); + drawArc(x + width - cornerRadius, y + cornerRadius, cornerRadius, 270, 360, color); + drawArc(x + width - cornerRadius, y + height - cornerRadius, cornerRadius, 180, 270, color); + drawArc(x + cornerRadius, y + height - cornerRadius, cornerRadius, 90, 180, color); + } + + public static void drawRoundedRectOutlineNew(double x, double y, double width, double height, double cornerRadius, Color color) { + drawRect(x - 0.5, y + cornerRadius, x + 0.5, y + height - cornerRadius, color.getRGB()); + drawRect(x + width - 0.5, y + cornerRadius, x + width + 0.5, y + height - cornerRadius, color.getRGB()); + + drawRect(x + cornerRadius, y - 0.5, x + width - cornerRadius, y + 0.5, color.getRGB()); + drawRect(x + cornerRadius, y + height - 0.5, x + width - cornerRadius, y + height + 0.5, color.getRGB()); + + drawArcOutline(x + cornerRadius, y + cornerRadius, cornerRadius, 0, 90, 2, color); + drawArcOutline(x + width - cornerRadius, y + cornerRadius, cornerRadius, 270, 360, 2, color); + drawArcOutline(x + width - cornerRadius, y + height - cornerRadius, cornerRadius, 180, 270, 2, color); + drawArcOutline(x + cornerRadius, y + height - cornerRadius, cornerRadius, 90, 180, 2, color); + } + + public static void drawArc(double x, double y, double radius, double startAngle, double endAngle, Color color) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(3553); + GL11.glBlendFunc(770, 771); + + VertexUtils.start(6); + VertexUtils.add(x, y, color); + + for (double i = (startAngle / 360.0 * 100); i <= (endAngle / 360.0 * 100); i++) { + double angle = (Math.PI * 2 * i / 100) + Math.toRadians(180); + VertexUtils.add(x + Math.sin(angle) * radius, y + Math.cos(angle) * radius, color); + } + + VertexUtils.end(); + + GL11.glEnable(3553); + GL11.glDisable(3042); + GL11.glPopMatrix(); + } + + public static void drawCircleOutline(double x, double y, double width, double height, float lineWidth, Color color) { + drawArcOutline(x + width / 2f, y + height / 2f, width / 2f, 0, 360f, lineWidth, color); + } + + public static void drawCheck(double x, double y, Color color) { + GlStateManager.pushMatrix(); + preRenderShade(); + GL11.glLineWidth(2); + + VertexUtils.start(GL11.GL_LINE_STRIP); + + VertexUtils.add(x + 1, y, color); + VertexUtils.add(x + 3, y + 3.5, color); + VertexUtils.add(x + 7, y - 2.5, color); + + VertexUtils.end(); + + postRenderShade(); + GlStateManager.popMatrix(); + } + + public static void drawArcOutline(double x, double y, double radius, double startAngle, double endAngle, float lineWidth, Color color) { + GlStateManager.pushMatrix(); + preRenderShade(); + GL11.glLineWidth(lineWidth); + + VertexUtils.start(GL11.GL_LINE_STRIP); + + for (double i = (startAngle / 360.0 * 100); i <= (endAngle / 360.0 * 100); i++) { + double angle = (Math.PI * 2 * i / 100) + Math.toRadians(180); + VertexUtils.add(x + Math.sin(angle) * radius, y + Math.cos(angle) * radius, color); + } + + VertexUtils.end(); + postRenderShade(); + GlStateManager.popMatrix(); + } + + public static void drawBorderedRect(double x, double y, + double x1, double y1, double width, int internalColor, int borderColor) { + drawRect(x + width, y + width, x1 - width, y1 - width, internalColor); + drawRect(x + width, y, x1 - width, y + width, borderColor); + drawRect(x, y, x + width, y1, borderColor); + drawRect(x1 - width, y, x1, y1, borderColor); + drawRect(x + width, y1 - width, x1 - width, y1, borderColor); + } + public static void bindFrameBuffer(double x, double y, double width, double height, Framebuffer framebuffer) { + GL11.glBindTexture(GL11.GL_TEXTURE_2D, framebuffer.framebufferTexture); + drawQuad(x, y, width, height); + } + + public static void drawSmoothRect(double left, double top, double right, double bottom, int color) { + GlStateManager.resetColor(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LINE_SMOOTH); + drawRect(left, top, right, bottom, color); + GL11.glScalef(0.5f, 0.5f, 0.5f); + drawRect(left * 2.0f - 1.0f, top * 2.0f, left * 2.0f, bottom * 2.0f - 1.0f, color); + drawRect(left * 2.0f, top * 2.0f - 1.0f, right * 2.0f, top * 2.0f, color); + drawRect(right * 2.0f, top * 2.0f, right * 2.0f + 1.0f, bottom * 2.0f - 1.0f, color); + GL11.glDisable(GL11.GL_BLEND); + GL11.glScalef(2.0f, 2.0f, 2.0f); + } + + public static void drawColorRect(double left, double top, double right, double bottom, Color color1, Color color2, Color color3, Color color4) + { + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glEnable(GL11.GL_LINE_SMOOTH); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glPushMatrix(); + GL11.glBegin(GL11.GL_QUADS); + glColor(color2); + GL11.glVertex2d(left, bottom); + glColor(color3); + GL11.glVertex2d(right, bottom); + glColor(color4); + GL11.glVertex2d(right, top); + glColor(color1); + GL11.glVertex2d(left, top); + GL11.glEnd(); + GL11.glPopMatrix(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_LINE_SMOOTH); + GL11.glShadeModel(GL11.GL_FLAT); + Gui.drawRect(0, 0, 0, 0, 0); + } + + public static void renderShadowVertical(Color c, float lineWidth, double startAlpha, int size, double posX, double posY1, double posY2, boolean right, boolean edges) + { + GlStateManager.resetColor(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_CULL_FACE); + renderShadowVertical(lineWidth, startAlpha, size, posX, posY1, posY2, right, edges, (float)c.getRed() / 255.0f, (float)c.getGreen() / 255.0f, (float)c.getBlue() / 255.0f); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_BLEND); + } + + public static void renderShadowVertical(float lineWidth, double startAlpha, int size, double posX, double posY1, double posY2, boolean right, boolean edges, float red, float green, float blue) + { + double alpha = startAlpha; + GlStateManager.alphaFunc(516, 0.0f); + GL11.glLineWidth(lineWidth); + + if (right) + { + for (double x = 0.5; x < (double)size; x += 0.5) + { + GL11.glColor4d(red, green, blue, alpha); + GL11.glBegin(GL11.GL_LINES); + GL11.glVertex2d(posX + x, posY1 - (edges ? x : 0.0)); + GL11.glVertex2d(posX + x, posY2 + (edges ? x : 0.0)); + GL11.glEnd(); + alpha = startAlpha - x / (double)size; + } + } + else + { + for (double x = 0.0; x < (double)size; x += 0.5) + { + GL11.glColor4d(red, green, blue, alpha); + GL11.glBegin(GL11.GL_LINES); + GL11.glVertex2d(posX - x, posY1 - (edges ? x : 0.0)); + GL11.glVertex2d(posX - x, posY2 + (edges ? x : 0.0)); + GL11.glEnd(); + alpha = startAlpha - x / (double)size; + } + } + } + + public static void drawNewRect(double left, double top, double right, double bottom, int color) { + if (left < right) { + double i = left; + left = right; + right = i; + } + if (top < bottom) { + double j = top; + top = bottom; + bottom = j; + } + float f3 = (float)(color >> 24 & 0xFF) / 255.0f; + float f = (float)(color >> 16 & 0xFF) / 255.0f; + float f1 = (float)(color >> 8 & 0xFF) / 255.0f; + float f2 = (float)(color & 0xFF) / 255.0f; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer vertexbuffer = tessellator.getWorldRenderer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 0, 1); + GlStateManager.color(f, f1, f2, f3); + vertexbuffer.begin(7, DefaultVertexFormats.POSITION); + vertexbuffer.pos(left, bottom, 0.0).endVertex(); + vertexbuffer.pos(right, bottom, 0.0).endVertex(); + vertexbuffer.pos(right, top, 0.0).endVertex(); + vertexbuffer.pos(left, top, 0.0).endVertex(); + tessellator.draw(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static void drawGradientRect(double d, double e, double e2, double g, int startColor, int endColor) + { + float f = (float)(startColor >> 24 & 255) / 255.0F; + float f1 = (float)(startColor >> 16 & 255) / 255.0F; + float f2 = (float)(startColor >> 8 & 255) / 255.0F; + float f3 = (float)(startColor & 255) / 255.0F; + float f4 = (float)(endColor >> 24 & 255) / 255.0F; + float f5 = (float)(endColor >> 16 & 255) / 255.0F; + float f6 = (float)(endColor >> 8 & 255) / 255.0F; + float f7 = (float)(endColor & 255) / 255.0F; + GlStateManager.disableTexture2D(); + GlStateManager.enableBlend(); + GlStateManager.disableAlpha(); + GlStateManager.tryBlendFuncSeparate(770, 771, 0, 1); + GlStateManager.shadeModel(7425); + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer bufferbuilder = tessellator.getWorldRenderer(); + bufferbuilder.begin(7, DefaultVertexFormats.POSITION_COLOR); + bufferbuilder.pos((double)e2, (double)e, (double)zLevel).color(f1, f2, f3, f).endVertex(); + bufferbuilder.pos((double)d, (double)e, (double)zLevel).color(f1, f2, f3, f).endVertex(); + bufferbuilder.pos((double)d, (double)g, (double)zLevel).color(f5, f6, f7, f4).endVertex(); + bufferbuilder.pos((double)e2, (double)g, (double)zLevel).color(f5, f6, f7, f4).endVertex(); + tessellator.draw(); + GlStateManager.shadeModel(7424); + GlStateManager.disableBlend(); + GlStateManager.enableAlpha(); + GlStateManager.enableTexture2D(); + } + + public static void drawGradientSideways(double left, double top, double right, double bottom, int col1, int col2) { + float f = (col1 >> 24 & 255) / 255.0f; + float f1 = (col1 >> 16 & 255) / 255.0f; + float f2 = (col1 >> 8 & 255) / 255.0f; + float f3 = (col1 & 255) / 255.0f; + float f4 = (col2 >> 24 & 255) / 255.0f; + float f5 = (col2 >> 16 & 255) / 255.0f; + float f6 = (col2 >> 8 & 255) / 255.0f; + float f7 = (col2 & 255) / 255.0f; + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glBlendFunc(770, 771); + GL11.glEnable(2848); + GL11.glShadeModel(7425); + GL11.glPushMatrix(); + GL11.glBegin(7); + GL11.glColor4f(f1, f2, f3, f); + GL11.glVertex2d(left, top); + GL11.glVertex2d(left, bottom); + GL11.glColor4f(f, f6, f7, f4); + GL11.glVertex2d(right, bottom); + GL11.glVertex2d(right, top); + GL11.glEnd(); + GL11.glPopMatrix(); + GL11.glEnable(3553); + GL11.glDisable(3042); + } + + public static void renderItem(ItemStack itemStack, int x, int y) { + GlStateManager.enableBlend(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.enableDepth(); + net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting(); + mc.getRenderItem().renderItemAndEffectIntoGUI(itemStack, x, y); + mc.getRenderItem().renderItemOverlays(mc.fontRendererObj, itemStack, x, y); + net.minecraft.client.renderer.RenderHelper.disableStandardItemLighting(); + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + GlStateManager.disableDepth(); + } + + public static void drawQuad(double x, double y, double width, double height) { + GL11.glBegin(GL11.GL_QUADS); + + GL11.glTexCoord2d(0, 1); + GL11.glVertex2d(x, y); + + GL11.glTexCoord2d(0, 0); + GL11.glVertex2d(x, y + height); + + GL11.glTexCoord2d(1, 0); + GL11.glVertex2d(x + width, y + height); + + GL11.glTexCoord2d(1, 1); + GL11.glVertex2d(x + width, y); + + GL11.glEnd(); + } + + public static Framebuffer createFrameBuffer(Framebuffer framebuffer) { + if (framebuffer == null || framebuffer.framebufferWidth != mc.displayWidth + || framebuffer.framebufferHeight != mc.displayHeight) { + if (framebuffer != null) { + framebuffer.deleteFramebuffer(); + } + + return new Framebuffer(mc.displayWidth, mc.displayHeight, true); + } + + return framebuffer; + } + + public static void preLight() { + mc.entityRenderer.disableLightmap(); + } + + public static void postLight() { + mc.entityRenderer.enableLightmap(); + } + + public static void drawRoundedRect2(double x, double y, double width, double height, double cornerRadius, int color) { + drawRoundedRect2(x, y, width, height, cornerRadius, true, true, true, true, color); + } + + public static void drawRoundedRect(double x, double y, double width, double height, double cornerRadius, int color) { + int i; + GL11.glPushMatrix(); + GL11.glDisable(3553); + GL11.glEnable(2848); + GL11.glBlendFunc(770, 771); + setGLColor(color); + GL11.glBegin(9); + double cornerX = x + width - cornerRadius; + double cornerY = y + height - cornerRadius; + for (i = 0; i <= 90; i += 30) { + GL11.glVertex2d(cornerX + Math.sin((double)i * Math.PI / 180.0) * cornerRadius, cornerY + Math.cos((double)i * Math.PI / 180.0) * cornerRadius); + } + cornerX = x + width - cornerRadius; + cornerY = y + cornerRadius; + for (i = 90; i <= 180; i += 30) { + GL11.glVertex2d(cornerX + Math.sin((double)i * Math.PI / 180.0) * cornerRadius, cornerY + Math.cos((double)i * Math.PI / 180.0) * cornerRadius); + } + cornerX = x + cornerRadius; + cornerY = y + cornerRadius; + for (i = 180; i <= 270; i += 30) { + GL11.glVertex2d(cornerX + Math.sin((double)i * Math.PI / 180.0) * cornerRadius, cornerY + Math.cos((double)i * Math.PI / 180.0) * cornerRadius); + } + cornerX = x + cornerRadius; + cornerY = y + height - cornerRadius; + for (i = 270; i <= 360; i += 30) { + GL11.glVertex2d(cornerX + Math.sin((double)i * Math.PI / 180.0) * cornerRadius, cornerY + Math.cos((double)i * Math.PI / 180.0) * cornerRadius); + } + GL11.glEnd(); + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + GL11.glDisable(2848); + GL11.glEnable(3553); + GL11.glPopMatrix(); + setGLColor(Color.white); + } + + public static void drawRoundedRect2(double x, double y, double width, double height, double cornerRadius, boolean leftTop, boolean rightTop, boolean rightBottom, boolean leftBottom, int color) { + int i; + GL11.glPushMatrix(); + GL11.glDisable(3553); + GL11.glEnable(2848); + GL11.glEnable(3042); + GlStateManager.tryBlendFuncSeparate(770, 771, 0, 1); + setGLColor(color); + GL11.glBegin(9); + double cornerX = x + width - cornerRadius; + double cornerY = y + height - cornerRadius; + if (rightBottom) { + for (i = 0; i <= 90; ++i) { + GL11.glVertex2d(cornerX + Math.sin((double)i * Math.PI / 180.0) * cornerRadius, cornerY + Math.cos((double)i * Math.PI / 180.0) * cornerRadius); + } + } else { + GL11.glVertex2d(x + width, y + height); + } + if (rightTop) { + cornerX = x + width - cornerRadius; + cornerY = y + cornerRadius; + for (i = 90; i <= 180; ++i) { + GL11.glVertex2d(cornerX + Math.sin((double)i * Math.PI / 180.0) * cornerRadius, cornerY + Math.cos((double)i * Math.PI / 180.0) * cornerRadius); + } + } else { + GL11.glVertex2d(x + width, y); + } + if (leftTop) { + cornerX = x + cornerRadius; + cornerY = y + cornerRadius; + for (i = 180; i <= 270; ++i) { + GL11.glVertex2d(cornerX + Math.sin((double)i * Math.PI / 180.0) * cornerRadius, cornerY + Math.cos((double)i * Math.PI / 180.0) * cornerRadius); + } + } else { + GL11.glVertex2d(x, y); + } + if (leftBottom) { + cornerX = x + cornerRadius; + cornerY = y + height - cornerRadius; + for (i = 270; i <= 360; ++i) { + GL11.glVertex2d(cornerX + Math.sin((double)i * Math.PI / 180.0) * cornerRadius, cornerY + Math.cos((double)i * Math.PI / 180.0) * cornerRadius); + } + } else { + GL11.glVertex2d(x, y + height); + } + GL11.glEnd(); + setGLColor(new Color(255, 255, 255, 255)); + GL11.glDisable(2848); + GL11.glEnable(3553); + GL11.glPopMatrix(); + } + + public static void drawRoundedRectGradient(double x, double y, double width, double height, double cornerRadius, Color start, Color end) { + int i; + GL11.glPushMatrix(); + GL11.glDisable(3553); + GL11.glEnable(2848); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glShadeModel(7425); + color(start); + GL11.glBegin(9); + double cornerX = x + width - cornerRadius; + double cornerY = y + height - cornerRadius; + for (i = 0; i <= 90; i += 30) { + GL11.glVertex2d(cornerX + Math.sin((double)i * Math.PI / 180.0) * cornerRadius, cornerY + Math.cos((double)i * Math.PI / 180.0) * cornerRadius); + } + cornerX = x + width - cornerRadius; + cornerY = y + cornerRadius; + for (i = 90; i <= 180; i += 30) { + GL11.glVertex2d(cornerX + Math.sin((double)i * Math.PI / 180.0) * cornerRadius, cornerY + Math.cos((double)i * Math.PI / 180.0) * cornerRadius); + } + color(end); + cornerX = x + cornerRadius; + cornerY = y + cornerRadius; + for (i = 180; i <= 270; i += 30) { + GL11.glVertex2d(cornerX + Math.sin((double)i * Math.PI / 180.0) * cornerRadius, cornerY + Math.cos((double)i * Math.PI / 180.0) * cornerRadius); + } + cornerX = x + cornerRadius; + cornerY = y + height - cornerRadius; + for (i = 270; i <= 360; i += 30) { + GL11.glVertex2d(cornerX + Math.sin((double)i * Math.PI / 180.0) * cornerRadius, cornerY + Math.cos((double)i * Math.PI / 180.0) * cornerRadius); + } + GL11.glEnd(); + GL11.glShadeModel(7424); + color(1.0f, 1.0f, 1.0f, 1.0f); + GL11.glDisable(3042); + GL11.glDisable(2848); + GL11.glEnable(3553); + GL11.glPopMatrix(); + } + public static void bindTexture(int texture) { + glBindTexture(GL_TEXTURE_2D, texture); + } + + public static Color injectAlpha(Color color, int alpha) { + alpha = MathHelper.clamp_int(alpha, 0, 255); + return new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha); + } + + private static Framebuffer bloomFramebuffer = new Framebuffer(1, 1, false); + + public static void setAlphaLimit(float limit) { + GlStateManager.enableAlpha(); + GlStateManager.alphaFunc(GL_GREATER, (float) (limit * .01)); + } + + public static void drawFilledCircle(float xx, float yy, float radius, Color color) { + int sections = 50; + double dAngle = 6.283185307179586D / sections; + GL11.glPushAttrib(8192); + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glBlendFunc(770, 771); + GL11.glEnable(2848); + GL11.glBegin(6); + for (int i = 0; i < sections; i++) { + float x = (float) (radius * Math.sin(i * dAngle)); + float y = (float) (radius * Math.cos(i * dAngle)); + GL11.glColor4f(color.getRed() / 255.0F, color.getGreen() / 255.0F, color.getBlue() / 255.0F, + color.getAlpha() / 255.0F); + GL11.glVertex2f(xx + x, yy + y); + } + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glEnd(); + GL11.glPopAttrib(); + } + + public static void renderBlur(int x, int y, int width, int height, int blurRadius) { + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glDisable(2884); + blurAreaBoarder(x, y, width, height, blurRadius); + GL11.glDisable(3042); + GL11.glEnable(3553); + GL11.glEnable(2884); + GL11.glEnable(3008); + GL11.glEnable(3553); + GL11.glEnable(3042); + } + public static void renderBlur(int x, int y, int width, int height, int blurWidth, int blurHeight, int blurRadius) { + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glDisable(2884); + blurAreaBoarder(x, y, width, height, blurRadius, blurWidth, blurHeight); + GL11.glDisable(3042); + GL11.glEnable(3553); + GL11.glEnable(2884); + GL11.glEnable(3008); + GL11.glEnable(3553); + GL11.glEnable(3042); + } + + public static void roundedBorder(float x, float y, float x2, float y2, float radius, int color) { + float left = x; + float top = y; + float bottom = y2; + float right = x2; + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDepthMask(true); + GL11.glEnable(GL11.GL_LINE_SMOOTH); + GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); + GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_NICEST); + setColor(color); + glLineWidth(2); + GL11.glBegin(GL11.GL_LINE_LOOP); + GL11.glVertex2d(left, top + radius); + GL11.glVertex2f(left + radius, top); + GL11.glVertex2f(right - radius, top); + GL11.glVertex2f(right, top + radius); + GL11.glVertex2f(right, bottom - radius); + GL11.glVertex2f(right - radius, bottom); + GL11.glVertex2f(left + radius, bottom); + GL11.glVertex2f(left, bottom - radius); + GL11.glEnd(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_LINE_SMOOTH); + GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_DONT_CARE); + GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_DONT_CARE); + } + + public static void prepareScissorBox(int factor, float height, float x, float y, float x2, float y2) { + + GL11.glScissor((int) (x * factor), (int) ((height - y2) * factor), (int) ((x2 - x) * factor), (int) ((y2 - y) * factor)); + + } + public static void drawCircle(float x, float y, float start, float end, float radius, boolean filled, Color color) { + float sin; + float cos; + float i; + GlStateManager.color(0, 0, 0, 0); + + float endOffset; + if (start > end) { + endOffset = end; + end = start; + start = endOffset; + } + + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + setColor(color.getRGB()); + GL11.glEnable(GL11.GL_LINE_SMOOTH); + GL11.glLineWidth(2); + GL11.glBegin(GL11.GL_LINE_STRIP); + for (i = end; i >= start; i -= 4) { + cos = (float) (Math.cos(i * Math.PI / 180) * radius * 1); + sin = (float) (Math.sin(i * Math.PI / 180) * radius * 1); + GL11.glVertex2f(x + cos, y + sin); + } + GL11.glEnd(); + GL11.glDisable(GL11.GL_LINE_SMOOTH); + + GL11.glEnable(GL11.GL_LINE_SMOOTH); + GL11.glBegin(filled ? GL11.GL_TRIANGLE_FAN : GL11.GL_LINE_STRIP); + for (i = end; i >= start; i -= 4) { + cos = (float) Math.cos(i * Math.PI / 180) * radius; + sin = (float) Math.sin(i * Math.PI / 180) * radius; + GL11.glVertex2f(x + cos, y + sin); + } + GL11.glEnd(); + GL11.glDisable(GL11.GL_LINE_SMOOTH); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static void roundedBorder(float x, float y, float x2, float y2, float radius, float line, int color) { + float left = x; + float top = y; + float bottom = y2; + float right = x2; + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDepthMask(true); + GL11.glEnable(GL11.GL_LINE_SMOOTH); + GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); + GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_NICEST); + setColor(color); + glLineWidth(line); + GL11.glBegin(GL11.GL_LINE_LOOP); + GL11.glVertex2d(left, top + radius); + GL11.glVertex2f(left + radius, top); + GL11.glVertex2f(right - radius, top); + GL11.glVertex2f(right, top + radius); + GL11.glVertex2f(right, bottom - radius); + GL11.glVertex2f(right - radius, bottom); + GL11.glVertex2f(left + radius, bottom); + GL11.glVertex2f(left, bottom - radius); + GL11.glEnd(); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_LINE_SMOOTH); + GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_DONT_CARE); + GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_DONT_CARE); + } + + + public static void setColor(int color) { + GL11.glColor4ub((byte) (color >> 16 & 0xFF), (byte) (color >> 8 & 0xFF), (byte) (color & 0xFF), (byte) (color >> 24 & 0xFF)); + } + private static ShaderGroup blurShaderW; + + private static void shaderConfigFix(float intensity, float blurWidth, float blurHeight) { + blurShaderW.listShaders.get(0).getShaderManager().getShaderUniform("Radius").set(intensity); + blurShaderW.listShaders.get(1).getShaderManager().getShaderUniform("Radius").set(intensity); + blurShaderW.listShaders.get(0).getShaderManager().getShaderUniform("BlurDir").set(blurWidth, blurHeight); + blurShaderW.listShaders.get(1).getShaderManager().getShaderUniform("BlurDir").set(blurHeight, blurWidth); + } + + public static void blurAreaBoarder(float x, float f, float width, float height, float intensity, float blurWidth, float blurHeight) { + ScaledResolution scale = new ScaledResolution(mc); + int factor = scale.getScaleFactor(); + int factor2 = scale.getScaledWidth(); + int factor3 = scale.getScaledHeight(); + if (lastScale != factor || lastScaleWidth != factor2 || lastScaleHeight != factor3 || buffer == null || blurShader == null) { + inShaderFBO(); + } + lastScale = factor; + lastScaleWidth = factor2; + lastScaleHeight = factor3; + GL11.glScissor((int) (x * (float) factor), (int) ((float) mc.displayHeight - f * (float) factor - height * (float) factor) + 1, (int) (width * (float) factor), (int) (height * (float) factor)); + GL11.glEnable(3089); + shaderConfigFix(intensity, blurWidth, blurHeight); + buffer.bindFramebuffer(true); + blurShader.loadShaderGroup(mc.timer.renderPartialTicks); + mc.getFramebuffer().bindFramebuffer(true); + GL11.glDisable(3089); + } + + public static void blurAreaBoarder(int x, int y, int width, int height, float intensity) { + ScaledResolution scale = new ScaledResolution(mc); + int factor = scale.getScaleFactor(); + int factor2 = scale.getScaledWidth(); + int factor3 = scale.getScaledHeight(); + if (lastScale != factor || lastScaleWidth != factor2 || lastScaleHeight != factor3 || buffer == null || blurShader == null) { + inShaderFBO(); + } + lastScale = factor; + lastScaleWidth = factor2; + lastScaleHeight = factor3; + GL11.glScissor(x * factor, mc.displayHeight - y * factor - height * factor, width * factor, height * factor); + GL11.glEnable(3089); + shaderConfigFix(intensity, 1.0f, 0.0f); + buffer.bindFramebuffer(true); + blurShader.loadShaderGroup(mc.timer.renderPartialTicks); + mc.getFramebuffer().bindFramebuffer(true); + GL11.glDisable(3089); + } + + + public static void color(float red, float green, float blue, float alpha) { + GL11.glColor4f(red / 255.0f, green / 255.0f, blue / 255.0f, alpha / 255.0f); + } + + public static void color(Color color) { + color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); + } + + + public static void setGLColor(Color color) { + float r = (float)color.getRed() / 255.0f; + float g = (float)color.getGreen() / 255.0f; + float b = (float)color.getBlue() / 255.0f; + float a = (float)color.getAlpha() / 255.0f; + GL11.glColor4f(r, g, b, a); + } + + public static void setGLColor(int color) { + setGLColor(new Color(color)); + } +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/utils/render/VisualUtils.java b/src/main/java/net/ccbluex/liquidbounce/utils/render/VisualUtils.java new file mode 100644 index 0000000000..9a48ed1a32 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/utils/render/VisualUtils.java @@ -0,0 +1,5901 @@ +package net.ccbluex.liquidbounce.utils.render; + + +import net.ccbluex.liquidbounce.event.Render3DEvent; +import net.ccbluex.liquidbounce.ui.font.Fonts; +import net.ccbluex.liquidbounce.utils.MinecraftInstance; +import net.ccbluex.liquidbounce.utils.block.BlockUtils; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.*; +import net.minecraft.client.renderer.culling.Frustum; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemArmor; +import net.minecraft.item.ItemBow; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.util.*; +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.GL11; +import org.lwjgl.util.glu.Cylinder; +import org.lwjgl.util.glu.GLU; + +import java.awt.Color; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Supplier; + +import static java.lang.Math.*; +import static net.minecraft.client.renderer.GlStateManager.*; +import static org.lwjgl.opengl.GL11.*; +import static org.lwjgl.opengl.GL14.glBlendFuncSeparate; + +public class VisualUtils extends MinecraftInstance { + public Color getColor() { + return this.colorSupplier.get(); + } + + private static final Map glCapMap = new HashMap<>(); + private static final FloatBuffer WND_POS_BUFFER = GLAllocation.createDirectFloatBuffer(4); + private static final IntBuffer VIEWPORT_BUFFER = GLAllocation.createDirectIntBuffer(16); + private static final FloatBuffer MODEL_MATRIX_BUFFER = GLAllocation.createDirectFloatBuffer(16); + private static final FloatBuffer PROJECTION_MATRIX_BUFFER = GLAllocation.createDirectFloatBuffer(16); + private static final IntBuffer SCISSOR_BUFFER = GLAllocation.createDirectIntBuffer(16); + + private static FloatBuffer colorBuffer; + public static float deltaTime; + static boolean drawMode; + private static int counts = 0; + + public static float delta; + public static double renderPosX; + public static double renderPosY; + public static double renderPosZ; + public static double interpolate(double current, double old, double scale) { + return old + (current - old) * scale; + } + private static Frustum frustrum = new Frustum(); + protected float zLevel; + + private static ScaledResolution scaledResolution; + private static int lastWidth; + private static int lastHeight; + private static int lastScaledWidth; + private static int lastScaledHeight; + private static int lastGuiScale; + + private static final int[] DISPLAY_LISTS_2D = new int[4]; + public static int width() { + return new ScaledResolution(Minecraft.getMinecraft()).getScaledWidth(); + } + + public static int height() { + return new ScaledResolution(Minecraft.getMinecraft()).getScaledHeight(); + } + public static boolean isHovered(int mouseX, int mouseY, double x, double y, double width, double height) { + return mouseX > x && mouseX < width && mouseY > y && mouseY < height; + } + + public static void resetColor() { + GlStateManager.color(1, 1, 1, 1); + } + + + public static void prepareScissorBox(double x, double y, double x2, double y2) { + ScaledResolution scale = new ScaledResolution(Minecraft.getMinecraft()); + int factor = scale.getScaleFactor(); + GL11.glScissor((int) (x * (float) factor), (int) (((float) scale.getScaledHeight() - y2) * (float) factor), (int) ((x2 - x) * (float) factor), (int) ((y2 - y) * (float) factor)); + } + + public static void drawBorderedRoundedRect(float x, float y, float x1, float y1, float borderSize, int borderC, int insideC) { + drawRoundedRect(x, y, x1, y1, borderSize, borderC); + drawRoundedRect((x + 0.5F), (y + 0.5F), (x1 - 0.5F), (y1 - 0.5F), borderSize, insideC); + } + + public static float getAnimationState(float animation, float finalState, float speed) { + float add = deltaTime * speed; + animation = animation < finalState ? (animation + add < finalState ? (animation += add) : finalState) : (animation - add > finalState ? (animation -= add) : finalState); + return animation; + } + + public static double getAnimationStateSmooth(double target, double current, double speed) { + boolean larger = target > current; + if (speed < 0.0) { + speed = 0.0; + } else if (speed > 1.0) { + speed = 1.0; + } + if (target == current) { + return target; + } + double dif = Math.max(target, current) - Math.min(target, current); + double factor = dif * speed; + if (factor < 0.1) { + factor = 0.1; + } + if (larger) { + if (current + factor > target) { + current = target; + } else { + current += factor; + } + } else { + if (current - factor < target) { + current = target; + } else { + current -= factor; + } + } + return current; + } + + + public static float smoothAnimation(float ani, float finalState, float speed, float scale) { + return getAnimationState(ani, finalState, Math.max(10, (Math.abs(ani - finalState)) * speed) * scale); + } + + public static void drawImage(ResourceLocation image, float x, float y, float width, float height, float alpha) { + GlStateManager.disableDepth(); + GlStateManager.enableBlend(); + GL11.glDepthMask(false); + OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); + + GL11.glColor4f(1.0f, 1.0f, 1.0f, alpha); + Minecraft.getMinecraft().getTextureManager().bindTexture(image); + drawModalRectWithCustomSizedTexture(x, y, 0.0f, 0.0f, width, height, width, height); + + GL11.glDepthMask(true); + GlStateManager.disableBlend(); + GlStateManager.enableDepth(); + + GlStateManager.resetColor(); + } + + public static void drawImage(ResourceLocation image, float x, float y, float width, float height, int color) { + GlStateManager.disableDepth(); + GlStateManager.enableBlend(); + GL11.glDepthMask(false); + OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); + + float f = ((color >> 24) & 0xff) / 255F; + float f1 = ((color >> 16) & 0xff) / 255F; + float f2 = ((color >> 8) & 0xff) / 255F; + float f3 = (color & 0xff) / 255F; + + GL11.glColor4f(f1, f2, f3, f); + Minecraft.getMinecraft().getTextureManager().bindTexture(image); + drawModalRectWithCustomSizedTexture(x, y, 0.0f, 0.0f, width, height, width, height); + + GL11.glDepthMask(true); + GlStateManager.disableBlend(); + GlStateManager.enableDepth(); + + GlStateManager.resetColor(); + } + + public static void drawImage(ResourceLocation image, int x, int y, int width, int height, Color color) { + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + GL11.glDisable(2929); + GL11.glEnable(3042); + GL11.glDepthMask(false); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glColor4f((float) color.getRed() / 255.0f, (float) color.getBlue() / 255.0f, (float) color.getRed() / 255.0f, 1.0f); + Minecraft.getMinecraft().getTextureManager().bindTexture(image); + Gui.drawModalRectWithCustomSizedTexture(x, y, 0.0f, 0.0f, width, height, (float) width, (float) height); + GL11.glDepthMask(true); + GL11.glDisable(3042); + GL11.glEnable(2929); + } + + public static void drawImage(ResourceLocation image, float x, float y, int width, int height, Color color) { + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + GL11.glDisable(2929); + GL11.glEnable(3042); + GL11.glDepthMask(false); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glColor4f((float) color.getRed() / 255.0f, (float) color.getBlue() / 255.0f, (float) color.getRed() / 255.0f, 1.0f); + Minecraft.getMinecraft().getTextureManager().bindTexture(image); + drawModalRectWithCustomSizedTexture(x, y, 0.0f, 0.0f, width, height, (float) width, (float) height); + GL11.glDepthMask(true); + GL11.glDisable(3042); + GL11.glEnable(2929); + } + + public static double getAnimationState1(double animation, final double finalState, final double speed) { + + if (animation == finalState || speed == 0.0) {//减少不必要计算 + return animation; + } + + final double minSpeed = speed / 6; + final double maxSpeed = speed * 2.5; + + double sp33d = Math.pow(Math.abs(finalState - animation), 1.2) * 1.8; + sp33d = Math.max(minSpeed, Math.min(maxSpeed, sp33d));//限制范围 + + final float add = (float) (VisualUtils.delta * sp33d); + + if (animation < finalState) { + if (animation + add < finalState) { + animation += add; + } else { + animation = finalState; + } + } else if (animation - add > finalState) { + animation -= add; + } else { + animation = finalState; + } + return animation; + } + + public static void drawCircle(Entity e, float PartialTicks, double drawPercent){ + mc.entityRenderer.disableLightmap(); + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL11.GL_LINE_SMOOTH); + glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glShadeModel(7425); + mc.entityRenderer.disableLightmap(); + + AxisAlignedBB bb = e.getEntityBoundingBox(); + float radius = (float) (((bb.maxX - bb.minX) + (bb.maxZ - bb.minZ)) * 0.5f); + double height = bb.maxY - bb.minY; + EntityLivingBase it = (EntityLivingBase) e; + double x = it.lastTickPosX + (it.posX - it.lastTickPosX) * PartialTicks - mc.getRenderManager().viewerPosX; + double y = (it.lastTickPosY + (it.posY - it.lastTickPosY) * PartialTicks - mc.getRenderManager().viewerPosY) + height * drawPercent; + double z = it.lastTickPosZ + (it.posZ - it.lastTickPosZ) * PartialTicks - mc.getRenderManager().viewerPosZ; + mc.entityRenderer.disableLightmap(); + GL11.glBegin(GL11.GL_QUAD_STRIP); + double eased = (height) / 3 * ((drawPercent > 0.5 ? 1 - drawPercent : drawPercent) * (drawMode ? -1 : 1)); + for (int i = 0;i<=360;i+=5) { + glColor4f(1,1,1,0.5f); + GL11.glVertex3d(x - Math.sin(i * Math.PI / 180F) * radius, y, z + Math.cos(i * Math.PI / 180F) * radius); + glColor4f(1,1,1,0f); + GL11.glVertex3d(x - Math.sin(i * Math.PI / 180F) * radius, y + eased /*+ (drawMode ? 0.2 : -0.2)*/, z + Math.cos(i * Math.PI / 180F) * radius); + } + GL11.glEnd(); + glEnable(GL11.GL_CULL_FACE); + GL11.glShadeModel(7424); + glColor4f(1f, 1f, 1f, 1f); + glEnable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_LINE_SMOOTH); + GL11.glDisable(GL11.GL_BLEND); + glEnable(GL11.GL_TEXTURE_2D); + glPopMatrix(); + } + public static void drawCircle2(Entity e, float PartialTicks,double drawPercent){ + mc.entityRenderer.disableLightmap(); + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL11.GL_LINE_SMOOTH); + glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_DEPTH_TEST); + AxisAlignedBB bb = e.getEntityBoundingBox(); + float radius = (float) (((bb.maxX - bb.minX) + (bb.maxZ - bb.minZ)) * 0.5f); + double height = bb.maxY - bb.minY; + EntityLivingBase it = (EntityLivingBase) e; + double x = it.lastTickPosX + (it.posX - it.lastTickPosX) * PartialTicks - mc.getRenderManager().viewerPosX; + double y = (it.lastTickPosY + (it.posY - it.lastTickPosY) * PartialTicks - mc.getRenderManager().viewerPosY) + height * drawPercent; + double z = it.lastTickPosZ + (it.posZ - it.lastTickPosZ) * PartialTicks - mc.getRenderManager().viewerPosZ; + mc.entityRenderer.disableLightmap(); + GL11.glLineWidth(2); + GL11.glBegin(GL11.GL_LINE_STRIP); + for (int i = 0;i<=360;i+=10) { + glColor4f(1,1,1,1f); + GL11.glVertex3d(x - Math.sin(i * Math.PI / 180F) * radius, y, z + Math.cos(i * Math.PI / 180F) * radius); + } + GL11.glEnd(); + glEnable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_LINE_SMOOTH); + GL11.glDisable(GL11.GL_BLEND); + glEnable(GL11.GL_TEXTURE_2D); + glPopMatrix(); + } + + public static Color getColorAnimationState(Color animation, Color finalState, double speed) { + float add = (float)((double)deltaTime * speed); + float animationr = animation.getRed(); + float animationg = animation.getGreen(); + float animationb = animation.getBlue(); + float finalStater = finalState.getRed(); + float finalStateg = finalState.getGreen(); + float finalStateb = finalState.getBlue(); + float finalStatea = finalState.getAlpha(); + animationr = animationr < finalStater ? (animationr + add < finalStater ? (animationr += add) : finalStater) : (animationr - add > finalStater ? (animationr -= add) : finalStater); + animationg = animationg < finalStateg ? (animationg + add < finalStateg ? (animationg += add) : finalStateg) : (animationg - add > finalStateg ? (animationg -= add) : finalStateg); + animationb = animationb < finalStateb ? (animationb + add < finalStateb ? (animationb += add) : finalStateb) : (animationb - add > finalStateb ? (animationb -= add) : finalStateb); + animationr /= 255.0f; + animationg /= 255.0f; + animationb /= 255.0f; + finalStatea /= 255.0f; + if (animationr > 1.0f) { + animationr = 1.0f; + } + if (animationg > 1.0f) { + animationg = 1.0f; + } + if (animationb > 1.0f) { + animationb = 1.0f; + } + if (finalStatea > 1.0f) { + finalStatea = 1.0f; + } + return new Color(animationr, animationg, animationb, finalStatea); + } + + + public static class R2DUtils { + public static void enableGL2D() { + GL11.glDisable((int) 2929); + GL11.glEnable((int) 3042); + GL11.glDisable((int) 3553); + GL11.glBlendFunc((int) 770, (int) 771); + GL11.glDepthMask((boolean) true); + GL11.glEnable((int) 2848); + GL11.glHint((int) 3154, (int) 4354); + GL11.glHint((int) 3155, (int) 4354); + } + + public static void disableGL2D() { + GL11.glEnable((int) 3553); + GL11.glDisable((int) 3042); + GL11.glEnable((int) 2929); + GL11.glDisable((int) 2848); + GL11.glHint((int) 3154, (int) 4352); + GL11.glHint((int) 3155, (int) 4352); + } + + public static void drawRoundedRect(float x, float y, float x1, float y1, int borderC, int insideC) { + R2DUtils.enableGL2D(); + GL11.glScalef((float) 0.5f, (float) 0.5f, (float) 0.5f); + R2DUtils.drawVLine(x *= 2.0f, (y *= 2.0f) + 1.0f, (y1 *= 2.0f) - 2.0f, borderC); + R2DUtils.drawVLine((x1 *= 2.0f) - 1.0f, y + 1.0f, y1 - 2.0f, borderC); + R2DUtils.drawHLine(x + 2.0f, x1 - 3.0f, y, borderC); + R2DUtils.drawHLine(x + 2.0f, x1 - 3.0f, y1 - 1.0f, borderC); + R2DUtils.drawHLine(x + 1.0f, x + 1.0f, y + 1.0f, borderC); + R2DUtils.drawHLine(x1 - 2.0f, x1 - 2.0f, y + 1.0f, borderC); + R2DUtils.drawHLine(x1 - 2.0f, x1 - 2.0f, y1 - 2.0f, borderC); + R2DUtils.drawHLine(x + 1.0f, x + 1.0f, y1 - 2.0f, borderC); + R2DUtils.drawRect(x + 1.0f, y + 1.0f, x1 - 1.0f, y1 - 1.0f, insideC); + GL11.glScalef((float) 2.0f, (float) 2.0f, (float) 2.0f); + R2DUtils.disableGL2D(); + Gui.drawRect(0, 0, 0, 0, 0); + } + + public static void drawRect(double x2, double y2, double x1, double y1, int color) { + R2DUtils.enableGL2D(); + R2DUtils.glColor(color); + R2DUtils.drawRect(x2, y2, x1, y1); + R2DUtils.disableGL2D(); + } + + private static void drawRect(double x2, double y2, double x1, double y1) { + GL11.glBegin((int) 7); + GL11.glVertex2d((double) x2, (double) y1); + GL11.glVertex2d((double) x1, (double) y1); + GL11.glVertex2d((double) x1, (double) y2); + GL11.glVertex2d((double) x2, (double) y2); + GL11.glEnd(); + } + + public static void glColor(int hex) { + float alpha = (float) (hex >> 24 & 255) / 255.0f; + float red = (float) (hex >> 16 & 255) / 255.0f; + float green = (float) (hex >> 8 & 255) / 255.0f; + float blue = (float) (hex & 255) / 255.0f; + GL11.glColor4f((float) red, (float) green, (float) blue, (float) alpha); + } + + public static void drawRect(float x, float y, float x1, float y1, int color) { + R2DUtils.enableGL2D(); + glColor(color); + R2DUtils.drawRect(x, y, x1, y1); + R2DUtils.disableGL2D(); + } + + public static void drawBorderedRect(float x, float y, float x1, float y1, float width, int borderColor) { + R2DUtils.enableGL2D(); + glColor(borderColor); + R2DUtils.drawRect(x + width, y, x1 - width, y + width); + R2DUtils.drawRect(x, y, x + width, y1); + R2DUtils.drawRect(x1 - width, y, x1, y1); + R2DUtils.drawRect(x + width, y1 - width, x1 - width, y1); + R2DUtils.disableGL2D(); + } + + public static void drawBorderedRect(float x, float y, float x1, float y1, int insideC, int borderC) { + R2DUtils.enableGL2D(); + GL11.glScalef((float) 0.5f, (float) 0.5f, (float) 0.5f); + R2DUtils.drawVLine(x *= 2.0f, y *= 2.0f, y1 *= 2.0f, borderC); + R2DUtils.drawVLine((x1 *= 2.0f) - 1.0f, y, y1, borderC); + R2DUtils.drawHLine(x, x1 - 1.0f, y, borderC); + R2DUtils.drawHLine(x, x1 - 2.0f, y1 - 1.0f, borderC); + R2DUtils.drawRect(x + 1.0f, y + 1.0f, x1 - 1.0f, y1 - 1.0f, insideC); + GL11.glScalef((float) 2.0f, (float) 2.0f, (float) 2.0f); + R2DUtils.disableGL2D(); + } + + public static void drawGradientRect(float x, float y, float x1, float y1, int topColor, int bottomColor) { + R2DUtils.enableGL2D(); + GL11.glShadeModel((int) 7425); + GL11.glBegin((int) 7); + glColor(topColor); + GL11.glVertex2f((float) x, (float) y1); + GL11.glVertex2f((float) x1, (float) y1); + glColor(bottomColor); + GL11.glVertex2f((float) x1, (float) y); + GL11.glVertex2f((float) x, (float) y); + GL11.glEnd(); + GL11.glShadeModel((int) 7424); + R2DUtils.disableGL2D(); + } + + public static void drawHLine(float x, float y, float x1, int y1) { + if (y < x) { + float var5 = x; + x = y; + y = var5; + } + R2DUtils.drawRect(x, x1, y + 1.0f, x1 + 1.0f, y1); + } + + public static void drawVLine(float x, float y, float x1, int y1) { + if (x1 < y) { + float var5 = y; + y = x1; + x1 = var5; + } + R2DUtils.drawRect(x, y + 1.0f, x + 1.0f, x1, y1); + } + + public static void drawHLine(float x, float y, float x1, int y1, int y2) { + if (y < x) { + float var5 = x; + x = y; + y = var5; + } + R2DUtils.drawGradientRect(x, x1, y + 1.0f, x1 + 1.0f, y1, y2); + } + + public static void drawRect(float x, float y, float x1, float y1) { + GL11.glBegin((int) 7); + GL11.glVertex2f((float) x, (float) y1); + GL11.glVertex2f((float) x1, (float) y1); + GL11.glVertex2f((float) x1, (float) y); + GL11.glVertex2f((float) x, (float) y); + GL11.glEnd(); + } + } + + //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan + //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan + //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan + //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan + //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan + //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan + //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan + //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan //utils skidder QingRan + + + + public static void drawLine(float x, float y, float x2, float y2, Color color) { + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate((int)770, (int)771, (int)1, (int)0); + GL11.glEnable((int)2848); + GL11.glLineWidth((float)1.0f); + GlStateManager.color((float)((float)color.getRed() / 255.0f), (float)((float)color.getGreen() / 255.0f), (float)((float)color.getBlue() / 255.0f), (float)((float)color.getAlpha() / 255.0f)); + worldrenderer.begin(1, DefaultVertexFormats.POSITION); + worldrenderer.pos((double)x, (double)y, 0.0).endVertex(); + worldrenderer.pos((double)x2, (double)y2, 0.0).endVertex(); + tessellator.draw(); + GL11.glDisable((int)2848); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + + public static void drawImage2(ResourceLocation image, float x, float y, int width, int height) { + glDisable(GL_DEPTH_TEST); + glEnable(GL_BLEND); + glDepthMask(false); + OpenGlHelper.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); + glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + glTranslatef(x, y, x); + mc.getTextureManager().bindTexture(image); + Gui.drawModalRectWithCustomSizedTexture(0, 0, 0, 0, width, height, width, height); + glTranslatef(-x, -y, -x); + glDepthMask(true); + glDisable(GL_BLEND); + glEnable(GL_DEPTH_TEST); + } + + public static void drawImage3(ResourceLocation image, float x, float y, int width, int height, float r, float g, float b, float al) { + glDisable(GL_DEPTH_TEST); + glEnable(GL_BLEND); + glDepthMask(false); + OpenGlHelper.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); + glColor4f(r, g, b, al); + glTranslatef(x, y, x); + mc.getTextureManager().bindTexture(image); + Gui.drawModalRectWithCustomSizedTexture(0, 0, 0, 0, width, height, width, height); + glTranslatef(-x, -y, -x); + glDepthMask(true); + glDisable(GL_BLEND); + glEnable(GL_DEPTH_TEST); + } + + + public static Color getGradientOffset(Color color1, Color color2, double offset) { + double inverse_percent; + int redPart; + if(offset > 1.0D) { + inverse_percent = offset % 1.0D; + redPart = (int)offset; + offset = redPart % 2 == 0?inverse_percent:1.0D - inverse_percent; + } + + inverse_percent = 1.0D - offset; + redPart = (int)((double)color1.getRed() * inverse_percent + (double)color2.getRed() * offset); + int greenPart = (int)((double)color1.getGreen() * inverse_percent + (double)color2.getGreen() * offset); + int bluePart = (int)((double)color1.getBlue() * inverse_percent + (double)color2.getBlue() * offset); + return new Color(redPart, greenPart, bluePart); + } + + public static int FadeRainbow(int var2, float bright, float st) { + double v1 = Math.ceil((double)(System.currentTimeMillis() + (long)(var2 * 109))) / 5.0D; + return getGradientOffset(new Color(168, 245, 143), new Color(115, 193, 98), v1 / 60.0D).getRGB(); + } + + public static void drawHorizontalLine(float x, float y, float x1, float thickness, int color) { + rectangle(x, y, x1, y + thickness, color); + } + + + public static void drawVerticalLine(float x, float y, float y1, float thickness, int color) { + rectangle(x, y, x + thickness, y1, color); + } + + public static void shadow(final Entity player, final double x, final double y, final double z, final double range,int s,int color) { + GL11.glPushMatrix(); + GL11.glDisable(2896); + GL11.glDisable(3553); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glDisable(2929); + GL11.glEnable(2848); + GL11.glDepthMask(true); + GlStateManager.translate(x, y, z); + GlStateManager.color(0.1f,0.1f,0.1f,0.75f); + GlStateManager.rotate(180.0f, 90.0f, 0.0f, 2.0f); + GlStateManager.rotate(180.0f, 0.0f, 90.0f, 90.0f); + GlStateManager.resetColor(); + glColor(color); + GL11.glBegin(2); + Cylinder c = new Cylinder(); + c.setDrawStyle(100011); + c.draw((float) (range - 0.45), + (float) (range - 0.5), 0.0f, s, 0); + GL11.glDepthMask(true); + GL11.glDisable(2848); + GL11.glEnable(2929); + GL11.glDisable(3042); + GL11.glEnable(2896); + GL11.glEnable(3553); + GL11.glPopMatrix(); + } + + public static void cylinder(final Entity player, final double x, final double y, final double z, final double range,int s,int color) { + GL11.glPushMatrix(); + GL11.glDisable(2896); + GL11.glDisable(3553); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glDisable(2929); + GL11.glEnable(2848); + GL11.glDepthMask(true); + GlStateManager.translate(x, y, z); + GlStateManager.color(1.0f, 1.0f, 1.0f, 0.75f); + GlStateManager.rotate(180.0f, 90.0f, 0.0f, 2.0f); + GlStateManager.rotate(180.0f, 0.0f, 90.0f, 90.0f); + GlStateManager.resetColor(); + glColor(color); + GL11.glBegin(2); + Cylinder c = new Cylinder(); + c.setDrawStyle(100011); + c.draw((float) (range - 0.5), + (float) (range - 0.5), 0.0f, s, 0); + GL11.glDepthMask(true); + GL11.glDisable(2848); + GL11.glEnable(2929); + GL11.glDisable(3042); + GL11.glEnable(2896); + GL11.glEnable(3553); + GL11.glPopMatrix(); + } + + public static void NdrawCircle(float cx, float cy, float r, int num_segments , float width , int color) { + GL11.glPushMatrix(); + cx *= 2.0F; + cy *= 2.0F; + float theta = (float) (6.2831852D / num_segments); + float p = (float) Math.cos(theta); + float s = (float) Math.sin(theta); + float x = r *= 2.0F; + float y = 0.0F; + enableGL2D(); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GlStateManager.color(0 , 0, 0); + glLineWidth(width); + + GlStateManager.resetColor(); + glColor(color); + GL11.glBegin(2); + int ii = 0; + while (ii < num_segments) { + GL11.glVertex2f(x + cx, y + cy); + float t = x; + x = p * x - s * y; + y = s * t + p * y; + ii++; + } + glColor(color); + GL11.glEnd(); + GL11.glScalef(2.0F, 2.0F, 2.0F); + disableGL2D(); + GlStateManager.color(1, 1, 1, 1); + GL11.glPopMatrix(); + } + + public static void drawESPCircle(float cx, float cy, float r, int num_segments, int color) { + GL11.glPushMatrix(); + cx *= 2.0F; + cy *= 2.0F; + float theta = (float) (6.2831852D / num_segments); + float p = (float) Math.cos(theta); + float s = (float) Math.sin(theta); + float x = r *= 2.0F; + float y = 0.0F; + enableGL2D(); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GlStateManager.color(0 , 0, 0); + + GlStateManager.resetColor(); + glColor(color); + GL11.glBegin(2); + int ii = 0; + while (ii < num_segments) { + GL11.glVertex2f(x + cx, y + cy); + float t = x; + x = p * x - s * y; + y = s * t + p * y; + ii++; + } + Colors.getColor(-1); + GL11.glEnd(); + GL11.glScalef(2.0F, 2.0F, 2.0F); + disableGL2D(); + GlStateManager.color(1, 1, 1, 1); + GL11.glPopMatrix(); + } + + + private static FloatBuffer modelView = BufferUtils.createFloatBuffer(16); + private static FloatBuffer projection = BufferUtils.createFloatBuffer(16); + private static IntBuffer viewport = BufferUtils.createIntBuffer(16); + + public static void updateView() { + GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelView); + GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projection); + GL11.glGetInteger(GL11.GL_VIEWPORT, viewport); + } + + public static Vec3 WorldToScreen(Vec3 position) { + FloatBuffer screenPositions = BufferUtils.createFloatBuffer(3); + boolean result = GLU.gluProject((float) position.xCoord, (float) position.yCoord, (float) position.zCoord, modelView, projection, viewport, screenPositions); + if (result) { + return new Vec3(screenPositions.get(0), Display.getHeight() - screenPositions.get(1), screenPositions.get(2)); + } + return null; + } + + + public static void drawNewRect(float left, float top, float right, float bottom, int color) + { + if (left < right) + { + float i = left; + left = right; + right = i; + } + + if (top < bottom) + { + float j = top; + top = bottom; + bottom = j; + } + + float f3 = (float)(color >> 24 & 255) / 255.0F; + float f = (float)(color >> 16 & 255) / 255.0F; + float f1 = (float)(color >> 8 & 255) / 255.0F; + float f2 = (float)(color & 255) / 255.0F; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.color(f, f1, f2, f3); + worldrenderer.begin(7, DefaultVertexFormats.POSITION); + worldrenderer.pos((double)left, (double)bottom, 0.0D).endVertex(); + worldrenderer.pos((double)right, (double)bottom, 0.0D).endVertex(); + worldrenderer.pos((double)right, (double)top, 0.0D).endVertex(); + worldrenderer.pos((double)left, (double)top, 0.0D).endVertex(); + tessellator.draw(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + public static Vec3 getEntityRenderPosition(Entity entity) { + return new Vec3(getEntityRenderX(entity), getEntityRenderY(entity), getEntityRenderZ(entity)); + } + + public static double getEntityRenderX(Entity entity) { + return entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * Minecraft.getMinecraft().timer.renderPartialTicks - mc.getRenderManager().renderPosX; + } + + public static double getEntityRenderY(Entity entity) { + return entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * Minecraft.getMinecraft().timer.renderPartialTicks - mc.getRenderManager().renderPosY; + } + + public static double getEntityRenderZ(Entity entity) { + return entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * Minecraft.getMinecraft().timer.renderPartialTicks - mc.getRenderManager().renderPosZ; + } + + public static int RedRainbow() { + counts++; + int RainbowColor = VisualUtils.rainbow(System.nanoTime(), counts, 0.5f).getRGB(); + int c = RainbowColor; + Color col = new Color(c); + return new Color(col.getRed()/150f, 25/ 255.0f, 25/ 255.0f).getRGB(); + } + + public static void chamsColor(final Color color) { + final float red = color.getRed() / 255F; + final float green = color.getGreen() / 255F; + final float blue = color.getBlue() / 255F; + final float alpha = color.getAlpha() / 255F; + GL11.glColor4d(red, green, blue, alpha); + } + + public static int getNormalRainbow(int delay, float sat, float brg) { + double rainbowState = Math.ceil((System.currentTimeMillis() + delay) / 20.0); + rainbowState %= 360; + return Color.getHSBColor((float) (rainbowState / 360.0f), sat, brg).getRGB(); + } + + public static void rectTexture(float x, float y, float w, float h, ResourceLocation texture, int color) { + if (texture == null) { + return; + } + GlStateManager.color(0.0f, 0.0f, 0.0f); + GL11.glColor4f((float)0.0f, (float)0.0f, (float)0.0f, (float)0.0f); + x = Math.round(x); + w = Math.round(w); + y = Math.round(y); + h = Math.round(h); + float var11 = (float)(color >> 24 & 0xFF) / 255.0f; + float var6 = (float)(color >> 16 & 0xFF) / 255.0f; + float var7 = (float)(color >> 8 & 0xFF) / 255.0f; + float var8 = (float)(color & 0xFF) / 255.0f; + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.color(var6, var7, var8, var11); + GL11.glEnable((int)3042); + GL11.glEnable((int)3553); + mc.getTextureManager().bindTexture(texture); + float tw = w / (float)w / (w / (float)w); + float th = h / (float)h / (h / (float)h); + GL11.glBegin((int)7); + GL11.glTexCoord2f((float)0.0f, (float)0.0f); + GL11.glVertex2f((float)x, (float)y); + GL11.glTexCoord2f((float)0.0f, (float)th); + GL11.glVertex2f((float)x, (float)(y + h)); + GL11.glTexCoord2f((float)tw, (float)th); + GL11.glVertex2f((float)(x + w), (float)(y + h)); + GL11.glTexCoord2f((float)tw, (float)0.0f); + GL11.glVertex2f((float)(x + w), (float)y); + GL11.glEnd(); + GL11.glDisable((int)3553); + GL11.glDisable((int)3042); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static void kaMark(final Entity entity, final Color color) { + final RenderManager renderManager = mc.getRenderManager(); + final Timer timer = mc.timer; + + final double x = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * timer.renderPartialTicks + - renderManager.renderPosX; + final double y = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * timer.renderPartialTicks + - renderManager.renderPosY; + final double z = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * timer.renderPartialTicks + - renderManager.renderPosZ; + + final AxisAlignedBB axisAlignedBB = entity.getEntityBoundingBox() + .offset(-entity.posX, -entity.posY, -entity.posZ) + .offset(x, y, z); + + drawAxisAlignedBB( + new AxisAlignedBB(axisAlignedBB.minX - 0.025, axisAlignedBB.maxY - 0.35, axisAlignedBB.minZ - 0.025, axisAlignedBB.maxX + 0.025, axisAlignedBB.maxY - 0.275, axisAlignedBB.maxZ + 0.025), + color + ); + } + + private final static FloatBuffer modelview = GLAllocation.createDirectFloatBuffer(16); + private final static FloatBuffer projections = GLAllocation.createDirectFloatBuffer(16); + + public static void MoondrawRect(double x, double y, double width, double height, int color) { + float f = (color >> 24 & 0xFF) / 255.0F; + float f1 = (color >> 16 & 0xFF) / 255.0F; + float f2 = (color >> 8 & 0xFF) / 255.0F; + float f3 = (color & 0xFF) / 255.0F; + GL11.glColor4f(f1, f2, f3, f); + MoondrawRect2(x, y, x + width, y + height, color); + } + + public static void MoondrawRect2(double left, double top, double right, double bottom, int color) { + if (left < right) + { + int i = (int)left; + left = right; + right = i; + } + + if (top < bottom) + { + int j = (int)top; + top = bottom; + bottom = j; + } + + float f3 = (float)(color >> 24 & 255) / 255.0F; + float f = (float)(color >> 16 & 255) / 255.0F; + float f1 = (float)(color >> 8 & 255) / 255.0F; + float f2 = (float)(color & 255) / 255.0F; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.color(f, f1, f2, f3); + worldrenderer.begin(7, DefaultVertexFormats.POSITION); + worldrenderer.pos((double)left, (double)bottom, 0.0D).endVertex(); + worldrenderer.pos((double)right, (double)bottom, 0.0D).endVertex(); + worldrenderer.pos((double)right, (double)top, 0.0D).endVertex(); + worldrenderer.pos((double)left, (double)top, 0.0D).endVertex(); + tessellator.draw(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static void drawESPCircle(float cx,float cy,float r,float n,Color color) { + GL11.glPushMatrix(); + cx *= 2.0; + cy *= 2.0; + double b = 6.2831852 / n; + double p = Math.cos(b); + double s = Math.sin(b); + double x = r *= 2.0; + double y = 0.0; + enableGL2D(); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GlStateManager.color(0,0,0); + GlStateManager.resetColor(); + glColor(color); + GL11.glBegin(2); + int ii = 0; + while (ii < n) { + GL11.glVertex2f((float)x + cx,(float) y + cy); + double t = x; + x = p * x - s * y; + y = s * t + p * y; + ii++; + } + GL11.glEnd(); + GL11.glScalef(2.0F, 2.0F, 2.0F); + disableGL2D(); + GlStateManager.color(1, 1, 1, 1); + GL11.glPopMatrix(); + } + + public static boolean isHovering(final int n, final int n2, final float n3, final float n4, final float n5, final float n6) { + return n > n3 && n < n5 && n2 > n4 && n2 < n6; + } + + public static void drawblock2(double a, double a2, double a3, int a4, int a5, float a6) { + float a7 = (float) (a4 >> 24 & 255) / 255.0f; + float a8 = (float) (a4 >> 16 & 255) / 255.0f; + float a9 = (float) (a4 >> 8 & 255) / 255.0f; + float a10 = (float) (a4 & 255) / 255.0f; + float a11 = (float) (a5 >> 24 & 255) / 255.0f; + float a12 = (float) (a5 >> 16 & 255) / 255.0f; + float a13 = (float) (a5 >> 8 & 255) / 255.0f; + float a14 = (float) (a5 & 255) / 255.0f; + GL11.glPushMatrix(); + GL11.glEnable(3042); + GL11.glBlendFunc(770, (int) 771); + GL11.glDisable(3553); + GL11.glEnable(2848); + GL11.glDisable(2929); + GL11.glDepthMask(false); + GL11.glColor4f((float) a8, (float) a9, (float) a10, (float) a7); + drawOutlinedBoundingBox(new AxisAlignedBB(a, a2, a3, a + 1.0, a2 + 1.0, a3 + 1.0)); + GL11.glLineWidth((float) a6); + GL11.glColor4f((float) a12, (float) a13, (float) a14, (float) a11); + drawOutlinedBoundingBox(new AxisAlignedBB(a, a2, a3, a + 1.0, a2 + 1.0, a3 + 1.0)); + GL11.glDisable(2848); + GL11.glEnable(3553); + GL11.glEnable(2929); + GL11.glDepthMask(true); + GL11.glDisable(3042); + GL11.glPopMatrix(); + } + + public static void drawVLine(final float x, final float y, final float x1, final float y1, final float width, final int color) { + if (width <= 0.0f) { + return; + } + GL11.glPushMatrix(); + pre3D(); + final float var11 = (color >> 24 & 0xFF) / 255.0f; + final float var12 = (color >> 16 & 0xFF) / 255.0f; + final float var13 = (color >> 8 & 0xFF) / 255.0f; + final float var14 = (color & 0xFF) / 255.0f; + GlStateManager.enableAlpha(); + GlStateManager.enableBlend(); + final int shade = GL11.glGetInteger(2900); + GlStateManager.shadeModel(7425); + GL11.glColor4f(var12, var13, var14, var11); + final float line = GL11.glGetFloat(2849); + GL11.glLineWidth(width); + GL11.glBegin(3); + GL11.glVertex3d((double)x, (double)y, 0.0); + GL11.glVertex3d((double)x1, (double)y1, 0.0); + GL11.glEnd(); + GlStateManager.shadeModel(shade); + GL11.glLineWidth(line); + post3D(); + GL11.glPopMatrix(); + } + + + public static void setupRender(final boolean start) { + if (start) { + GlStateManager.enableBlend(); + GL11.glEnable(2848); + GlStateManager.disableDepth(); + GlStateManager.disableTexture2D(); + GlStateManager.blendFunc(770, 771); + GL11.glHint(3154, 4354); + } + else { + GlStateManager.disableBlend(); + GlStateManager.enableTexture2D(); + GL11.glDisable(2848); + GlStateManager.enableDepth(); + } + GlStateManager.depthMask(!start); + } + + + public static double[] convertTo2D(final double x, final double y, final double z) { + final FloatBuffer screenCoords = BufferUtils.createFloatBuffer(3); + final IntBuffer viewport = BufferUtils.createIntBuffer(16); + final FloatBuffer modelView = BufferUtils.createFloatBuffer(16); + final FloatBuffer projection = BufferUtils.createFloatBuffer(16); + GL11.glGetFloat(2982, modelView); + GL11.glGetFloat(2983, projection); + GL11.glGetInteger(2978, viewport); + final boolean result = GLU.gluProject((float) x, (float) y, (float) z, modelView, projection, viewport, + screenCoords); + return (double[]) (result + ? new double[] { screenCoords.get(0), Display.getHeight() - screenCoords.get(1), screenCoords.get(2) } + : null); + } + + public static double interpolate(double newPos, double oldPos) { + return oldPos + (newPos - oldPos) * (double) Minecraft.getMinecraft().timer.renderPartialTicks; + } + + public static void entityESPBox(Entity e, Color color, Render3DEvent event) { + double renderPosX = mc.getRenderManager().renderPosX; + double renderPosY = mc.getRenderManager().renderPosY; + double renderPosZ = mc.getRenderManager().renderPosZ; + double posX = e.lastTickPosX + (e.posX - e.lastTickPosX) * (double) event.getPartialTicks() - renderPosX; + double posY = e.lastTickPosY + (e.posY - e.lastTickPosY) * (double) event.getPartialTicks() - renderPosY; + double posZ = e.lastTickPosZ + (e.posZ - e.lastTickPosZ) * (double) event.getPartialTicks() - renderPosZ; + AxisAlignedBB box = AxisAlignedBB.fromBounds(posX - (double) e.width, posY, posZ - (double) e.width, + posX + (double) e.width, posY + (double) e.height + 0.2, posZ + (double) e.width); + if (e instanceof EntityLivingBase) { + box = AxisAlignedBB.fromBounds(posX - (double) e.width + 0.2, posY, posZ - (double) e.width + 0.2, + posX + (double) e.width - 0.2, posY + (double) e.height + (e.isSneaking() ? 0.02 : 0.2), + posZ + (double) e.width - 0.2); + } + EntityLivingBase e2 = (EntityLivingBase)e; + if(e2.hurtTime!=0) { + GL11.glColor4f(1f, 0.2f, 0.1f, 0.2f); + }else{ + GL11.glColor4f(1f, 1f, 1f, 0.2f); + } + VisualUtils.drawBoundingBox(box); + } + + public static void pre() { + GL11.glDisable(2929); + GL11.glDisable(3553); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + } + + public static void pre3D() { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_LINE_SMOOTH); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDepthMask(false); + GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST); + } + + public static void post3D() { + GL11.glDepthMask(true); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_LINE_SMOOTH); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + GL11.glColor4f(1, 1, 1, 1); + } + + public static void enableGL3D(float lineWidth) { + GL11.glDisable(3008); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glDisable(3553); + GL11.glDisable(2929); + GL11.glDepthMask(false); + GL11.glEnable(2884); + GL11.glEnable(2848); + GL11.glHint(3154, 4354); + GL11.glHint(3155, 4354); + GL11.glLineWidth(lineWidth); + } + public static void disableGL3D() { + GL11.glEnable(3553); + GL11.glEnable(2929); + GL11.glDisable(3042); + GL11.glEnable(3008); + GL11.glDepthMask(true); + GL11.glCullFace(1029); + GL11.glDisable(2848); + GL11.glHint(3154, 4352); + GL11.glHint(3155, 4352); + } + + public static void drawHead(ResourceLocation skin, int width, int height) { + GL11.glColor4f(1F, 1F, 1F, 1F); + mc.getTextureManager().bindTexture(skin); + Gui.drawScaledCustomSizeModalRect(2, 2, 8F, 8F, 8, 8, width, height, + 64F, 64F); + } + + public static void setColor(int colorHex) { + float alpha = (float) (colorHex >> 24 & 255) / 255.0F; + float red = (float) (colorHex >> 16 & 255) / 255.0F; + float green = (float) (colorHex >> 8 & 255) / 255.0F; + float blue = (float) (colorHex & 255) / 255.0F; + GL11.glColor4f(red, green, blue, alpha == 0.0F ? 1.0F : alpha); + } + + public static void drawWolframEntityESP(EntityLivingBase entity, int rgb, double posX, double posY, double posZ) { + GL11.glPushMatrix(); + GL11.glTranslated(posX, posY, posZ); + GL11.glRotatef(-entity.rotationYaw, 0.0F, 1.0F, 0.0F); + setColor(rgb); + enableGL3D(1.0F); + Cylinder c = new Cylinder(); + GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); + c.setDrawStyle(100011); + c.draw(0.5F, 0.5F, entity.height + 0.1F, 18, 1); + disableGL3D(); + GL11.glPopMatrix(); + } + + + public static void glColor114514(final int hex) { + final float alpha = (hex >> 24 & 0xFF) / 255F; + final float red = (hex >> 16 & 0xFF) / 255F; + final float green = (hex >> 8 & 0xFF) / 255F; + final float blue = (hex & 0xFF) / 255F; + + GlStateManager.color(red, green, blue, alpha); + } + + public static void enableGL2D() { + GL11.glDisable(2929); + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glBlendFunc(770, 771); + GL11.glDepthMask(true); + GL11.glEnable(2848); + GL11.glHint(3154, 4354); + GL11.glHint(3155, 4354); + } + + public static void disableGL2D() { + GL11.glEnable(3553); + GL11.glDisable(3042); + GL11.glEnable(2929); + GL11.glDisable(2848); + GL11.glHint(3154, 4352); + GL11.glHint(3155, 4352); + } + + public static void drawTriAngle(float cx,float cy,float r,float n,int color) { + GL11.glPushMatrix(); + cx *= 2.0; + cy *= 2.0; + double b = Math.PI * 2 / n; + double p = Math.cos(b); + double s = Math.sin(b); + double x = r * 2.0; + double y = 0.0; + enableGL2D(); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GlStateManager.color(0,0,0); + GlStateManager.resetColor(); + glColor114514(color); + GL11.glBegin(2); + int ii = 0; + while (ii < n) { + GL11.glVertex2d(x + cx, y + cy); + double t = x; + x = p * x - s * y; + y = s * t + p * y; + ii++; + } + GL11.glEnd(); + GL11.glScalef(2.0F, 2.0F, 2.0F); + disableGL2D(); + GlStateManager.color(1, 1, 1, 1); + GL11.glPopMatrix(); + } + + + + public static void triangle(float x1, float y1, float x2, float y2, float x3, float y3, int fill) { + GlStateManager.color(0, 0, 0); + GL11.glColor4f(0, 0, 0, 0); + + float var11 = (float)(fill >> 24 & 255) / 255.0F; + float var6 = (float)(fill >> 16 & 255) / 255.0F; + float var7 = (float)(fill >> 8 & 255) / 255.0F; + float var8 = (float)(fill & 255) / 255.0F; + + Tessellator var9 = Tessellator.getInstance(); + WorldRenderer var10 = var9.getWorldRenderer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.color(var6, var7, var8, var11); + GL11.glEnable(GL_LINE_SMOOTH); + GL11.glBegin(GL11.GL_TRIANGLE_FAN); + GL11.glVertex2f(x1, y1); + GL11.glVertex2f(x3, y3); + GL11.glVertex2f(x2, y2); + GL11.glVertex2f(x1, y1); + GL11.glEnd(); + GL11.glDisable(GL_LINE_SMOOTH); + + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static int drawText(String text, int width, int height, float size) { + GlStateManager.pushMatrix(); + GlStateManager.scale(size, size, size); + int length = mc.fontRendererObj.drawString(text, Math.round(width / size), Math.round(height / size), 0xffffffff); + GlStateManager.popMatrix(); + return length; + } + + + public static int getRGB(int r, int g, int b) { + return getRGB(r,g,b,255); + } + + @SuppressWarnings("PointlessBitwiseExpression") + public static int getRGB(int r, int g, int b, int a) { + return ((a & 0xFF) << 24) | + ((r & 0xFF) << 16) | + ((g & 0xFF) << 8) | + ((b & 0xFF) << 0); + } + + public static int getRGB(int rgb) { + return 0xff000000 | rgb; + } + + public static int getRed(int rgb) { + return (rgb >> 16) & 0xFF; + } + + public static int getGreen(int rgb) { + return (rgb >> 8) & 0xFF; + } + + @SuppressWarnings("PointlessBitwiseExpression") + public static int getBlue(int rgb) { + return (rgb >> 0) & 0xFF; + } + + + public static void drawCheck(double x, double y, int lineWidth, int color) { + start2D(); + GL11.glPushMatrix(); + GL11.glLineWidth(lineWidth); + setColor(new Color(color)); + GL11.glBegin(GL_LINE_STRIP); + GL11.glVertex2d(x, y); + GL11.glVertex2d(x + 2, y + 3); + GL11.glVertex2d(x + 6, y - 2); + GL11.glEnd(); + GL11.glPopMatrix(); + stop2D(); + } + + public static void drawRect2(float x, float y, float x2, float y2, int color, boolean shadow) { + float var1 = 1.0F; + if(shadow) { + for(int i = 0; i < 2; ++i) { + drawRect(x - var1, y - var1, x2 + var1, y2 + var1, (new Color(0, 0, 0, 50)).getRGB()); + var1 = (float)((double)var1 - 0.5D); + } + } + + drawRect(x, y, x2, y2, color); + } + + public static void start2D() { + glEnable(3042); + glDisable(3553); + glBlendFunc(770, 771); + glEnable(2848); + } + + public static void stop2D() { + glEnable(3553); + glDisable(3042); + glDisable(2848); + enableTexture2D(); + disableBlend(); + glColor4f(1, 1, 1, 1); + } + + public static void setColor(Color color) { + float alpha = (color.getRGB() >> 24 & 0xFF) / 255.0F; + float red = (color.getRGB() >> 16 & 0xFF) / 255.0F; + float green = (color.getRGB() >> 8 & 0xFF) / 255.0F; + float blue = (color.getRGB() & 0xFF) / 255.0F; + GL11.glColor4f(red, green, blue, alpha); + } + + public static void drawArrow(double x, double y, int lineWidth, int color, double length) { + start2D(); + GL11.glPushMatrix(); + GL11.glLineWidth(lineWidth); + setColor(new Color(color)); + GL11.glBegin(GL_LINE_STRIP); + GL11.glVertex2d(x, y); + GL11.glVertex2d(x + 3, y + length); + GL11.glVertex2d(x + 3 * 2, y); + GL11.glEnd(); + GL11.glPopMatrix(); + stop2D(); + } + + public static void renderItemStack(final ItemStack stack, final int x, final int y) { + GlStateManager.pushMatrix(); + GlStateManager.depthMask(true); + GlStateManager.clear(256); + RenderHelper.enableStandardItemLighting(); + Minecraft.getMinecraft().getRenderItem().zLevel = -150.0f; + GlStateManager.disableDepth(); + GlStateManager.disableTexture2D(); + GlStateManager.enableBlend(); + GlStateManager.enableAlpha(); + GlStateManager.enableTexture2D(); + GlStateManager.enableLighting(); + GlStateManager.enableDepth(); + Minecraft.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI(stack, x, y); + final RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); + Minecraft.getMinecraft(); + renderItem.renderItemOverlays(mc.fontRendererObj, stack, x, y); + Minecraft.getMinecraft().getRenderItem().zLevel = 0.0f; + RenderHelper.disableStandardItemLighting(); + GlStateManager.disableCull(); + GlStateManager.enableAlpha(); + GlStateManager.disableBlend(); + GlStateManager.disableLighting(); + final double s = 0.5; + GlStateManager.scale(s, s, s); + GlStateManager.disableDepth(); + GlStateManager.enableDepth(); + GlStateManager.scale(2.0f, 2.0f, 2.0f); + GlStateManager.popMatrix(); + } + + public static Color reAlpha(Color cIn, float alpha){ + return new Color(cIn.getRed()/255f,cIn.getGreen()/255f,cIn.getBlue()/255f,cIn.getAlpha() / 255f * alpha); + } + + public static void drawtargethudRect(double d, double e, double g, double h, int color, int i) { + drawRect(d+1, e, g-1, h, color); + drawRect(d, e+1, d+1, h-1, color); + drawRect(d+1, e+1, d+0.5, e+0.5, color); + drawRect(d+1, e+1, d+0.5, e+0.5, color); + drawRect(g-1, e+1, g-0.5, e+0.5, color); + drawRect(g-1, e+1, g, h-1, color); + drawRect(d+1, h-1, d+0.5, h-0.5, color); + drawRect(g-1, h-1, g-0.5, h-0.5, color); + } + + public static void drawblock(double a, double a2, double a3, int a4, int a5, float a6) { + float a7 = (float) (a4 >> 24 & 255) / 255.0f; + float a8 = (float) (a4 >> 16 & 255) / 255.0f; + float a9 = (float) (a4 >> 8 & 255) / 255.0f; + float a10 = (float) (a4 & 255) / 255.0f; + float a11 = (float) (a5 >> 24 & 255) / 255.0f; + float a12 = (float) (a5 >> 16 & 255) / 255.0f; + float a13 = (float) (a5 >> 8 & 255) / 255.0f; + float a14 = (float) (a5 & 255) / 255.0f; + GL11.glPushMatrix(); + GL11.glEnable((int) 3042); + GL11.glBlendFunc((int) 770, (int) 771); + GL11.glDisable((int) 3553); + GL11.glEnable((int) 2848); + GL11.glDisable((int) 2929); + GL11.glDepthMask((boolean) false); + GL11.glColor4f((float) a8, (float) a9, (float) a10, (float) a7); + drawOutlinedBoundingBox(new AxisAlignedBB(a, a2, a3, a + 1.0, a2 + 1.0, a3 + 1.0)); + GL11.glLineWidth((float) a6); + GL11.glColor4f((float) a12, (float) a13, (float) a14, (float) a11); + drawOutlinedBoundingBox(new AxisAlignedBB(a, a2, a3, a + 1.0, a2 + 1.0, a3 + 1.0)); + GL11.glDisable((int) 2848); + GL11.glEnable((int) 3553); + GL11.glEnable((int) 2929); + GL11.glDepthMask((boolean) true); + GL11.glDisable((int) 3042); + GL11.glPopMatrix(); + } + public static void drawFace(int x, int y,float scale, AbstractClientPlayer target) { + try { + ResourceLocation skin = target.getLocationSkin(); + Minecraft.getMinecraft().getTextureManager().bindTexture(skin); + GL11.glEnable(GL11.GL_BLEND); + GL11.glColor4f(1, 1, 1, 1); + Gui.drawScaledCustomSizeModalRect(x, y, 8.0f, 8.0f, 8, 8, (int)scale, (int)scale, 64.0f, 64.0f); + GL11.glDisable(GL11.GL_BLEND); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void prepareScissorBox(final float x, final float y, final float x2, final float y2) { + final ScaledResolution scale = new ScaledResolution(mc); + final int factor = scale.getScaleFactor(); + GL11.glScissor((int)(x * factor), (int)((scale.getScaledHeight() - y2) * factor), (int)((x2 - x) * factor), (int)((y2 - y) * factor)); + } + + public static void drawBordered(double x2, double y2, double width, double height, double length, int innerColor, int outerColor) { + drawRect(x2, y2, x2 + width, y2 + height, innerColor); + drawRect(x2 - length, y2, x2, y2 + height, outerColor); + drawRect(x2 - length, y2 - length, x2 + width, y2, outerColor); + drawRect(x2 + width, y2 - length, x2 + width + length, y2 + height + length, outerColor); + drawRect(x2 - length, y2 + height, x2 + width, y2 + height + length, outerColor); + } + + public static void drawRoundRect(float d, float e, float g, float h, int color) + { + drawRect(d+1, e, g, h, color); + drawRect(d, e+0.75, d, h, color); + drawRect(d, e+1, d+1, h-0.5, color); + drawRect(d-0.75, e+1.5, d, h-1.25, color); + } + + public static void autoExhibition(double x, double y, double x1, double y1, double size) { + rectangleBordered(x, y, x1 + size, y1 + size, 0.5, Colors.getColor(90), Colors.getColor(0)); + rectangleBordered(x + 1.0, y + 1.0, x1 + size - 1.0, y1 + size - 1.0, 1.0, Colors.getColor(90), Colors.getColor(61)); + rectangleBordered(x + 2.5, y + 2.5, x1 + size - 2.5, y1 + size - 2.5, 0.5, Colors.getColor(61), Colors.getColor(0)); + } + + public static void drawCheckMark(float x, float y, int width, int color) { + float f = (color >> 24 & 255) / 255.0f; + float f1 = (color >> 16 & 255) / 255.0f; + float f2 = (color >> 8 & 255) / 255.0f; + float f3 = (color & 255) / 255.0f; + GL11.glPushMatrix(); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glDisable(3553); + glEnable(2848); + glBlendFunc(770, 771); + GL11.glLineWidth(1.5f); + GL11.glBegin(3); + GL11.glColor4f(f1, f2, f3, f); + GL11.glVertex2d(x + width - 6.5, y + 3); + GL11.glVertex2d(x + width - 11.5, y + 10); + GL11.glVertex2d(x + width - 13.5, y + 8); + GL11.glEnd(); + glEnable(3553); + glDisable(GL_BLEND); + GL11.glPopMatrix(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + + public static void drawRoundedRect(int left, int top, int right, int bottom, int smooth, Color color) { + Gui.drawRect((left + smooth), top, (right - smooth), bottom, color.getRGB()); + Gui.drawRect(left, (top + smooth), right, (bottom - smooth), color.getRGB()); + drawFilledCircle((int)left + smooth, (int)top + smooth, smooth, color); + drawFilledCircle((int)right - smooth, (int)top + smooth, smooth, color); + drawFilledCircle((int)right - smooth, (int)bottom - smooth, smooth, color); + drawFilledCircle((int)left + smooth, (int)bottom - smooth, smooth, color); + } + + public static void drawLine(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) { + + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + + minX -= Minecraft.getMinecraft().getRenderManager().renderPosX; + minY -= Minecraft.getMinecraft().getRenderManager().renderPosY; + minZ -= Minecraft.getMinecraft().getRenderManager().renderPosZ; + + maxX -= Minecraft.getMinecraft().getRenderManager().renderPosX; + maxY -= Minecraft.getMinecraft().getRenderManager().renderPosY; + maxZ -= Minecraft.getMinecraft().getRenderManager().renderPosZ; + + GL11.glBlendFunc(770, 771); + GL11.glEnable(GL11.GL_BLEND); + GL11.glLineWidth(3.0F); + GL11.glColor4d(0, 1, 0, 0.15F); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glDepthMask(false); + //drawColorBox(new AxisAlignedBB(x, y, z, x + 1.0, y + 1.0, z + 1.0)); + GL11.glColor4d(1, 1, 1, 0.5F); + + worldrenderer.begin(1, DefaultVertexFormats.POSITION); + worldrenderer.pos(minX, minY, minZ).endVertex(); + worldrenderer.pos(maxX, maxY, maxZ).endVertex(); + tessellator.draw(); + + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glDepthMask(true); + GL11.glDisable(GL11.GL_BLEND); + GL11.glColor4f(1, 1, 1, 1); + + } + + public static void drawTracerLine(double x, double y, double z, float red, float green, float blue, float alpha, float lineWdith) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LINE_SMOOTH); + GL11.glDisable(GL11.GL_DEPTH_TEST); + // GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glBlendFunc(770, 771); + GL11.glEnable(GL11.GL_BLEND); + GL11.glLineWidth(lineWdith); + GL11.glColor4f(red, green, blue, alpha); + GL11.glBegin(2); + GL11.glVertex3d(0.0D, 0.0D + Minecraft.getMinecraft().thePlayer.getEyeHeight(), 0.0D); + GL11.glVertex3d(x, y, z); + GL11.glEnd(); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glDisable(GL11.GL_LINE_SMOOTH); + GL11.glDisable(GL11.GL_BLEND); + // GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + + public static boolean ifdrawRect(int x1, int y1, float x2, int y2, int mousex, int mousey, int color) { + if (mousex > x1 && mousex < x2 && mousey > y1 && mousey < y2) { + GL11.glPushMatrix(); + GlStateManager.enableBlend(); + GL11.glEnable((int) 3042); + GL11.glDisable((int) 3553); + GL11.glBlendFunc((int) 770, (int) 771); + GL11.glEnable((int) 2848); + GL11.glPushMatrix(); + color(color); + GL11.glBegin((int) 7); + GL11.glVertex2d((double) x2, (double) y1); + GL11.glVertex2d((double) x1, (double) y1); + GL11.glVertex2d((double) x1, (double) y2); + GL11.glVertex2d((double) x2, (double) y2); + GL11.glEnd(); + GL11.glPopMatrix(); + GL11.glEnable((int) 3553); + GL11.glDisable((int) 3042); + GL11.glDisable((int) 2848); + GlStateManager.disableBlend(); + GL11.glPopMatrix(); + return true; + } else { + return false; + } + } + + public static void stopDrawing() { + GL11.glDisable(3042); + GL11.glEnable(3553); + GL11.glDisable(2848); + GL11.glDisable(3042); + GL11.glEnable(2929); + } + public static void startDrawing() { + GL11.glEnable(3042); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glEnable(2848); + GL11.glDisable(3553); + GL11.glDisable(2929); + Minecraft.getMinecraft().entityRenderer.setupCameraTransform(Minecraft.getMinecraft().timer.renderPartialTicks, 0); + } + + public static void post() { + GL11.glDisable(3042); + GL11.glEnable(3553); + GL11.glEnable(2929); + GL11.glColor3d(1.0, 1.0, 1.0); + } + + public static boolean isInViewFrustrum(Entity entity) { + return isInViewFrustrum(entity.getEntityBoundingBox()) || entity.ignoreFrustumCheck; + } + + public static boolean isInViewFrustrum(AxisAlignedBB bb) { + Entity current = Minecraft.getMinecraft().getRenderViewEntity(); + frustrum.setPosition(current.posX, current.posY, current.posZ); + return frustrum.isBoundingBoxInFrustum(bb); + } + + public static void doGlScissor(int x, int y, int width, int height2) { + int scaleFactor = 1; + int k = mc.gameSettings.guiScale; + if (k == 0) { + k = 1000; + } + while (scaleFactor < k && mc.displayWidth / (scaleFactor + 1) >= 320 && mc.displayHeight / (scaleFactor + 1) >= 240) { + ++scaleFactor; + } + GL11.glScissor((x * scaleFactor), (mc.displayHeight - (y + height2) * scaleFactor), (width * scaleFactor), (height2 * scaleFactor)); + } + public static void doGlScissor(float x, float y, float windowWidth2, float windowHeight2) { + int scaleFactor = 1; + float k = mc.gameSettings.guiScale; + if (k == 0) { + k = 1000; + } + while (scaleFactor < k && mc.displayWidth / (scaleFactor + 1) >= 320 + && mc.displayHeight / (scaleFactor + 1) >= 240) { + ++scaleFactor; + } + GL11.glScissor((int) (x * scaleFactor), (int) (mc.displayHeight - (y + windowHeight2) * scaleFactor), + (int) (windowWidth2 * scaleFactor), (int) (windowHeight2 * scaleFactor)); + } + + + private static final long startTime=System.currentTimeMillis(); + + public static Color arrayRainbow(int offset){ + return new Color(Color.HSBtoRGB((float) ((double) ((System.currentTimeMillis()-startTime)/10000F)+ Math.sin((double) (((System.currentTimeMillis()-startTime)/100F)%50) + offset) / 50.0 * 1.6) % 1.0f, 0.5f, 1.0f)); + } + public static void drawScaledRect(int x, int y, float u, float v, int uWidth, int vHeight, int width, int height, + float tileWidth, float tileHeight) { + Gui.drawScaledCustomSizeModalRect(x, y, u, v, uWidth, vHeight, width, height, tileWidth, tileHeight); + } + + public static void drawRect1(float g, float h, float i, float j, int col1) { + float f2 = (float) (col1 >> 24 & 255) / 255.0f; + float f22 = (float) (col1 >> 16 & 255) / 255.0f; + float f3 = (float) (col1 >> 8 & 255) / 255.0f; + float f4 = (float) (col1 & 255) / 255.0f; + GL11.glEnable((int) 3042); + GL11.glDisable((int) 3553); + GL11.glBlendFunc((int) 770, (int) 771); + GL11.glEnable((int) 2848); + GL11.glPushMatrix(); + GL11.glColor4f((float) f22, (float) f3, (float) f4, (float) f2); + GL11.glBegin((int) 7); + GL11.glVertex2d((double) i, (double) h); + GL11.glVertex2d((double) g, (double) h); + GL11.glVertex2d((double) g, (double) j); + GL11.glVertex2d((double) i, (double) j); + GL11.glEnd(); + GL11.glPopMatrix(); + GL11.glEnable((int) 3553); + GL11.glDisable((int) 3042); + GL11.glDisable((int) 2848); + } + + + public static void circle1(final float x, final float y, final float radius, final int fill) { + + arc(x, y, 0.0f, 360.0f, radius, fill); + } + + public static void circle1(final float x, final float y, final float radius, final Color fill) { + arc(x, y, 0.0f, 360.0f, radius, fill); + } + + + public static void arc1(final float x, final float y, final float start, final float end, final float radius, + final int color) { + arcEllipse1(x, y, start, end, radius, radius, color); + } + public static void arcEllipse1(final float x, final float y, float start, float end, final float w, final float h, + final int color) { + GlStateManager.color(0.0f, 0.0f, 0.0f); + GL11.glColor4f(0.0f, 0.0f, 0.0f, 0.0f); + float temp; + if (start > end) { + temp = end; + end = start; + start = temp; + } + final float alpha = (color >> 24 & 0xFF) / 255.0f; + final float red = (color >> 16 & 0xFF) / 255.0f; + final float green = (color >> 8 & 0xFF) / 255.0f; + final float blue = (color & 0xFF) / 255.0f; + final Tessellator tessellator = Tessellator.getInstance(); + tessellator.getWorldRenderer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.color(red, green, blue, alpha); + if (alpha > 0.5f) { + GL11.glEnable(GL_POLYGON_SMOOTH); + GL11.glEnable(2848); + GL11.glLineWidth(2.0f); + GL11.glBegin(3); + for (float i = end; i >= start; i -= 4.0f) { + final float ldx = (float) Math.cos(i * Math.PI / 180.0) * w * 1.001f; + final float ldy = (float) Math.sin(i * Math.PI / 180.0) * h * 1.001f; + GL11.glVertex2f(x + ldx, y + ldy); + } + GL11.glEnd(); + GL11.glDisable(2848); + GL11.glDisable(GL_POLYGON_SMOOTH); + } + GL11.glBegin(6); + for (float i = end; i >= start; i -= 4.0F) { + final float ldx = (float) Math.cos(i * Math.PI / 180.0) * w; + final float ldy = (float) Math.sin(i * Math.PI / 180.0) * h; + GL11.glVertex2f(x + ldx, y + ldy); + } + GL11.glEnd(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + public static void drawFilledCircle1(float xx, float yy, float radius, int col) { + float f = (float) (col >> 24 & 255) / 255.0f; + float f1 = (float) (col >> 16 & 255) / 255.0f; + float f2 = (float) (col >> 8 & 255) / 255.0f; + float f3 = (float) (col & 255) / 255.0f; + int sections = 50; + double dAngle = 6.283185307179586 / (double) sections; + GL11.glPushMatrix(); + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glBlendFunc(770, 771); + GL11.glEnable(2848); + GL11.glBegin(6); + int i = 0; + while (i < sections) { + float x = (float) ((double) radius * Math.sin((double) i * dAngle)); + float y = (float) ((double) radius * Math.cos((double) i * dAngle)); + GL11.glColor4f(f1, f2, f3, f); + GL11.glVertex2f(xx + x, yy + y); + ++i; + } + GlStateManager.color(0.0f, 0.0f, 0.0f); + GL11.glEnd(); + GL11.glEnable(3553); + GL11.glDisable(3042); + GL11.glDisable(2848); + GL11.glPopMatrix(); + } + + public static void drawFilledCircle1(final int xx, final int yy, final float radius, final Color color) { + int sections = 50; + double dAngle = 2 * Math.PI / sections; + float x, y; + + glPushMatrix(); + glEnable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_LINE_SMOOTH); + + for (int i = 0; i < sections; i++) { + x = (float) (radius * Math.sin((i * dAngle))); + y = (float) (radius * Math.cos((i * dAngle))); + + glColor4f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, color.getAlpha() / 255F); + glVertex2f(xx + x, yy + y); + } + GlStateManager.color(0, 0, 0); + + glEnable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + glDisable(GL_LINE_SMOOTH); + glPopMatrix(); + } + + public static void outlineRect(double x, double y, double x1, double y1, double width, int internalColor, int borderColor) { + drawRect(x + width, y + width, x1 - width, y1 - width, internalColor); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + drawRect(x + width, y, x1 - width, y + width, borderColor); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + drawRect(x, y, x + width, y1, borderColor); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + drawRect(x1 - width, y, x1, y1, borderColor); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + drawRect(x + width, y1 - width, x1 - width, y1, borderColor); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + } + public static void drawTexturedRect(final float x, final float y, final float width, final float height, final String image) { + GL11.glPushMatrix(); + final boolean enableBlend = GL11.glIsEnabled(3042); + final boolean disableAlpha = !GL11.glIsEnabled(3008); + if (!enableBlend) { + GL11.glEnable(3042); + } + if (!disableAlpha) { + GL11.glDisable(3008); + } + RenderUtils.mc.getTextureManager().bindTexture(new ResourceLocation("zavz/shadow/" + image + ".png")); + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + drawModalRectWithCustomSizedTexture(x, y, 0.0f, 0.0f, width, height, width, height); + if (!enableBlend) { + GL11.glDisable(3042); + } + if (!disableAlpha) { + GL11.glEnable(3008); + } + GL11.glPopMatrix(); + } + public static void drawEntityESP(double x, double y, double z, double width, double height, float red, + float green, float blue, float alpha) { + GL11.glPushMatrix(); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glDisable(3553); + GL11.glEnable(2848); + GL11.glDisable(2929); + GL11.glDepthMask(false); + GL11.glLineWidth(1.0F); + GL11.glColor4f(red, green, blue, 1.0f); + drawOutlinedBoundingBox(new AxisAlignedBB(x - width, y, z - width, x + width, y + height, z + width)); + GL11.glColor4f(red, green, blue, alpha); + drawBoundingBox(new AxisAlignedBB(x - width, y, z - width, x + width, y + height, z + width)); + GL11.glDisable(2848); + GL11.glEnable(3553); + GL11.glEnable(2929); + GL11.glDepthMask(true); + GL11.glDisable(3042); + GL11.glPopMatrix(); + } + + public static void drawEntityESP(double x, double y, double z, double x1, double y1, double z1, float red, + float green, float blue, float alpha) { + GL11.glPushMatrix(); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glDisable(3553); + GL11.glEnable(2848); + GL11.glDisable(2929); + GL11.glDepthMask(false); + GL11.glLineWidth(1.0F); + GL11.glColor4f(red, green, blue, 1.0f); + drawOutlinedBoundingBox(new AxisAlignedBB(x, y, z, x1, y1, z1)); + GL11.glColor4f(red, green, blue, alpha); + drawBoundingBox(new AxisAlignedBB(x, y, z, x1, y1, z1)); + GL11.glDisable(2848); + GL11.glEnable(3553); + GL11.glEnable(2929); + GL11.glDepthMask(true); + GL11.glDisable(3042); + GL11.glPopMatrix(); + } + + public static void drawEntityESP(AxisAlignedBB axisAlignedBB, float red, + float green, float blue, float alpha) { + GL11.glPushMatrix(); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glDisable(3553); + GL11.glEnable(2848); + GL11.glDisable(2929); + GL11.glDepthMask(false); + GL11.glLineWidth(1.0F); + GL11.glColor4f(red, green, blue, 1.0f); + drawOutlinedBoundingBox(axisAlignedBB); + GL11.glColor4f(red, green, blue, alpha); + drawBoundingBox(axisAlignedBB); + GL11.glDisable(2848); + GL11.glEnable(3553); + GL11.glEnable(2929); + GL11.glDepthMask(true); + GL11.glDisable(3042); + GL11.glPopMatrix(); + } + public static void drawModalRectWithCustomSizedTexture(final float x, final float y, final float u, final float v, final float width, final float height, final float textureWidth, final float textureHeight) { + final float f = 1.0f / textureWidth; + final float f2 = 1.0f / textureHeight; + final Tessellator tessellator = Tessellator.getInstance(); + final WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); + worldrenderer.pos((double)x, (double)(y + height), 0.0).tex((double)(u * f), (double)((v + height) * f2)).endVertex(); + worldrenderer.pos((double)(x + width), (double)(y + height), 0.0).tex((double)((u + width) * f), (double)((v + height) * f2)).endVertex(); + worldrenderer.pos((double)(x + width), (double)y, 0.0).tex((double)((u + width) * f), (double)(v * f2)).endVertex(); + worldrenderer.pos((double)x, (double)y, 0.0).tex((double)(u * f), (double)(v * f2)).endVertex(); + tessellator.draw(); + } + + public static boolean isHovered(float x, float y, float x2, float y2, int mouseX, int mouseY) { + return mouseX >= x && mouseX <= x2 && mouseY >= y && mouseY <= y2; + } + + public static void drawShadowWithCustomAlpha(float x, float y, float width, float height, float alpha) { + drawTexturedRectWithCustomAlpha(x - 9, y - 9, 9, 9, "paneltopleft", alpha); + drawTexturedRectWithCustomAlpha(x - 9, y + height, 9, 9, "panelbottomleft", alpha); + drawTexturedRectWithCustomAlpha(x + width, y + height, 9, 9, "panelbottomright", alpha); + drawTexturedRectWithCustomAlpha(x + width, y - 9, 9, 9, "paneltopright", alpha); + drawTexturedRectWithCustomAlpha(x - 9, y, 9, height, "panelleft", alpha); + drawTexturedRectWithCustomAlpha(x + width, y, 9, height, "panelright", alpha); + drawTexturedRectWithCustomAlpha(x, y - 9, width, 9, "paneltop", alpha); + drawTexturedRectWithCustomAlpha(x, y + height, width, 9, "panelbottom", alpha); + } + + public static void drawTexturedRectWithCustomAlpha(float x, float y, float width, float height, String image, float alpha) { + glPushMatrix(); + final boolean enableBlend = glIsEnabled(GL_BLEND); + final boolean disableAlpha = !glIsEnabled(GL_ALPHA_TEST); + if(!enableBlend) glEnable(GL_BLEND); + if(!disableAlpha) glDisable(GL_ALPHA_TEST); + GlStateManager.color(1F, 1F, 1F, alpha); + mc.getTextureManager().bindTexture(new ResourceLocation("zavz/shadow/" + image + ".png")); + drawModalRectWithCustomSizedTexture(x, y, 0, 0, width, height, width, height); + if(!enableBlend) glDisable(GL_BLEND); + if(!disableAlpha) glEnable(GL_ALPHA_TEST); + GlStateManager.resetColor(); + glPopMatrix(); + } + + + public static void drawShadow(final float x, final float y, final float width, final float height) { + drawTexturedRect(x - 9.0f, y - 9.0f, 9.0f, 9.0f, "paneltopleft"); + drawTexturedRect(x - 9.0f, y + height, 9.0f, 9.0f, "panelbottomleft"); + drawTexturedRect(x + width, y + height, 9.0f, 9.0f, "panelbottomright"); + drawTexturedRect(x + width, y - 9.0f, 9.0f, 9.0f, "paneltopright"); + drawTexturedRect(x - 9.0f, y, 9.0f, height, "panelleft"); + drawTexturedRect(x + width, y, 9.0f, height, "panelright"); + drawTexturedRect(x, y - 9.0f, width, 9.0f, "paneltop"); + drawTexturedRect(x, y + height, width, 9.0f, "panelbottom"); + } + + public static void drawOutlinedBoundingBox(AxisAlignedBB aa) { + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldRenderer = tessellator.getWorldRenderer(); + worldRenderer.begin(3, DefaultVertexFormats.POSITION); + worldRenderer.pos(aa.minX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.minY, aa.minZ).endVertex(); + tessellator.draw(); + worldRenderer.begin(3, DefaultVertexFormats.POSITION); + worldRenderer.pos(aa.minX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.minZ).endVertex(); + tessellator.draw(); + worldRenderer.begin(1, DefaultVertexFormats.POSITION); + worldRenderer.pos(aa.minX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.maxZ).endVertex(); + tessellator.draw(); + } + public static void drawBoundingBox(AxisAlignedBB aa) { + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldRenderer = tessellator.getWorldRenderer(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(aa.minX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.maxZ).endVertex(); + tessellator.draw(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(aa.maxX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.minX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.maxZ).endVertex(); + tessellator.draw(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(aa.minX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.minZ).endVertex(); + tessellator.draw(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(aa.minX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.minX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.minZ).endVertex(); + tessellator.draw(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(aa.minX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.minX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.minZ).endVertex(); + tessellator.draw(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(aa.minX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.minY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.minX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.minX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.minZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.maxY, aa.maxZ).endVertex(); + worldRenderer.pos(aa.maxX, aa.minY, aa.maxZ).endVertex(); + tessellator.draw(); + } + + public static void glColor(final Color color, final int alpha) { + glColor(color, alpha/255F); + } + + public static void draw2D(final EntityLivingBase entity, final double posX, final double posY, final double posZ, final int color, final int backgroundColor) { + GlStateManager.pushMatrix(); + GlStateManager.translate(posX, posY, posZ); + GlStateManager.rotate(-mc.getRenderManager().playerViewY, 0F, 1F, 0F); + GlStateManager.scale(-0.1D, -0.1D, 0.1D); + + glDisable(GL_DEPTH_TEST); + glEnable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + GlStateManager.depthMask(true); + + glColor(color); + + glCallList(DISPLAY_LISTS_2D[0]); + + glColor(backgroundColor); + + glCallList(DISPLAY_LISTS_2D[1]); + + GlStateManager.translate(0, 21 + -(entity.getEntityBoundingBox().maxY - entity.getEntityBoundingBox().minY) * 12, 0); + + glColor(color); + glCallList(DISPLAY_LISTS_2D[2]); + + glColor(backgroundColor); + glCallList(DISPLAY_LISTS_2D[3]); + + // Stop render + glEnable(GL_DEPTH_TEST); + glEnable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + + GlStateManager.popMatrix(); + } + + public static void draw2D(final BlockPos blockPos, final int color, final int backgroundColor) { + final RenderManager renderManager = mc.getRenderManager(); + + final double posX = (blockPos.getX() + 0.5) - renderManager.renderPosX; + final double posY = blockPos.getY() - renderManager.renderPosY; + final double posZ = (blockPos.getZ() + 0.5) - renderManager.renderPosZ; + + GlStateManager.pushMatrix(); + GlStateManager.translate(posX, posY, posZ); + GlStateManager.rotate(-mc.getRenderManager().playerViewY, 0F, 1F, 0F); + GlStateManager.scale(-0.1D, -0.1D, 0.1D); + + glDisable(GL_DEPTH_TEST); + glEnable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + GlStateManager.depthMask(true); + + glColor(color); + + glCallList(DISPLAY_LISTS_2D[0]); + + glColor(backgroundColor); + + glCallList(DISPLAY_LISTS_2D[1]); + + GlStateManager.translate(0, 9, 0); + + glColor(color); + + glCallList(DISPLAY_LISTS_2D[2]); + + glColor(backgroundColor); + + glCallList(DISPLAY_LISTS_2D[3]); + + // Stop render + glEnable(GL_DEPTH_TEST); + glEnable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + + GlStateManager.popMatrix(); + } + + public static void clearCaps() { + glCapMap.clear(); + } + + // skid in https://github.com/WYSI-Foundation/LiquidBouncePlus/ + public static void drawBorder(float x, float y, float x2, float y2, float width, int color1) { + glEnable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_LINE_SMOOTH); + + glColor(color1); + glLineWidth(width); + + + glVertex2d(x2, y); + glVertex2d(x, y); + glVertex2d(x, y2); + glVertex2d(x2, y2); + + + glEnable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + glDisable(GL_LINE_SMOOTH); + } + + public static void drawOutLineRect(double x, double y, double x1, double y1, double width, int internalColor, int borderColor) { + drawRect(x + width, y + width, x1 - width, y1 - width, internalColor); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + drawRect(x + width, y, x1 - width, y + width, borderColor); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + drawRect(x, y, x + width, y1, borderColor); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + drawRect(x1 - width, y, x1, y1, borderColor); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + drawRect(x + width, y1 - width, x1 - width, y1, borderColor); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + } + + public static ByteBuffer readImageToBuffer(BufferedImage bufferedImage){ + int[] rgbArray = bufferedImage.getRGB(0, 0, bufferedImage.getWidth(), bufferedImage.getHeight(), null, 0, bufferedImage.getWidth()); + + ByteBuffer byteBuffer = ByteBuffer.allocateDirect(4 * rgbArray.length); + for(int rgb : rgbArray){ + byteBuffer.putInt(rgb << 8 | rgb >> 24 & 255); + } + byteBuffer.flip(); + + return byteBuffer; + } + + /** + * Resize the image to the specified width and height. + * @author liulihaocai + */ + public static BufferedImage resizeImage(BufferedImage image, int width,int height) { + BufferedImage buffImg = new BufferedImage(width,height, BufferedImage.TYPE_4BYTE_ABGR); + buffImg.getGraphics().drawImage(image.getScaledInstance(width,height, Image.SCALE_SMOOTH), 0, 0, null); + return buffImg; + } + + /** + * Reads the image into a texture. + * @return texture id + * @author func16 + */ + public static int loadGlTexture(BufferedImage bufferedImage){ + int textureId = GL11.glGenTextures(); + + GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId); + + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); + GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); + + GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, bufferedImage.getWidth(), bufferedImage.getHeight(), + 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, readImageToBuffer(bufferedImage)); + + GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); + + return textureId; + } + + public static void quickDrawRect(final float x, final float y, final float x2, final float y2, final Color color) { + quickDrawRect(x, y, x2, y2, color.getRGB()); + } + + public static void drawRect(final float x, final float y, final float x2, final float y2, final Color color) { + drawRect(x, y, x2, y2, color.getRGB()); + } + + + public static void drawEntityBox(final Entity entity, final Color color, final boolean outline, final boolean box, final float outlineWidth) { + final RenderManager renderManager = mc.getRenderManager(); + final Timer timer = mc.timer; + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + enableGlCap(GL_BLEND); + disableGlCap(GL_TEXTURE_2D, GL_DEPTH_TEST); + glDepthMask(false); + + final double x = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * timer.renderPartialTicks + - renderManager.renderPosX; + final double y = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * timer.renderPartialTicks + - renderManager.renderPosY; + final double z = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * timer.renderPartialTicks + - renderManager.renderPosZ; + + final AxisAlignedBB entityBox = entity.getEntityBoundingBox(); + final AxisAlignedBB axisAlignedBB = new AxisAlignedBB( + entityBox.minX - entity.posX + x - 0.05D, + entityBox.minY - entity.posY + y, + entityBox.minZ - entity.posZ + z - 0.05D, + entityBox.maxX - entity.posX + x + 0.05D, + entityBox.maxY - entity.posY + y + 0.15D, + entityBox.maxZ - entity.posZ + z + 0.05D + ); + + if (outline) { + glLineWidth(outlineWidth); + enableGlCap(GL_LINE_SMOOTH); + glColor(color.getRed(), color.getGreen(), color.getBlue(), box?170:255); + drawSelectionBoundingBox(axisAlignedBB); + } + + if(box) { + glColor(color.getRed(), color.getGreen(), color.getBlue(), outline ? 26 : 35); + drawFilledBox(axisAlignedBB); + } + + GlStateManager.resetColor(); + glDepthMask(true); + resetCaps(); + } + + public static void drawSelectionBoundingBox(AxisAlignedBB boundingBox) { + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + + worldrenderer.begin(GL_LINE_STRIP, DefaultVertexFormats.POSITION); + + // Lower Rectangle + worldrenderer.pos(boundingBox.minX, boundingBox.minY, boundingBox.minZ).endVertex(); + worldrenderer.pos(boundingBox.minX, boundingBox.minY, boundingBox.maxZ).endVertex(); + worldrenderer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.maxZ).endVertex(); + worldrenderer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.minZ).endVertex(); + worldrenderer.pos(boundingBox.minX, boundingBox.minY, boundingBox.minZ).endVertex(); + + // Upper Rectangle + worldrenderer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.minZ).endVertex(); + worldrenderer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ).endVertex(); + worldrenderer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ).endVertex(); + worldrenderer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ).endVertex(); + worldrenderer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.minZ).endVertex(); + + // Upper Rectangle + worldrenderer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ).endVertex(); + worldrenderer.pos(boundingBox.minX, boundingBox.minY, boundingBox.maxZ).endVertex(); + + worldrenderer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.maxZ).endVertex(); + worldrenderer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ).endVertex(); + + worldrenderer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ).endVertex(); + worldrenderer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.minZ).endVertex(); + + tessellator.draw(); + } + + public static void drawBlockBox(final BlockPos blockPos, final Color color, final boolean outline, final boolean box, final float outlineWidth) { + final RenderManager renderManager = mc.getRenderManager(); + final Timer timer = mc.timer; + + final double x = blockPos.getX() - renderManager.renderPosX; + final double y = blockPos.getY() - renderManager.renderPosY; + final double z = blockPos.getZ() - renderManager.renderPosZ; + + AxisAlignedBB axisAlignedBB = new AxisAlignedBB(x, y, z, x + 1.0, y + 1.0, z + 1.0); + final Block block = BlockUtils.getBlock(blockPos); + + if (block != null) { + final EntityPlayer player = mc.thePlayer; + + final double posX = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) timer.renderPartialTicks; + final double posY = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) timer.renderPartialTicks; + final double posZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) timer.renderPartialTicks; + axisAlignedBB = block.getSelectedBoundingBox(mc.theWorld, blockPos) + .expand(0.0020000000949949026D, 0.0020000000949949026D, 0.0020000000949949026D) + .offset(-posX, -posY, -posZ); + } + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + enableGlCap(GL_BLEND); + disableGlCap(GL_TEXTURE_2D, GL_DEPTH_TEST); + glDepthMask(false); + + if(box) { + glColor(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha() != 255 ? color.getAlpha() : outline ? 26 : 35); + drawFilledBox(axisAlignedBB); + } + + if (outline) { + glLineWidth(outlineWidth); + enableGlCap(GL_LINE_SMOOTH); + glColor(color); + + drawSelectionBoundingBox(axisAlignedBB); + } + + GlStateManager.resetColor(); + glDepthMask(true); + resetCaps(); + } + + public static void drawRoundedCornerRect(float x, float y, float x1, float y1, float radius, int color) { + glEnable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_LINE_SMOOTH); + + glColor(color); + drawRoundedCornerRect(x, y, x1, y1, radius); + + glEnable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + glDisable(GL_LINE_SMOOTH); + } + + public static void drawRoundedCornerRect(float x, float y, float x1, float y1, float radius) { + + float xRadius = (float) Math.min((x1 - x) * 0.5, radius); + float yRadius = (float) Math.min((y1 - y) * 0.5, radius); + quickPolygonCircle(x + xRadius,y + yRadius, xRadius, yRadius,180,270,4); + quickPolygonCircle(x1 - xRadius,y + yRadius, xRadius, yRadius,90,180,4); + quickPolygonCircle(x1 - xRadius,y1 - yRadius, xRadius, yRadius,0,90,4); + quickPolygonCircle(x + xRadius,y1 - yRadius, xRadius, yRadius,270,360,4); + + } + + public static void drawGradientSidewaysH(double left, double top, double right, double bottom, int col1, int col2) { + glEnable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_LINE_SMOOTH); + glShadeModel(GL_SMOOTH); + + quickDrawGradientSidewaysH(left, top, right, bottom, col1, col2); + + glEnable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + glDisable(GL_LINE_SMOOTH); + glShadeModel(GL_FLAT); + } + + public static void quickDrawGradientSidewaysH(double left, double top, double right, double bottom, int col1, int col2) { + + glColor(col1); + glVertex2d(left, top); + glVertex2d(left, bottom); + glColor(col2); + glVertex2d(right, bottom); + glVertex2d(right, top); + + } + + public static void quickDrawGradientSidewaysV(double left, double top, double right, double bottom, int col1, int col2) { + + glColor(col1); + glVertex2d(right, top); + glVertex2d(left, top); + glColor(col2); + glVertex2d(left, bottom); // TODO: Fix this, this may have been a mistake + glVertex2d(right, bottom); + + } + + public static void renderCircle(double x, double y, double radius, int color) { + renderCircle(x, y, 0, 360, radius - 1, color); + } + + public static void renderCircle(double x, double y, double start, double end, double radius, int color) { + renderCircle(x, y, start, end, radius, radius, color); + } + + public static void renderCircle(double x, double y, double start, double end, double w, double h, int color) { + GlStateManager.color(0, 0, 0); + GL11.glColor4f(0, 0, 0, 0); + + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + glColor(color); + + quickRenderCircle(x, y, start, end, w, h); + + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static void connectPoints(float xOne, float yOne, float xTwo, float yTwo) { + glPushMatrix(); + glEnable(GL_LINE_SMOOTH); + glColor4f(1.0F, 1.0F, 1.0F, 0.8F); + glDisable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glLineWidth(0.5F); + glVertex2f(xOne, yOne); + glVertex2f(xTwo, yTwo); + glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + glDisable(GL_LINE_SMOOTH); + glEnable(GL_TEXTURE_2D); + glPopMatrix(); + } + + + public static void drawFilledCircle2(final float xx, final float yy, final float radius, final Color color) { + int sections = 50; + double dAngle = 2 * Math.PI / sections; + float x, y; + + glPushAttrib(GL_ENABLE_BIT); + + glEnable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_LINE_SMOOTH); + + for (int i = 0; i < sections; i++) { + x = (float) (radius * Math.sin((i * dAngle))); + y = (float) (radius * Math.cos((i * dAngle))); + + glColor4f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, color.getAlpha() / 255F); + glVertex2f(xx + x, yy + y); + } + + GlStateManager.color(0, 0, 0); + + glPopAttrib(); + } + + + public static Color skyRainbow(int var2, float st, float bright) { + double v1 = Math.ceil(System.currentTimeMillis() + (long) (var2 * 109)) / 5; + return Color.getHSBColor((double) ((float) ((v1 %= 360.0) / 360.0)) < 0.5 ? -((float) (v1 / 360.0)) : (float) (v1 / 360.0), st, bright); + } + public static Color skyRainbow(int var2, float bright, float st, double speed) { + double v1 = Math.ceil((System.currentTimeMillis()/speed) + (var2 * 109L)) / 5; + return Color.getHSBColor((double) ((float) ((v1 %= 360.0) / 360.0)) < 0.5 ? -((float) (v1 / 360.0)) : (float) (v1 / 360.0), st, bright); + } + + private static void quickPolygonCircle(float x, float y, float xRadius, float yRadius, int start, int end, int split) { + for(int i = end; i >= start; i-=split) { + glVertex2d(x + Math.sin(i * Math.PI / 180.0D) * xRadius, y + Math.cos(i * Math.PI / 180.0D) * yRadius); + } + } + + public static void drawCircleRect(float x, float y, float x1, float y1, float radius, int color) { + glColor(color); + glEnable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glDisable(GL_CULL_FACE); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_LINE_SMOOTH); + glPushMatrix(); + glLineWidth(1F); + + float xRadius = (float) Math.min((x1 - x) * 0.5, radius); + float yRadius = (float) Math.min((y1 - y) * 0.5, radius); + quickPolygonCircle(x+xRadius,y+yRadius, xRadius, yRadius,180,270,4); + quickPolygonCircle(x1-xRadius,y+yRadius, xRadius, yRadius,90,180,4); + quickPolygonCircle(x1-xRadius,y1-yRadius, xRadius, yRadius,0,90,4); + quickPolygonCircle(x+xRadius,y1-yRadius, xRadius, yRadius,270,360,4); + + glPopMatrix(); + glEnable(GL_TEXTURE_2D); + glEnable(GL_CULL_FACE); + glDisable(GL_LINE_SMOOTH); + glColor4f(1F, 1F, 1F, 1F); + } + + public static void drawExhiRect(float x, float y, float x2, float y2) { + drawRect(x - 3.5F, y - 3.5F, x2 + 3.5F, y2 + 3.5F, Color.black.getRGB()); + drawRect(x - 3F, y - 3F, x2 + 3F, y2 + 3F, new Color(50, 50, 50).getRGB()); + //drawBorder(x - 1.5F, y - 1.5F, x2 + 1.5F, y2 + 1.5F, 2.5F, new Color(26, 26, 26).getRGB()); + drawRect(x - 2.5F, y - 2.5F, x2 + 2.5F, y2 + 2.5F, new Color(26, 26, 26).getRGB()); + drawRect(x - 0.5F, y - 0.5F, x2 + 0.5F, y2 + 0.5F, new Color(50, 50, 50).getRGB()); + drawRect(x, y, x2, y2, new Color(18, 18, 18).getRGB()); + } + + public static void drawFilledCircle2(final int xx, final int yy, final float radius, final Color color) { + int sections = 50; + double dAngle = 2 * Math.PI / sections; + float x, y; + + glPushAttrib(GL_ENABLE_BIT); + + glEnable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_LINE_SMOOTH); + + for (int i = 0; i < sections; i++) { + x = (float) (radius * Math.sin((i * dAngle))); + y = (float) (radius * Math.cos((i * dAngle))); + + glColor4f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, color.getAlpha() / 255F); + glVertex2f(xx + x, yy + y); + } + + GlStateManager.color(0, 0, 0); + + + glPopAttrib(); + } + + public static int Astolfo(int var2) { + double v1 = Math.ceil(System.currentTimeMillis() + (long) (var2 * 109)) / 5; + return Color.getHSBColor((double) ((float) ((v1 %= 360.0) / 360.0)) < 0.5 ? -((float) (v1 / 360.0)) : (float) (v1 / 360.0), 0.5F, 1.0F).getRGB(); + } + + public static void drawNoFullCircle(final float x, final float y, final float radius, final int fill) { + arc233(x, y, 0.0f, 360.0f, radius, fill); + } + + public static void arc233(final float x, final float y, final float start, final float end, final float radius, + final int color) { + arcEllipse233(x, y, start, end, radius, radius, color); + } + + public static void arcEllipse233(final float x, final float y, float start, float end, final float w, final float h, + final int color) { + GlStateManager.color(0.0f, 0.0f, 0.0f); + GL11.glColor4f(0.0f, 0.0f, 0.0f, 0.0f); + float temp; + if (start > end) { + temp = end; + end = start; + start = temp; + } + final float alpha = (color >> 24 & 0xFF) / 255.0f; + final float red = (color >> 16 & 0xFF) / 255.0f; + final float green = (color >> 8 & 0xFF) / 255.0f; + final float blue = (color & 0xFF) / 255.0f; + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.color(red, green, blue, alpha); + if (alpha > 0.5f) { + GL11.glEnable(GL_POLYGON_SMOOTH); + GL11.glEnable(2848); + GL11.glLineWidth(1.5F); + GL11.glBegin(3); + for (float i = end; i >= start; i -= 4.0f) { + final float ldx = (float) Math.cos(i * Math.PI / 180.0) * w * 1.001f; + final float ldy = (float) Math.sin(i * Math.PI / 180.0) * h * 1.001f; + GL11.glVertex2f(x + ldx, y + ldy); + } + GL11.glEnd(); + GL11.glDisable(2848); + GL11.glDisable(GL_POLYGON_SMOOTH); + } + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static void drawOutlinedString(String str, int x, int y, int color,int color2) { + Minecraft mc = Minecraft.getMinecraft(); + mc.fontRendererObj.drawString(str, (int) (x - 1.0F), y, color2); + mc.fontRendererObj.drawString(str, (int) (x + 1.0F), y,color2); + mc.fontRendererObj.drawString(str, x, (int) (y + 1.0F), color2); + mc.fontRendererObj.drawString(str, x, (int) (y -1.0F),color2); + mc.fontRendererObj.drawString(str, x, y, color); + } + + public static void HanaBidrawRect(float x1, float y1, float x2, float y2, int color) { + GL11.glPushMatrix(); + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glBlendFunc(770, 771); + GL11.glEnable(2848); + GL11.glPushMatrix(); + color(color); + GL11.glBegin(7); + GL11.glVertex2d(x2, y1); + GL11.glVertex2d(x1, y1); + GL11.glVertex2d(x1, y2); + GL11.glVertex2d(x2, y2); + GL11.glEnd(); + GL11.glPopMatrix(); + GL11.glEnable(3553); + GL11.glDisable(3042); + GL11.glDisable(2848); + GL11.glPopMatrix(); + Gui.drawRect(0,0,0,0,0); + } + + public static void color(int color) { + float f = (float)(color >> 24 & 255) / 255.0f; + float f1 = (float)(color >> 16 & 255) / 255.0f; + float f2 = (float)(color >> 8 & 255) / 255.0f; + float f3 = (float)(color & 255) / 255.0f; + GL11.glColor4f(f1, f2, f3, f); + } + + public static void quickDrawHead(ResourceLocation skin, int x, int y, int width, int height) { + mc.getTextureManager().bindTexture(skin); + VisualUtils.drawScaledCustomSizeModalRect(x, y, 8F, 8F, 8, 8, width, height, + 64F, 64F); + VisualUtils.drawScaledCustomSizeModalRect(x, y, 40F, 8F, 8, 8, width, height, + 64F, 64F); + } + + public static void drawBlockBox2(final BlockPos blockPos, final Color color, final boolean outline, final boolean box, final float outlineWidth) { + final RenderManager renderManager = mc.getRenderManager(); + final Timer timer = mc.timer; + + final double x = blockPos.getX() - renderManager.renderPosX; + final double y = blockPos.getY() - renderManager.renderPosY; + final double z = blockPos.getZ() - renderManager.renderPosZ; + + AxisAlignedBB axisAlignedBB = new AxisAlignedBB(x, y, z, x + 1.0, y + 1.0, z + 1.0); + final Block block = BlockUtils.getBlock(blockPos); + + if (block != null) { + final EntityPlayer player = mc.thePlayer; + + final double posX = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) timer.renderPartialTicks; + final double posY = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) timer.renderPartialTicks; + final double posZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) timer.renderPartialTicks; + axisAlignedBB = block.getSelectedBoundingBox(mc.theWorld, blockPos) + .expand(0.0020000000949949026D, 0.0020000000949949026D, 0.0020000000949949026D) + .offset(-posX, -posY, -posZ); + } + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + enableGlCap(GL_BLEND); + disableGlCap(GL_TEXTURE_2D, GL_DEPTH_TEST); + glDepthMask(false); + + if(box) { + glColor(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha() != 255 ? color.getAlpha() : outline ? 26 : 35); + drawFilledBox(axisAlignedBB); + } + + if (outline) { + glLineWidth(outlineWidth); + enableGlCap(GL_LINE_SMOOTH); + glColor(color); + + drawSelectionBoundingBox(axisAlignedBB); + } + + GlStateManager.resetColor(); + glDepthMask(true); + resetCaps(); + } + + public static void drawRect2(final double x, final double y, final double x2, final double y2, final int color) { + glEnable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_LINE_SMOOTH); + + glColor(color); + + glVertex2d(x2, y); + glVertex2d(x, y); + glVertex2d(x, y2); + glVertex2d(x2, y2); + + glEnable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + glDisable(GL_LINE_SMOOTH); + } + + public static void drawGradientSidewaysV(double left, double top, double right, double bottom, int col1, int col2) { + float f = (float) (col1 >> 24 & 255) / 255.0f; + float f1 = (float) (col1 >> 16 & 255) / 255.0f; + float f2 = (float) (col1 >> 8 & 255) / 255.0f; + float f3 = (float) (col1 & 255) / 255.0f; + float f4 = (float) (col2 >> 24 & 255) / 255.0f; + float f5 = (float) (col2 >> 16 & 255) / 255.0f; + float f6 = (float) (col2 >> 8 & 255) / 255.0f; + float f7 = (float) (col2 & 255) / 255.0f; + GL11.glEnable((int) 3042); + GL11.glDisable((int) 3553); + GL11.glBlendFunc((int) 770, (int) 771); + GL11.glEnable((int) 2848); + GL11.glShadeModel(7425); + GL11.glPushMatrix(); + GL11.glBegin(7); + GL11.glColor4f((float) f1, (float) f2, (float) f3, (float) f); + GL11.glVertex2d((double) left, (double) bottom); + GL11.glVertex2d((double) right, (double) bottom); + GL11.glColor4f((float) f5, (float) f6, (float) f7, (float) f4); + GL11.glVertex2d((double) right, (double) top); + GL11.glVertex2d((double) left, (double) top); + GL11.glEnd(); + GL11.glPopMatrix(); + GL11.glEnable((int) 3553); + GL11.glDisable((int) 3042); + GL11.glDisable((int) 2848); + GL11.glShadeModel((int) 7424); + Gui.drawRect(0, 0, 0, 0, 0); + } + + public static void enableDepth() { + GL11.glDepthMask(true); + GL11.glEnable(2929); + } + + public static void disableDepth() { + GL11.glDepthMask(false); + GL11.glDisable(2929); + } + public static void enableBlending() { + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + } + + public static void drawBlockBox(final BlockPos blockPos, final Color color, final boolean outline) { + final RenderManager renderManager = mc.getRenderManager(); + final Timer timer = mc.timer; + + final double x = blockPos.getX() - renderManager.renderPosX; + final double y = blockPos.getY() - renderManager.renderPosY; + final double z = blockPos.getZ() - renderManager.renderPosZ; + + AxisAlignedBB axisAlignedBB = new AxisAlignedBB(x, y, z, x + 1.0, y + 1.0, z + 1.0); + final Block block = BlockUtils.getBlock(blockPos); + + if (block != null) { + final EntityPlayer player = mc.thePlayer; + + final double posX = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) timer.renderPartialTicks; + final double posY = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) timer.renderPartialTicks; + final double posZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) timer.renderPartialTicks; + axisAlignedBB = block.getSelectedBoundingBox(mc.theWorld, blockPos) + .expand(0.0020000000949949026D, 0.0020000000949949026D, 0.0020000000949949026D) + .offset(-posX, -posY, -posZ); + } + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + enableGlCap(GL_BLEND); + disableGlCap(GL_TEXTURE_2D, GL_DEPTH_TEST); + glDepthMask(false); + + glColor(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha() != 255 ? color.getAlpha() : outline ? 26 : 35); + drawFilledBox(axisAlignedBB); + + if (outline) { + glLineWidth(1F); + enableGlCap(GL_LINE_SMOOTH); + glColor(color); + drawSelectionBoundingBox(axisAlignedBB); + } + + GlStateManager.resetColor(); + glDepthMask(true); + resetCaps(); + } + + public static void drawEntityBox(final Entity entity, final Color color, final boolean outline) { + final RenderManager renderManager = mc.getRenderManager(); + final Timer timer = mc.timer; + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + enableGlCap(GL_BLEND); + disableGlCap(GL_TEXTURE_2D, GL_DEPTH_TEST); + glDepthMask(false); + + final double x = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * timer.renderPartialTicks + - renderManager.renderPosX; + final double y = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * timer.renderPartialTicks + - renderManager.renderPosY; + final double z = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * timer.renderPartialTicks + - renderManager.renderPosZ; + + final AxisAlignedBB entityBox = entity.getEntityBoundingBox(); + final AxisAlignedBB axisAlignedBB = new AxisAlignedBB( + entityBox.minX - entity.posX + x - 0.05D, + entityBox.minY - entity.posY + y, + entityBox.minZ - entity.posZ + z - 0.05D, + entityBox.maxX - entity.posX + x + 0.05D, + entityBox.maxY - entity.posY + y + 0.15D, + entityBox.maxZ - entity.posZ + z + 0.05D + ); + + if (outline) { + glLineWidth(1F); + enableGlCap(GL_LINE_SMOOTH); + glColor(color.getRed(), color.getGreen(), color.getBlue(), 95); + drawSelectionBoundingBox(axisAlignedBB); + } + + glColor(color.getRed(), color.getGreen(), color.getBlue(), outline ? 26 : 35); + drawFilledBox(axisAlignedBB); + GlStateManager.resetColor(); + glDepthMask(true); + resetCaps(); + } + + public static void drawEntityOnScreen(final int posX, final int posY, final int scale, final EntityLivingBase entity) { + GlStateManager.pushMatrix(); + GlStateManager.enableColorMaterial(); + + GlStateManager.translate(posX, posY, 50.0); + GlStateManager.scale((-scale), scale, scale); + GlStateManager.rotate(180F, 0F, 0F, 1F); + GlStateManager.rotate(135F, 0F, 1F, 0F); + RenderHelper.enableStandardItemLighting(); + GlStateManager.rotate(-135F, 0F, 1F, 0F); + GlStateManager.translate(0.0, 0.0, 0.0); + + float renderYawOffset = entity.renderYawOffset; + float rotationYaw = entity.rotationYaw; + float rotationPitch = entity.rotationPitch; + float prevRotationYawHead = entity.prevRotationYawHead; + float rotationYawHead = entity.rotationYawHead; + + + entity.renderYawOffset = 0; + entity.rotationYaw = 0; + entity.rotationPitch = 90; + entity.rotationYawHead = entity.rotationYaw; + entity.prevRotationYawHead = entity.rotationYaw; + + RenderManager rendermanager = mc.getRenderManager(); + rendermanager.setPlayerViewY(180F); + rendermanager.setRenderShadow(false); + rendermanager.renderEntityWithPosYaw(entity, 0.0, 0.0, 0.0, 0F, 1F); + rendermanager.setRenderShadow(true); + + entity.renderYawOffset = renderYawOffset; + entity.rotationYaw = rotationYaw; + entity.rotationPitch = rotationPitch; + entity.prevRotationYawHead = prevRotationYawHead; + entity.rotationYawHead = rotationYawHead; + + GlStateManager.popMatrix(); + RenderHelper.disableStandardItemLighting(); + GlStateManager.disableRescaleNormal(); + GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GlStateManager.disableTexture2D(); + GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); + } + + public static void drawEntityBox2(final Entity entity, final Color color, final boolean outline, final boolean box, final float outlineWidth) { + final RenderManager renderManager = mc.getRenderManager(); + final Timer timer = mc.timer; + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + enableGlCap(GL_BLEND); + disableGlCap(GL_TEXTURE_2D, GL_DEPTH_TEST); + glDepthMask(false); + + final double x = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * timer.renderPartialTicks + - renderManager.renderPosX; + final double y = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * timer.renderPartialTicks + - renderManager.renderPosY; + final double z = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * timer.renderPartialTicks + - renderManager.renderPosZ; + + final AxisAlignedBB entityBox = entity.getEntityBoundingBox(); + final AxisAlignedBB axisAlignedBB = new AxisAlignedBB( + entityBox.minX - entity.posX + x - 0.05D, + entityBox.minY - entity.posY + y, + entityBox.minZ - entity.posZ + z - 0.05D, + entityBox.maxX - entity.posX + x + 0.05D, + entityBox.maxY - entity.posY + y + 0.15D, + entityBox.maxZ - entity.posZ + z + 0.05D + ); + + if (outline) { + glLineWidth(outlineWidth); + enableGlCap(GL_LINE_SMOOTH); + glColor(color.getRed(), color.getGreen(), color.getBlue(), box?170:255); + drawSelectionBoundingBox(axisAlignedBB); + } + + if(box) { + glColor(color.getRed(), color.getGreen(), color.getBlue(), outline ? 26 : 35); + drawFilledBox(axisAlignedBB); + } + + GlStateManager.resetColor(); + glDepthMask(true); + resetCaps(); + } + + public static void drawCircle(float x, float y ,float radius, final Color color) { + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); + glColor(Color.WHITE); + + glEnable(GL_LINE_SMOOTH); + glLineWidth(1); + for (float i = 180; i >= -180; i -= (360 / 90)) { + glColor4f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, color.getAlpha() / 255F); + glVertex2f((float) (x + (cos(i * PI / 180) * (radius * 1.001F))), (float) (y + (sin(i * PI / 180) * (radius * 1.001F)))); + } + glDisable(GL_LINE_SMOOTH); + + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + public static void drawCircleD(float x, float y, float radius, int color) { + float alpha = (float) (color >> 24 & 255) / 255.0f; + float red = (float) (color >> 16 & 255) / 255.0f; + float green = (float) (color >> 8 & 255) / 255.0f; + float blue = (float) (color & 255) / 255.0f; + boolean blend = GL11.glIsEnabled((int) 3042); + boolean line = GL11.glIsEnabled((int) 2848); + boolean texture = GL11.glIsEnabled((int) 3553); + if (!blend) { + GL11.glEnable((int) 3042); + } + if (!line) { + GL11.glEnable((int) 2848); + } + if (texture) { + GL11.glDisable((int) 3553); + } + GL11.glBlendFunc((int) 770, (int) 771); + GL11.glColor4f((float) red, (float) green, (float) blue, (float) alpha); + GL11.glBegin((int) 9); + int i = 0; + while (i <= 360) { + GL11.glVertex2d((double) ((double) x + Math.sin((double) i * 3.141526 / 180.0) * (double) radius), (double) ((double) y + Math.cos((double) i * 3.141526 / 180.0) * (double) radius)); + ++i; + } + GL11.glEnd(); + if (texture) { + GL11.glEnable((int) 3553); + } + if (!line) { + GL11.glDisable((int) 2848); + } + if (!blend) { + GL11.glDisable((int) 3042); + } + } + + public static void drawCircle(float x, float y, float radius, int color) { + glColor(color); + glEnable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_LINE_SMOOTH); + glPushMatrix(); + glLineWidth(1F); + for(int i = 0; i <= 360; i++) + glVertex2d(x + Math.sin(i * Math.PI / 180.0D) * radius, y + Math.cos(i * Math.PI / 180.0D) * radius); + glPopMatrix(); + glEnable(GL_TEXTURE_2D); + glDisable(GL_LINE_SMOOTH); + glColor4f(1F, 1F, 1F, 1F); + } + + + public static void drawCircleFull(float x, float y ,float radius, float Bord , final Color color) { + drawCircle(x , y , radius + 0.15f, color); + drawCircleD(x , y , radius, color.getRGB()); + } + + public static void drawAxisAlignedBB(final AxisAlignedBB axisAlignedBB, final Color color, final boolean outline, final boolean box, final float outlineWidth) { + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glLineWidth(outlineWidth); + glDisable(GL_TEXTURE_2D); + glDisable(GL_DEPTH_TEST); + glDepthMask(false); + glColor(color); + + if (outline) { + glLineWidth(outlineWidth); + enableGlCap(GL_LINE_SMOOTH); + glColor(color.getRed(), color.getGreen(), color.getBlue(), 95); + drawSelectionBoundingBox(axisAlignedBB); + } + + if(box) { + glColor(color.getRed(), color.getGreen(), color.getBlue(), outline ? 26 : 35); + drawFilledBox(axisAlignedBB); + } + + GlStateManager.resetColor(); + glEnable(GL_TEXTURE_2D); + glEnable(GL_DEPTH_TEST); + glDepthMask(true); + glDisable(GL_BLEND); + } + + + public static void drawAxisAlignedBB(final AxisAlignedBB axisAlignedBB, final Color color) { + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glLineWidth(2F); + glDisable(GL_TEXTURE_2D); + glDisable(GL_DEPTH_TEST); + glDepthMask(false); + glColor(color); + drawFilledBox(axisAlignedBB); + GlStateManager.resetColor(); + glEnable(GL_TEXTURE_2D); + glEnable(GL_DEPTH_TEST); + glDepthMask(true); + glDisable(GL_BLEND); + } + + public static void drawPlatform(final double y, final Color color, final double size) { + final RenderManager renderManager = mc.getRenderManager(); + final double renderY = y - renderManager.renderPosY; + + drawAxisAlignedBB(new AxisAlignedBB(size, renderY + 0.02D, size, -size, renderY, -size), color); + } + + public static void drawPlatform(final Entity entity, final Color color) { + final RenderManager renderManager = mc.getRenderManager(); + final Timer timer = mc.timer; + + final double x = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * timer.renderPartialTicks + - renderManager.renderPosX; + final double y = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * timer.renderPartialTicks + - renderManager.renderPosY; + final double z = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * timer.renderPartialTicks + - renderManager.renderPosZ; + + final AxisAlignedBB axisAlignedBB = entity.getEntityBoundingBox() + .offset(-entity.posX, -entity.posY, -entity.posZ) + .offset(x, y, z); + + drawAxisAlignedBB( + new AxisAlignedBB(axisAlignedBB.minX, axisAlignedBB.maxY + 0.2, axisAlignedBB.minZ, axisAlignedBB.maxX, axisAlignedBB.maxY + 0.26, axisAlignedBB.maxZ), + color + ); + } + + public static void drawFilledBox(final AxisAlignedBB axisAlignedBB) { + final Tessellator tessellator = Tessellator.getInstance(); + final WorldRenderer worldRenderer = tessellator.getWorldRenderer(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ).endVertex(); + worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.minZ).endVertex(); + worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.minZ).endVertex(); + worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.minZ).endVertex(); + worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.maxZ).endVertex(); + worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.maxZ).endVertex(); + worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.maxZ).endVertex(); + worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.maxZ).endVertex(); + tessellator.draw(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.minZ).endVertex(); + worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.minZ).endVertex(); + worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.minZ).endVertex(); + worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ).endVertex(); + worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.maxZ).endVertex(); + worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.maxZ).endVertex(); + worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.maxZ).endVertex(); + worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.maxZ).endVertex(); + tessellator.draw(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.minZ).endVertex(); + worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.minZ).endVertex(); + worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.maxZ).endVertex(); + worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.maxZ).endVertex(); + worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.minZ).endVertex(); + worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.maxZ).endVertex(); + worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.maxZ).endVertex(); + worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.minZ).endVertex(); + tessellator.draw(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ).endVertex(); + worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.minZ).endVertex(); + worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.maxZ).endVertex(); + worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.maxZ).endVertex(); + worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ).endVertex(); + worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.maxZ).endVertex(); + worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.maxZ).endVertex(); + worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.minZ).endVertex(); + tessellator.draw(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ).endVertex(); + worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.minZ).endVertex(); + worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.maxZ).endVertex(); + worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.maxZ).endVertex(); + worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.maxZ).endVertex(); + worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.maxZ).endVertex(); + worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.minZ).endVertex(); + worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.minZ).endVertex(); + tessellator.draw(); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.maxZ).endVertex(); + worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.maxZ).endVertex(); + worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.minZ).endVertex(); + worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ).endVertex(); + worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.minZ).endVertex(); + worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.minZ).endVertex(); + worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.maxZ).endVertex(); + worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.maxZ).endVertex(); + tessellator.draw(); + } + + public static void drawRectBlur(final float x, final float y, final float x2, final float y2, final int color) { + glEnable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_LINE_SMOOTH); + + glColor(color); + quickDrawRect(x, y, x2, y2); + + glEnable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + glDisable(GL_LINE_SMOOTH); + } + + + public static void drawBorderedRect2(final float x, final float y, final float x2, final float y2, final float width, final int color1, final int color2) { + drawRectBlur(x, y, x2, y2, color2); + glEnable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_LINE_SMOOTH); + + glColor(color1); + glLineWidth(width); + glVertex2d(x, y); + glVertex2d(x, y2); + glVertex2d(x2, y2); + glVertex2d(x2, y); + glVertex2d(x, y); + glVertex2d(x2, y); + glVertex2d(x, y2); + glVertex2d(x2, y2); + + glEnable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + glDisable(GL_LINE_SMOOTH); + } + + public static void drawLoadingCircle(float x, float y) { + for (int i = 0; i < 4; i++) { + int rot = (int) ((System.nanoTime() / 5000000 * i) % 360); + drawCircle(x, y, i * 10, rot - 180, rot); + } + } + + public static void drawCircle(float x, float y, float radius, int start, int end) { + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); + glColor(Color.WHITE); + + glEnable(GL_LINE_SMOOTH); + glLineWidth(2F); + for (float i = end; i >= start; i -= (360 / 90)) + glVertex2f((float) (x + (cos(i * PI / 180) * (radius * 1.001F))), (float) (y + (sin(i * PI / 180) * (radius * 1.001F)))); + glDisable(GL_LINE_SMOOTH); + + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + + public static void originalRoundedRect(float paramXStart, float paramYStart, float paramXEnd, float paramYEnd, float radius, int color) { + float alpha = (color >> 24 & 0xFF) / 255.0F; + float red = (color >> 16 & 0xFF) / 255.0F; + float green = (color >> 8 & 0xFF) / 255.0F; + float blue = (color & 0xFF) / 255.0F; + + float z = 0; + if (paramXStart > paramXEnd) { + z = paramXStart; + paramXStart = paramXEnd; + paramXEnd = z; + } + + if (paramYStart > paramYEnd) { + z = paramYStart; + paramYStart = paramYEnd; + paramYEnd = z; + } + + double x1 = (double)(paramXStart + radius); + double y1 = (double)(paramYStart + radius); + double x2 = (double)(paramXEnd - radius); + double y2 = (double)(paramYEnd - radius); + + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.color(red, green, blue, alpha); + worldrenderer.begin(GL_POLYGON, DefaultVertexFormats.POSITION); + + double degree = Math.PI / 180; + for (double i = 0; i <= 90; i += 1) + worldrenderer.pos(x2 + Math.sin(i * degree) * radius, y2 + Math.cos(i * degree) * radius, 0.0D).endVertex(); + for (double i = 90; i <= 180; i += 1) + worldrenderer.pos(x2 + Math.sin(i * degree) * radius, y1 + Math.cos(i * degree) * radius, 0.0D).endVertex(); + for (double i = 180; i <= 270; i += 1) + worldrenderer.pos(x1 + Math.sin(i * degree) * radius, y1 + Math.cos(i * degree) * radius, 0.0D).endVertex(); + for (double i = 270; i <= 360; i += 1) + worldrenderer.pos(x1 + Math.sin(i * degree) * radius, y2 + Math.cos(i * degree) * radius, 0.0D).endVertex(); + + tessellator.draw(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static void glColor(final int red, final int green, final int blue, final int alpha) { + GlStateManager.color(red / 255F, green / 255F, blue / 255F, alpha / 255F); + } + + public static void glColor(final Color color) { + final float red = color.getRed() / 255F; + final float green = color.getGreen() / 255F; + final float blue = color.getBlue() / 255F; + final float alpha = color.getAlpha() / 255F; + + GlStateManager.color(red, green, blue, alpha); + } + + public static void glColor(final int hex, final int alpha) { + final float red = (hex >> 16 & 0xFF) / 255F; + final float green = (hex >> 8 & 0xFF) / 255F; + final float blue = (hex & 0xFF) / 255F; + + GlStateManager.color(red, green, blue, alpha / 255F); + } + + public static void glColor(final int hex, final float alpha) { + final float red = (hex >> 16 & 0xFF) / 255F; + final float green = (hex >> 8 & 0xFF) / 255F; + final float blue = (hex & 0xFF) / 255F; + + GlStateManager.color(red, green, blue, alpha); + } + + public static void glColor(final Color color, final float alpha) { + final float red = color.getRed() / 255F; + final float green = color.getGreen() / 255F; + final float blue = color.getBlue() / 255F; + + GlStateManager.color(red, green, blue, alpha); + } + + public static void renderNameTag(final String string, final double x, final double y, final double z) { + final RenderManager renderManager = mc.getRenderManager(); + + glPushMatrix(); + glTranslated(x - renderManager.renderPosX, y - renderManager.renderPosY, z - renderManager.renderPosZ); + glNormal3f(0F, 1F, 0F); + glRotatef(-mc.getRenderManager().playerViewY, 0F, 1F, 0F); + glRotatef(mc.getRenderManager().playerViewX, 1F, 0F, 0F); + glScalef(-0.05F, -0.05F, 0.05F); + setGlCap(GL_LIGHTING, false); + setGlCap(GL_DEPTH_TEST, false); + setGlCap(GL_BLEND, true); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + final int width = Fonts.font35.getStringWidth(string) / 2; + + Gui.drawRect(-width - 1, -1, width + 1, Fonts.font35.FONT_HEIGHT, Integer.MIN_VALUE); + Fonts.font35.drawString(string, -width, 1.5F, Color.WHITE.getRGB(), true); + + resetCaps(); + glColor4f(1F, 1F, 1F, 1F); + glPopMatrix(); + } + + public static void drawLine(final double x, final double y, final double x1, final double y1, final float width) { + glDisable(GL_TEXTURE_2D); + glLineWidth(width); + glVertex2d(x, y); + glVertex2d(x1, y1); + glEnable(GL_TEXTURE_2D); + } + + public static void makeScissorBox(final float x, final float y, final float x2, final float y2) { + final ScaledResolution scaledResolution = new ScaledResolution(mc); + final int factor = scaledResolution.getScaleFactor(); + glScissor((int) (x * factor), (int) ((scaledResolution.getScaledHeight() - y2) * factor), (int) ((x2 - x) * factor), (int) ((y2 - y) * factor)); + } + + /** + * GL CAP MANAGER + * + * TODO: Remove gl cap manager and replace by something better + */ + + public static void resetCaps() { + glCapMap.forEach(VisualUtils::setGlState); + } + + public static void enableGlCap(final int cap) { + setGlCap(cap, true); + } + + public static void enableGlCap(final int... caps) { + for (final int cap : caps) + setGlCap(cap, true); + } + + public static void disableGlCap(final int cap) { + setGlCap(cap, true); + } + + public static void disableGlCap(final int... caps) { + for (final int cap : caps) + setGlCap(cap, false); + } + + public static void setGlCap(final int cap, final boolean state) { + glCapMap.put(cap, glGetBoolean(cap)); + setGlState(cap, state); + } + + public static void setGlState(final int cap, final boolean state) { + if (state) + glEnable(cap); + else + glDisable(cap); + } + + public static void enableSmoothLine(float width) { + GL11.glDisable(3008); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glDisable(3553); + GL11.glDisable(2929); + GL11.glDepthMask(false); + GL11.glEnable(2884); + GL11.glEnable(2848); + GL11.glHint(3154, 4354); + GL11.glHint(3155, 4354); + GL11.glLineWidth(width); + } + + + public static double getAnimationState2(double animation, double finalState, double speed) { + float add = (float) (0.01 * speed); + if (animation < finalState) { + if (animation + add < finalState) + animation += add; + else + animation = finalState; + } else { + if (animation - add > finalState) + animation -= add; + else + animation = finalState; + } + return animation; + } + + + public static void drawScaledCustomSizeModalCircle(int x, int y, float u, float v, int uWidth, int vHeight, int width, int height, float tileWidth, float tileHeight) { + float f = 1.0F / tileWidth; + float f1 = 1.0F / tileHeight; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + worldrenderer.begin(GL_POLYGON, DefaultVertexFormats.POSITION_TEX); + float xRadius = width / 2f; + float yRadius = height / 2f; + float uRadius = (((u + (float) uWidth) * f) - (u * f)) / 2f; + float vRadius = (((v + (float) vHeight) * f1) - (v * f1)) / 2f; + for(int i = 0; i <= 360; i+=10) { + double xPosOffset = Math.sin(i * Math.PI / 180.0D); + double yPosOffset = Math.cos(i * Math.PI / 180.0D); + worldrenderer.pos(x + xRadius + xPosOffset * xRadius, y + yRadius + yPosOffset * yRadius, 0) + .tex(u * f + uRadius + xPosOffset * uRadius, v * f1 + vRadius + yPosOffset * vRadius).endVertex(); + } + tessellator.draw(); + } + + public static boolean glEnableBlend() { + final boolean wasEnabled = glIsEnabled(GL_BLEND); + + if (!wasEnabled) { + glEnable(GL_BLEND); + glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, 1, 0); + } + + return wasEnabled; + } + + public static void targetHudRect(final double x, final double y, final double x1, final double y1, final double size) { + rectangleBordered(x, y - 4.0, x1 + size, y1 + size, 0.5, new Color(60, 60, 60).getRGB(), new Color(10, 10, 10).getRGB()); + rectangleBordered(x + 1.0, y - 3.0, x1 + size - 1.0, y1 + size - 1.0, 1.0, new Color(40, 40, 40).getRGB(), new Color(40, 40, 40).getRGB()); + rectangleBordered(x + 2.5, y - 1.5, x1 + size - 2.5, y1 + size - 2.5, 0.5, new Color(40, 40, 40).getRGB(), new Color(60, 60, 60).getRGB()); + rectangleBordered(x + 2.5, y - 1.5, x1 + size - 2.5, y1 + size - 2.5, 0.5, new Color(22, 22, 22).getRGB(), new Color(255, 255, 255, 0).getRGB()); + } + + public static void targetHudRect1(final double x, final double y, final double x1, final double y1, final double size) { + rectangleBordered(x + 4.35, y + 0.5, x1 + size - 84.5, y1 + size - 4.35, 0.5, new Color(48, 48, 48).getRGB(), new Color(10, 10, 10).getRGB()); + rectangleBordered(x + 5.0, y + 1.0, x1 + size - 85.0, y1 + size - 5.0, 0.5, new Color(17, 17, 17).getRGB(), new Color(255, 255, 255, 0).getRGB()); + } + + public static boolean antialiiasing = false; + + public static void f(float x, float y, float x2, float y2, float l1, int col1, int col2) { + drawRect(x, y, x2, y2, col2); + float f = (col1 >> 24 & 0xFF) / 255.0f; + float f2 = (col1 >> 16 & 0xFF) / 255.0f; + float f3 = (col1 >> 8 & 0xFF) / 255.0f; + float f4 = (col1 & 0xFF) / 255.0f; + GL11.glPushMatrix(); + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glBlendFunc(770, 771); + GL11.glEnable(2848); + GL11.glColor4f(f2, f3, f4, f); + GL11.glLineWidth(l1); + GL11.glBegin(1); + GL11.glVertex2d(x, y); + GL11.glVertex2d(x, y2); + GL11.glVertex2d(x2, y2); + GL11.glVertex2d(x2, y); + GL11.glVertex2d(x, y); + GL11.glVertex2d(x2, y); + GL11.glVertex2d(x, y2); + GL11.glVertex2d(x2, y2); + GL11.glEnd(); + GL11.glEnable(3553); + GL11.glDisable(3042); + GL11.glDisable(2848); + GL11.glPopMatrix(); + } + + public static int getRainbow(int speed, int offset, float s) { + float hue = (System.currentTimeMillis() + offset) % speed; + hue /= speed; + return Color.getHSBColor(hue, s, 1f).getRGB(); + } + + public static void drawRoundedRectangle(double left, double top, double right, double bottom, double radius, int color) { + glScaled(0.5D, 0.5D, 0.5D); + left *= 2.0D; + top *= 2.0D; + right *= 2.0D; + bottom *= 2.0D; + glDisable(GL_TEXTURE_2D); + glEnable(GL_LINE_SMOOTH); + enableBlend(); + glColor(color); + + int i; + for (i = 0; i <= 90; i += 1) + glVertex2d(left + radius + Math.sin(i * Math.PI / 180.0D) * radius * -1.0D, top + radius + Math.cos(i * Math.PI / 180.0D) * radius * -1.0D); + for (i = 90; i <= 180; i += 1) + glVertex2d(left + radius + Math.sin(i * Math.PI / 180.0D) * radius * -1.0D, bottom - radius + Math.cos(i * Math.PI / 180.0D) * radius * -1.0D); + for (i = 0; i <= 90; i += 1) + glVertex2d(right - radius + Math.sin(i * Math.PI / 180.0D) * radius, bottom - radius + Math.cos(i * Math.PI / 180.0D) * radius); + for (i = 90; i <= 180; i += 1) + glVertex2d(right - radius + Math.sin(i * Math.PI / 180.0D) * radius, top + radius + Math.cos(i * Math.PI / 180.0D) * radius); + glEnable(GL_TEXTURE_2D); + glScaled(2.0D, 2.0D, 2.0D); + glColor4d(1, 1, 1, 1); + } + + public static void drawRectAlpha(float g, float h, float i, float j, int col1,float alpha) { + float f2 = (col1 >> 16 & 0xFF) / 255.0f; + float f3 = (col1 >> 8 & 0xFF) / 255.0f; + float f4 = (col1 & 0xFF) / 255.0f; + GL11.glPushMatrix(); + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glBlendFunc(770, 771); + GL11.glEnable(2848); + GL11.glColor4f(f2, f3, f4, alpha); + GL11.glBegin(7); + GL11.glVertex2d(i, h); + GL11.glVertex2d(g, h); + GL11.glVertex2d(g, j); + GL11.glVertex2d(i, j); + GL11.glEnd(); + GL11.glEnable(3553); + GL11.glDisable(3042); + GL11.glDisable(2848); + GL11.glPopMatrix(); + } + + public static void outlineOne() { + GL11.glPushAttrib(1048575); + GL11.glDisable(3008); + GL11.glDisable(3553); + GL11.glDisable(2896); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glLineWidth(3.0f); + GL11.glEnable(2848); + GL11.glHint(3154, 4354); + GL11.glEnable(2960); + GL11.glClear(1024); + GL11.glClearStencil(15); + GL11.glStencilFunc(512, 1, 15); + GL11.glStencilOp(7681, 7681, 7681); + GL11.glLineWidth(3.8f); + GL11.glStencilOp(7681, 7681, 7681); + GL11.glPolygonMode(1032, 6913); + } + + public static Color transparency(int color, double alpha) { + Color c = new Color(color); + float r = 0.003921569f * c.getRed(); + float g = 0.003921569f * c.getGreen(); + float b = 0.003921569f * c.getBlue(); + return new Color(r, g, b, (float)alpha); + } + + public static void outlineTwo() { + GL11.glStencilFunc(512, 0, 15); + GL11.glStencilOp(7681, 7681, 7681); + GL11.glPolygonMode(1032, 6914); + } + + public static void outlineThree() { + GL11.glStencilFunc(514, 1, 15); + GL11.glStencilOp(7680, 7680, 7680); + GL11.glPolygonMode(1032, 6913); + } + + public static void outlineFour() { + GL11.glEnable(10754); + GL11.glPolygonOffset(1.0f, -2000000.0f); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0f, 240.0f); + } + + public static void outlineFive() { + GL11.glPolygonOffset(1.0f, 2000000.0f); + GL11.glDisable(10754); + GL11.glDisable(2960); + GL11.glDisable(2848); + GL11.glHint(3154, 4352); + GL11.glDisable(3042); + GL11.glEnable(2896); + GL11.glEnable(3553); + GL11.glEnable(3008); + GL11.glPopAttrib(); + } + + public static void drawFineBorderedRect(int x, int y, int x1, int y1, int bord, int color) { + GL11.glScaled(0.5, 0.5, 0.5); + x *= 2; + y *= 2; + x1 *= 2; + y1 *= 2; + drawRect2(x + 1, y + 1, x1, y1, color); + drawVerticalLine(x, y, y1, bord); + drawVerticalLine(x1, y, y1, bord); + drawHorizontalLine(x + 1, y, x1, bord); + drawHorizontalLine(x, y1, x1 + 1, bord); + GL11.glScaled(2.0, 2.0, 2.0); + } + + public static void drawHorizontalLine(int x, int y, int width, int color) { + drawRect(x, y, width, y + 1, color); + } + + public static void drawBorderedRect(float x, float y, float x1, float y1, int insideC, int borderC) { + enableGL2D(); + x *= 2.0f; + x1 *= 2.0f; + y *= 2.0f; + y1 *= 2.0f; + GL11.glScalef(0.5f, 0.5f, 0.5f); + drawVLine(x, y, y1, borderC); + drawVLine(x1 - 1.0f, y, y1, borderC); + drawHLine(x, x1 - 1.0f, y, borderC); + drawHLine(x, x1 - 2.0f, y1 - 1.0f, borderC); + drawRect(x + 1.0f, y + 1.0f, x1 - 1.0f, y1 - 1.0f, insideC); + GL11.glScalef(2.0f, 2.0f, 2.0f); + disableGL2D(); + } + + public static void enableLighting() { + GL11.glDisable(3042); + GL11.glEnable(3553); + GL11.glDisable(2848); + GL11.glDisable(3042); + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glMatrixMode(5890); + GL11.glLoadIdentity(); + final float var3 = 0.0039063f; + GL11.glScalef(var3, var3, var3); + GL11.glTranslatef(8.0f, 8.0f, 8.0f); + GL11.glMatrixMode(5888); + GL11.glTexParameteri(3553, 10241, 9729); + GL11.glTexParameteri(3553, 10240, 9729); + GL11.glTexParameteri(3553, 10242, 10496); + GL11.glTexParameteri(3553, 10243, 10496); + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + } + + public static void disableLighting() { + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glDisable(3553); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glEnable(2848); + GL11.glDisable(2896); + GL11.glDisable(3553); + } + + public static void drawOutlineRect(double x, double y, double x2, double y2, double scale, int color) { + drawRect(x, y, x + scale, y2, color); + drawRect(x, y, x2, y + scale, color); + drawRect(x2, y, x2 + scale, y2, color); + drawRect(x, y2, x2 + scale, y2 + scale, color); + } + + public static void drawGlow(double x, double y, double size, int col, int col2){ + int times = (int) size; + for(int i = 0; i < times ; i++){ + GlStateManager.pushMatrix(); + GlStateManager.translate(x,y,0); + glRotated((360f / times) * i,0,0,1); + drawGradientRect(0,0,(360f/times) * 6, 0 + size, col, col2); + GlStateManager.translate(-x,-y,0); + glRotated(-(360f / times) * i,0,0,1); + GlStateManager.popMatrix(); + } + } + + public static void drawGradientRect(float x, float y, float x1, float y1, int topColor, int bottomColor) { + enableGL2D(); + GL11.glShadeModel(GL_SMOOTH); + GL11.glBegin(7); + glColor(topColor); + GL11.glVertex2f(x, y1); + GL11.glVertex2f(x1, y1); + glColor(bottomColor); + GL11.glVertex2f(x1, y); + GL11.glVertex2f(x, y); + GL11.glEnd(); + GL11.glShadeModel(GL_SMOOTH); + disableGL2D(); + } + + public static void drawGradientRect(double d, double e, double f, double g, int topColor, int bottomColor) { + enableGL2D(); + GL11.glShadeModel(GL_SMOOTH); + GL11.glBegin(GL_LINE_STRIP); + glColor(topColor); + GL11.glVertex2d(d, g); + GL11.glVertex2d(f, g); + glColor(bottomColor); + GL11.glVertex2d(f, e); + GL11.glVertex2d(d, e); + GL11.glEnd(); + GL11.glShadeModel(GL_SMOOTH); + disableGL2D(); + } + + public static void drawBorderedRect(double left, double top, double right, double bottom, float width, int borderColour, int colour) { + GlStateManager.pushMatrix(); + drawRect(left, top, right, bottom, colour); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.blendFunc(770, 771); + glColor(borderColour); + GL11.glEnable(2848); + GL11.glLineWidth(width); + GL11.glBegin(1); + GL11.glVertex2d(left, top); + GL11.glVertex2d(left, bottom); + GL11.glVertex2d(right, bottom); + GL11.glVertex2d(right, top); + GL11.glVertex2d(left, top); + GL11.glVertex2d(right, top); + GL11.glVertex2d(left, bottom); + GL11.glVertex2d(right, bottom); + GL11.glEnd(); + GL11.glDisable(2848); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + GlStateManager.popMatrix(); + } + + public static void drawGradientBorderedRect(float x, float y, float x1, float y1, float lineWidth, int border, int bottom, int top) { + enableGL2D(); + drawGradientRect(x, y, x1, y1, top, bottom); + glColor(border); + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glBlendFunc(770, 771); + GL11.glLineWidth(lineWidth); + GL11.glBegin(3); + GL11.glVertex2f(x, y); + GL11.glVertex2f(x, y1); + GL11.glVertex2f(x1, y1); + GL11.glVertex2f(x1, y); + GL11.glVertex2f(x, y); + GL11.glEnd(); + GL11.glEnable(3553); + GL11.glDisable(3042); + disableGL2D(); + } + + public static void beginGl() { + GlStateManager.pushMatrix(); + RenderHelper.enableStandardItemLighting(); + GlStateManager.disableLighting(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.disableDepth(); + GlStateManager.depthMask(false); + GlStateManager.disableTexture2D(); + if (antialiiasing) + GL11.glEnable(GL11.GL_LINE_SMOOTH); + GL11.glLineWidth(1.0f); + } + + public static void endGl() { + GL11.glLineWidth(2.0F); + if (antialiiasing) + GL11.glDisable(GL11.GL_LINE_SMOOTH); + GlStateManager.enableTexture2D(); + GlStateManager.depthMask(true); + GlStateManager.enableDepth(); + GlStateManager.disableBlend(); + GlStateManager.enableLighting(); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + RenderHelper.disableStandardItemLighting(); + GlStateManager.popMatrix(); + } + + public static void drawLines(AxisAlignedBB boundingBox) { + GL11.glPushMatrix(); + GL11.glBegin(2); + GL11.glVertex3d(boundingBox.minX, boundingBox.minY, boundingBox.minZ); + GL11.glVertex3d(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ); + GL11.glVertex3d(boundingBox.maxX, boundingBox.minY, boundingBox.minZ); + GL11.glVertex3d(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ); + GL11.glVertex3d(boundingBox.maxX, boundingBox.minY, boundingBox.maxZ); + GL11.glVertex3d(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ); + GL11.glVertex3d(boundingBox.maxX, boundingBox.minY, boundingBox.minZ); + GL11.glVertex3d(boundingBox.minX, boundingBox.maxY, boundingBox.minZ); + GL11.glVertex3d(boundingBox.maxX, boundingBox.minY, boundingBox.minZ); + GL11.glVertex3d(boundingBox.minX, boundingBox.minY, boundingBox.maxZ); + GL11.glVertex3d(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ); + GL11.glVertex3d(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ); + GL11.glEnd(); + GL11.glPopMatrix(); + } + + public static void drawBorderedRefinedRect(float x, float y, float x1, float y1, float lineWidth, int inside, int border) { + enableGL2D(); + drawRect(x, y, x1, y1, inside); + glColor(border); + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glBlendFunc(770, 771); + GL11.glLineWidth(lineWidth); + GL11.glBegin(3); + GL11.glVertex2f(x, y); + GL11.glVertex2f(x, y1); + GL11.glVertex2f(x1, y1); + GL11.glVertex2f(x1, y); + GL11.glVertex2f(x, y); + GL11.glEnd(); + GL11.glEnable(3553); + GL11.glDisable(3042); + disableGL2D(); + } + + public static void drawHead(final AbstractClientPlayer target, final int x, final int y, final int width, final int height) { + final ResourceLocation skin = target.getLocationSkin(); + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + Minecraft.getMinecraft().getTextureManager().bindTexture(skin); + drawScaledCustomSizeModalRect(x, y, 8.0f, 8.0f, 8, 8, width, height, 64.0f, 64.0f); + drawScaledCustomSizeModalRect(x, y, 40.0f, 8.0f, 8, 8, width, height, 64.0f, 64.0f); + } + + public static void drawOutlinedRoundedRect(double x, double y, double width, double height, double radius, float linewidth, int color) { + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + double x1 = x + width; + double y1 = y + height; + float f = (color >> 24 & 0xFF) / 255.0F; + float f1 = (color >> 16 & 0xFF) / 255.0F; + float f2 = (color >> 8 & 0xFF) / 255.0F; + float f3 = (color & 0xFF) / 255.0F; + GL11.glPushAttrib(0); + GL11.glScaled(0.5, 0.5, 0.5); + + x *= 2; + y *= 2; + x1 *= 2; + y1 *= 2; + GL11.glLineWidth(linewidth); + + glDisable(GL11.GL_TEXTURE_2D); + GL11.glColor4f(f1, f2, f3, f); + glEnable(GL11.GL_LINE_SMOOTH); + GL11.glBegin(2); + + for (int i = 0; i <= 90; i += 3) { + GL11.glVertex2d(x + radius + +(Math.sin((i * Math.PI / 180)) * (radius * -1)), y + radius + (Math.cos((i * Math.PI / 180)) * (radius * -1))); + } + + for (int i = 90; i <= 180; i += 3) { + GL11.glVertex2d(x + radius + (Math.sin((i * Math.PI / 180)) * (radius * -1)), y1 - radius + (Math.cos((i * Math.PI / 180)) * (radius * -1))); + } + + for (int i = 0; i <= 90; i += 3) { + GL11.glVertex2d(x1 - radius + (Math.sin((i * Math.PI / 180)) * radius), y1 - radius + (Math.cos((i * Math.PI / 180)) * radius)); + } + + for (int i = 90; i <= 180; i += 3) { + GL11.glVertex2d(x1 - radius + (Math.sin((i * Math.PI / 180)) * radius), y + radius + (Math.cos((i * Math.PI / 180)) * radius)); + } + + GL11.glEnd(); + + glEnable(GL11.GL_TEXTURE_2D); + glDisable(GL11.GL_LINE_SMOOTH); + glEnable(GL11.GL_TEXTURE_2D); + + GL11.glScaled(2, 2, 2); + + GL11.glPopAttrib(); + GL11.glColor4f(1, 1, 1, 1); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + + } + + public static void drawLineToPosition(double x,double y,double z, int color) { + Minecraft mc = Minecraft.getMinecraft(); + double renderPosXDelta = x - mc.getRenderManager().viewerPosX; + double renderPosYDelta = y - mc.getRenderManager().viewerPosY; + double renderPosZDelta = z - mc.getRenderManager().viewerPosZ; + GL11.glPushMatrix(); + GL11.glEnable(3042); + GL11.glEnable(2848); + GL11.glDisable(2929); + GL11.glDisable(3553); + GL11.glBlendFunc(770, 771); + GL11.glLineWidth(1.0F); + float blockPos9 = (float) (mc.thePlayer.posX - x); + float blockPos7 = (float) (mc.thePlayer.posY - y); + float f = (float) (color >> 16 & 0xFF) / 255.0f; + float f2 = (float) (color >> 8 & 0xFF) / 255.0f; + float f3 = (float) (color & 0xFF) / 255.0f; + float f4 = (float) (color >> 24 & 0xFF) / 255.0f; + GL11.glColor4f(f, f2, f3, f4); + GL11.glLoadIdentity(); + boolean previousState = mc.gameSettings.viewBobbing; + mc.gameSettings.viewBobbing = false; + GL11.glBegin(3); + GL11.glVertex3d(0.0D, mc.thePlayer.getEyeHeight(), 0.0D); + GL11.glVertex3d(renderPosXDelta, renderPosYDelta, renderPosZDelta); + GL11.glVertex3d(renderPosXDelta, renderPosYDelta, renderPosZDelta); + GL11.glEnd(); + mc.gameSettings.viewBobbing = previousState; + GL11.glEnable(3553); + GL11.glEnable(2929); + GL11.glDisable(2848); + GL11.glDisable(3042); + GL11.glPopMatrix(); + } + + public static void drawVerticalLine(int x, int y, int height, int color) { + drawRect2(x, y, x + 1, height, color); + } + + public static void drawRoundedRect(double x, double y, final double width, final double height, final double radius, final int color) { + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + double x2 = x + width; + double y2 = y + height; + final float f = (color >> 24 & 0xFF) / 255.0f; + final float f2 = (color >> 16 & 0xFF) / 255.0f; + final float f3 = (color >> 8 & 0xFF) / 255.0f; + final float f4 = (color & 0xFF) / 255.0f; + GL11.glPushAttrib(0); + GL11.glScaled(0.5, 0.5, 0.5); + x *= 2.0; + y *= 2.0; + x2 *= 2.0; + y2 *= 2.0; + GL11.glDisable(3553); + GL11.glColor4f(f2, f3, f4, f); + GL11.glEnable(2848); + GL11.glBegin(9); + for (int i = 0; i <= 90; i += 3) { + GL11.glVertex2d(x + radius + Math.sin(i * 3.141592653589793 / 180.0) * (radius * -1.0), y + radius + Math.cos(i * 3.141592653589793 / 180.0) * (radius * -1.0)); + } + for (int i = 90; i <= 180; i += 3) { + GL11.glVertex2d(x + radius + Math.sin(i * 3.141592653589793 / 180.0) * (radius * -1.0), y2 - radius + Math.cos(i * 3.141592653589793 / 180.0) * (radius * -1.0)); + } + for (int i = 0; i <= 90; i += 3) { + GL11.glVertex2d(x2 - radius + Math.sin(i * 3.141592653589793 / 180.0) * radius, y2 - radius + Math.cos(i * 3.141592653589793 / 180.0) * radius); + } + for (int i = 90; i <= 180; i += 3) { + GL11.glVertex2d(x2 - radius + Math.sin(i * 3.141592653589793 / 180.0) * radius, y + radius + Math.cos(i * 3.141592653589793 / 180.0) * radius); + } + GL11.glEnd(); + GL11.glEnable(3553); + GL11.glDisable(2848); + GL11.glEnable(3553); + GL11.glScaled(2.0, 2.0, 2.0); + GL11.glPopAttrib(); + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static void drawRoundedRectNew(double x, double y, double width, double height, double radius, int color) { + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + double x1 = x + width; + double y1 = y + height; + float f = (float)(color >> 24 & 255) / 255.0F; + float f1 = (float)(color >> 16 & 255) / 255.0F; + float f2 = (float)(color >> 8 & 255) / 255.0F; + float f3 = (float)(color & 255) / 255.0F; + GL11.glPushAttrib(0); + GL11.glScaled(0.5D, 0.5D, 0.5D); + x *= 2.0D; + y *= 2.0D; + x1 *= 2.0D; + y1 *= 2.0D; + GL11.glDisable(3553); + GL11.glColor4f(f1, f2, f3, f); + GL11.glEnable(2848); + GL11.glBegin(9); + + int i; + for(i = 0; i <= 90; i += 3) { + GL11.glVertex2d(x + radius + Math.sin((double)i * 3.141592653589793D / 180.0D) * radius * -1.0D, y + radius + Math.cos((double)i * 3.141592653589793D / 180.0D) * radius * -1.0D); + } + + for(i = 90; i <= 180; i += 3) { + GL11.glVertex2d(x + radius + Math.sin((double)i * 3.141592653589793D / 180.0D) * radius * -1.0D, y1 - radius + Math.cos((double)i * 3.141592653589793D / 180.0D) * radius * -1.0D); + } + + for(i = 0; i <= 90; i += 3) { + GL11.glVertex2d(x1 - radius + Math.sin((double)i * 3.141592653589793D / 180.0D) * radius, y1 - radius + Math.cos((double)i * 3.141592653589793D / 180.0D) * radius); + } + + for(i = 90; i <= 180; i += 3) { + GL11.glVertex2d(x1 - radius + Math.sin((double)i * 3.141592653589793D / 180.0D) * radius, y + radius + Math.cos((double)i * 3.141592653589793D / 180.0D) * radius); + } + + GL11.glEnd(); + GL11.glEnable(3553); + GL11.glDisable(2848); + GL11.glEnable(3553); + GL11.glScaled(2.0D, 2.0D, 2.0D); + GL11.glPopAttrib(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static void illlIIIIiii(final float x, final float y, float start, float end, final float w, final float h, final int color, final float lineWidth) { + if (start > end) { + final float temp = end; + end = start; + start = temp; + } + final float alpha = (color >> 24 & 0xFF) / 255.0f; + final float red = (color >> 16 & 0xFF) / 255.0f; + final float green = (color >> 8 & 0xFF) / 255.0f; + final float blue = (color & 0xFF) / 255.0f; + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 0, 1); + GlStateManager.color(red, green, blue, alpha); + GL11.glEnable(2881); + GL11.glEnable(2848); + GL11.glLineWidth(lineWidth); + GL11.glBegin(3); + for (float i = end; i >= start; i -= 4.0f) { + GL11.glVertex2d(x + Math.cos(i * 3.141592653589793 / 180.0) * w * 1.001, y + Math.sin(i * 3.141592653589793 / 180.0) * h * 1.001); + } + GL11.glEnd(); + GL11.glDisable(2848); + GL11.glDisable(2881); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static void drawBorderRect(float x, float y, float x2, float y2, float round, int color) { + drawRect((x += ((round / 2.0F) + 0.5F)), + (y += ((round / 2.0f) + 0.5F)), + (x2 -= ((round / 2.0f) + 0.5F)), + (y2 -= ((round / 2.0f) + 0.5F)), color); + circle(x2 - round / 2.0f, y + round / 2.0f, round, color); + circle(x + round / 2.0f, y2 - round / 2.0f - 0.2f, round, color); + circle(x + round / 2.0f, y + round / 2.0f, round, color); + circle(x2 - round / 2.0f, y2 - round / 2.0f - 0.2f, round, color); + drawRect((x - round / 2.0f - 0.5f), (y + round / 2.0f), x2, (y2 - round / 2.0f), + color); + drawRect( x, (y + round / 2.0f), (x2 + round / 2.0f + 0.5f), (y2 - round / 2.0f), + color); + drawRect((x + round / 2.0f), (y - round / 2.0f - 0.5f), (x2 - round / 2.0f), + (y2 - round / 2.0f), color); + drawRect((x + round / 2.0f), y, (x2 - round / 2.0f),(y2 + round / 2.0f + 0.5f), + color); + + } + public static void arc3(final float x, final float y, final float start, final float end, final float radius, + final Color color) { + arcEllipse(x, y, start, end, radius, radius, color); + } + + public static void stopGlScissor() { + GL11.glDisable(3089); + GL11.glPopMatrix(); + } + + public static int getRainbowOpaque(int get, float get1, float get2, int i) { + return 0; + } + + public static int SkyRainbow(int i, float get, float get1) { + return 0; + } + + public static void drawRoundedRect3(float x, float y, float x2, float y2, final float round, final int color,final int mode) { + final float rectX = x,rectY = y, rectX2 = x2, rectY2 = y2; + x += (float) (round / 2.0f + 0.5); + y += (float) (round / 2.0f + 0.5); + x2 -= (float) (round / 2.0f + 0.5); + y2 -= (float) (round / 2.0f + 0.5); + if(mode == 1) + drawRect(x , rectY, rectX2, rectY2, color); + else + drawRect(rectX, rectY, x2, rectY2, color); + circle(x2 - round / 2.0f, y + round / 2.0f, round, color); + circle(x + round / 2.0f, y2 - round / 2.0f, round, color); + circle(x + round / 2.0f, y + round / 2.0f, round, color); + circle(x2 - round / 2.0f, y2 - round / 2.0f, round, color); + drawRect((int) (x - round / 2.0f - 0.5f), (int) (y + round / 2.0f), (int) x2, (int) (y2 - round / 2.0f), + color); + drawRect((int) x, (int) (y + round / 2.0f), (int) (x2 + round / 2.0f + 0.5f), (int) (y2 - round / 2.0f), + color); + drawRect((int) (x + round / 2.0f), (int) (y - round / 2.0f - 0.5f), (int) (x2 - round / 2.0f), + (int) (y2 - round / 2.0f), color); + drawRect((int) (x + round / 2.0f), (int) y, (int) (x2 - round / 2.0f), (int) (y2 + round / 2.0f + 0.5f), + color); + } + + public static void drawFastRoundedRect(final float x0, final float y0, final float x1, final float y1, + final float radius, final int color) { + final int Semicircle = 18; + final float f = 90.0f / Semicircle; + final float f2 = (color >> 24 & 0xFF) / 255.0f; + final float f3 = (color >> 16 & 0xFF) / 255.0f; + final float f4 = (color >> 8 & 0xFF) / 255.0f; + final float f5 = (color & 0xFF) / 255.0f; + GL11.glDisable(2884); + GL11.glDisable(3553); + GL11.glEnable(3042); + GlStateManager.enableBlend(); + //GL11.glBlendFunc(770, 771); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GlStateManager.disableTexture2D(); + GL11.glColor4f(f3, f4, f5, f2); + GL11.glBegin(5); + GL11.glVertex2f(x0 + radius, y0); + GL11.glVertex2f(x0 + radius, y1); + GL11.glVertex2f(x1 - radius, y0); + GL11.glVertex2f(x1 - radius, y1); + GL11.glEnd(); + GL11.glBegin(5); + GL11.glVertex2f(x0, y0 + radius); + GL11.glVertex2f(x0 + radius, y0 + radius); + GL11.glVertex2f(x0, y1 - radius); + GL11.glVertex2f(x0 + radius, y1 - radius); + GL11.glEnd(); + GL11.glBegin(5); + GL11.glVertex2f(x1, y0 + radius); + GL11.glVertex2f(x1 - radius, y0 + radius); + GL11.glVertex2f(x1, y1 - radius); + GL11.glVertex2f(x1 - radius, y1 - radius); + GL11.glEnd(); + GL11.glBegin(6); + float f6 = x1 - radius; + float f7 = y0 + radius; + GL11.glVertex2f(f6, f7); + int j; + for (j = 0; j <= Semicircle; ++j) { + final float f8 = j * f; + GL11.glVertex2f((float) (f6 + radius * Math.cos(Math.toRadians(f8))), + (float) (f7 - radius * Math.sin(Math.toRadians(f8)))); + } + GL11.glEnd(); + GL11.glBegin(6); + f6 = x0 + radius; + f7 = y0 + radius; + GL11.glVertex2f(f6, f7); + for (j = 0; j <= Semicircle; ++j) { + final float f9 = j * f; + GL11.glVertex2f((float) (f6 - radius * Math.cos(Math.toRadians(f9))), + (float) (f7 - radius * Math.sin(Math.toRadians(f9)))); + } + GL11.glEnd(); + GL11.glBegin(6); + f6 = x0 + radius; + f7 = y1 - radius; + GL11.glVertex2f(f6, f7); + for (j = 0; j <= Semicircle; ++j) { + final float f10 = j * f; + GL11.glVertex2f((float) (f6 - radius * Math.cos(Math.toRadians(f10))), + (float) (f7 + radius * Math.sin(Math.toRadians(f10)))); + } + GL11.glEnd(); + GL11.glBegin(6); + f6 = x1 - radius; + f7 = y1 - radius; + GL11.glVertex2f(f6, f7); + for (j = 0; j <= Semicircle; ++j) { + final float f11 = j * f; + GL11.glVertex2f((float) (f6 + radius * Math.cos(Math.toRadians(f11))), + (float) (f7 + radius * Math.sin(Math.toRadians(f11)))); + } + GL11.glEnd(); + GL11.glEnable(3553); + GL11.glEnable(2884); + GL11.glDisable(3042); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static void drawFullCircle(final float x, final float y,final float radius, + final int color,final int outSideColor) { + final float alpha = (color >> 24 & 0xFF) / 255.0f; + final float red = (color >> 16 & 0xFF) / 255.0f; + final float green = (color >> 8 & 0xFF) / 255.0f; + final float blue = (color & 0xFF) / 255.0f; + final float outSideAlpha = (outSideColor >> 24 & 0xFF) / 255.0f; + final float outSideRed = (outSideColor >> 16 & 0xFF) / 255.0f; + final float outSideGreen = (outSideColor >> 8 & 0xFF) / 255.0f; + final float outSideBlue = (outSideColor & 0xFF) / 255.0f; + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.color(outSideRed, outSideGreen, outSideBlue, outSideAlpha); + if (alpha > 0.5f) { + GL11.glEnable(2881); + GL11.glEnable(2848); +// GL11.glLineWidth(2.5F); + enableSmoothLine(2F); + + GL11.glBlendFunc(770, 771); + //GL11.glLineWidth(2.0f); + GL11.glBegin(3); + for(int i = 0; i <= 360; ++i) { + GL11.glVertex2d( + ( x + Math.sin( ((double) i * 3.141526 / 180.0)) * radius), + ( y + Math.cos( ((double) i * 3.141526 / 180.0)) * radius)); + } + GL11.glEnd(); + GL11.glDisable(2848); + GL11.glDisable(2881); + GlStateManager.resetColor(); + } + GlStateManager.color(red, green, blue, alpha); + GL11.glBegin(6); + for(int i = 0; i <= 360; ++i) { + GL11.glVertex2d( + (x + Math.sin( ((double) i * 3.141526 / 180.0)) * radius), + (y + Math.cos( ((double) i * 3.141526 / 180.0)) * radius)); + } + GL11.glEnd(); + disableSmoothLine(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static void drawFace(int x, int y, float u, float v, int uWidth, int vHeight, int width, int height, float tileWidth, float tileHeight, AbstractClientPlayer target) { + try { + ResourceLocation skin = target.getLocationSkin(); + Minecraft.getMinecraft().getTextureManager().bindTexture(skin); + GL11.glEnable(GL11.GL_BLEND); + GL11.glColor4f(1, 1, 1, 1); + Gui.drawScaledCustomSizeModalRect(x, y, u, v, uWidth, vHeight, width, height, tileWidth, tileHeight); + GL11.glDisable(GL11.GL_BLEND); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void drawRoundedRect31(float x, float y, float x1, float y1, int borderC, int insideC) { + enableGL2D(); + GL11.glScalef((float) 0.5f, (float) 0.5f, (float) 0.5f); + drawVLine(x *= 2.0f, (y *= 2.0f) + 1.0f, (y1 *= 2.0f) - 2.0f, borderC); + drawVLine((x1 *= 2.0f) - 1.0f, y + 1.0f, y1 - 2.0f, borderC); + drawHLine(x + 2.0f, x1 - 3.0f, y, borderC); + drawHLine(x + 2.0f, x1 - 3.0f, y1 - 1.0f, borderC); + drawHLine(x + 1.0f, x + 1.0f, y + 1.0f, borderC); + drawHLine(x1 - 2.0f, x1 - 2.0f, y + 1.0f, borderC); + drawHLine(x1 - 2.0f, x1 - 2.0f, y1 - 2.0f, borderC); + drawHLine(x + 1.0f, x + 1.0f, y1 - 2.0f, borderC); + drawRect(x + 1.0f, y + 1.0f, x1 - 1.0f, y1 - 1.0f, insideC); + GL11.glScalef((float) 2.0f, (float) 2.0f, (float) 2.0f); + disableGL2D(); + Gui.drawRect(0, 0, 0, 0, 0); + } + + + public static void drawRoundRect4(float x, float y, float x1, float y1, int color) { + drawRoundedRect31(x, y, x1, y1, color, color); + GlStateManager.color(1,1,1); + } + + public static void startGlScissor(int x, int y, int width, int height) { + int scaleFactor = new ScaledResolution(mc).getScaleFactor(); + GL11.glPushMatrix(); + GL11.glEnable(3089); + GL11.glScissor((x * scaleFactor), (mc.displayHeight - (y + height) * scaleFactor), + (width * scaleFactor), ((height += 14) * scaleFactor)); + } + + public static void arcIiiilllIIiii(final float x, final float y, final float start, final float end, final float radius, final int color, final float lineWidth) { + illlIIIIiii(x, y, start, end, radius, radius, color, lineWidth); + } + + + public static void drawHead(ResourceLocation skin, int x, int y, int width, int height) { + GL11.glColor4f(1F, 1F, 1F, 1F); + mc.getTextureManager().bindTexture(skin); + VisualUtils.drawScaledCustomSizeModalRect(x, y, 8F, 8F, 8, 8, width, height, + 64F, 64F); + VisualUtils.drawScaledCustomSizeModalRect(x, y, 40F, 8F, 8, 8, width, height, + 64F, 64F); + } + + public static void disableSmoothLine() { + GL11.glEnable(3553); + GL11.glEnable(2929); + GL11.glDisable(3042); + GL11.glEnable(3008); + GL11.glDepthMask(true); + GL11.glCullFace(1029); + GL11.glDisable(2848); + GL11.glHint(3154, 4352); + GL11.glHint(3155, 4352); + } + public static int getRainbow(int index, int offset, float bright, float st) { + float hue = (System.currentTimeMillis() + ((long) offset * index)) % 2000L; + return Color.getHSBColor((float) (hue /= 2000L), st, bright).getRGB(); + } + + public static int Astolfo(int var2, float bright, float st, int index, int offset, float client) { + double rainbowDelay = Math.ceil(System.currentTimeMillis() + (long) (var2 * index)) / offset; + return Color.getHSBColor((double) ((float) ((rainbowDelay %= client) / client)) < 0.5 ? -((float) (rainbowDelay / client)) : (float) (rainbowDelay / client), st, bright).getRGB(); + } + + public static void drawShadow(int x, int y, int width, int height) { + ScaledResolution sr = new ScaledResolution(mc); + drawTexturedRect(x - 9, y - 9, 9, 9, "paneltopleft", sr); + drawTexturedRect(x - 9, y + height, 9, 9, "panelbottomleft", sr); + drawTexturedRect(x + width, y + height, 9, 9, "panelbottomright", sr); + drawTexturedRect(x + width, y - 9, 9, 9, "paneltopright", sr); + drawTexturedRect(x - 9, y, 9, height, "panelleft", sr); + drawTexturedRect(x + width, y, 9, height, "panelright", sr); + drawTexturedRect(x, y - 9, width, 9, "paneltop", sr); + drawTexturedRect(x, y + height, width, 9, "panelbottom", sr); + } + + public static void drawTexturedRect(int x, int y, int width, int height, String image, ScaledResolution sr) { + GL11.glPushMatrix(); + GlStateManager.enableBlend(); + GlStateManager.disableAlpha(); + mc.getTextureManager().bindTexture(new ResourceLocation("zavz/shadow/" + image + ".png")); + GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); + Gui.drawModalRectWithCustomSizedTexture(x, y, 0, 0, width, height, width, height); + GlStateManager.disableBlend(); + GlStateManager.enableAlpha(); + GL11.glPopMatrix(); + } + + private final Supplier colorSupplier; + + VisualUtils(Supplier colorSupplier) { + this.colorSupplier = colorSupplier; + } + + public static Color fade(Color color) { + return VisualUtils.fade(color, 2, 100, 2); + } + + public static Color fade(Color color, int index, int count, float customValue) { + float[] hsb = new float[3]; + Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsb); + float brightness = Math.abs(((float)(System.currentTimeMillis() % 2000L) / 1000.0f + (float)index / (float)count * 2.0f) % customValue - 1.0f); + brightness = 0.5f + 0.5f * brightness; + hsb[2] = brightness % 2.0f; + return new Color(Color.HSBtoRGB(hsb[0], hsb[1], hsb[2])); + } + + public static Color fade2(Color color, int index, int count) { + float[] hsb = new float[3]; + Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsb); + float brightness = Math.abs(((float)(System.currentTimeMillis() % 10000L) / 1000.0f + (float)index / (float)count * 2.0f) % 2.0F - 1.0f); + brightness = 0.5f + 0.5f * brightness; + hsb[2] = brightness % 2.0f; + return new Color(Color.HSBtoRGB(hsb[0], hsb[1], hsb[2])); + } + + public static void drawSuperCircle(final float x, final float y,final float radius, + final int color) { + final float alpha = (color >> 24 & 0xFF) / 255.0f; + final float red = (color >> 16 & 0xFF) / 255.0f; + final float green = (color >> 8 & 0xFF) / 255.0f; + final float blue = (color & 0xFF) / 255.0f; + final Tessellator tessellator = Tessellator.getInstance(); + tessellator.getWorldRenderer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.color(red, green, blue, alpha); + if (alpha > 0.5f) { + GL11.glEnable(GL_POLYGON_SMOOTH); + GL11.glEnable(2848); + GL11.glBlendFunc(770, 771); + //GL11.glLineWidth(2.0f); + GL11.glBegin(3); + + int i = 0; + while (i <= 180) { + GL11.glVertex2d( + ( x + Math.sin( ((double) i * 3.141526 / 180.0)) * radius), + ( y + Math.cos( ((double) i * 3.141526 / 180.0)) * radius)); + ++i; + } + GL11.glEnd(); + GL11.glDisable(2848); + GL11.glDisable(GL_POLYGON_SMOOTH); + } + GL11.glBegin(6); + int i = 0; + while (i <= 180) { + GL11.glVertex2d( + ( x + Math.sin( ((double) i * 3.141526 / 180.0)) * radius), + ( y + Math.cos( ((double) i * 3.141526 / 180.0)) * radius)); + ++i; + } + GL11.glEnd(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + public static void rectangleBordered(double x, double y, double x1, double y1, double width, int internalColor, int borderColor) { + rectangle(x + width, y + width, x1 - width, y1 - width, internalColor); + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + rectangle(x + width, y, x1 - width, y + width, borderColor); + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + rectangle(x, y, x + width, y1, borderColor); + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + rectangle(x1 - width, y, x1, y1, borderColor); + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + rectangle(x + width, y1 - width, x1 - width, y1, borderColor); + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); + } + public static void drawRectBordered(double x, double y, double x1, double y1, double width, int internalColor,int borderColor) { + rectangle(x + width, y + width, x1 - width, y1 - width, internalColor); + rectangle(x + width, y, x1 - width, y + width, borderColor); + rectangle(x, y, x + width, y1, borderColor); + rectangle(x1 - width, y, x1, y1, borderColor); + rectangle(x + width, y1 - width, x1 - width, y1, borderColor); + } + + public static void drawRect(final float x, final float y, final float x2, final float y2, final int color) { + glEnable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_LINE_SMOOTH); + + glColor(color); + + glVertex2d(x2, y); + glVertex2d(x, y); + glVertex2d(x, y2); + glVertex2d(x2, y2); + + glEnable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + glDisable(GL_LINE_SMOOTH); + } + + public static void drawLeftRounded(double left, double top, double right, double bottom, double radius, int color) { + GL11.glScaled(0.5D, 0.5D, 0.5D); + left *= 2.0D; + top *= 2.0D; + right *= 2.0D; + bottom *= 2.0D; + GL11.glDisable(GL_TEXTURE_2D); + glEnable(GL_LINE_SMOOTH); + enableBlend(); + glColor(color); +// GlStateManager.enableAlpha(); +// GlStateManager.enableBlend(); + GL11.glBegin(9); + int i; + for (i = 0; i <= 90; i += 1) + GL11.glVertex2d(left + radius + Math.sin(i * Math.PI / 180.0D) * radius * -1.0D, top + radius + Math.cos(i * Math.PI / 180.0D) * radius * -1.0D); + for (i = 90; i <= 180; i += 1) + GL11.glVertex2d(left + radius + Math.sin(i * Math.PI / 180.0D) * radius * -1.0D, bottom - radius + Math.cos(i * Math.PI / 180.0D) * radius * -1.0D); + GL11.glVertex2d(right, bottom); + GL11.glVertex2d(right,top); + GL11.glEnd(); + GL11.glEnable(GL_TEXTURE_2D); + GL11.glScaled(2.0D, 2.0D, 2.0D); + glColor4d(1, 1, 1, 1); +// GlStateManager.enableAlpha(); +// GlStateManager.enableBlend(); +// GL11.glPopAttrib(); + } + + + public static void drawOutlinedRect(int x, int y, int width, int height, int lineSize, Color lineColor, Color backgroundColor) { + drawRect(x, y, width, height, backgroundColor.getRGB()); + drawRect(x, y, width, y + lineSize, lineColor.getRGB()); + drawRect(x, height - lineSize, width, height, lineColor.getRGB()); + drawRect(x, y + lineSize, x + lineSize, height - lineSize, lineColor.getRGB()); + drawRect(width - lineSize, y + lineSize, width, height - lineSize, lineColor.getRGB()); + } + + public static T clamp(T value, T minimum, T maximum) { + if (value instanceof Integer) { + if (value.intValue() > maximum.intValue()) { + value = maximum; + } else if (value.intValue() < minimum.intValue()) { + value = minimum; + } + } else if (value instanceof Float) { + if (value.floatValue() > maximum.floatValue()) { + value = maximum; + } else if (value.floatValue() < minimum.floatValue()) { + value = minimum; + } + } else if (value instanceof Double) { + if (value.doubleValue() > maximum.doubleValue()) { + value = maximum; + } else if (value.doubleValue() < minimum.doubleValue()) { + value = minimum; + } + } else if (value instanceof Long) { + if (value.longValue() > maximum.longValue()) { + value = maximum; + } else if (value.longValue() < minimum.longValue()) { + value = minimum; + } + } else if (value instanceof Short) { + if (value.shortValue() > maximum.shortValue()) { + value = maximum; + } else if (value.shortValue() < minimum.shortValue()) { + value = minimum; + } + } else if (value instanceof Byte) { + if (value.byteValue() > maximum.byteValue()) { + value = maximum; + } else if (value.byteValue() < minimum.byteValue()) { + value = minimum; + } + } + + return value; + } + + + public static Color fade(final Color color, int index, int count) { + float[] hsb = new float[3]; + Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsb); + + float brightness = Math.abs((((System.currentTimeMillis() % 2000) / 1000F + (index / (float) count) * 2F) % 2F) - 1); + brightness = 0.5f + (0.5f * brightness); + + hsb[2] = brightness % 2F; + return new Color(Color.HSBtoRGB(hsb[0], hsb[1], hsb[2])); + } + + public static void colorRGBA(int color) { + float a = (float) (color >> 24 & 255) / 255.0F; + float r = (float) (color >> 16 & 255) / 255.0F; + float g = (float) (color >> 8 & 255) / 255.0F; + float b = (float) (color & 255) / 255.0F; + + GlStateManager.color(r, g, b, a); + } + + public static void drawFillRectangle(double x, double y, double width, double height) { + GlStateManager.enableBlend(); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glBegin(GL11.GL_QUADS); + GL11.glVertex2d(x, y + height); + GL11.glVertex2d(x + width, y + height); + GL11.glVertex2d(x + width, y); + GL11.glVertex2d(x, y); + GL11.glEnd(); + } + + public static void drawCirclePart(double x, double y, float fromAngle, float toAngle, float radius, int slices) { + GlStateManager.enableBlend(); + GL11.glBegin(GL11.GL_TRIANGLE_FAN); + GL11.glVertex2d(x, y); + final float increment = (toAngle - fromAngle) / slices; + + for (int i = 0; i <= slices; i++) { + final float angle = fromAngle + i * increment; + + final float dX = MathHelper.sin(angle); + final float dY = MathHelper.cos(angle); + + GL11.glVertex2d(x + dX * radius, y + dY * radius); + } + GL11.glEnd(); + } + + public static int getOppositeColor(int color) { + int R = color & 255; + int G = (color >> 8) & 255; + int B = (color >> 16) & 255; + int A = (color >> 24) & 255; + R = 255 - R; + G = 255 - G; + B = 255 - B; + return R + (G << 8) + (B << 16) + (A << 24); + } + + public static void drawBorderedRect(float x, float y, float x2, float y2, float l1, int col1, int col2) { + drawRect(x, y, x2, y2, col2); + + final float f = (col1 >> 24 & 0xFF) / 255.0F, // @off + f1 = (col1 >> 16 & 0xFF) / 255.0F, + f2 = (col1 >> 8 & 0xFF) / 255.0F, + f3 = (col1 & 0xFF) / 255.0F; // @on + + glEnable(3042); + glDisable(3553); + GL11.glBlendFunc(770, 771); + glEnable(2848); + + GL11.glPushMatrix(); + GL11.glColor4f(f1, f2, f3, f); + GL11.glLineWidth(l1); + GL11.glBegin(1); + GL11.glVertex2d(x, y); + GL11.glVertex2d(x, y2); + GL11.glVertex2d(x2, y2); + GL11.glVertex2d(x2, y); + GL11.glVertex2d(x, y); + GL11.glVertex2d(x2, y); + GL11.glVertex2d(x, y2); + GL11.glVertex2d(x2, y2); + GL11.glEnd(); + GL11.glColor4f(1, 1, 1, 1); + GL11.glPopMatrix(); + enableTexture2D(); + disableBlend(); + GL11.glColor4f(1, 1, 1, 255); + glEnable(3553); + glDisable(3042); + glDisable(2848); + } + + public static void quickRenderCircle(double x, double y, double start, double end, double w, double h) { + if (start > end) { + double temp = end; + end = start; + start = temp; + } + + GL11.glBegin(GL11.GL_TRIANGLE_FAN); + GL11.glVertex2d(x, y); + for(double i = end; i >= start; i-=4) { + double ldx = Math.cos(i * Math.PI / 180.0) * w; + double ldy = Math.sin(i * Math.PI / 180.0) * h; + GL11.glVertex2d(x + ldx, y + ldy); + } + GL11.glVertex2d(x, y); + GL11.glEnd(); + } + + public static void quickDrawRect(final float x, final float y, final float x2, final float y2, final int color) { + glColor(color); + glVertex2d(x2, y); + glVertex2d(x, y); + glVertex2d(x, y2); + glVertex2d(x2, y2); + + } + + public static void quickDrawRect(final float x, final float y, final float x2, final float y2) { + + glVertex2d(x2, y); + glVertex2d(x, y); + glVertex2d(x, y2); + glVertex2d(x2, y2); + + } + + public static void drawFilledCircle(double x, double y, double r, int c, int id) { + float f = (float) (c >> 24 & 0xff) / 255F; + float f1 = (float) (c >> 16 & 0xff) / 255F; + float f2 = (float) (c >> 8 & 0xff) / 255F; + float f3 = (float) (c & 0xff) / 255F; + glEnable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glColor4f(f1, f2, f3, f); + if (id == 1) { + glVertex2d(x, y); + for (int i = 0; i <= 90; i++) { + double x2 = Math.sin((i * 3.141526D / 180)) * r; + double y2 = Math.cos((i * 3.141526D / 180)) * r; + glVertex2d(x - x2, y - y2); + } + } else if (id == 2) { + glVertex2d(x, y); + for (int i = 90; i <= 180; i++) { + double x2 = Math.sin((i * 3.141526D / 180)) * r; + double y2 = Math.cos((i * 3.141526D / 180)) * r; + glVertex2d(x - x2, y - y2); + } + } else if (id == 3) { + glVertex2d(x, y); + for (int i = 270; i <= 360; i++) { + double x2 = Math.sin((i * 3.141526D / 180)) * r; + double y2 = Math.cos((i * 3.141526D / 180)) * r; + glVertex2d(x - x2, y - y2); + } + } else if (id == 4) { + glVertex2d(x, y); + for (int i = 180; i <= 270; i++) { + double x2 = Math.sin((i * 3.141526D / 180)) * r; + double y2 = Math.cos((i * 3.141526D / 180)) * r; + glVertex2d(x - x2, y - y2); + } + } else { + for (int i = 0; i <= 360; i++) { + double x2 = Math.sin((i * 3.141526D / 180)) * r; + double y2 = Math.cos((i * 3.141526D / 180)) * r; + glVertex2f((float) (x - x2), (float) (y - y2)); + } + } + glEnable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + } + + public static Color rainbow(long time, float count, float fade) { + float hue = ((float)time + (1.0f + count) * 2.0E8f) / 1.0E10f % 1.0f; + long color = Long.parseLong(Integer.toHexString(Color.HSBtoRGB(hue, 1.0f, 1.0f)), 16); + Color c = new Color((int)color); + return new Color((float)c.getRed() / 255.0f * fade, (float)c.getGreen() / 255.0f * fade, (float)c.getBlue() / 255.0f * fade, (float)c.getAlpha() / 255.0f); + } + + public static void rectangle(double left, double top, double right, double bottom, int color) { + double var5; + if (left < right) { + var5 = left; + left = right; + right = var5; + } + if (top < bottom) { + var5 = top; + top = bottom; + bottom = var5; + } + float var11 = (float) (color >> 24 & 255) / 255.0f; + float var6 = (float) (color >> 16 & 255) / 255.0f; + float var7 = (float) (color >> 8 & 255) / 255.0f; + float var8 = (float) (color & 255) / 255.0f; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldRenderer = tessellator.getWorldRenderer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate((int) 770, (int) 771, (int) 1, (int) 0); + GlStateManager.color((float) var6, (float) var7, (float) var8, (float) var11); + worldRenderer.begin(7, DefaultVertexFormats.POSITION); + worldRenderer.pos(left, bottom, 0.0).endVertex(); + worldRenderer.pos(right, bottom, 0.0).endVertex(); + worldRenderer.pos(right, top, 0.0).endVertex(); + worldRenderer.pos(left, top, 0.0).endVertex(); + tessellator.draw(); + enableTexture2D(); + disableBlend(); + GlStateManager.color((float) 1.0f, (float) 1.0f, (float) 1.0f, (float) 1.0f); + } + + public static void drawFancy(double d, double e, double f2, double f3, int paramColor) { + float alpha = (float)(paramColor >> 24 & 255) / 255.0F; + float red = (float)(paramColor >> 16 & 255) / 255.0F; + float green = (float)(paramColor >> 8 & 255) / 255.0F; + float blue = (float)(paramColor & 255) / 255.0F; + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GL11.glPushMatrix(); + GL11.glEnable(2848); + GL11.glEnable(2881); + GL11.glEnable(2832); + GL11.glEnable(3042); + GL11.glColor4f(red, green, blue, alpha); + GL11.glBegin(7); + GL11.glVertex2d(f2 + 1.300000011920929D, e); + GL11.glVertex2d(d + 1.0D, e); + GL11.glVertex2d(d - 1.300000011920929D, f3); + GL11.glVertex2d(f2 - 1.0D, f3); + GL11.glEnd(); + GL11.glDisable(2848); + GL11.glDisable(2881); + GL11.glDisable(2832); + GL11.glDisable(3042); + enableTexture2D(); + disableBlend(); + GL11.glPopMatrix(); + } + + public static void Gamesense(double x, double y, double x1, double y1, double size , float color1, float color2 , float color3) { + rectangleBordered(x, y, x1 + size, y1 + size, 0.5d, Colors.getColor(90), Colors.getColor(0)); + rectangleBordered(x + 1.0f, y + 1.0f, (x1 + size - 1.0f), y1 + size - 1.0f, 1.0, Colors.getColor(90),Colors.getColor(61)); + rectangleBordered(x + 2.5, y + 2.5, (x1 + size) - 2.5, (y1 + size) - 2.5, 0.5, Colors.getColor(61),Colors.getColor(0)); + drawGradientSideways(x + size * 3, (y + 3.0f), x1 - size * 2, y + 4, (int) color2, (int) color3); + } + + public static int reAlpha(final int n, final float n2) { + final Color color = new Color(n); + return new Color(0.003921569f * color.getRed(), 0.003921569f * color.getGreen(), 0.003921569f * color.getBlue(), n2).getRGB(); + } + + public static Color rainbow(int delay) { + double rainbowState = Math.ceil((System.currentTimeMillis() + delay) / 20.0); + rainbowState %= 360; + return Color.getHSBColor((float) (rainbowState / 360.0f), 0.8f, 0.7f); + } + + public static void drawScaledCustomSizeModalRect(double x, double y, float u, float v, double uWidth, double vHeight, double width, double height, float tileWidth, float tileHeight) { + float f2 = 1.0f / tileWidth; + float f1 = 1.0f / tileHeight; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); + worldrenderer.pos(x, y + height, 0.0).tex(u * f2, (v + (float)vHeight) * f1).endVertex(); + worldrenderer.pos(x + width, y + height, 0.0).tex((u + (float)uWidth) * f2, (v + (float)vHeight) * f1).endVertex(); + worldrenderer.pos(x + width, y, 0.0).tex((u + (float)uWidth) * f2, v * f1).endVertex(); + worldrenderer.pos(x, y, 0.0).tex(u * f2, v * f1).endVertex(); + tessellator.draw(); + } + + public static void drawScaledCustomSizeModalRect(int x, int y, float u, float v, int uWidth, int vHeight, int width, int height, float tileWidth, float tileHeight) { + float f = 1.0F / tileWidth; + float f1 = 1.0F / tileHeight; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); + worldrenderer.pos(x, y + height, 0.0D).tex(u * f, (v + (float) vHeight) * f1).endVertex(); + worldrenderer.pos(x + width, y + height, 0.0D).tex((u + (float) uWidth) * f, (v + (float) vHeight) * f1).endVertex(); + worldrenderer.pos(x + width, y, 0.0D).tex((u + (float) uWidth) * f, v * f1).endVertex(); + worldrenderer.pos(x, y, 0.0D).tex(u * f, v * f1).endVertex(); + tessellator.draw(); + } + + public static void quickDrawGradientSideways(double left, double top, double right, double bottom, int col1, int col2) { + float f = (col1 >> 24 & 0xFF) / 255.0F; + float f1 = (col1 >> 16 & 0xFF) / 255.0F; + float f2 = (col1 >> 8 & 0xFF) / 255.0F; + float f3 = (col1 & 0xFF) / 255.0F; + + float f4 = (col2 >> 24 & 0xFF) / 255.0F; + float f5 = (col2 >> 16 & 0xFF) / 255.0F; + float f6 = (col2 >> 8 & 0xFF) / 255.0F; + float f7 = (col2 & 0xFF) / 255.0F; + + glPushMatrix(); + glColor4f(f1, f2, f3, f); + glVertex2d(left, top); + glVertex2d(left, bottom); + + glColor4f(f5, f6, f7, f4); + glVertex2d(right, bottom); + glVertex2d(right, top); + glPopMatrix(); + } + + public static void drawMatrixRound(Entity entity, float partialTicks, double rad) { + float points = 90F; + GlStateManager.enableDepth(); + Entity livingPlayer = null; + double viewerPosX = livingPlayer.lastTickPosX + (livingPlayer.posX - livingPlayer.lastTickPosX) * (double)partialTicks; + double viewerPosY = livingPlayer.lastTickPosY + (livingPlayer.posY - livingPlayer.lastTickPosY) * (double)partialTicks; + double viewerPosZ = livingPlayer.lastTickPosZ + (livingPlayer.posZ - livingPlayer.lastTickPosZ) * (double)partialTicks; + + for (double il = 0; il < 4.9E-324; il += 4.9E-324) { + GL11.glPushMatrix(); + GL11.glDisable(3553); + GL11.glEnable(2848); + GL11.glEnable(2881); + GL11.glEnable(2832); + GL11.glEnable(3042); + GL11.glBlendFunc(770, 771); + GL11.glHint(3154, 4354); + GL11.glHint(3155, 4354); + GL11.glHint(3153, 4354); + GL11.glDisable(2929); + GL11.glLineWidth(3.5f); + GL11.glBegin(3); + final double x = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks - viewerPosX; + final double y = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks - viewerPosY; + final double z = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks - viewerPosZ; + float speed = 5000f; + float baseHue = System.currentTimeMillis() % (int) speed; + while (baseHue > speed) { + baseHue -= speed; + } + baseHue /= speed; + for (int i = 0; i <= 90; ++i) { + float max = ((float) i + (float) (il * 8)) / points; + float hue = max + baseHue; + while (hue > 1) { + hue -= 1; + } + final float r = 0.003921569f * new Color(Color.HSBtoRGB(hue, 0.75F, 1F)).getRed(); + final float g = 0.003921569f * new Color(Color.HSBtoRGB(hue, 0.75F, 1F)).getGreen(); + final float b = 0.003921569f * new Color(Color.HSBtoRGB(hue, 0.75F, 1F)).getBlue(); + final double pix2 = Math.PI * 2.0D; + for (int i2 = 0; i2 <= 6; ++i2) { + GlStateManager.color(rainbow(i2 * 100).getRed(), rainbow(i2 * 100).getGreen(), rainbow(i2 * 100).getRed(), 255); + GL11.glVertex3d(x + rad * Math.cos(i2 * pix2 / 6.0), y, z + rad * Math.sin(i2 * pix2 / 6.0)); + } + } + GL11.glEnd(); + GL11.glDepthMask(true); + GL11.glEnable(2929); + GL11.glDisable(2848); + GL11.glDisable(2881); + GL11.glEnable(2832); + GL11.glEnable(3553); + GL11.glPopMatrix(); + GlStateManager.color(255, 255, 255); + } + + + } + + public static void drawRect(double x, double y, double x2, double y2, int color) { + Gui.drawRect((int) x, (int) y, (int) x2, (int) y2, color); + } + + public static void drawVLine(float x, float y, float x1, int y1) { + if (x1 < y) { + float var5 = y; + y = x1; + x1 = var5; + } + drawRect(x, y + 1.0f, x + 1.0f, x1, y1); + } + + public static void drawHLine(float x, float y, float x1, int y1) { + if (y < x) { + float var5 = x; + x = y; + y = var5; + } + drawRect(x, x1, y + 1.0f, x1 + 1.0f, y1); + } + + public static void drawRoundedRect(float n, float n2, float n3, float n4, final int n5, final int n6) { + GL11.glDisable(2929); + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glBlendFunc(770, 771); + GL11.glDepthMask(true); + GL11.glEnable(2848); + GL11.glHint(3154, 4354); + GL11.glHint(3155, 4354); + GL11.glScalef(0.5f, 0.5f, 0.5f); + drawVLine(n *= 2.0f, (n2 *= 2.0f) + 1.0f, (n4 *= 2.0f) - 2.0f, n5); + drawVLine((n3 *= 2.0f) - 1.0f, n2 + 1.0f, n4 - 2.0f, n5); + drawHLine(n + 2.0f, n3 - 3.0f, n2, n5); + drawHLine(n + 2.0f, n3 - 3.0f, n4 - 1.0f, n5); + drawHLine(n + 1.0f, n + 1.0f, n2 + 1.0f, n5); + drawHLine(n3 - 2.0f, n3 - 2.0f, n2 + 1.0f, n5); + drawHLine(n3 - 2.0f, n3 - 2.0f, n4 - 2.0f, n5); + drawHLine(n + 1.0f, n + 1.0f, n4 - 2.0f, n5); + drawRect(n + 1.0f, n2 + 1.0f, n3 - 1.0f, n4 - 1.0f, n6); + GL11.glScalef(2.0f, 2.0f, 2.0f); + GL11.glEnable(3553); + GL11.glDisable(3042); + GL11.glEnable(2929); + GL11.glDisable(2848); + GL11.glHint(3154, 4352); + GL11.glHint(3155, 4352); + } + public static void drawRoundedRect2(float x, float y, float x2, float y2, final float round, final int color) { + x += (float) (round / 2.0f + 0.5); + y += (float) (round / 2.0f + 0.5); + x2 -= (float) (round / 2.0f + 0.5); + y2 -= (float) (round / 2.0f + 0.5); + drawRect((int) x, (int) y, (int) x2, (int) y2, color); + circle(x2 - round / 2.0f, y + round / 2.0f, round, color); + circle(x + round / 2.0f, y2 - round / 2.0f, round, color); + circle(x + round / 2.0f, y + round / 2.0f, round, color); + circle(x2 - round / 2.0f, y2 - round / 2.0f, round, color); + drawRect((int) (x - round / 2.0f - 0.5f), (int) (y + round / 2.0f), (int) x2, (int) (y2 - round / 2.0f), + color); + drawRect((int) x, (int) (y + round / 2.0f), (int) (x2 + round / 2.0f + 0.5f), (int) (y2 - round / 2.0f), + color); + drawRect((int) (x + round / 2.0f), (int) (y - round / 2.0f - 0.5f), (int) (x2 - round / 2.0f), + (int) (y2 - round / 2.0f), color); + drawRect((int) (x + round / 2.0f), (int) y, (int) (x2 - round / 2.0f), (int) (y2 + round / 2.0f + 0.5f), + color); + } + + public static void ACircle(final float x, final float y, float start, float end, final float w, final float h, final int color, final float lineWidth) { + float temp; + if (start > end) { + temp = end; + end = start; + start = temp; + } + final float alpha = (color >> 24 & 0xFF) / 255.0f; + final float red = (color >> 16 & 0xFF) / 255.0f; + final float green = (color >> 8 & 0xFF) / 255.0f; + final float blue = (color & 0xFF) / 255.0f; + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE); + GlStateManager.color(red, green, blue, alpha); + GL11.glEnable(GL_POLYGON_SMOOTH); + GL11.glEnable(2848); + GL11.glLineWidth(lineWidth); + GL11.glBegin(3); + for (float i = end; i >= start; i -= 4.0f) { + GL11.glVertex2d(x + Math.cos(i * Math.PI / 180.0) * w * 1.001, y + Math.sin(i * Math.PI / 180.0) * h * 1.001); + } + GL11.glEnd(); + GL11.glDisable(2848); + GL11.glDisable(GL_POLYGON_SMOOTH); + enableTexture2D(); + disableBlend(); + } + + public static void BCricle(final float x, final float y, final float start, final float end, final float radius,final int color, final float lineWidth) { + ACircle(x, y, start, end, radius, radius, color, lineWidth); + } + + public static void glColor(final int cl) { + final float alpha = (cl >> 24 & 0xFF) / 255F; + final float red = (cl >> 16 & 0xFF) / 255F; + final float green = (cl >> 8 & 0xFF) / 255F; + final float blue = (cl & 0xFF) / 255F; + + GlStateManager.color(red, green, blue, alpha); + } + + public static void drawGradientSideways(double left, double top, double right, double bottom, int col1, int col2) { + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glBlendFunc(770, 771); + GL11.glEnable(2848); + GL11.glShadeModel(7425); + + GL11.glPushMatrix(); + GL11.glBegin(7); + glColor(col1); + GL11.glVertex2d(left, top); + GL11.glVertex2d(left, bottom); + glColor(col2); + GL11.glVertex2d(right, bottom); + GL11.glVertex2d(right, top); + GL11.glEnd(); + GL11.glPopMatrix(); + + GL11.glEnable(3553); + GL11.glDisable(3042); + GL11.glDisable(2848); + GL11.glShadeModel(7424); + } + + public static void drawOutFullCircle(final float x, final float y, final float radius, final int fill, final float lineWidth) { + BCricle(x, y, 0.0F, 360.0F, radius, fill, lineWidth); + } + + public static void drawOutFullCircle(final float x, final float y, final float radius, final int fill, final float lineWidth, final float start, final float end) { + BCricle(x, y, start, end, radius, fill, lineWidth); + } + + public static void drawRoundRect(double xPosition, double yPosition, double endX, double endY, int radius, int color) { + double width = endX - xPosition; + double height = endY - yPosition; + + drawRect(xPosition + radius, yPosition + radius, (xPosition + width - radius), (yPosition + height - radius), color); + drawRect(xPosition, yPosition + radius, xPosition + radius, (yPosition + height - radius), color); + drawRect((xPosition + width - radius), yPosition + radius, (xPosition + width), (yPosition + height - radius), color); + drawRect(xPosition + radius, yPosition, (xPosition + width - radius), yPosition + radius, color); + drawRect(xPosition + radius, (yPosition + height - radius), (xPosition + width - radius), (yPosition + height), color); + + drawFilledCircle(xPosition + radius, yPosition + radius, radius, color, 1); + drawFilledCircle(xPosition + radius, (yPosition + height - radius), radius, color, 2); + drawFilledCircle((xPosition + width - radius), yPosition + radius, radius, color, 3); + drawFilledCircle((xPosition + width - radius), (yPosition + height - radius), radius, color, 4); + drawFilledCircle(xPosition + radius, yPosition + radius, radius, color, 1); + drawFilledCircle(xPosition + radius, (yPosition + height - radius), radius, color, 2); + drawFilledCircle((xPosition + width - radius), yPosition + radius, radius, color, 3); + drawFilledCircle((xPosition + width - radius), (yPosition + height - radius), radius, color, 4); + + drawRect(0, 0, 0, 0, 0); + } + + public static void drawImage(final ResourceLocation image, double x, double y, double width, double height) { + GL11.glDisable(2929); + GL11.glEnable(3042); + GL11.glDepthMask(false); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + mc.getTextureManager().bindTexture(image); + drawModalRectWithCustomSizedTexture(x, y, 0.0f, 0.0f, width, height, width, height); + GL11.glDepthMask(true); + GL11.glDisable(3042); + GL11.glEnable(2929); + } + + public static void drawImage(final ResourceLocation image, double x, double y, double width, double height, Color color) { + GL11.glDisable(2929); + GL11.glEnable(3042); + GL11.glDepthMask(false); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glColor4f(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, color.getAlpha() / 255f); + mc.getTextureManager().bindTexture(image); + drawModalRectWithCustomSizedTexture(x, y, 0.0f, 0.0f, width, height, width, height); + GL11.glDepthMask(true); + GL11.glDisable(3042); + GL11.glEnable(2929); + } + + public static void drawModalRectWithCustomSizedTexture(double x, double y, double u, double v, double width, double height, double textureWidth, double textureHeight) { + double f = 1.0F / textureWidth; + double f1 = 1.0F / textureHeight; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); + worldrenderer.pos(x, y + height, 0.0D).tex(u * f, (v + (float) height) * f1).endVertex(); + worldrenderer.pos(x + width, y + height, 0.0D).tex((u + (float) width) * f, (v + (float) height) * f1).endVertex(); + worldrenderer.pos(x + width, y, 0.0D).tex((u + (float) width) * f, v * f1).endVertex(); + worldrenderer.pos(x, y, 0.0D).tex(u * f, v * f1).endVertex(); + tessellator.draw(); + } + + public static void drawFilledCircle(int xx, int yy, float radius, Color col) { + int sections = 100; + double dAngle = 6.283185307179586 / (double) sections; + GL11.glPushMatrix(); + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glBlendFunc(770, 771); + GL11.glEnable(2848); + GL11.glBegin(6); + int i = 0; + while (i < sections) { + float x = (float) ((double) radius * Math.sin((double) i * dAngle)); + float y = (float) ((double) radius * Math.cos((double) i * dAngle)); + GL11.glColor4f((float) col.getRed() / 255.0f, (float) col.getGreen() / 255.0f, (float) col.getBlue() / 255.0f, (float) col.getAlpha() / 255.0f); + GL11.glVertex2f((float) xx + x, (float) yy + y); + ++i; + } + GlStateManager.color(0.0f, 0.0f, 0.0f); + GL11.glEnd(); + GL11.glEnable(3553); + GL11.glDisable(3042); + GL11.glDisable(2848); + GL11.glPopMatrix(); + } + + public static void drawFilledCircle(float xx, float yy, float radius, Color col) { + int sections = 50; + double dAngle = 6.283185307179586 / (double) sections; + GL11.glPushMatrix(); + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glBlendFunc(770, 771); + GL11.glEnable(2848); + GL11.glBegin(6); + int i = 0; + while (i < sections) { + float x = (float) ((double) radius * Math.sin((double) i * dAngle)); + float y = (float) ((double) radius * Math.cos((double) i * dAngle)); + GL11.glColor4f((float) col.getRed() / 255.0f, (float) col.getGreen() / 255.0f, (float) col.getBlue() / 255.0f, (float) col.getAlpha() / 255.0f); + GL11.glVertex2f(xx + x, yy + y); + ++i; + } + GlStateManager.color(0.0f, 0.0f, 0.0f); + GL11.glEnd(); + GL11.glEnable(3553); + GL11.glDisable(3042); + GL11.glDisable(2848); + GL11.glPopMatrix(); + } + + public static void startScale(float x, float y, float scale) { + GlStateManager.pushMatrix(); + GlStateManager.translate(x, y, 0); + GlStateManager.scale(scale, scale, 1); + GlStateManager.translate(-x, -y, 0); + } + + public static void startScale(float x, float y, float width, float height, float scale) { + GlStateManager.pushMatrix(); + GlStateManager.translate((x + (x + width)) / 2, (y + (y + height)) / 2, 0); + GlStateManager.scale(scale, scale, 1); + GlStateManager.translate(-(x + (x + width)) / 2, -(y + (y + height)) / 2, 0); + } + + public static void stopScale() { + GlStateManager.popMatrix(); + } + + + + public static void startTranslate(float x, float y) { + GlStateManager.pushMatrix(); + GlStateManager.translate(x, y, 0); + } + + public static void stopTranslate() { + GlStateManager.popMatrix(); + } + + public static void drawFilledCircle(int xx, int yy, float radius, int col) { + float f = (float) (col >> 24 & 255) / 255.0f; + float f1 = (float) (col >> 16 & 255) / 255.0f; + float f2 = (float) (col >> 8 & 255) / 255.0f; + float f3 = (float) (col & 255) / 255.0f; + int sections = 50; + double dAngle = 6.283185307179586 / (double) sections; + GL11.glPushMatrix(); + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glEnable(2848); + GL11.glBlendFunc(770, 771); + GL11.glBegin(6); + int i = 0; + while (i < sections) { + float x = (float) ((double) radius * Math.sin((double) i * dAngle)); + float y = (float) ((double) radius * Math.cos((double) i * dAngle)); + GL11.glColor4f(f1, f2, f3, f); + GL11.glVertex2f((float) xx + x, (float) yy + y); + ++i; + } + GlStateManager.color(0.0f, 0.0f, 0.0f); + GL11.glEnd(); + GL11.glEnable(3553); + GL11.glDisable(3042); + GL11.glDisable(2848); + GL11.glPopMatrix(); + } + + public static void drawFilledCircle(float xx, float yy, float radius, int col) { + float f = (float) (col >> 24 & 255) / 255.0f; + float f1 = (float) (col >> 16 & 255) / 255.0f; + float f2 = (float) (col >> 8 & 255) / 255.0f; + float f3 = (float) (col & 255) / 255.0f; + int sections = 50; + double dAngle = 6.283185307179586 / (double) sections; + GL11.glPushMatrix(); + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glBlendFunc(770, 771); + GL11.glEnable(2848); + GL11.glBegin(6); + int i = 0; + while (i < sections) { + float x = (float) ((double) radius * Math.sin((double) i * dAngle)); + float y = (float) ((double) radius * Math.cos((double) i * dAngle)); + GL11.glColor4f(f1, f2, f3, f); + GL11.glVertex2f(xx + x, yy + y); + ++i; + } + GlStateManager.color(0.0f, 0.0f, 0.0f); + GL11.glEnd(); + GL11.glEnable(3553); + GL11.glDisable(3042); + GL11.glDisable(2848); + GL11.glPopMatrix(); + } + + public static void drawFilledCircle(int xx, int yy, float radius, int col, int xLeft, int yAbove, int xRight, int yUnder) { + float f = (float) (col >> 24 & 255) / 255.0f; + float f1 = (float) (col >> 16 & 255) / 255.0f; + float f2 = (float) (col >> 8 & 255) / 255.0f; + float f3 = (float) (col & 255) / 255.0f; + int sections = 50; + double dAngle = 6.283185307179586 / (double) sections; + GL11.glPushMatrix(); + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glBlendFunc(770, 771); + GL11.glEnable(2848); + GL11.glBegin(6); + int i = 0; + while (i < sections) { + float x = (float) ((double) radius * Math.sin((double) i * dAngle)); + float y = (float) ((double) radius * Math.cos((double) i * dAngle)); + float xEnd = (float) xx + x; + float yEnd = (float) yy + y; + if (xEnd < (float) xLeft) { + xEnd = xLeft; + } + if (xEnd > (float) xRight) { + xEnd = xRight; + } + if (yEnd < (float) yAbove) { + yEnd = yAbove; + } + if (yEnd > (float) yUnder) { + yEnd = yUnder; + } + GL11.glColor4f(f1, f2, f3, f); + GL11.glVertex2f(xEnd, yEnd); + ++i; + } + GlStateManager.color(0.0f, 0.0f, 0.0f); + GL11.glEnd(); + GL11.glEnable(3553); + GL11.glDisable(3042); + GL11.glDisable(2848); + GL11.glPopMatrix(); + } + + public static double getAnimationState(double n, final double n2, final double n3) { + final float n4 = (float)(delta * n3); + if (n < n2) { + if (n + n4 < n2) { + n += n4; + }else { + n = n2; + } + }else if (n - n4 > n2) { + n -= n4; + }else { + n = n2; + } + return n; + } + + public static void drawImage(ResourceLocation image, int x, int y, int width, int height, float alpha) { + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + GL11.glDisable(2929); + GL11.glEnable(3042); + GL11.glDepthMask(false); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glColor4f(1.0f, 1.0f, 1.0f, alpha); + Minecraft.getMinecraft().getTextureManager().bindTexture(image); + Gui.drawModalRectWithCustomSizedTexture(x, y, 0.0f, 0.0f, width, height, (float) width, (float) height); + GL11.glDepthMask(true); + GL11.glDisable(3042); + GL11.glEnable(2929); + } + + public static void drawImage(ResourceLocation image, int x, int y, int width, int height) { + drawImage(image, x, y, width, height, 1.0f); + } + + public static void drawImage(ResourceLocation image, float x, float y, float width, float height) { + drawImage(image, (int)x, (int)y, (int)width, (int)height, 1.0f); + } + + public static void drawCustomImage(final int x, final int y, final int width, final int height,final ResourceLocation image) { + final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + GL11.glDisable(2929); + GL11.glEnable(3042); + GL11.glDepthMask(false); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + Minecraft.getMinecraft().getTextureManager().bindTexture(image); + Gui.drawModalRectWithCustomSizedTexture(x, y, 0.0f, 0.0f, width, height, (float) width, (float) height); + GL11.glDepthMask(true); + GL11.glDisable(3042); + GL11.glEnable(2929); + } + + public static void arcEllipse(float x, float y, float start, float end, float w, float h, int color) { + float ldy; + float ldx; + float i; + GlStateManager.color(0.0f, 0.0f, 0.0f); + GL11.glColor4f(0.0f, 0.0f, 0.0f, 0.0f); + float temp = 0.0f; + if (start > end) { + temp = end; + end = start; + start = temp; + } + float var11 = (float) (color >> 24 & 255) / 255.0f; + float var6 = (float) (color >> 16 & 255) / 255.0f; + float var7 = (float) (color >> 8 & 255) / 255.0f; + float var8 = (float) (color & 255) / 255.0f; + Tessellator var9 = Tessellator.getInstance(); + WorldRenderer var10 = var9.getWorldRenderer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.color(var6, var7, var8, var11); + if (var11 > 0.5f) { + GL11.glEnable(2848); + GL11.glLineWidth(2.0f); + GL11.glBegin(3); + i = end; + while (i >= start) { + ldx = (float) Math.cos((double) i * 3.141592653589793 / 180.0) * (w * 1.001f); + ldy = (float) Math.sin((double) i * 3.141592653589793 / 180.0) * (h * 1.001f); + GL11.glVertex2f(x + ldx, y + ldy); + i -= 4.0f; + } + GL11.glEnd(); + GL11.glDisable(2848); + } + GL11.glBegin(6); + i = end; + while (i >= start) { + ldx = (float) Math.cos((double) i * 3.141592653589793 / 180.0) * w; + ldy = (float) Math.sin((double) i * 3.141592653589793 / 180.0) * h; + GL11.glVertex2f(x + ldx, y + ldy); + i -= 4.0f; + } + GL11.glEnd(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static void arcEllipse(float x, float y, float start, float end, float w, float h, Color color) { + float ldy; + float ldx; + float i; + GlStateManager.color(0.0f, 0.0f, 0.0f); + GL11.glColor4f(0.0f, 0.0f, 0.0f, 0.0f); + float temp = 0.0f; + if (start > end) { + temp = end; + end = start; + start = temp; + } + Tessellator var9 = Tessellator.getInstance(); + WorldRenderer var10 = var9.getWorldRenderer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.color((float) color.getRed() / 255.0f, (float) color.getGreen() / 255.0f, (float) color.getBlue() / 255.0f, (float) color.getAlpha() / 255.0f); + if ((float) color.getAlpha() > 0.5f) { + GL11.glEnable(2848); + GL11.glLineWidth(2.0f); + GL11.glBegin(3); + i = end; + while (i >= start) { + ldx = (float) Math.cos((double) i * 3.141592653589793 / 180.0) * (w * 1.001f); + ldy = (float) Math.sin((double) i * 3.141592653589793 / 180.0) * (h * 1.001f); + GL11.glVertex2f(x + ldx, y + ldy); + i -= 4.0f; + } + GL11.glEnd(); + GL11.glDisable(2848); + } + GL11.glBegin(6); + i = end; + while (i >= start) { + ldx = (float) Math.cos((double) i * 3.141592653589793 / 180.0) * w; + ldy = (float) Math.sin((double) i * 3.141592653589793 / 180.0) * h; + GL11.glVertex2f(x + ldx, y + ldy); + i -= 4.0f; + } + GL11.glEnd(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static void arc(float x, float y, float start, float end, float radius, int color) { + arcEllipse(x, y, start, end, radius, radius, color); + } + + public static void arc(float x, float y, float start, float end, float radius, Color color) { + arcEllipse(x, y, start, end, radius, radius, color); + } + + public static void circle(float x, float y, float radius, int fill) { + GL11.glEnable(3042); + arc(x, y, 0.0f, 360.0f, radius, fill); + GL11.glDisable(3042); + } + + public static void drawArc(float x1, float y1, double r, int color, int startPoint, double arc, int linewidth) { + r *= 2.0D; + x1 *= 2; + y1 *= 2; + float f = (color >> 24 & 0xFF) / 255.0F; + float f1 = (color >> 16 & 0xFF) / 255.0F; + float f2 = (color >> 8 & 0xFF) / 255.0F; + float f3 = (color & 0xFF) / 255.0F; + GL11.glDisable(2929); + GL11.glEnable(3042); + GL11.glDisable(3553); + GL11.glBlendFunc(770, 771); + GL11.glDepthMask(true); + GL11.glEnable(2848); + GL11.glHint(3154, 4354); + GL11.glHint(3155, 4354); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glLineWidth(linewidth); + GL11.glEnable(GL11.GL_LINE_SMOOTH); + GL11.glColor4f(f1, f2, f3, f); + GL11.glBegin(GL11.GL_LINE_STRIP); + for (int i = startPoint; i <= arc; i += 1) { + double x = Math.sin(i * 3.141592653589793D / 180.0D) * r; + double y = Math.cos(i * 3.141592653589793D / 180.0D) * r; + GL11.glVertex2d(x1 + x, y1 + y); + } + GL11.glEnd(); + GL11.glDisable(GL11.GL_LINE_SMOOTH); + GL11.glScalef(2.0F, 2.0F, 2.0F); + GL11.glEnable(3553); + GL11.glDisable(3042); + GL11.glEnable(2929); + GL11.glDisable(2848); + GL11.glHint(3154, 4352); + GL11.glHint(3155, 4352); + } + + public static void color(int color, float alpha) { + float r = (float) (color >> 16 & 255) / 255.0F; + float g = (float) (color >> 8 & 255) / 255.0F; + float b = (float) (color & 255) / 255.0F; + GlStateManager.color(r, g, b, alpha); + } + + public static void circle(float x, float y, float radius, Color fill) { + arc(x, y, 0.0f, 360.0f, radius, fill); + } + + public static void drawRoundedRect(float paramXStart, float paramYStart, float paramXEnd, float paramYEnd, float radius, int color, boolean popPush) { + float alpha = (color >> 24 & 0xFF) / 255.0F; + float red = (color >> 16 & 0xFF) / 255.0F; + float green = (color >> 8 & 0xFF) / 255.0F; + float blue = (color & 0xFF) / 255.0F; + + float z = 0; + if (paramXStart > paramXEnd) { + z = paramXStart; + paramXStart = paramXEnd; + paramXEnd = z; + } + + if (paramYStart > paramYEnd) { + z = paramYStart; + paramYStart = paramYEnd; + paramYEnd = z; + } + + double x1 = (double)(paramXStart + radius); + double y1 = (double)(paramYStart + radius); + double x2 = (double)(paramXEnd - radius); + double y2 = (double)(paramYEnd - radius); + + if (popPush) glPushMatrix(); + glEnable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_LINE_SMOOTH); + glLineWidth(1); + + glColor4f(red, green, blue, alpha); + + double degree = Math.PI / 180; + for (double i = 0; i <= 90; i += 1) + glVertex2d(x2 + Math.sin(i * degree) * radius, y2 + Math.cos(i * degree) * radius); + for (double i = 90; i <= 180; i += 1) + glVertex2d(x2 + Math.sin(i * degree) * radius, y1 + Math.cos(i * degree) * radius); + for (double i = 180; i <= 270; i += 1) + glVertex2d(x1 + Math.sin(i * degree) * radius, y1 + Math.cos(i * degree) * radius); + for (double i = 270; i <= 360; i += 1) + glVertex2d(x1 + Math.sin(i * degree) * radius, y2 + Math.cos(i * degree) * radius); + + glEnable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + glDisable(GL_LINE_SMOOTH); + if (popPush) glPopMatrix(); + } + + public static void drawRoundedRect(float paramXStart, float paramYStart, float paramXEnd, float paramYEnd, float radius, int color) { + drawRoundedRect(paramXStart, paramYStart, paramXEnd, paramYEnd, radius, color, true); + } + + public static void drawExhiEnchants(ItemStack stack, float x, float y) { + RenderHelper.disableStandardItemLighting(); + GlStateManager.disableDepth(); + GlStateManager.disableBlend(); + GlStateManager.resetColor(); + final int darkBorder = 0xFF000000; + if (stack.getItem() instanceof ItemArmor) { + int prot = EnchantmentHelper.getEnchantmentLevel(Enchantment.protection.effectId, stack); + int unb = EnchantmentHelper.getEnchantmentLevel(Enchantment.unbreaking.effectId, stack); + int thorn = EnchantmentHelper.getEnchantmentLevel(Enchantment.thorns.effectId, stack); + if (prot > 0) { + drawExhiOutlined(prot + "", drawExhiOutlined("P", x, y, 0.35F, darkBorder, -1, true), y, 0.35F, getBorderColor(prot), getMainColor(prot), true); + y += 4; + } + if (unb > 0) { + drawExhiOutlined(unb + "", drawExhiOutlined("U", x, y, 0.35F, darkBorder, -1, true), y, 0.35F, getBorderColor(unb),getMainColor(unb), true); + y += 4; + } + if (thorn > 0) { + drawExhiOutlined(thorn + "", drawExhiOutlined("T", x, y, 0.35F, darkBorder, -1, true), y, 0.35F, getBorderColor(thorn), getMainColor(thorn), true); + y += 4; + } + } + if (stack.getItem() instanceof ItemBow) { + int power = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, stack); + int punch = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, stack); + int flame = EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, stack); + int unb = EnchantmentHelper.getEnchantmentLevel(Enchantment.unbreaking.effectId, stack); + if (power > 0) { + drawExhiOutlined(power + "", drawExhiOutlined("Pow", x, y, 0.35F, darkBorder, -1, true), y, 0.35F, getBorderColor(power), getMainColor(power), true); + y += 4; + } + if (punch > 0) { + drawExhiOutlined(punch + "", drawExhiOutlined("Pun", x, y, 0.35F, darkBorder, -1, true), y, 0.35F, getBorderColor(punch), getMainColor(punch), true); + y += 4; + } + if (flame > 0) { + drawExhiOutlined(flame + "", drawExhiOutlined("F", x, y, 0.35F, darkBorder, -1, true), y, 0.35F, getBorderColor(flame), getMainColor(flame), true); + y += 4; + } + if (unb > 0) { + drawExhiOutlined(unb + "", drawExhiOutlined("U", x, y, 0.35F, darkBorder, -1, true), y, 0.35F, getBorderColor(unb), getMainColor(unb), true); + y += 4; + } + } + if (stack.getItem() instanceof ItemSword) { + int sharp = EnchantmentHelper.getEnchantmentLevel(Enchantment.sharpness.effectId, stack); + int kb = EnchantmentHelper.getEnchantmentLevel(Enchantment.knockback.effectId, stack); + int fire = EnchantmentHelper.getEnchantmentLevel(Enchantment.fireAspect.effectId, stack); + int unb = EnchantmentHelper.getEnchantmentLevel(Enchantment.unbreaking.effectId, stack); + if (sharp > 0) { + drawExhiOutlined(sharp + "", drawExhiOutlined("S", x, y, 0.35F, darkBorder, -1, true), y, 0.35F, getBorderColor(sharp), getMainColor(sharp), true); + y += 4; + } + if (kb > 0) { + drawExhiOutlined(kb + "", drawExhiOutlined("K", x, y, 0.35F, darkBorder, -1, true), y, 0.35F, getBorderColor(kb), getMainColor(kb), true); + y += 4; + } + if (fire > 0) { + drawExhiOutlined(fire + "", drawExhiOutlined("F", x, y, 0.35F, darkBorder, -1, true), y, 0.35F, getBorderColor(fire), getMainColor(fire), true); + y += 4; + } + if (unb > 0) { + drawExhiOutlined(unb + "", drawExhiOutlined("U", x, y, 0.35F, darkBorder, -1, true), y, 0.35F, getBorderColor(unb), getMainColor(unb), true); + y += 4; + } + } + GlStateManager.enableDepth(); + RenderHelper.enableGUIStandardItemLighting(); + } + + private static float drawExhiOutlined(String text, float x, float y, float borderWidth, int borderColor, int mainColor, boolean drawText) { + Fonts.font40.drawString(text, x, y - borderWidth, borderColor); + Fonts.font40.drawString(text, x, y + borderWidth, borderColor); + Fonts.font40.drawString(text, x - borderWidth, y, borderColor); + Fonts.font40.drawString(text, x + borderWidth, y, borderColor); + if (drawText) + Fonts.font40.drawString(text, x, y, mainColor); + return x + Fonts.font40.getStringWidth(text) - 2F; + } + + private static int getMainColor(int level) { + if (level == 4) + return 0xFFAA0000; + return -1; + } + + private static int getBorderColor(int level) { + if (level == 2) + return 0x7055FF55; + if (level == 3) + return 0x7000AAAA; + if (level == 4) + return 0x70AA0000; + if (level >= 5) + return 0x70FFAA00; + return 0x70FFFFFF; + } + + public static void drawCircle(float x, float y, float radius, float lineWidth, int start, int end, Color color) { + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); + glColor(color); + + glEnable(GL_LINE_SMOOTH); + glLineWidth(lineWidth); + for (float i = end; i >= start; i -= (360 / 90.0f)) { + glVertex2f((float) (x + (cos(i * PI / 180) * (radius * 1.001F))), (float) (y + (sin(i * PI / 180) * (radius * 1.001F)))); + } + glDisable(GL_LINE_SMOOTH); + + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + + public static void drawTriAngle(float cx, float cy, float r, float n, Color color, boolean polygon) { + cx *= 2.0; + cy *= 2.0; + double b = 6.2831852 / n; + double p = Math.cos(b); + double s = Math.sin(b); + r *= 2.0; + double x = r; + double y = 0.0; + + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + glLineWidth(1F); + enableGlCap(GL_LINE_SMOOTH); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.resetColor(); + glColor(color); + GlStateManager.scale(0.5f, 0.5f, 0.5f); + worldrenderer.begin(polygon ? GL_POLYGON : 2, DefaultVertexFormats.POSITION); + int ii = 0; + while (ii < n) { + worldrenderer.pos((double)x + cx, (double)y + cy, 0.0D).endVertex(); + double t = x; + x = p * x - s * y; + y = s * t + p * y; + ii++; + } + tessellator.draw(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + GlStateManager.scale(2f, 2f, 2f); + GlStateManager.color(1, 1, 1, 1); + } + + public static void drawRectBasedBorder(float x, float y, float x2, float y2, float width, int color1) { + drawRect(x - width / 2F, y - width / 2F, x2 + width / 2F, y + width / 2F, color1); + drawRect(x - width / 2F, y + width / 2F, x + width / 2F, y2 + width / 2F, color1); + drawRect(x2 - width / 2F, y + width / 2F, x2 + width / 2F, y2 + width / 2F, color1); + drawRect(x + width / 2F, y2 - width / 2F, x2 - width / 2F, y2 + width / 2F, color1); + } + + public static void newDrawRect(float left, float top, float right, float bottom, int color) + { + if (left < right) + { + float i = left; + left = right; + right = i; + } + + if (top < bottom) + { + float j = top; + top = bottom; + bottom = j; + } + + float f3 = (float)(color >> 24 & 255) / 255.0F; + float f = (float)(color >> 16 & 255) / 255.0F; + float f1 = (float)(color >> 8 & 255) / 255.0F; + float f2 = (float)(color & 255) / 255.0F; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.color(f, f1, f2, f3); + worldrenderer.begin(7, DefaultVertexFormats.POSITION); + worldrenderer.pos((double)left, (double)bottom, 0.0D).endVertex(); + worldrenderer.pos((double)right, (double)bottom, 0.0D).endVertex(); + worldrenderer.pos((double)right, (double)top, 0.0D).endVertex(); + worldrenderer.pos((double)left, (double)top, 0.0D).endVertex(); + tessellator.draw(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static void newDrawRect(double left, double top, double right, double bottom, int color) + { + if (left < right) + { + double i = left; + left = right; + right = i; + } + + if (top < bottom) + { + double j = top; + top = bottom; + bottom = j; + } + + float f3 = (float)(color >> 24 & 255) / 255.0F; + float f = (float)(color >> 16 & 255) / 255.0F; + float f1 = (float)(color >> 8 & 255) / 255.0F; + float f2 = (float)(color & 255) / 255.0F; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.color(f, f1, f2, f3); + worldrenderer.begin(7, DefaultVertexFormats.POSITION); + worldrenderer.pos(left, bottom, 0.0D).endVertex(); + worldrenderer.pos(right, bottom, 0.0D).endVertex(); + worldrenderer.pos(right, top, 0.0D).endVertex(); + worldrenderer.pos(left, top, 0.0D).endVertex(); + tessellator.draw(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static void drawRectBasedBorder(double x, double y, double x2, double y2, double width, int color1) { + newDrawRect(x - width / 2F, y - width / 2F, x2 + width / 2F, y + width / 2F, color1); + newDrawRect(x - width / 2F, y + width / 2F, x + width / 2F, y2 + width / 2F, color1); + newDrawRect(x2 - width / 2F, y + width / 2F, x2 + width / 2F, y2 + width / 2F, color1); + newDrawRect(x + width / 2F, y2 - width / 2F, x2 - width / 2F, y2 + width / 2F, color1); + } + + public static void drawExhiRect(float x, float y, float x2, float y2, float alpha) { + drawRect(x - 3.5F, y - 3.5F, x2 + 3.5F, y2 + 3.5F, new Color(0, 0, 0, alpha).getRGB()); + drawRect(x - 3F, y - 3F, x2 + 3F, y2 + 3F, new Color(50F / 255F, 50F / 255F, 50F / 255F, alpha).getRGB()); + drawRect(x - 2.5F, y - 2.5F, x2 + 2.5F, y2 + 2.5F, new Color(26F / 255F, 26F / 255F, 26F / 255F, alpha).getRGB()); + drawRect(x - 0.5F, y - 0.5F, x2 + 0.5F, y2 + 0.5F, new Color(50F / 255F, 50F / 255F, 50F / 255F, alpha).getRGB()); + drawRect(x, y, x2, y2, new Color(18F / 255F, 18 / 255F, 18F / 255F, alpha).getRGB()); + } + + public static void drawMosswareRect(final float x, final float y, final float x2, final float y2, final float width, + final int color1, final int color2) { + drawRect(x, y, x2, y2, color2); + drawBorder(x, y, x2, y2, width, color1); + } + + public static void drawTexturedModalRect(int x, int y, int textureX, int textureY, int width, int height, float zLevel) + { + float f = 0.00390625F; + float f1 = 0.00390625F; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); + worldrenderer.pos((double)(x + 0), (double)(y + height), (double)zLevel).tex((double)((float)(textureX + 0) * f), (double)((float)(textureY + height) * f1)).endVertex(); + worldrenderer.pos((double)(x + width), (double)(y + height), (double)zLevel).tex((double)((float)(textureX + width) * f), (double)((float)(textureY + height) * f1)).endVertex(); + worldrenderer.pos((double)(x + width), (double)(y + 0), (double)zLevel).tex((double)((float)(textureX + width) * f), (double)((float)(textureY + 0) * f1)).endVertex(); + worldrenderer.pos((double)(x + 0), (double)(y + 0), (double)zLevel).tex((double)((float)(textureX + 0) * f), (double)((float)(textureY + 0) * f1)).endVertex(); + tessellator.draw(); + } + + public static void MdrawRect(double d, double e, double g, double h, int color) + { + if (d < g) + { + int i = (int) d; + d = g; + g = i; + } + + if (e < h) + { + int j = (int) e; + e = h; + h = j; + } + + float f3 = (float)(color >> 24 & 255) / 255.0F; + float f = (float)(color >> 16 & 255) / 255.0F; + float f1 = (float)(color >> 8 & 255) / 255.0F; + float f2 = (float)(color & 255) / 255.0F; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + GlStateManager.enableBlend(); + GlStateManager.disableTexture2D(); + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); + GlStateManager.color(f, f1, f2, f3); + worldrenderer.begin(7, DefaultVertexFormats.POSITION); + worldrenderer.pos((double)d, (double)h, 0.0D).endVertex(); + worldrenderer.pos((double)g, (double)h, 0.0D).endVertex(); + worldrenderer.pos((double)g, (double)e, 0.0D).endVertex(); + worldrenderer.pos((double)d, (double)e, 0.0D).endVertex(); + tessellator.draw(); + GlStateManager.enableTexture2D(); + GlStateManager.disableBlend(); + } + + public static void drawOutlinedRect(float x, float y, float width, float height, float lineSize, int lineColor) { + RenderUtils.drawRect(x, y, width, y + lineSize, lineColor); + RenderUtils.drawRect(x, height - lineSize, width, height, lineColor); + RenderUtils.drawRect(x, y + lineSize, x + lineSize, height - lineSize, lineColor); + RenderUtils.drawRect(width - lineSize, y + lineSize, width, height - lineSize, lineColor); + } + + public static void drawEntityOnScreen(final double posX, final double posY, final float scale, final EntityLivingBase entity) { + GlStateManager.pushMatrix(); + GlStateManager.enableColorMaterial(); + + GlStateManager.translate(posX, posY, 50.0); + GlStateManager.scale((-scale), scale, scale); + GlStateManager.rotate(180F, 0F, 0F, 1F); + GlStateManager.rotate(135F, 0F, 1F, 0F); + RenderHelper.enableStandardItemLighting(); + GlStateManager.rotate(-135F, 0F, 1F, 0F); + GlStateManager.translate(0.0, 0.0, 0.0); + + RenderManager rendermanager = mc.getRenderManager(); + rendermanager.setPlayerViewY(180F); + rendermanager.setRenderShadow(false); + rendermanager.renderEntityWithPosYaw(entity, 0.0, 0.0, 0.0, 0F, 1F); + rendermanager.setRenderShadow(true); + + GlStateManager.popMatrix(); + RenderHelper.disableStandardItemLighting(); + GlStateManager.disableRescaleNormal(); + GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GlStateManager.disableTexture2D(); + GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); + } + + public static float calculateCompensation(float target, float current, long delta, double speed) { + float diff = current - target; + if (delta < 1L) { + delta = 1L; + } + if (delta > 1000L) { + delta = 16L; + } + if ((double) diff > speed) { + double xD = speed * (double) delta / 16.0 < 0.5 ? 0.5 : speed * (double) delta / 16.0; + if ((current = (float) ((double) current - xD)) < target) { + current = target; + } + } else if ((double) diff < -speed) { + double xD = speed * (double) delta / 16.0 < 0.5 ? 0.5 : speed * (double) delta / 16.0; + if ((current = (float) ((double) current + xD)) > target) { + current = target; + } + } else { + current = target; + } + return current; + } + + public static ScaledResolution getScaledResolution() { + int displayWidth = Display.getWidth(); + int displayHeight = Display.getHeight(); + int guiScale = Minecraft.getMinecraft().gameSettings.guiScale; + + if (displayWidth != lastScaledWidth || + displayHeight != lastScaledHeight || + guiScale != lastGuiScale) { + lastScaledWidth = displayWidth; + lastScaledHeight = displayHeight; + lastGuiScale = guiScale; + return scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + } + + return scaledResolution; + } + + + public static void startScissorBox(final ScaledResolution sr, final int x, final int y, final int width, final int height) { + final int sf = sr.getScaleFactor(); + GL11.glScissor(x * sf, (sr.getScaledHeight() - (y + height)) * sf, width * sf, height * sf); + } + + public static int darker(final int color, final float factor) { + final int r = (int)((color >> 16 & 0xFF) * factor); + final int g = (int)((color >> 8 & 0xFF) * factor); + final int b = (int)((color & 0xFF) * factor); + final int a = color >> 24 & 0xFF; + return (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF) | (a & 0xFF) << 24; + } + + public static int darker(int color) { + return darker(color, 0.6F); + } + +} \ No newline at end of file diff --git a/src/main/java/net/ccbluex/liquidbounce/utils/render/shader/shaders/BackgroundShader.java b/src/main/java/net/ccbluex/liquidbounce/utils/render/shader/shaders/BackgroundShader.java new file mode 100644 index 0000000000..2b8d1af621 --- /dev/null +++ b/src/main/java/net/ccbluex/liquidbounce/utils/render/shader/shaders/BackgroundShader.java @@ -0,0 +1,43 @@ +/* + * FDPClient Hacked Client + * A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge by LiquidBounce. + * https://github.com/SkidderMC/FDPClient/ + */ +package net.ccbluex.liquidbounce.utils.render.shader.shaders; + +import net.ccbluex.liquidbounce.utils.render.RenderUtils; +import net.ccbluex.liquidbounce.utils.render.shader.Shader; +import net.minecraft.client.gui.ScaledResolution; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.GL20; + +public final class BackgroundShader extends Shader { + + public final static BackgroundShader BACKGROUND_SHADER = new BackgroundShader(); + + private float time; + + public BackgroundShader() { + super("background.frag"); + } + + @Override + public void setupUniforms() { + setupUniform("iResolution"); + setupUniform("iTime"); + } + + @Override + public void updateUniforms() { + final ScaledResolution scaledResolution = new ScaledResolution(mc); + + final int resolutionID = getUniform("iResolution"); + if(resolutionID > -1) + GL20.glUniform2f(resolutionID, (float) Display.getWidth(), (float) Display.getHeight()); + final int timeID = getUniform("iTime"); + if(timeID > -1) GL20.glUniform1f(timeID, time); + + time += 0.005F * RenderUtils.deltaTime; + } + +} diff --git a/src/main/resources/mixins.fdpclient.json b/src/main/resources/mixins.fdpclient.json index 485b33781f..230bb6235e 100644 --- a/src/main/resources/mixins.fdpclient.json +++ b/src/main/resources/mixins.fdpclient.json @@ -100,6 +100,7 @@ "render.MixinRenderPlayer", "render.MixinVisGraph", "render.MixinRenderManager", + "item.MixinItemStack", "resources.MixinDefaultResourcePack", "patcher.bugfixes.MixinBlockFluidRenderer", "patcher.bugfixes.MixinClientCommandHandler",