Merge pull request #38 from Silent-Client/TEST2

Test2
This commit is contained in:
kirillsaint 2023-09-04 20:30:40 +06:00 committed by GitHub
commit d4c7109614
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 65 additions and 22 deletions

View File

@ -153,7 +153,10 @@ public class ModSettings extends SilentScreen {
}
Client.getInstance().getSilentFontRenderer().drawString(mod.getName(), x + 100, (int) (y + 5) + scrollAnimation.getValue(), 14, SilentFontRenderer.FontType.TITLE);
mod.renderCustomLiteComponent(x + 100, (int) (y + 25 + scrollAnimation.getValue()), width, height, mouseX, mouseY);
MouseCursorHandler.CursorType cursorTypeCustom = mod.renderCustomLiteComponent(x + 100, (int) (y + 25 + scrollAnimation.getValue()), width, height, mouseX, mouseY);
if(cursorTypeCustom != null) {
cursorType = cursorTypeCustom;
}
int inputIndex = 0;
for (Setting setting : Client.getInstance().getSettingsManager().getSettingByMod(mod)) {
if(mod.getName() == "Crosshair" && Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset Crosshair").getValBoolean() && setting.getName() != "Scale" && setting.getName() != "Crosshair Color" && setting.getName() != "Vanilla Blendering") {
@ -228,7 +231,7 @@ public class ModSettings extends SilentScreen {
GL11.glPopMatrix();
super.drawScreen(mouseX, mouseY, partialTicks);
final Scroll scroll = MouseUtils.scroll();
if(scroll != null) {

View File

@ -86,7 +86,11 @@ public class ModSettings extends SilentScreen {
float settingY = 66 - scrollAnimation.getValue();
int inputIndex = 0;
GlStateManager.color(1, 1, 1, 1);
mod.renderCustomComponent(3, (int) settingY, 144, height, mouseX, mouseY);
MouseCursorHandler.CursorType cursorTypeCustom = mod.renderCustomComponent(3, (int) settingY, 144, height, mouseX, mouseY);
if(cursorTypeCustom != null) {
cursorType = cursorTypeCustom;
}
settingY += mod.customComponentHeight();

View File

@ -12,9 +12,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin({S14PacketEntity.class, S19PacketEntityHeadLook.class, S19PacketEntityStatus.class})
public class EntityPacketsMixin {
@SuppressWarnings("UnresolvedMixinReference")
@Inject(
method = {"getEntity", "func_149065_a", "func_149381_a", "func_149161_a"},
method = {"getEntity"},
at = @At("HEAD"),
cancellable = true,
remap = false

View File

@ -8,6 +8,7 @@ import net.silentclient.client.event.EventManager;
import net.silentclient.client.gui.animation.SimpleAnimation;
import net.silentclient.client.gui.hud.ScreenPosition;
import net.silentclient.client.utils.MenuBlurUtils;
import net.silentclient.client.utils.MouseCursorHandler;
import net.silentclient.client.utils.RawInputHandler;
import java.awt.*;
@ -175,8 +176,8 @@ public class Mod implements IMod {
return toggled;
}
public void renderCustomLiteComponent(int x, int y, int width, int height, int mouseX, int mouseY) {
return;
public MouseCursorHandler.CursorType renderCustomLiteComponent(int x, int y, int width, int height, int mouseX, int mouseY) {
return null;
}
public int customComponentLiteWidth() {
@ -191,8 +192,8 @@ public class Mod implements IMod {
}
public void renderCustomComponent(int x, int y, int width, int height, int mouseX, int mouseY) {
return;
public MouseCursorHandler.CursorType renderCustomComponent(int x, int y, int width, int height, int mouseX, int mouseY) {
return null;
}
public int customComponentWidth() {

View File

@ -19,6 +19,7 @@ import net.silentclient.client.mods.CustomFontRenderer;
import net.silentclient.client.mods.Mod;
import net.silentclient.client.mods.ModCategory;
import net.silentclient.client.utils.MenuBlurUtils;
import net.silentclient.client.utils.MouseCursorHandler;
import net.silentclient.client.utils.NotificationUtils;
import org.lwjgl.input.Keyboard;
@ -38,45 +39,65 @@ public class AutoTextMod extends Mod {
}
@Override
public void renderCustomLiteComponent(int x, int y, int width, int height, int mouseX, int mouseY) {
public MouseCursorHandler.CursorType renderCustomLiteComponent(int x, int y, int width, int height, int mouseX, int mouseY) {
MouseCursorHandler.CursorType cursorType = null;
CustomFontRenderer font = new CustomFontRenderer();
font.setRenderMode(CustomFontRenderer.RenderMode.CUSTOM);
font.drawString("Macros:", x, y, -1, 14);
font.drawString("Create Macro", x + customComponentLiteWidth() - font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE) - 20, y, MouseUtils.isInside(mouseX, mouseY, x + customComponentLiteWidth() - font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE) - 20, y, font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE), 12) ? new Color(255, 255, 255, 127).getRGB() : -1, 12);
boolean createHovered = MouseUtils.isInside(mouseX, mouseY, x + customComponentLiteWidth() - font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE) - 20, y, font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE), 12);
font.drawString("Create Macro", x + customComponentLiteWidth() - font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE) - 20, y, createHovered ? new Color(255, 255, 255, 127).getRGB() : -1, 12);
if(createHovered) {
cursorType = MouseCursorHandler.CursorType.POINTER;
}
int spacing = y + 20;
for(AutoTextCommand command : commands) {
font.drawString("Command: " + command.getCommand(), x, spacing, -1, 12);
font.drawString("Key: " + Keyboard.getKeyName(command.getKey()), x, spacing + 10, -1, 12);
font.drawString("Remove", x, spacing + 20, MouseUtils.isInside(mouseX, mouseY, x, spacing + 20, font.getStringWidth("Remove"), 12) ? new Color(255, 255, 255, 127).getRGB() : -1, 12);
boolean deleteHovered = MouseUtils.isInside(mouseX, mouseY, x, spacing + 20, font.getStringWidth("Remove"), 12);
font.drawString("Remove", x, spacing + 20, deleteHovered ? new Color(255, 255, 255, 127).getRGB() : -1, 12);
if(deleteHovered) {
cursorType = MouseCursorHandler.CursorType.POINTER;
}
spacing += 40;
}
componentHeight = spacing - 30;
return cursorType;
}
@Override
public void renderCustomComponent(int x, int y, int width, int height, int mouseX, int mouseY) {
public MouseCursorHandler.CursorType renderCustomComponent(int x, int y, int width, int height, int mouseX, int mouseY) {
MouseCursorHandler.CursorType cursorType = null;
CustomFontRenderer font = new CustomFontRenderer();
font.setRenderMode(CustomFontRenderer.RenderMode.CUSTOM);
font.drawString("Macros:", x, y, -1, 14);
font.drawString("Create Macro", x + customComponentWidth() - font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE), y, MouseUtils.isInside(mouseX, mouseY, x + customComponentWidth() - font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE), y, font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE), 12) ? new Color(255, 255, 255, 127).getRGB() : -1, 12);
boolean createHovered = MouseUtils.isInside(mouseX, mouseY, x + customComponentWidth() - font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE), y, font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE), 12);
font.drawString("Create Macro", x + customComponentWidth() - font.getStringWidth("Create Macro", 12, SilentFontRenderer.FontType.TITLE), y, createHovered ? new Color(255, 255, 255, 127).getRGB() : -1, 12);
if(createHovered) {
cursorType = MouseCursorHandler.CursorType.POINTER;
}
int spacing = y + 20;
for(AutoTextCommand command : commands) {
font.drawString("Command: " + command.getCommand(), x, spacing, -1, 12);
font.drawString("Key: " + Keyboard.getKeyName(command.getKey()), x, spacing + 10, -1, 12);
font.drawString("Remove", x, spacing + 20, MouseUtils.isInside(mouseX, mouseY, x, spacing + 20, font.getStringWidth("Remove"), 12) ? new Color(255, 255, 255, 127).getRGB() : -1, 12);
boolean deleteHovered = MouseUtils.isInside(mouseX, mouseY, x, spacing + 20, font.getStringWidth("Remove"), 12);
font.drawString("Remove", x, spacing + 20, deleteHovered ? new Color(255, 255, 255, 127).getRGB() : -1, 12);
if(deleteHovered) {
cursorType = MouseCursorHandler.CursorType.POINTER;
}
spacing += 40;
}
componentHeight = spacing - 30;
return cursorType;
}
@Override

View File

@ -22,6 +22,7 @@ import net.silentclient.client.mods.Mod;
import net.silentclient.client.mods.ModCategory;
import net.silentclient.client.mods.settings.RenderMod;
import net.silentclient.client.utils.DisplayUtil;
import net.silentclient.client.utils.MouseCursorHandler;
import net.silentclient.client.utils.Sounds;
import org.lwjgl.opengl.GL11;
@ -161,7 +162,8 @@ public class CrosshairMod extends Mod {
}
@Override
public void renderCustomComponent(int x, int y, int width, int height, int mouseX, int mouseY) {
public MouseCursorHandler.CursorType renderCustomComponent(int x, int y, int width, int height, int mouseX, int mouseY) {
MouseCursorHandler.CursorType cursorType = null;
CustomFontRenderer font = new CustomFontRenderer();
font.setRenderMode(CustomFontRenderer.RenderMode.CUSTOM);
GlStateManager.pushMatrix();
@ -173,6 +175,9 @@ public class CrosshairMod extends Mod {
RenderUtils.drawRect(x + buttonWidth, y, buttonWidth, 20, preset ? -1 : new Color(0, 0, 0).getRGB());
font.drawString("Preset", x + buttonWidth + ((buttonWidth / 2) - (font.getStringWidth("Preset", 14, SilentFontRenderer.FontType.TITLE) / 2)), y + 3, preset ? new Color(0, 0, 0).getRGB() : -1, 14);
componentWidth = width;
if(MouseUtils.isInside(mouseX, mouseY, x, y, buttonWidth, 20) || MouseUtils.isInside(mouseX, mouseY, x + buttonWidth, y, buttonWidth, 20)) {
cursorType = MouseCursorHandler.CursorType.POINTER;
}
if(preset) {
int crossIndex = 1;
int spacing = 10;
@ -192,6 +197,7 @@ public class CrosshairMod extends Mod {
if(MouseUtils.isInside(mouseX, mouseY, x + spacing, crossY, 22, 22)) {
RenderUtil.drawRoundedOutline(x + spacing, crossY, 22, 22, 5, 3, new Color(255, 255, 255, 127).getRGB());
cursorType = MouseCursorHandler.CursorType.POINTER;
}
RenderUtil.waitDrawImage(new ResourceLocation("silentclient/mods/crosshair/crosshair" + presetID + ".png"), x + spacing + ((22 / 2) - (15 / 2)), crossY - 1 + ((22 / 2) - (15 / 2)), 15, 15, false);
@ -205,6 +211,7 @@ public class CrosshairMod extends Mod {
}
}
GlStateManager.popMatrix();
return cursorType;
}
@Override
@ -246,7 +253,8 @@ public class CrosshairMod extends Mod {
}
@Override
public void renderCustomLiteComponent(int x, int y, int width, int height, int mouseX, int mouseY) {
public MouseCursorHandler.CursorType renderCustomLiteComponent(int x, int y, int width, int height, int mouseX, int mouseY) {
MouseCursorHandler.CursorType cursorType = null;
CustomFontRenderer font = new CustomFontRenderer();
font.setRenderMode(CustomFontRenderer.RenderMode.CUSTOM);
GlStateManager.pushMatrix();
@ -258,6 +266,9 @@ public class CrosshairMod extends Mod {
RenderUtils.drawRect(x + buttonWidth, y, buttonWidth, 20, preset ? -1 : new Color(0, 0, 0).getRGB());
font.drawString("Preset", x + buttonWidth + ((buttonWidth / 2) - (font.getStringWidth("Preset", 14, SilentFontRenderer.FontType.TITLE) / 2)), y + 3, preset ? new Color(0, 0, 0).getRGB() : -1, 14);
componentWidth = width;
if(MouseUtils.isInside(mouseX, mouseY, x, y, buttonWidth, 20) || MouseUtils.isInside(mouseX, mouseY, x + buttonWidth, y, buttonWidth, 20)) {
cursorType = MouseCursorHandler.CursorType.POINTER;
}
if(preset) {
int crossIndex = 1;
int spacing = 0;
@ -265,7 +276,6 @@ public class CrosshairMod extends Mod {
String selected = Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset ID").getValString();
RenderUtil.drawRoundedRect(x + spacing, crossY - 1, 22, 22, 5, new Color(0, 0, 0).getRGB());
RenderUtil.drawRoundedOutline(x + spacing, crossY - 1, 22, 22, 5, 3, -1);
RenderUtil.waitDrawImage(new ResourceLocation("silentclient/mods/crosshair/crosshair" + selected + ".png"), x + spacing + ((22 / 2) - (15 / 2)), crossY - 1 + ((22 / 2) - (15 / 2)), 15, 15, false);
spacing += 25;
crossIndex += 1;
@ -277,6 +287,7 @@ public class CrosshairMod extends Mod {
if(MouseUtils.isInside(mouseX, mouseY, x + spacing, crossY - 1, 22, 22)) {
RenderUtil.drawRoundedOutline(x + spacing, crossY - 1, 22, 22, 5, 3, new Color(255, 255, 255, 127).getRGB());
cursorType = MouseCursorHandler.CursorType.POINTER;
}
RenderUtil.waitDrawImage(new ResourceLocation("silentclient/mods/crosshair/crosshair" + presetID + ".png"), x + spacing + ((22 / 2) - (15 / 2)), crossY - 1 + ((22 / 2) - (15 / 2)), 15, 15, false);
@ -290,6 +301,8 @@ public class CrosshairMod extends Mod {
}
}
GlStateManager.popMatrix();
return cursorType;
}
@Override

View File

@ -115,6 +115,8 @@
"accessors.optifine.ConfigAccessor",
"mixins.NetworkPlayerInfoMixin",
"accessors.NetworkPlayerInfoAccessor",
"mixins.MathHelperMixin"
"mixins.MathHelperMixin",
"mixins.GuiLanguageMixin",
"mixins.RenderArrowMixin"
]
}