Fixed keypress and hud rendering
This commit is contained in:
+2
-2
@@ -6,8 +6,8 @@ yarn_mappings=1.21.4+build.7
|
|||||||
loader_version=0.16.10
|
loader_version=0.16.10
|
||||||
fabric_version=0.114.0+1.21.4
|
fabric_version=0.114.0+1.21.4
|
||||||
|
|
||||||
mod_version = 0.0.3-beta0
|
mod_version = 0.0.3-beta3
|
||||||
maven_group = org.saturnclient
|
maven_group = org.saturnclient
|
||||||
archives_base_name = saturnclient
|
archives_base_name = saturnclient
|
||||||
|
|
||||||
player_anim = 2.0.3+1.21.4
|
player_anim = 2.0.3+1.21.4
|
||||||
|
|||||||
@@ -1,26 +1,19 @@
|
|||||||
package org.saturnclient.modules;
|
package org.saturnclient.modules;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||||
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
|
|
||||||
import net.minecraft.client.font.TextRenderer;
|
|
||||||
import net.minecraft.client.render.RenderLayer;
|
|
||||||
|
|
||||||
import org.saturnclient.modules.mods.*;
|
import org.saturnclient.modules.mods.*;
|
||||||
import org.saturnclient.saturnclient.SaturnClient;
|
|
||||||
import org.saturnclient.saturnclient.menus.HudEditor;
|
|
||||||
import org.saturnclient.saturnclient.mixin.DrawContextAccessor;
|
|
||||||
import org.saturnclient.ui2.RenderScope;
|
|
||||||
|
|
||||||
public class ModManager {
|
public class ModManager {
|
||||||
public static Module[] MODS = {
|
public static Module[] MODS = {
|
||||||
new Crosshair(),
|
new Crosshair(),
|
||||||
new AutoSprint(),
|
new AutoSprint(),
|
||||||
new ArmorDisplay(),
|
new ArmorDisplay(),
|
||||||
new Fps(),
|
new Fps(),
|
||||||
new PotionDisplay(),
|
new PotionDisplay(),
|
||||||
new Coordinates(),
|
new Coordinates(),
|
||||||
new Freelook(),
|
new Freelook(),
|
||||||
new Keystrokes()
|
new Keystrokes()
|
||||||
};
|
};
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
@@ -31,39 +24,5 @@ public class ModManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
HudRenderCallback.EVENT.register((context, _o) -> {
|
|
||||||
TextRenderer textRenderer = SaturnClient.client.textRenderer;
|
|
||||||
|
|
||||||
if (textRenderer != null &&
|
|
||||||
!(SaturnClient.client.currentScreen instanceof HudEditor)) {
|
|
||||||
RenderScope renderScope = new RenderScope(context.getMatrices(),
|
|
||||||
((DrawContextAccessor) context).getVertexConsumers());
|
|
||||||
|
|
||||||
for (Module m : MODS) {
|
|
||||||
if (m instanceof HudMod && m.isEnabled()) {
|
|
||||||
ModDimensions dim = ((HudMod) m).getDimensions();
|
|
||||||
|
|
||||||
renderScope.matrices.push();
|
|
||||||
|
|
||||||
renderScope.matrices.translate(dim.x.value, (float) dim.y.value, 0);
|
|
||||||
|
|
||||||
renderScope.matrices.scale(dim.scale.value, dim.scale.value, 1.0f);
|
|
||||||
|
|
||||||
if (dim.renderBackground) {
|
|
||||||
renderScope.drawRoundedRectangle(0, 0, dim.width, dim.height, dim.radius.value, dim.bgColor.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
renderScope.setRenderLayer(RenderLayer::getGuiTextured);
|
|
||||||
|
|
||||||
((HudMod) m).renderHud(renderScope);
|
|
||||||
|
|
||||||
renderScope.matrices.pop();
|
|
||||||
} else {
|
|
||||||
m.render(renderScope);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package org.saturnclient.modules.mods.mixins;
|
||||||
|
|
||||||
|
import org.saturnclient.modules.HudMod;
|
||||||
|
import org.saturnclient.modules.ModDimensions;
|
||||||
|
import org.saturnclient.modules.ModManager;
|
||||||
|
import org.saturnclient.saturnclient.SaturnClient;
|
||||||
|
import org.saturnclient.saturnclient.menus.HudEditor;
|
||||||
|
import org.saturnclient.saturnclient.mixin.DrawContextAccessor;
|
||||||
|
import org.saturnclient.ui2.RenderScope;
|
||||||
|
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.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import net.minecraft.client.font.TextRenderer;
|
||||||
|
import net.minecraft.client.gui.DrawContext;
|
||||||
|
import net.minecraft.client.gui.hud.InGameHud;
|
||||||
|
import net.minecraft.client.render.RenderLayer;
|
||||||
|
import net.minecraft.client.render.RenderTickCounter;
|
||||||
|
|
||||||
|
@Mixin(InGameHud.class)
|
||||||
|
public class RenderMixin {
|
||||||
|
@Inject(method = "renderChat", at = @At("TAIL"))
|
||||||
|
public void renderMods(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) {
|
||||||
|
TextRenderer textRenderer = SaturnClient.client.textRenderer;
|
||||||
|
|
||||||
|
if (textRenderer != null &&
|
||||||
|
!(SaturnClient.client.currentScreen instanceof HudEditor)) {
|
||||||
|
RenderScope renderScope = new RenderScope(context.getMatrices(),
|
||||||
|
((DrawContextAccessor) context).getVertexConsumers());
|
||||||
|
|
||||||
|
for (org.saturnclient.modules.Module m : ModManager.MODS) {
|
||||||
|
if (m instanceof HudMod && m.isEnabled()) {
|
||||||
|
ModDimensions dim = ((HudMod) m).getDimensions();
|
||||||
|
|
||||||
|
renderScope.matrices.push();
|
||||||
|
|
||||||
|
renderScope.matrices.translate(dim.x.value, (float) dim.y.value, 0);
|
||||||
|
|
||||||
|
renderScope.matrices.scale(dim.scale.value, dim.scale.value, 1.0f);
|
||||||
|
|
||||||
|
if (dim.renderBackground) {
|
||||||
|
renderScope.drawRoundedRectangle(0, 0, dim.width, dim.height, dim.radius.value,
|
||||||
|
dim.bgColor.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
renderScope.setRenderLayer(RenderLayer::getGuiTextured);
|
||||||
|
|
||||||
|
((HudMod) m).renderHud(renderScope);
|
||||||
|
|
||||||
|
renderScope.matrices.pop();
|
||||||
|
} else {
|
||||||
|
m.render(renderScope);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -89,13 +89,17 @@ public class Property<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void next() {
|
public void next() {
|
||||||
if ((Integer) value < availableValues.length-1) setValue((Integer)value+1);
|
if ((Integer) value < availableValues.length - 1)
|
||||||
else setValue(0);
|
setValue((Integer) value + 1);
|
||||||
|
else
|
||||||
|
setValue(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void prev() {
|
public void prev() {
|
||||||
if ((Integer) value > 0) setValue((Integer)value-1);
|
if ((Integer) value > 0)
|
||||||
else setValue(availableValues.length - 1);
|
setValue((Integer) value - 1);
|
||||||
|
else
|
||||||
|
setValue(availableValues.length - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelection(int selection) {
|
public void setSelection(int selection) {
|
||||||
@@ -197,18 +201,14 @@ public class Property<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isKeyPressed() {
|
public boolean isKeyPressed() {
|
||||||
return (Integer) value == -1 ? false : GLFW.glfwGetKey(SaturnClient.client.getWindow().getHandle(), (Integer) (Object) value) == GLFW.GLFW_PRESS;
|
return (Integer) value == -1 ? false
|
||||||
|
: GLFW.glfwGetKey(SaturnClient.client.getWindow().getHandle(),
|
||||||
|
(Integer) (Object) value) == GLFW.GLFW_PRESS && SaturnClient.client.currentScreen == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean wasKeyPressed() {
|
public boolean wasKeyPressed() {
|
||||||
long window = SaturnClient.client.getWindow().getHandle();
|
boolean isPressed = this.isKeyPressed();
|
||||||
int key = (Integer) value;
|
wasPressedLastTick = isPressed && !wasPressedLastTick;
|
||||||
|
return wasPressedLastTick;
|
||||||
boolean isPressed = key != -1 && GLFW.glfwGetKey(window, key) == GLFW.GLFW_PRESS;
|
|
||||||
|
|
||||||
boolean wasJustPressed = isPressed && !wasPressedLastTick;
|
|
||||||
wasPressedLastTick = isPressed;
|
|
||||||
|
|
||||||
return wasJustPressed;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class KeyInputHandler {
|
|||||||
client.setScreen(new ShiftMenu());
|
client.setScreen(new ShiftMenu());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SaturnClientConfig.openEmoteWheel.wasKeyPressed()) {
|
if (SaturnClientConfig.openEmoteWheel.wasKeyPressed() && client.currentScreen == null) {
|
||||||
client.setScreen(new EmoteWheel());
|
client.setScreen(new EmoteWheel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
"compatibilityLevel": "JAVA_21",
|
"compatibilityLevel": "JAVA_21",
|
||||||
"client": [
|
"client": [
|
||||||
"CameraMixin",
|
"CameraMixin",
|
||||||
"EntityMixin"
|
"EntityMixin",
|
||||||
|
"RenderMixin"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
"defaultRequire": 1
|
"defaultRequire": 1
|
||||||
|
|||||||
Reference in New Issue
Block a user