Huge update to v2.0.0

This commit is contained in:
Cameron Reed 2023-01-26 17:27:39 -07:00
parent 811e8fc6a3
commit 0d56349c53
23 changed files with 151 additions and 415 deletions

1
.gitignore vendored
View File

@ -117,3 +117,4 @@ run/
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
/libs/

View File

@ -26,6 +26,7 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation files("libs/cmods-1.0.0-dev.jar")
modCompileOnly "com.terraformersmc:modmenu:4.1.1"
}

View File

@ -4,9 +4,9 @@ org.gradle.jvmargs=-Xmx2G
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.19.3
yarn_mappings=1.19.3+build.2
loader_version=0.14.11
loader_version=0.14.13
# Mod Properties
mod_version=1.2.2
mod_version=2.0.0
maven_group=cmods
archives_base_name=haxxor
# Dependencies

View File

@ -0,0 +1,84 @@
package cmods.haxxor;
import cmods.cmods.api.ButtonBuilder;
import cmods.cmods.api.Module;
import cmods.cmods.api.ModuleOptions;
import cmods.cmods.client.ui.Line;
import cmods.cmods.client.ui.ToggleButton;
import cmods.haxxor.client.AutoFarmer;
import cmods.haxxor.client.options.HaxxorOptions;
import cmods.haxxor.client.ui.FarmerOptionsScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.text.Text;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.function.Consumer;
import static cmods.cmods.client.ui.Constants.buttonHeight;
import static cmods.cmods.client.ui.Constants.buttonWidth;
public class HaxxorModule extends Module {
private static final int precedence = 0;
private HaxxorModule(@Nullable ModuleOptions options, @Nullable ArrayList<ButtonBuilder> optionButtons,
@Nullable ArrayList<ButtonBuilder> uiOptions, Consumer<ArrayList<Line>> hudDrawCallback) {
super(precedence, options, optionButtons, uiOptions, hudDrawCallback);
}
public static void init() {
HaxxorOptions options = HaxxorOptions.getInstance();
ArrayList<ButtonBuilder> optionButtons = new ArrayList<>(2);
ArrayList<ButtonBuilder> uiOptions = new ArrayList<>(2);
optionButtons.add((screen, client) -> ButtonWidget.builder(Text.translatable("haxxor.options.farmer"),
button -> client.setScreen(new FarmerOptionsScreen(screen))).build());
optionButtons.add((screen, client) -> new ToggleButton(0, 0, buttonWidth, buttonHeight,
Text.translatable("haxxor.options.fall_damage"), options.cancelFallDamage));
uiOptions.add((screen, client) -> new ToggleButton(0, 0, buttonWidth, buttonHeight,
Text.translatable("haxxor.options.ui.show_farmer"), options.uiOptions.show_auto_farmer));
uiOptions.add((screen, client) -> new ToggleButton(0, 0, buttonWidth, buttonHeight,
Text.translatable("haxxor.options.ui.show_fly_hack"), options.uiOptions.show_fly_hack));
HaxxorModule module = new HaxxorModule(options, optionButtons, uiOptions, HaxxorModule::addLines);
module.register();
}
public static void addLines(ArrayList<Line> lines) {
final HaxxorOptions options = HaxxorOptions.getInstance();
int red = 0xff0000;
int green = 0x00ff00;
if (options.uiOptions.show_auto_farmer.get()) {
if (options.autoFarmer.enabled.get()) {
lines.add(new Line(Text.translatable("haxxor.hud.auto_farm_enabled")
.append(Text.translatable("haxxor.state.on")), green, 0));
} else {
lines.add(new Line(Text.translatable("haxxor.hud.auto_farm_enabled")
.append(Text.translatable("haxxor.state.off")), red, 0));
}
if (AutoFarmer.canFarm()) {
lines.add(new Line(Text.translatable("haxxor.actions.available"), green, 1));
}
}
if (options.uiOptions.show_fly_hack.get()) {
if (options.flyHackEnabled.get()) {
lines.add(new Line(Text.translatable("haxxor.hud.fly_hack_enabled")
.append(Text.translatable("haxxor.state.on")), green, 0));
} else {
lines.add(new Line(Text.translatable("haxxor.hud.fly_hack_enabled")
.append(Text.translatable("haxxor.state.off")), red, 0));
}
}
}
}

View File

@ -1,5 +1,6 @@
package cmods.haxxor.client;
import cmods.haxxor.HaxxorModule;
import cmods.haxxor.client.options.HaxxorOptions;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType;
@ -16,7 +17,7 @@ import java.util.Optional;
@Environment(EnvType.CLIENT)
public class HaxxorClient implements ClientModInitializer {
public static String MOD_ID = "haxxor";
public static final String MOD_ID = "haxxor";
public static String version = "Unknown";
private static StickyKeyBinding auto_farm_key;
@ -29,6 +30,8 @@ public class HaxxorClient implements ClientModInitializer {
modContainer.ifPresentOrElse(container -> version = container.getMetadata().getVersion().getFriendlyString(),
() -> System.out.println("Haxxor: Could not get mod version"));
HaxxorModule.init();
auto_farm_key = (StickyKeyBinding) KeyBindingHelper.registerKeyBinding(new StickyKeyBinding(
"key.haxxor.auto_farm",
GLFW.GLFW_KEY_Z,

View File

@ -1,11 +0,0 @@
package cmods.haxxor.client.options;
public class BooleanOption extends Option<Boolean> {
BooleanOption(Boolean default_value) {
super(default_value);
}
public boolean toggle() {
return value = !value;
}
}

View File

@ -1,30 +1,37 @@
package cmods.haxxor.client.options;
import cmods.cmods.api.ModuleOptions;
import cmods.cmods.client.options.BooleanOption;
import cmods.cmods.client.options.CmodsOptions;
import cmods.cmods.client.options.IntegerOption;
import cmods.haxxor.client.AutoFarmer;
import net.fabricmc.loader.api.FabricLoader;
import org.jetbrains.annotations.Nullable;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Properties;
public final class HaxxorOptions {
public final class HaxxorOptions extends ModuleOptions {
private static HaxxorOptions instance = null;
private static final String MODULE_PREFIX = "haxxor.";
private final Path properties_file = FabricLoader.getInstance().getConfigDir().resolve("Haxxor.properties");
public final AutoFarmerOptions autoFarmer;
public final UIOptions uiOptions;
public BooleanOption flyHackEnabled = new BooleanOption(false);
public BooleanOption cancelFallDamage = new BooleanOption(true);
public final BooleanOption flyHackEnabled = new BooleanOption(false);
public final BooleanOption cancelFallDamage = new BooleanOption(true);
public static HaxxorOptions getInstance() {
if (instance == null)
if (instance == null) {
instance = new HaxxorOptions();
CmodsOptions.addOptions(instance);
}
return instance;
}
@ -32,18 +39,9 @@ public final class HaxxorOptions {
private HaxxorOptions() {
autoFarmer = new AutoFarmerOptions();
uiOptions = new UIOptions();
load();
}
public void load() {
Properties properties = new Properties();
try (FileReader reader = new FileReader(properties_file.toFile())) {
properties.load(reader);
} catch (IOException e) {
properties = null;
}
public void load(@Nullable Properties properties) {
// Sub category properties
autoFarmer.load(properties);
uiOptions.load(properties);
@ -52,9 +50,7 @@ public final class HaxxorOptions {
cancelFallDamage.value = getBooleanProperty(properties, "cancel_fall_damage", cancelFallDamage.value);
}
public void save() {
Properties properties = new Properties();
public void save(Properties properties) {
// Sub category properties
autoFarmer.save(properties);
uiOptions.save(properties);
@ -84,22 +80,22 @@ public final class HaxxorOptions {
public static class AutoFarmerOptions {
private final String PREFIX = "auto_farmer.";
private final String PREFIX = MODULE_PREFIX + "auto_farmer.";
public BooleanOption enabled = new BooleanOption(false);
public BooleanOption move_seeds = new BooleanOption(true);
public final BooleanOption enabled = new BooleanOption(false);
public final BooleanOption move_seeds = new BooleanOption(true);
public IntegerOption min_y = new IntegerOption(-2);
public IntegerOption max_y = new IntegerOption(1);
public final IntegerOption min_y = new IntegerOption(-2);
public final IntegerOption max_y = new IntegerOption(1);
public IntegerOption horizontal_reach = new IntegerOption(4);
public IntegerOption max_actions_per_tick = new IntegerOption(30);
public final IntegerOption horizontal_reach = new IntegerOption(4);
public final IntegerOption max_actions_per_tick = new IntegerOption(30);
public final BooleanOption[] seeds_enabled = new BooleanOption[AutoFarmer.crops.length];
public final BooleanOption[] crops_enabled = new BooleanOption[AutoFarmer.crops.length];
public AutoFarmerOptions() { }
AutoFarmerOptions() { }
private void load(@Nullable Properties properties) {
@ -149,27 +145,21 @@ public final class HaxxorOptions {
}
public static class UIOptions {
private final String PREFIX = "ui.";
private final String PREFIX = MODULE_PREFIX + "ui.";
public BooleanOption enabled = new BooleanOption(true);
public BooleanOption show_coordinates = new BooleanOption(true);
public BooleanOption show_auto_farmer = new BooleanOption(true);
public BooleanOption show_fly_hack = new BooleanOption(true);
public final BooleanOption show_auto_farmer = new BooleanOption(true);
public final BooleanOption show_fly_hack = new BooleanOption(true);
public UIOptions() { }
UIOptions() { }
private void load(@Nullable Properties properties) {
enabled.value = getBooleanProperty(properties, PREFIX + "enabled", true);
show_coordinates.value = getBooleanProperty(properties, PREFIX + "show_coordinates", true);
show_auto_farmer.value = getBooleanProperty(properties, PREFIX + "show_auto_farmer", true);
show_fly_hack.value = getBooleanProperty(properties, PREFIX + "show_fly_hack", true);
}
private void save(Properties properties) {
properties.setProperty(PREFIX + "enabled", enabled.value.toString());
properties.setProperty(PREFIX + "show_coordinates", show_coordinates.value.toString());
properties.setProperty(PREFIX + "show_auto_farmer", show_auto_farmer.value.toString());
properties.setProperty(PREFIX + "show_fly_hack", show_fly_hack.value.toString());
}

View File

@ -1,23 +0,0 @@
package cmods.haxxor.client.options;
public class IntegerOption extends Option<Integer> {
IntegerOption(Integer default_value) {
super(default_value);
}
public Integer inc() {
return inc(1);
}
public Integer inc(int amount) {
return value += amount;
}
public Integer dec() {
return dec(1);
}
public Integer dec(int amount) {
return value -= amount;
}
}

View File

@ -1,17 +0,0 @@
package cmods.haxxor.client.options;
public class Option<T> {
T value;
Option(T default_value) {
value = default_value;
}
public T get() {
return value;
}
public void set(T new_value) {
value = new_value;
}
}

View File

@ -1,14 +0,0 @@
package cmods.haxxor.client.ui;
public class Constants {
public static final int buttonWidth = 150;
public static final int buttonHeight = 20;
public static final int column1_offset = -5 - buttonWidth;
public static final int column2_offset = 5;
public static final float startHeight_multiplier = 1.0f / 6.0f;
public static final int rowIncrement = buttonHeight + 5;
public static final int doneButtonWidth = buttonWidth + buttonWidth / 3;
public static final int doneButtonX_offset = -(doneButtonWidth / 2);
public static final int doneButtonRowIncrement = rowIncrement + 4;
}

View File

@ -1,5 +1,7 @@
package cmods.haxxor.client.ui;
import cmods.cmods.client.options.CmodsOptions;
import cmods.cmods.client.ui.ToggleButton;
import cmods.haxxor.client.AutoFarmer;
import cmods.haxxor.client.options.HaxxorOptions;
import net.minecraft.client.gui.screen.Screen;
@ -11,10 +13,11 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
import static cmods.haxxor.client.ui.Constants.*;
import static cmods.cmods.client.ui.Constants.*;
public class CropSelectScreen extends Screen {
private final HaxxorOptions options;
private final CmodsOptions global_options = CmodsOptions.getInstance();
private final HaxxorOptions options = HaxxorOptions.getInstance();
private final Screen parent;
private final int heightOffset = 10;
@ -22,7 +25,6 @@ public class CropSelectScreen extends Screen {
protected CropSelectScreen(Screen parent) {
super(Text.translatable("haxxor.options.farmer.crop_select.title"));
this.parent = parent;
options = HaxxorOptions.getInstance();
}
protected void init() {
@ -76,6 +78,6 @@ public class CropSelectScreen extends Screen {
}
public void removed() {
options.save();
global_options.save();
}
}

View File

@ -1,5 +1,8 @@
package cmods.haxxor.client.ui;
import cmods.cmods.client.options.CmodsOptions;
import cmods.cmods.client.ui.IntegerAdjustWidget;
import cmods.cmods.client.ui.ToggleButton;
import cmods.haxxor.client.HaxxorClient;
import cmods.haxxor.client.options.HaxxorOptions;
import net.minecraft.client.gui.screen.Screen;
@ -10,13 +13,14 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
import static cmods.haxxor.client.ui.Constants.*;
import static cmods.cmods.client.ui.Constants.*;
public class FarmerOptionsScreen extends Screen {
private final Screen parent;
private final CmodsOptions global_options = CmodsOptions.getInstance();
private final HaxxorOptions options = HaxxorOptions.getInstance();
protected FarmerOptionsScreen(Screen parent) {
public FarmerOptionsScreen(Screen parent) {
super(Text.translatable("haxxor.options.farmer.title"));
this.parent = parent;
}
@ -79,6 +83,6 @@ public class FarmerOptionsScreen extends Screen {
}
public void removed() {
options.save();
global_options.save();
}
}

View File

@ -1,5 +1,7 @@
package cmods.haxxor.client.ui;
import cmods.cmods.client.options.CmodsOptions;
import cmods.cmods.client.ui.ToggleButton;
import cmods.haxxor.client.HaxxorClient;
import cmods.haxxor.client.options.HaxxorOptions;
import net.minecraft.client.gui.screen.Screen;
@ -10,11 +12,12 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
import static cmods.haxxor.client.ui.Constants.*;
import static cmods.cmods.client.ui.Constants.*;
public class HaxxorOptionsScreen extends Screen {
private final HaxxorOptions options = HaxxorOptions.getInstance();
private final Screen parent;
private final CmodsOptions global_options = CmodsOptions.getInstance();
private final HaxxorOptions options = HaxxorOptions.getInstance();
public HaxxorOptionsScreen(Screen parent) {
super(Text.translatable("haxxor.options.title"));
@ -31,15 +34,15 @@ public class HaxxorOptionsScreen extends Screen {
grid.getMainPositioner().marginX(5).marginBottom(4).alignHorizontalCenter();
GridWidget.Adder adder = grid.createAdder(2);
adder.add(ButtonWidget.builder(Text.translatable("haxxor.options.ui"),
button -> this.client.setScreen(new UIOptionsScreen(this))).build());
adder.add(ButtonWidget.builder(Text.translatable("haxxor.options.farmer"),
button -> this.client.setScreen(new FarmerOptionsScreen(this))).build());
adder.add(new ToggleButton(0, 0, buttonWidth, buttonHeight,
Text.translatable("haxxor.options.fall_damage"), options.cancelFallDamage));
adder.add(ButtonWidget.builder(Text.translatable("haxxor.options.ui"),
button -> this.client.setScreen(new UIOptionsScreen(this))).build());
adder.add(ButtonWidget.builder(ScreenTexts.DONE, button -> client.setScreen(parent))
.width(doneButtonWidth).build(), 2, adder.copyPositioner().marginTop(doneButtonRowIncrement));
@ -60,6 +63,6 @@ public class HaxxorOptionsScreen extends Screen {
}
public void removed() {
options.save();
global_options.save();
}
}

View File

@ -1,80 +0,0 @@
package cmods.haxxor.client.ui;
import cmods.haxxor.client.options.IntegerOption;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.ClickableWidget;
import net.minecraft.client.gui.widget.WrapperWidget;
import net.minecraft.text.Text;
import java.util.ArrayList;
import java.util.List;
public class IntegerAdjustWidget extends WrapperWidget {
private final ArrayList<ButtonWidget> children;
private final IntegerOption option;
private final int delta;
public IntegerAdjustWidget(Text text, IntegerOption option) {
this(text, option, 1);
}
public IntegerAdjustWidget(Text text, IntegerOption option, int delta) {
super(0, 0, 150, 20, text);
this.option = option;
this.delta = delta;
children = new ArrayList<>(3);
refreshDimensions();
}
@Override
protected List<? extends ClickableWidget> wrappedWidgets() {
return children;
}
@Override
public void setWidth(int width) {
super.setWidth(width);
refreshDimensions();
}
@Override
public void setX(int x) {
super.setX(x);
refreshDimensions();
}
@Override
public void setY(int y) {
super.setY(y);
refreshDimensions();
}
@Override
public void setPos(int x, int y) {
super.setPos(x, y);
refreshDimensions();
}
private void refreshDimensions() {
final int button_width = 25;
final String labelStr = getMessage().getString() + ": ";
children.clear();
ButtonWidget middle = ButtonWidget.builder(Text.literal(labelStr + option.get()), button -> {})
.dimensions(getX() + button_width - 1, getY(),width - (button_width * 2) + 2, height).build();
ButtonWidget sub = ButtonWidget.builder(Text.literal("-"),
button -> middle.setMessage(Text.literal(labelStr + option.dec(delta))))
.dimensions(getX(), getY(), button_width, height).build();
ButtonWidget add = ButtonWidget.builder(Text.literal("+"),
button -> middle.setMessage(Text.literal(labelStr + option.inc(delta))))
.dimensions(getX() + width - button_width + 1, getY(), button_width, height).build();
children.add(sub);
children.add(middle);
children.add(add);
}
}

View File

@ -1,7 +0,0 @@
package cmods.haxxor.client.ui;
import net.minecraft.text.Text;
public record Line(Text text, int color, int indent) {
}

View File

@ -1,6 +1,6 @@
package cmods.haxxor.client.ui;
import cmods.haxxor.client.options.IntegerOption;
import cmods.cmods.client.options.IntegerOption;
import net.minecraft.client.gui.widget.SliderWidget;
import net.minecraft.text.Text;

View File

@ -1,43 +0,0 @@
package cmods.haxxor.client.ui;
import cmods.haxxor.client.options.BooleanOption;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import org.apache.http.util.TextUtils;
public class ToggleButton extends ButtonWidget {
private final String name;
private final BooleanOption option;
private final String enabledText = Text.translatable("haxxor.state.enabled").getString();
private final String disabledText = Text.translatable("haxxor.state.disabled").getString();
public ToggleButton(int x, int y, int width, int height, Text name, BooleanOption option) {
this(x, y, width, height, name, option, ButtonWidget.DEFAULT_NARRATION_SUPPLIER);
}
public ToggleButton(int x, int y, int width, int height, Text name, BooleanOption option,
NarrationSupplier narrationSupplier) {
super(x, y, width, height, name, b -> {}, narrationSupplier);
this.name = !TextUtils.isEmpty(name.getString()) ? name.getString() + ": " : "";
this.option = option;
}
private void updateText() {
setMessage(Text.literal(name + (option.get() ? enabledText : disabledText)));
}
@Override
public void onPress() {
option.toggle();
}
@Override
public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
updateText();
super.renderButton(matrices, mouseX, mouseY, delta);
}
}

View File

@ -1,5 +1,7 @@
package cmods.haxxor.client.ui;
import cmods.cmods.client.options.CmodsOptions;
import cmods.cmods.client.ui.ToggleButton;
import cmods.haxxor.client.options.HaxxorOptions;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
@ -9,10 +11,11 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
import static cmods.haxxor.client.ui.Constants.*;
import static cmods.cmods.client.ui.Constants.*;
public class UIOptionsScreen extends Screen {
private final Screen parent;
private final CmodsOptions global_options = CmodsOptions.getInstance();
private final HaxxorOptions options = HaxxorOptions.getInstance();
public UIOptionsScreen(Screen parent) {
@ -31,10 +34,7 @@ public class UIOptionsScreen extends Screen {
GridWidget.Adder adder = grid.createAdder(2);
adder.add(new ToggleButton(0, 0, buttonWidth, buttonHeight,
Text.translatable("haxxor.options.ui.hud_enabled"), options.uiOptions.enabled));
adder.add(new ToggleButton(0, 0, buttonWidth, buttonHeight,
Text.translatable("haxxor.options.ui.show_coordinates"), options.uiOptions.show_coordinates));
Text.translatable("haxxor.options.ui.hud_enabled"), global_options.uiOptions.enabled));
adder.add(new ToggleButton(0, 0, buttonWidth, buttonHeight,
Text.translatable("haxxor.options.ui.show_farmer"), options.uiOptions.show_auto_farmer));
@ -57,6 +57,6 @@ public class UIOptionsScreen extends Screen {
}
public void removed() {
options.save();
global_options.save();
}
}

View File

@ -1,95 +0,0 @@
package cmods.haxxor.mixin;
import cmods.haxxor.client.AutoFarmer;
import cmods.haxxor.client.options.HaxxorOptions;
import cmods.haxxor.client.ui.Line;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.ArrayList;
@Mixin(InGameHud.class)
public abstract class HudMixin extends DrawableHelper {
@Shadow @Final private MinecraftClient client;
@Shadow public abstract TextRenderer getTextRenderer();
@Inject(at = @At("TAIL"), method = "render")
private void render(MatrixStack matrices, float tickDelta, CallbackInfo callback) {
HaxxorOptions options = HaxxorOptions.getInstance();
if (this.client.options.debugEnabled || this.client.isPaused() || client.player == null ||
!options.uiOptions.enabled.get()) {
return;
}
TextRenderer textRenderer = this.getTextRenderer();
ArrayList<Line> lines = new ArrayList<>();
int x = 5;
int y = 5;
int white = 0xffffff;
int red = 0xff0000;
int green = 0x00ff00;
if (options.uiOptions.show_coordinates.get()) {
BlockPos pos = client.player.getBlockPos();
String coordinate_string = String.format("X: %d, Y: %d, Z: %d", pos.getX(), pos.getY(), pos.getZ());
lines.add(new Line(Text.literal(coordinate_string), white, 0));
}
if (options.uiOptions.show_auto_farmer.get()) {
if (options.autoFarmer.enabled.get()) {
lines.add(new Line(Text.translatable("haxxor.hud.auto_farm_enabled")
.append(Text.translatable("haxxor.state.on")), green, 0));
} else {
lines.add(new Line(Text.translatable("haxxor.hud.auto_farm_enabled")
.append(Text.translatable("haxxor.state.off")), red, 0));
}
if (AutoFarmer.canFarm()) {
lines.add(new Line(Text.translatable("haxxor.actions.available"), green, 1));
}
}
if (options.uiOptions.show_fly_hack.get()) {
if (options.flyHackEnabled.get()) {
lines.add(new Line(Text.translatable("haxxor.hud.fly_hack_enabled")
.append(Text.translatable("haxxor.state.on")), green, 0));
} else {
lines.add(new Line(Text.translatable("haxxor.hud.fly_hack_enabled")
.append(Text.translatable("haxxor.state.off")), red, 0));
}
}
for (int i = 0; i < lines.size(); i++) {
Line line = lines.get(i);
if (i > 0 && lines.get(i - 1).indent() > line.indent()) {
y += 3;
} else if (i > 0 && lines.get(i - 1).indent() < line.indent()) {
y += 2;
}
DrawableHelper.drawTextWithShadow(matrices, textRenderer, line.text(), x + (5 * line.indent()), y,
line.color());
y += textRenderer.fontHeight;
}
}
}

View File

@ -1,29 +0,0 @@
package cmods.haxxor.mixin;
import cmods.haxxor.client.ui.HaxxorOptionsScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.option.OptionsScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.text.Text;
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;
@Mixin(OptionsScreen.class)
public class OptionsMixin extends Screen {
protected OptionsMixin(Text title) {
super(title);
}
@Inject(at = @At("TAIL"), method = "init")
private void init(CallbackInfo ci) {
if (client == null)
return;
addDrawableChild(ButtonWidget.builder(Text.translatable("haxxor.options"),
button -> client.setScreen(new HaxxorOptionsScreen(this)))
.position(20, 20).width(100).build());
}
}

View File

@ -1,30 +0,0 @@
package cmods.haxxor.mixin;
import cmods.haxxor.client.ui.HaxxorOptionsScreen;
import net.minecraft.client.gui.screen.GameMenuScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.text.Text;
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;
@Mixin(GameMenuScreen.class)
public class PauseMixin extends Screen {
protected PauseMixin(Text title) {
super(title);
}
@Inject(at = @At("TAIL"), method = "init")
public void init(CallbackInfo ci) {
if (client == null)
return;
addDrawableChild(ButtonWidget.builder(Text.translatable("haxxor.options"),
button -> client.setScreen(new HaxxorOptionsScreen(this)))
.position(20, 20).width(100).build());
}
}

View File

@ -2,7 +2,7 @@
"schemaVersion": 1,
"id": "haxxor",
"version": "${version}",
"name": "Haxxor",
"name": "Cmods - Haxxor",
"description": "A collection of hacks because yes",
"authors": [
"Cameron Reed"
@ -23,6 +23,7 @@
"depends": {
"fabricloader": ">=0.14.11",
"fabric": "*",
"minecraft": "1.19.3"
"minecraft": "1.19.3",
"cmods": "1.0.0"
}
}

View File

@ -5,11 +5,7 @@
"compatibilityLevel": "JAVA_17",
"mixins": [
],
"client": [
"HudMixin",
"OptionsMixin",
"PauseMixin"
],
"client": [],
"injectors": {
"defaultRequire": 1
}