Skip to content

Commit

Permalink
Misc: Add remaining methods used by Elementa and Vigilance
Browse files Browse the repository at this point in the history
GitHub: #76
  • Loading branch information
Johni0702 authored Aug 6, 2024
1 parent 34cec8d commit 6eafe0f
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 4 deletions.
19 changes: 15 additions & 4 deletions api/UniversalCraft.api
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public class gg/essential/universal/UGraphics {
@1.12.2-forge,1.16.2-forge
public fun <init> (Lnet/minecraft/client/renderer/BufferBuilder;)V
public static fun activeTexture (I)V
public static fun alphaFunc (IF)V
public static fun areShadersSupported ()Z
public fun asUVertexConsumer ()Lgg/essential/universal/vertex/UVertexConsumer;
@1.17.1-forge,1.18.1-forge,1.19.2-forge,1.19.3-forge,1.19.4-forge,1.20.1-forge,1.20.2-forge,1.20.4-forge
Expand Down Expand Up @@ -174,6 +175,7 @@ public class gg/essential/universal/UGraphics {
public static fun enableDepth ()V
public static fun enableLight (I)V
public static fun enableLighting ()V
public static fun enableStencil ()V
public static fun enableTexture2D ()V
public fun endVertex ()Lgg/essential/universal/UGraphics;
public static fun getActiveTexture ()I
Expand Down Expand Up @@ -202,6 +204,7 @@ public class gg/essential/universal/UGraphics {
public static fun glGetShaderi (II)I
public static fun glLinkProgram (I)V
public static fun glUseProgram (I)V
public static fun isCoreProfile ()Z
public static fun isOpenGl21Supported ()Z
public fun light (II)Lgg/essential/universal/UGraphics;
public static fun listFormattedStringToWidth (Ljava/lang/String;I)Ljava/util/List;
Expand Down Expand Up @@ -304,6 +307,11 @@ public final class gg/essential/universal/UGuiButton {
public static final fun getY (Lnet/minecraft/client/gui/GuiButton;)I
}

public final class gg/essential/universal/UI18n {
public static final field INSTANCE Lgg/essential/universal/UI18n;
public final fun i18n (Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
}

public final class gg/essential/universal/UImage {
public static final field Companion Lgg/essential/universal/UImage$Companion;
@1.17.1-forge,1.18.1-forge,1.19.2-forge,1.19.3-forge,1.19.4-forge,1.20.1-forge,1.20.2-forge,1.20.4-forge
Expand Down Expand Up @@ -645,16 +653,17 @@ public final class gg/essential/universal/UMinecraft {
public static final field isRunningOnMac Z
@1.17.1-forge,1.18.1-forge,1.19.2-forge,1.19.3-forge,1.19.4-forge,1.20.1-forge,1.20.2-forge,1.20.4-forge
public static final fun getChatGUI ()Lnet/minecraft/client/gui/components/ChatComponent;
@1.17.1-forge,1.18.1-forge,1.19.2-forge,1.19.3-forge,1.19.4-forge,1.20.1-forge,1.20.2-forge,1.20.4-forge
public static final fun getFontRenderer ()Lnet/minecraft/client/gui/Font;
@1.16.2-forge
public static final fun getChatGUI ()Lnet/minecraft/client/gui/NewChatGui;
@1.16.2-fabric,1.17.1-fabric,1.18.1-fabric,1.19-fabric,1.19.1-fabric,1.19.2-fabric,1.19.3-fabric,1.19.4-fabric,1.20-fabric,1.20.1-fabric,1.20.2-fabric,1.20.4-fabric,1.20.6-fabric,1.21-fabric
public static final fun getChatGUI ()Lnet/minecraft/client/gui/hud/ChatHud;
@1.16.2-fabric,1.17.1-fabric,1.18.1-fabric,1.19-fabric,1.19.1-fabric,1.19.2-fabric,1.19.3-fabric,1.19.4-fabric,1.20-fabric,1.20.1-fabric,1.20.2-fabric,1.20.4-fabric,1.20.6-fabric,1.21-fabric
public static final fun getFontRenderer ()Lnet/minecraft/client/font/TextRenderer;
@1.12.2-forge,1.8.9-forge
public static final fun getChatGUI ()Lnet/minecraft/client/gui/GuiNewChat;
public static final fun getCurrentScreenObj ()Ljava/lang/Object;
@1.17.1-forge,1.18.1-forge,1.19.2-forge,1.19.3-forge,1.19.4-forge,1.20.1-forge,1.20.2-forge,1.20.4-forge
public static final fun getFontRenderer ()Lnet/minecraft/client/gui/Font;
@1.16.2-fabric,1.17.1-fabric,1.18.1-fabric,1.19-fabric,1.19.1-fabric,1.19.2-fabric,1.19.3-fabric,1.19.4-fabric,1.20-fabric,1.20.1-fabric,1.20.2-fabric,1.20.4-fabric,1.20.6-fabric,1.21-fabric
public static final fun getFontRenderer ()Lnet/minecraft/client/font/TextRenderer;
@1.12.2-forge,1.16.2-forge,1.8.9-forge
public static final fun getFontRenderer ()Lnet/minecraft/client/gui/FontRenderer;
public static final fun getGuiScale ()I
Expand Down Expand Up @@ -695,6 +704,8 @@ public final class gg/essential/universal/UMinecraft {
public static final fun getWorld ()Lnet/minecraft/client/world/ClientWorld;
@1.12.2-forge,1.8.9-forge
public static final fun getWorld ()Lnet/minecraft/client/multiplayer/WorldClient;
public static final fun isCallingFromMinecraftThread ()Z
public static final fun setCurrentScreenObj (Ljava/lang/Object;)V
public static final fun setGuiScale (I)V
}

Expand Down
26 changes: 26 additions & 0 deletions src/main/java/gg/essential/universal/UGraphics.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import gg.essential.universal.utils.ReleasedDynamicTexture;
import gg.essential.universal.vertex.UVertexConsumer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
Expand All @@ -19,6 +20,7 @@
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.renderer.vertex.VertexFormatElement;
import net.minecraft.client.shader.Framebuffer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;

Expand Down Expand Up @@ -176,6 +178,24 @@ public static void draw() {
}
//#endif

public static boolean isCoreProfile() {
//#if MC>=11700
//$$ return true;
//#else
return false;
//#endif
}

@Deprecated // only works on Forge 1.12.2 and below (relies on a Forge patch)
public static void enableStencil() {
//#if MC<11400
Framebuffer framebuffer = Minecraft.getMinecraft().getFramebuffer();
if (!framebuffer.isStencilEnabled()) {
framebuffer.enableStencil();
}
//#endif
}

public static void cullFace(int mode) {
//#if MC>=11502
//$$ GL11.glCullFace(mode);
Expand Down Expand Up @@ -241,6 +261,12 @@ public static void disableAlpha() {
//#endif
}

public static void alphaFunc(int func, float ref) {
//#if MC<11700
GlStateManager.alphaFunc(func, ref);
//#endif
}

public static void shadeModel(int mode) {
//#if MC<11700
GlStateManager.shadeModel(mode);
Expand Down
9 changes: 9 additions & 0 deletions src/main/kotlin/gg/essential/universal/UI18n.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package gg.essential.universal

import net.minecraft.client.resources.I18n

object UI18n {
fun i18n(key: String, vararg arguments: Any?): String {
return I18n.format(key, *arguments)
}
}
20 changes: 20 additions & 0 deletions src/main/kotlin/gg/essential/universal/UMinecraft.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import net.minecraft.client.Minecraft
import net.minecraft.client.entity.EntityPlayerSP
import net.minecraft.client.gui.FontRenderer
import net.minecraft.client.gui.GuiNewChat
import net.minecraft.client.gui.GuiScreen
import net.minecraft.client.multiplayer.WorldClient
import net.minecraft.client.network.NetHandlerPlayClient
import net.minecraft.client.settings.GameSettings
Expand Down Expand Up @@ -79,4 +80,23 @@ object UMinecraft {

@JvmStatic
fun getSettings(): GameSettings = getMinecraft().gameSettings

@JvmStatic
var currentScreenObj: Any?
get() = getMinecraft().currentScreen
set(value) {
//#if MC<11200
@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
//#endif
getMinecraft().displayGuiScreen(value as GuiScreen?)
}

@JvmStatic
fun isCallingFromMinecraftThread(): Boolean {
//#if MC>=11400
//$$ return Minecraft.getInstance().isOnExecutionThread
//#else
return Minecraft.getMinecraft().isCallingFromMinecraftThread
//#endif
}
}

0 comments on commit 6eafe0f

Please sign in to comment.