Skip to content

Commit

Permalink
v1.2 for mc1.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
breelock committed Aug 19, 2024
1 parent bb50b3b commit 3516585
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 34 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.19.4
yarn_mappings=1.19.4+build.2
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.16.2

# Mod Properties
Expand All @@ -14,4 +14,4 @@ maven_group=com.breelock.autoclicky
archives_base_name=autoclicky

# Fabric API
fabric_version=0.87.2+1.19.4
fabric_version=0.92.2+1.20.1
32 changes: 16 additions & 16 deletions src/main/java/com/breelock/autoclicky/pages/OldCombat.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import com.breelock.autoclicky.widgets.TooltipSliderWidget;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;

Expand Down Expand Up @@ -134,30 +134,30 @@ protected void applyValue() {
}

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
this.renderBackground(matrices);
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
this.renderBackground(context);

// Draw title
drawCenteredTextWithShadow(matrices, this.textRenderer, this.title, this.width / 2, this.height / 4 - 50, 16777215);
drawCenteredTextWithShadow(matrices, this.textRenderer, Text.literal("by breelock").formatted(Formatting.GRAY), this.width / 2, this.height / 4 - 50 + 10, 16777215);
context.drawText(this.textRenderer, this.title, (this.width - this.textRenderer.getWidth(this.title)) / 2, this.height / 4 - 50, 16777215, false);
context.drawText(this.textRenderer, Text.literal("by breelock").formatted(Formatting.GRAY), (this.width - this.textRenderer.getWidth("by breelock")) / 2, this.height / 4 - 50 + 10, 16777215, false);

// Draw labels
this.textRenderer.draw(matrices, Text.literal(Text.translatable("gui.autoclicky.leftBind").getString()), (float) this.width / 2 - 95 - 10f / 2 + 2, (float) this.height / 4 + 10, 16777215);
this.textRenderer.draw(matrices, Text.literal(Text.translatable("gui.autoclicky.rightBind").getString()), (float) this.width / 2 + 10f / 2 + 2, (float) this.height / 4 + 10, 16777215);
context.drawText(this.textRenderer, Text.translatable("gui.autoclicky.leftBind"), Math.round((float) this.width / 2 - 95 - 10f / 2 + 2), this.height / 4 + 10, 16777215, false);
context.drawText(this.textRenderer, Text.translatable("gui.autoclicky.rightBind"), Math.round((float) this.width / 2 + 10f / 2 + 2), this.height / 4 + 10, 16777215, false);

// Draw sliders
leftMinDelaySlider.render(matrices, mouseX, mouseY, delta);
leftMaxDelaySlider.render(matrices, mouseX, mouseY, delta);
rightMinDelaySlider.render(matrices, mouseX, mouseY, delta);
rightMaxDelaySlider.render(matrices, mouseX, mouseY, delta);
leftMinDelaySlider.render(context, mouseX, mouseY, delta);
leftMaxDelaySlider.render(context, mouseX, mouseY, delta);
rightMinDelaySlider.render(context, mouseX, mouseY, delta);
rightMaxDelaySlider.render(context, mouseX, mouseY, delta);

// Draw checkboxes
interruptCheckbox.render(matrices, mouseX, mouseY, delta);
showMessageCheckbox.render(matrices, mouseX, mouseY, delta);
autoJumpCheckbox.render(matrices, mouseX, mouseY, delta);
onlyEntityCheckbox.render(matrices, mouseX, mouseY, delta);
interruptCheckbox.render(context, mouseX, mouseY, delta);
showMessageCheckbox.render(context, mouseX, mouseY, delta);
autoJumpCheckbox.render(context, mouseX, mouseY, delta);
onlyEntityCheckbox.render(context, mouseX, mouseY, delta);

super.render(matrices, mouseX, mouseY, delta);
super.render(context, mouseX, mouseY, delta);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.breelock.autoclicky.widgets;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.widget.CheckboxWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;

public class TooltipCheckboxWidget extends CheckboxWidget {

private final String tooltipText;

public TooltipCheckboxWidget(int x, int y, int width, int height, Text message, boolean checked, String tooltipText) {
Expand All @@ -15,12 +14,16 @@ public TooltipCheckboxWidget(int x, int y, int width, int height, Text message,
}

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
super.render(matrices, mouseX, mouseY, delta);
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
super.render(context, mouseX, mouseY, delta);

if (isHovered() && MinecraftClient.getInstance().currentScreen != null && tooltipText != null) {
MinecraftClient.getInstance().currentScreen.renderTooltip(matrices, Text.literal(tooltipText), mouseX, mouseY);
// Check if the mouse is hovering over the checkbox
if (this.isMouseOver(mouseX, mouseY) && this.tooltipText != null && !this.tooltipText.trim().isEmpty()) {
renderTooltip(context, mouseX, mouseY);
}
}
}

private void renderTooltip(DrawContext context, int mouseX, int mouseY) {
context.drawTooltip(MinecraftClient.getInstance().textRenderer, Text.of(tooltipText), mouseX, mouseY);
}
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
package com.breelock.autoclicky.widgets;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.widget.SliderWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;

public abstract class TooltipSliderWidget extends SliderWidget {

private final String tooltipText;

public TooltipSliderWidget(int x, int y, int width, int height, Text text, double value, String tooltipText) {
super(x, y, width, height, text, value);
this.tooltipText = tooltipText;
this.updateMessage();
}

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
super.render(matrices, mouseX, mouseY, delta);
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
super.render(context, mouseX, mouseY, delta);

if (isHovered() && MinecraftClient.getInstance().currentScreen != null && tooltipText != null) {
MinecraftClient.getInstance().currentScreen.renderTooltip(matrices, Text.literal(tooltipText), mouseX, mouseY);
// Check if the mouse is hovering over the slider
if (this.isMouseOver(mouseX, mouseY) && this.tooltipText != null && !this.tooltipText.trim().isEmpty()) {
renderTooltip(context, mouseX, mouseY);
}
}
}

private void renderTooltip(DrawContext context, int mouseX, int mouseY) {
context.drawTooltip(MinecraftClient.getInstance().textRenderer, Text.of(tooltipText), mouseX, mouseY);
}
}
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"depends": {
"fabricloader": ">=0.15.11",
"minecraft": "1.19.4",
"minecraft": "1.20.1",
"java": ">=8",
"fabric": "*"
},
Expand Down

0 comments on commit 3516585

Please sign in to comment.