Compare commits

..

21 Commits
v1.1.0 ... main

Author SHA1 Message Date
705c57a571 1.21.0 2024-07-01 00:02:37 -06:00
f0cc430e2e Update to 1.20.4 2024-02-15 14:51:43 -07:00
ee3879dbf3 Update to 1.20.1 2023-08-28 22:37:21 -06:00
02227b5a7d Update to 1.20 2023-08-28 22:31:56 -06:00
7e0ea95b67 Update to 1.19.4 2023-03-14 13:24:33 -06:00
745c6b36a5 removed libs dir from .gitignore 2023-02-25 22:23:58 -07:00
38e8eeabd3 Version bump 2023-02-25 22:01:44 -07:00
52c0e78be5 Fixed an issue where some crop seeds were null, breaking seed replanting
And yes, this is what caused it. I know it seems unrelated
2023-02-25 22:00:46 -07:00
110bd42042 Just reordered some items 2023-02-25 21:59:47 -07:00
930c66aa51 Version bump 2023-02-22 22:18:57 -07:00
c03c04eca1 GLOW 2023-02-22 22:17:35 -07:00
682aeedc7e Added teleporting up and down 2023-02-20 11:32:43 -07:00
f046b5c458 Disabling sugar cane seed will now break the bottom block 2023-02-19 20:24:54 -07:00
ba64b3190b Fixed spectator flight 2023-02-19 18:57:33 -07:00
93884ec751 Minor fixes 2023-02-10 10:29:10 -07:00
0d56349c53 Huge update to v2.0.0 2023-01-26 17:27:39 -07:00
811e8fc6a3 Add UI options and Coordinate UI 2023-01-24 21:38:17 -07:00
55425da586 Store options in a properties file 2022-12-12 22:47:21 -07:00
9692e06a13 Version bump 2022-12-12 19:23:51 -07:00
3e75601832 Updated to 1.19.3 2022-12-12 19:06:37 -07:00
5c5e86d1d8 Minor changes 2022-12-10 20:45:02 -07:00
34 changed files with 1074 additions and 621 deletions

View File

@ -1,11 +1,15 @@
plugins { plugins {
id 'fabric-loom' version '1.0-SNAPSHOT' id 'fabric-loom' version '1.7-SNAPSHOT'
id 'maven-publish' id 'maven-publish'
} }
version = project.mod_version version = project.mod_version
group = project.maven_group group = project.maven_group
base {
archivesName = project.archives_base_name
}
repositories { repositories {
// Add repositories to retrieve artifacts from in here. // Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because // You should only use this when depending on other mods because
@ -18,6 +22,17 @@ repositories {
} }
} }
loom {
splitEnvironmentSourceSets()
mods {
"haxxor" {
sourceSet sourceSets.client
sourceSet sourceSets.main
}
}
}
dependencies { dependencies {
// To change the versions see the gradle.properties file // To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}" minecraft "com.mojang:minecraft:${project.minecraft_version}"
@ -26,52 +41,43 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway. // Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation files("libs/cmods-1.2.2-dev.jar")
modCompileOnly "com.terraformersmc:modmenu:4.1.1" modCompileOnly "com.terraformersmc:modmenu:4.1.1"
} }
processResources { processResources {
inputs.property "version", project.version inputs.property "version", project.version
filteringCharset "UTF-8"
filesMatching("fabric.mod.json") { filesMatching("fabric.mod.json") {
expand "version": project.version expand "version": project.version
} }
} }
def targetJavaVersion = 17
tasks.withType(JavaCompile).configureEach { tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is it.options.release = 21
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
it.options.release = targetJavaVersion
}
} }
java { java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
archivesBaseName = project.archives_base_name
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present. // if it is present.
// If you remove this line, sources will not be generated. // If you remove this line, sources will not be generated.
withSourcesJar() withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
} }
jar { jar {
from("LICENSE") { from("LICENSE") {
rename { "${it}_${project.archivesBaseName}" } rename { "${it}_${project.base.archivesName.get()}"}
} }
} }
// configure the maven publication // configure the maven publication
publishing { publishing {
publications { publications {
mavenJava(MavenPublication) { create("mavenJava", MavenPublication) {
artifactId = project.archives_base_name
from components.java from components.java
} }
} }

View File

@ -2,13 +2,13 @@
org.gradle.jvmargs=-Xmx2G org.gradle.jvmargs=-Xmx2G
# Fabric Properties # Fabric Properties
# check these on https://modmuss50.me/fabric.html # check these on https://modmuss50.me/fabric.html
minecraft_version=1.19.2 minecraft_version=1.21
yarn_mappings=1.19.2+build.28 yarn_mappings=1.21+build.7
loader_version=0.14.10 loader_version=0.15.11
# Mod Properties # Mod Properties
mod_version=1.1.0 mod_version=2.4.2
maven_group=cmods maven_group=cmods
archives_base_name=haxxor archives_base_name=haxxor
# Dependencies # Dependencies
# check this on https://modmuss50.me/fabric.html # check this on https://modmuss50.me/fabric.html
fabric_version=0.67.1+1.19.2 fabric_version=0.100.4+1.21

View File

@ -1 +1 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip

View File

@ -1,5 +1,10 @@
package cmods.haxxor.client; package cmods.haxxor;
import cmods.haxxor.hacks.AutoFarmer;
import cmods.haxxor.hacks.Elevator;
import cmods.haxxor.hacks.FallDamageCancel;
import cmods.haxxor.hacks.FlyHack;
import cmods.haxxor.options.HaxxorOptions;
import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
@ -15,11 +20,12 @@ import java.util.Optional;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public class HaxxorClient implements ClientModInitializer { public class HaxxorClient implements ClientModInitializer {
public static String MOD_ID = "haxxor"; public static final String MOD_ID = "haxxor";
public static String version = "Unknown"; public static String version = "Unknown";
private static StickyKeyBinding auto_farm_key; private static StickyKeyBinding auto_farm_key;
private static StickyKeyBinding fly_hack_key; private static StickyKeyBinding fly_hack_key;
private static StickyKeyBinding glow_key;
private static final HaxxorOptions options = HaxxorOptions.getInstance(); private static final HaxxorOptions options = HaxxorOptions.getInstance();
@Override @Override
@ -28,6 +34,8 @@ public class HaxxorClient implements ClientModInitializer {
modContainer.ifPresentOrElse(container -> version = container.getMetadata().getVersion().getFriendlyString(), modContainer.ifPresentOrElse(container -> version = container.getMetadata().getVersion().getFriendlyString(),
() -> System.out.println("Haxxor: Could not get mod version")); () -> System.out.println("Haxxor: Could not get mod version"));
HaxxorModule.init();
auto_farm_key = (StickyKeyBinding) KeyBindingHelper.registerKeyBinding(new StickyKeyBinding( auto_farm_key = (StickyKeyBinding) KeyBindingHelper.registerKeyBinding(new StickyKeyBinding(
"key.haxxor.auto_farm", "key.haxxor.auto_farm",
GLFW.GLFW_KEY_Z, GLFW.GLFW_KEY_Z,
@ -42,22 +50,40 @@ public class HaxxorClient implements ClientModInitializer {
() -> true () -> true
)); ));
glow_key = (StickyKeyBinding) KeyBindingHelper.registerKeyBinding(new StickyKeyBinding(
"key.haxxor.glow",
-1,
"category.haxxor.options",
() -> true
));
AutoFarmer.init(); AutoFarmer.init();
Elevator.init();
ClientTickEvents.END_CLIENT_TICK.register(this::tick); ClientTickEvents.END_CLIENT_TICK.register(this::tick);
} }
public static boolean toggleAutoFarmer() { public static boolean toggleAutoFarmer() {
auto_farm_key.setPressed(true); auto_farm_key.setPressed(true);
options.autoFarmer.enabled.set(auto_farm_key.isPressed());
return options.autoFarmer.enabled = auto_farm_key.isPressed(); return options.autoFarmer.enabled.get();
}
public static boolean toggleGlow() {
glow_key.setPressed(true);
options.glow.enabled.set(glow_key.isPressed());
return options.glow.enabled.get();
} }
private void tick(MinecraftClient client) { private void tick(MinecraftClient client) {
options.autoFarmer.enabled = auto_farm_key.isPressed(); options.autoFarmer.enabled.set(auto_farm_key.isPressed());
options.flyHack.enabled = fly_hack_key.isPressed(); options.flyHackEnabled.set(fly_hack_key.isPressed());
options.glow.enabled.set(glow_key.isPressed());
AutoFarmer.tick(client); AutoFarmer.tick(client);
Elevator.tick(client);
FlyHack.tick(client); FlyHack.tick(client);
FallDamageCancel.tick(client); FallDamageCancel.tick(client);
} }

View File

@ -0,0 +1,92 @@
package cmods.haxxor;
import cmods.cmods.api.ButtonBuilder;
import cmods.cmods.api.Module;
import cmods.cmods.api.ModuleOptions;
import cmods.cmods.ui.Line;
import cmods.cmods.ui.ToggleButton;
import cmods.haxxor.hacks.AutoFarmer;
import cmods.haxxor.options.HaxxorOptions;
import cmods.haxxor.ui.ElevatorOptionsScreen;
import cmods.haxxor.ui.FarmerOptionsScreen;
import cmods.haxxor.ui.GlowOptionsScreen;
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.ui.Constants.buttonHeight;
import static cmods.cmods.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() {
final HaxxorOptions options = HaxxorOptions.getInstance();
ArrayList<ButtonBuilder> optionButtons = new ArrayList<>(4);
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) -> ButtonWidget.builder(Text.translatable("haxxor.options.elevator"),
button -> client.setScreen(new ElevatorOptionsScreen(screen))).build()));
optionButtons.add(((screen, client) -> ButtonWidget.builder(Text.translatable("haxxor.options.glow"),
button -> client.setScreen(new GlowOptionsScreen(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,6 +1,6 @@
package cmods.haxxor.client; package cmods.haxxor;
import cmods.haxxor.client.ui.HaxxorOptionsScreen; import cmods.haxxor.ui.HaxxorOptionsScreen;
import com.terraformersmc.modmenu.api.ConfigScreenFactory; import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi; import com.terraformersmc.modmenu.api.ModMenuApi;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;

View File

@ -1,5 +1,6 @@
package cmods.haxxor.client; package cmods.haxxor.hacks;
import cmods.haxxor.options.HaxxorOptions;
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import net.minecraft.block.*; import net.minecraft.block.*;
@ -30,7 +31,7 @@ public class AutoFarmer { // Really just a namespace and needed to separate thin
new AutoFarmerCropType(Blocks.POTATOES, Items.POTATO, GROWTH_PATTERN.BASIC, Blocks.FARMLAND), new AutoFarmerCropType(Blocks.POTATOES, Items.POTATO, GROWTH_PATTERN.BASIC, Blocks.FARMLAND),
new AutoFarmerCropType(Blocks.CARROTS, Items.CARROT, GROWTH_PATTERN.BASIC, Blocks.FARMLAND), new AutoFarmerCropType(Blocks.CARROTS, Items.CARROT, GROWTH_PATTERN.BASIC, Blocks.FARMLAND),
new AutoFarmerCropType(Blocks.NETHER_WART, Items.NETHER_WART, GROWTH_PATTERN.BASIC, Blocks.SOUL_SAND), new AutoFarmerCropType(Blocks.NETHER_WART, Items.NETHER_WART, GROWTH_PATTERN.BASIC, Blocks.SOUL_SAND),
new AutoFarmerCropType(Blocks.SUGAR_CANE, null, GROWTH_PATTERN.LEAVE_BASE, null) new AutoFarmerCropType(Blocks.SUGAR_CANE, Items.SUGAR_CANE, GROWTH_PATTERN.LEAVE_BASE, null)
}; };
@ -42,7 +43,7 @@ public class AutoFarmer { // Really just a namespace and needed to separate thin
PLACE_OFF_HAND PLACE_OFF_HAND
} }
private enum GROWTH_PATTERN { public enum GROWTH_PATTERN {
BASIC, BASIC,
LEAVE_BASE LEAVE_BASE
} }
@ -60,22 +61,22 @@ public class AutoFarmer { // Really just a namespace and needed to separate thin
} }
public static boolean canFarm() { public static boolean canFarm() {
return queuedActions.size() > 0; return !queuedActions.isEmpty();
} }
public static void tick(MinecraftClient client) { public static void tick(MinecraftClient client) {
if (client.player == null) if (client.player == null)
return; return;
if (queuedStopPackets.size() > 0) if (!queuedStopPackets.isEmpty())
sendStopPackets(client); sendStopPackets(client);
scanBlocks(client); scanBlocks(client);
if (options.move_seeds && options.enabled) if (options.move_seeds.get() && options.enabled.get())
adjustInventory(client); adjustInventory(client);
findActions(client); findActions(client);
if (options.enabled) if (options.enabled.get())
run(client); run(client);
} }
@ -110,7 +111,7 @@ public class AutoFarmer { // Really just a namespace and needed to separate thin
for (int i = 0; i < crops.length; i++) { for (int i = 0; i < crops.length; i++) {
int slot = inventory.getSlotWithStack(new ItemStack(crops[i].seed_type)); int slot = inventory.getSlotWithStack(new ItemStack(crops[i].seed_type));
if (crops[i].seed_type != null && crops[i].planted_on != null && block.isOf(crops[i].planted_on) && if (crops[i].seed_type != null && crops[i].planted_on != null && block.isOf(crops[i].planted_on) &&
options.crops_enabled[i] && slot != -1) { options.crops_enabled[i].get() && slot != -1) {
if (!item_in_main) { if (!item_in_main) {
if (PlayerInventory.isValidHotbarIndex(slot)) { if (PlayerInventory.isValidHotbarIndex(slot)) {
selectSlot(client, slot); selectSlot(client, slot);
@ -168,9 +169,9 @@ public class AutoFarmer { // Really just a namespace and needed to separate thin
potentialActions.clear(); potentialActions.clear();
BlockPos playerPos = client.player.getBlockPos(); BlockPos playerPos = client.player.getBlockPos();
for (int y = options.min_y; y <= options.max_y; y++) { for (int y = options.min_y.get(); y <= options.max_y.get(); y++) {
for (int x = -options.horizontal_reach; x <= options.horizontal_reach; x++) { for (int x = -options.horizontal_reach.get(); x <= options.horizontal_reach.get(); x++) {
for (int z = -options.horizontal_reach; z <= options.horizontal_reach; z++) { for (int z = -options.horizontal_reach.get(); z <= options.horizontal_reach.get(); z++) {
BlockPos pos = playerPos.add(x, y, z); BlockPos pos = playerPos.add(x, y, z);
ACTION_TYPE action = checkBlock(client, pos); ACTION_TYPE action = checkBlock(client, pos);
@ -192,17 +193,21 @@ public class AutoFarmer { // Really just a namespace and needed to separate thin
AutoFarmerCropType cropType = crops[i]; AutoFarmerCropType cropType = crops[i];
if (cropType.growth_pattern == GROWTH_PATTERN.BASIC && block.isOf(cropType.crop_type) && if (cropType.growth_pattern == GROWTH_PATTERN.BASIC && block.isOf(cropType.crop_type) &&
options.crops_enabled[i]) { options.crops_enabled[i].get()) {
return isMature(block, cropType.crop_type.getClass()) ? ACTION_TYPE.BREAK : ACTION_TYPE.NONE; return isMature(block, cropType.crop_type.getClass()) ? ACTION_TYPE.BREAK : ACTION_TYPE.NONE;
} }
if (cropType.growth_pattern == GROWTH_PATTERN.LEAVE_BASE && block.isOf(cropType.crop_type) && if (cropType.growth_pattern == GROWTH_PATTERN.LEAVE_BASE && block.isOf(cropType.crop_type) &&
options.crops_enabled[i]) { options.crops_enabled[i].get()) {
return isSecondBlock(client.world, pos, cropType.crop_type) ? ACTION_TYPE.BREAK : ACTION_TYPE.NONE; if (options.seeds_enabled[i].get()) {
return isSecondBlock(client.world, pos, cropType.crop_type) ? ACTION_TYPE.BREAK : ACTION_TYPE.NONE;
} else {
return isBottomBlock(client.world, pos, cropType.crop_type) ? ACTION_TYPE.BREAK : ACTION_TYPE.NONE;
}
} }
if (cropType.seed_type != null && cropType.planted_on != null && block.isOf(cropType.planted_on) && if (cropType.seed_type != null && cropType.planted_on != null && block.isOf(cropType.planted_on) &&
client.world.getBlockState(pos.up()).isAir() && options.seeds_enabled[i]) { client.world.getBlockState(pos.up()).isAir() && options.seeds_enabled[i].get()) {
return ACTION_TYPE.PLACE; return ACTION_TYPE.PLACE;
} }
} }
@ -226,7 +231,7 @@ public class AutoFarmer { // Really just a namespace and needed to separate thin
} }
} }
if (queuedActions.size() >= options.max_actions_per_tick) if (queuedActions.size() >= options.max_actions_per_tick.get())
return; return;
} }
} }
@ -244,7 +249,7 @@ public class AutoFarmer { // Really just a namespace and needed to separate thin
AutoFarmerCropType cropType = crops[i]; AutoFarmerCropType cropType = crops[i];
if (cropType.seed_type != null && cropType.planted_on != null && block.isOf(cropType.planted_on) && if (cropType.seed_type != null && cropType.planted_on != null && block.isOf(cropType.planted_on) &&
client.world.getBlockState(pos.up()).isAir() && options.seeds_enabled[i]) { client.world.getBlockState(pos.up()).isAir() && options.seeds_enabled[i].get()) {
if (mainHandItem.isOf(cropType.seed_type)) { if (mainHandItem.isOf(cropType.seed_type)) {
return ACTION_TYPE.PLACE_MAIN_HAND; return ACTION_TYPE.PLACE_MAIN_HAND;
} else if (offHandItem.isOf(cropType.seed_type)) { } else if (offHandItem.isOf(cropType.seed_type)) {
@ -260,7 +265,7 @@ public class AutoFarmer { // Really just a namespace and needed to separate thin
if (block.getBlock() instanceof CropBlock) if (block.getBlock() instanceof CropBlock)
return ((CropBlock) block.getBlock()).isMature(block); return ((CropBlock) block.getBlock()).isMature(block);
if (blockType == NetherWartBlock.class) if (blockType == NetherWartBlock.class)
return block.get(NetherWartBlock.AGE) >= NetherWartBlock.field_31199; return block.get(NetherWartBlock.AGE) >= NetherWartBlock.MAX_AGE;
return false; return false;
} }
@ -270,6 +275,10 @@ public class AutoFarmer { // Really just a namespace and needed to separate thin
!world.getBlockState(pos.down().down()).isOf(crop_type); !world.getBlockState(pos.down().down()).isOf(crop_type);
} }
private static boolean isBottomBlock(ClientWorld world, BlockPos pos, Block crop_type) {
return world.getBlockState(pos).isOf(crop_type) && !world.getBlockState(pos.down()).isOf(crop_type);
}
private static void sendStopPackets(MinecraftClient client) { private static void sendStopPackets(MinecraftClient client) {
if (client.world == null || client.player == null) if (client.world == null || client.player == null)
return; return;

View File

@ -0,0 +1,118 @@
package cmods.haxxor.hacks;
import cmods.haxxor.options.HaxxorOptions;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import org.lwjgl.glfw.GLFW;
import java.util.Objects;
public class Elevator {
private static KeyBinding teleport_up_key;
private static KeyBinding teleport_down_key;
private static boolean up_was_pressed = false;
private static boolean down_was_pressed = false;
private static final HaxxorOptions.ElevatorOptions options = HaxxorOptions.getInstance().elevatorOptions;
public static void init() {
teleport_up_key = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.haxxor.elevator.up",
GLFW.GLFW_KEY_UP,
"category.haxxor.options"
));
teleport_down_key = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.haxxor.elevator.down",
GLFW.GLFW_KEY_DOWN,
"category.haxxor.options"
));
}
public static void tick(MinecraftClient client) {
if (teleport_up_key.isPressed() && !up_was_pressed)
tp_up(client);
if (teleport_down_key.isPressed() && !down_was_pressed)
tp_down(client);
up_was_pressed = teleport_up_key.isPressed();
down_was_pressed = teleport_down_key.isPressed();
}
private static void tp_up(MinecraftClient client) {
if (client == null || client.player == null || client.world == null)
return;
BlockPos blockPos = client.player.getBlockPos();
Vec3d pos = null;
for (int i = 1; i <= options.max_tp_up.get(); i++) {
if (can_tp_to_block(client, blockPos.up(i))) {
pos = blockPos.up(i).toCenterPos();
break;
}
}
if (pos == null) {
if (options.send_too_far_message.get())
client.player.sendMessage(Text.translatable("haxxor.message.elevator.too_far"));
return;
}
teleport(client, pos.getX(), Math.floor(pos.getY()), pos.getZ());
}
private static void tp_down(MinecraftClient client) {
if (client == null || client.player == null || client.world == null)
return;
BlockPos blockPos = client.player.getBlockPos();
Vec3d pos = null;
for (int i = 1; i <= options.max_tp_down.get(); i++) {
if (can_tp_to_block(client, blockPos.down(i))) {
pos = blockPos.down(i).toCenterPos();
break;
}
}
if (pos == null) {
if (options.send_too_far_message.get())
client.player.sendMessage(Text.translatable("haxxor.message.elevator.too_far"));
return;
}
teleport(client, pos.getX(), Math.floor(pos.getY()), pos.getZ());
}
private static boolean can_tp_to_block(MinecraftClient client, BlockPos pos) {
if (client.player == null || client.world == null)
return false;
return client.world.getBlockState(pos.down()).hasSolidTopSurface(client.world, pos, client.player) &&
client.world.getBlockState(pos).isAir() &&
client.world.getBlockState(pos.up()).isAir();
}
private static void teleport(MinecraftClient client, double x, double y, double z) {
if (client.player == null)
return;
Vec3d position = new Vec3d(x, y, z);
if (options.send_tp_message.get())
client.player.sendMessage(Text.translatable("haxxor.message.elevator", position.getX(), position.getY(), position.getZ()));
client.player.setPosition(position);
PlayerMoveC2SPacket packet = new PlayerMoveC2SPacket.PositionAndOnGround(position.getX(), position.getY(),
position.getZ(), client.player.isOnGround());
Objects.requireNonNull(client.getNetworkHandler()).sendPacket(packet);
}
}

View File

@ -1,5 +1,6 @@
package cmods.haxxor.client; package cmods.haxxor.hacks;
import cmods.haxxor.options.HaxxorOptions;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@ -9,21 +10,28 @@ import java.util.Objects;
public class FallDamageCancel { public class FallDamageCancel {
private static final HaxxorOptions options = HaxxorOptions.getInstance(); private static final HaxxorOptions options = HaxxorOptions.getInstance();
private static final int triggerHeight = 4; private static final int triggerHeight = 5;
private static final float heightAdjust = 0.5f; private static final float heightAdjust = 0.5f;
public static void tick(MinecraftClient client) { public static void tick(MinecraftClient client) {
if (!options.cancel_fall_damage || client.world == null || client.player == null || client.player.isOnGround()) if (!options.cancelFallDamage.get() || client.world == null || client.player == null ||
client.player.isCreative() || client.player.isOnGround() || client.player.getVelocity().getY() >= 0)
return; return;
BlockPos playerPos = client.player.getBlockPos(); BlockPos playerPos = client.player.getBlockPos();
if (!client.world.isSpaceEmpty(client.player.getBoundingBox().expand(0, heightAdjust, 0))) {
return;
}
for (int i = 0; i < triggerHeight; i++) { for (int i = 0; i < triggerHeight; i++) {
if (!client.world.getBlockState(playerPos.down(i)).isAir()) { if (!client.world.getBlockState(playerPos.down(i)).isAir()) {
float totalFallDist = client.player.fallDistance + i; float totalFallDist = client.player.fallDistance + i;
if (totalFallDist >= client.player.getSafeFallDistance()) { if (totalFallDist >= client.player.getSafeFallDistance()) {
sendPacket(client); sendPacket(client);
} }
break;
} }
} }
} }

View File

@ -1,5 +1,6 @@
package cmods.haxxor.client; package cmods.haxxor.hacks;
import cmods.haxxor.options.HaxxorOptions;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
@ -7,20 +8,20 @@ import java.util.Objects;
public class FlyHack { public class FlyHack {
private static final HaxxorOptions.FlyHackOptions options = HaxxorOptions.getInstance().flyHack; private static final HaxxorOptions options = HaxxorOptions.getInstance();
private static final int ticksToFirst = 40; private static final int ticksToFirst = 40;
private static final int waitTicks = 8; private static final int waitTicks = 5;
private static final float fallDist = 0.5f; private static final float fallDist = 0.5f;
private static int tickCounter = ticksToFirst; private static int tickCounter = ticksToFirst;
public static void tick(MinecraftClient client) { public static void tick(MinecraftClient client) {
if (client.player == null || client.world == null || client.player.isCreative()) if (client.player == null || client.world == null || client.player.isCreative() || client.player.isSpectator())
return; return;
client.player.getAbilities().allowFlying = options.enabled; client.player.getAbilities().allowFlying = options.flyHackEnabled.get();
if (!options.enabled && client.player.getAbilities().flying) { if (!options.flyHackEnabled.get() && client.player.getAbilities().flying) {
client.player.getAbilities().flying = false; client.player.getAbilities().flying = false;
} }

View File

@ -0,0 +1,18 @@
package cmods.haxxor.mixin;
import cmods.haxxor.options.HaxxorOptions;
import net.minecraft.entity.LivingEntity;
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.CallbackInfoReturnable;
@Mixin(LivingEntity.class)
public class GlobalGlow {
@Inject(method = "isGlowing()Z", at = @At("RETURN"), cancellable = true)
private void isGlowingOverride(CallbackInfoReturnable<Boolean> cir) {
if (HaxxorOptions.getInstance().glow.enabled.get()) {
cir.setReturnValue(true);
}
}
}

View File

@ -0,0 +1,20 @@
package cmods.haxxor.mixin;
import cmods.haxxor.options.HaxxorOptions;
import net.minecraft.entity.Entity;
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.CallbackInfoReturnable;
@Mixin(Entity.class)
public class GlobalGlowAll {
@Inject(method = "isGlowing()Z", at = @At("RETURN"), cancellable = true)
private void isGlowingOverride(CallbackInfoReturnable<Boolean> cir) {
HaxxorOptions options = HaxxorOptions.getInstance();
if (options.glow.enabled.get() && options.glow.include_non_living.get()) {
cir.setReturnValue(true);
}
}
}

View File

@ -0,0 +1,196 @@
package cmods.haxxor.options;
import cmods.cmods.api.ModuleOptions;
import cmods.cmods.options.BooleanOption;
import cmods.cmods.options.IntegerOption;
import cmods.haxxor.hacks.AutoFarmer;
import org.jetbrains.annotations.Nullable;
import java.util.Properties;
import static cmods.cmods.api.PropertyUtils.getBooleanProperty;
import static cmods.cmods.api.PropertyUtils.getIntegerProperty;
public final class HaxxorOptions extends ModuleOptions {
private static HaxxorOptions instance = null;
private static final String MODULE_PREFIX = "haxxor.";
public final AutoFarmerOptions autoFarmer;
public final UIOptions uiOptions;
public final ElevatorOptions elevatorOptions;
public final GlowOptions glow;
public final BooleanOption flyHackEnabled = new BooleanOption(false);
public final BooleanOption cancelFallDamage = new BooleanOption(true);
public static HaxxorOptions getInstance() {
if (instance == null) {
instance = new HaxxorOptions();
}
return instance;
}
private HaxxorOptions() {
autoFarmer = new AutoFarmerOptions();
uiOptions = new UIOptions();
elevatorOptions = new ElevatorOptions();
glow = new GlowOptions();
}
public void load(@Nullable Properties properties) {
// Sub category properties
autoFarmer.load(properties);
uiOptions.load(properties);
elevatorOptions.load(properties);
glow.load(properties);
// Top level properties
cancelFallDamage.value = getBooleanProperty(properties, "cancel_fall_damage", cancelFallDamage.value);
}
public void save(Properties properties) {
// Sub category properties
autoFarmer.save(properties);
uiOptions.save(properties);
elevatorOptions.save(properties);
glow.save(properties);
// Top level properties
properties.setProperty("cancel_fall_damage", cancelFallDamage.value.toString());
}
public static class AutoFarmerOptions {
private final String PREFIX = MODULE_PREFIX + "auto_farmer.";
public final BooleanOption enabled = new BooleanOption(false);
public final BooleanOption move_seeds = new BooleanOption(true);
public final IntegerOption min_y = new IntegerOption(-2);
public final IntegerOption max_y = new IntegerOption(1);
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];
AutoFarmerOptions() { }
private void load(@Nullable Properties properties) {
move_seeds.value = getBooleanProperty(properties, PREFIX + "move_seeds", move_seeds.value);
min_y.value = getIntegerProperty(properties, PREFIX + "min_y", min_y.value);
max_y.value = getIntegerProperty(properties, PREFIX + "max_y", max_y.value);
horizontal_reach.value = getIntegerProperty(properties, PREFIX + "horizontal_reach",
horizontal_reach.value);
max_actions_per_tick.value = getIntegerProperty(properties, PREFIX + "max_actions_per_tick",
max_actions_per_tick.value);
for (int i = 0; i < AutoFarmer.crops.length; i++) {
seeds_enabled[i] = new BooleanOption(true);
crops_enabled[i] = new BooleanOption(true);
if (AutoFarmer.crops[i].seed_type != null) {
seeds_enabled[i].value = getBooleanProperty(properties,
PREFIX + "seeds." + AutoFarmer.crops[i].seed_type.getName().getString(), seeds_enabled[i].value);
}
if (AutoFarmer.crops[i].crop_type != null) {
crops_enabled[i].value = getBooleanProperty(properties,
PREFIX + "crops." + AutoFarmer.crops[i].crop_type.getName().getString(), crops_enabled[i].value);
}
}
}
private void save(Properties properties) {
properties.setProperty(PREFIX + "move_seeds", move_seeds.value.toString());
properties.setProperty(PREFIX + "min_y", min_y.value.toString());
properties.setProperty(PREFIX + "max_y", max_y.value.toString());
properties.setProperty(PREFIX + "horizontal_reach", horizontal_reach.value.toString());
properties.setProperty(PREFIX + "max_actions_per_tick", max_actions_per_tick.value.toString());
for (int i = 0; i < AutoFarmer.crops.length; i++) {
if (AutoFarmer.crops[i].seed_type != null) {
properties.setProperty(PREFIX + "seeds." + AutoFarmer.crops[i].seed_type.getName().getString(),
seeds_enabled[i].value.toString());
}
if (AutoFarmer.crops[i].crop_type != null) {
properties.setProperty(PREFIX + "crops." + AutoFarmer.crops[i].crop_type.getName().getString(),
crops_enabled[i].value.toString());
}
}
}
}
public static class UIOptions {
private final String PREFIX = MODULE_PREFIX + "ui.";
public final BooleanOption show_auto_farmer = new BooleanOption(true);
public final BooleanOption show_fly_hack = new BooleanOption(true);
UIOptions() { }
private void load(@Nullable Properties properties) {
show_auto_farmer.value = getBooleanProperty(properties, PREFIX + "show_auto_farmer", show_auto_farmer.value);
show_fly_hack.value = getBooleanProperty(properties, PREFIX + "show_fly_hack", show_fly_hack.value);
}
private void save(Properties properties) {
properties.setProperty(PREFIX + "show_auto_farmer", show_auto_farmer.value.toString());
properties.setProperty(PREFIX + "show_fly_hack", show_fly_hack.value.toString());
}
}
public static class ElevatorOptions {
private final String PREFIX = MODULE_PREFIX + "elevator.";
public final BooleanOption send_too_far_message = new BooleanOption(true);
public final BooleanOption send_tp_message = new BooleanOption(true);
public final IntegerOption max_tp_up = new IntegerOption(10);
public final IntegerOption max_tp_down = new IntegerOption(10);
ElevatorOptions() { }
private void load(@Nullable Properties properties) {
send_too_far_message.value = getBooleanProperty(properties, PREFIX + "send_too_far_message", send_too_far_message.value);
send_tp_message.value = getBooleanProperty(properties, PREFIX + "send_tp_message", send_tp_message.value);
max_tp_up.value = getIntegerProperty(properties, PREFIX + "max_tp_up", max_tp_up.value);
max_tp_down.value = getIntegerProperty(properties, PREFIX + "max_tp_down", max_tp_down.value);
}
private void save(Properties properties) {
properties.setProperty(PREFIX + "send_too_far_message", send_too_far_message.value.toString());
properties.setProperty(PREFIX + "send_tp_message", send_tp_message.value.toString());
properties.setProperty(PREFIX + "max_tp_up", max_tp_up.value.toString());
properties.setProperty(PREFIX + "max_tp_down", max_tp_down.value.toString());
}
}
public static class GlowOptions {
private final String PREFIX = MODULE_PREFIX + "glow.";
public final BooleanOption enabled = new BooleanOption(false);
public final BooleanOption include_non_living = new BooleanOption(false);
GlowOptions() { }
private void load(@Nullable Properties properties) {
include_non_living.value = getBooleanProperty(properties, PREFIX + "include_non_living", include_non_living.value);
}
private void save(Properties properties) {
properties.setProperty(PREFIX + "include_non_living", include_non_living.value.toString());
}
}
}

View File

@ -0,0 +1,83 @@
package cmods.haxxor.ui;
import cmods.cmods.options.CmodsOptions;
import cmods.cmods.ui.ToggleButton;
import cmods.haxxor.hacks.AutoFarmer;
import cmods.haxxor.options.HaxxorOptions;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.EmptyWidget;
import net.minecraft.client.gui.widget.GridWidget;
import net.minecraft.client.gui.widget.SimplePositioningWidget;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
import static cmods.cmods.ui.Constants.*;
public class CropSelectScreen extends Screen {
private final CmodsOptions global_options = CmodsOptions.getInstance();
private final HaxxorOptions options = HaxxorOptions.getInstance();
private final Screen parent;
private final int heightOffset = 10;
protected CropSelectScreen(Screen parent) {
super(Text.translatable("haxxor.options.farmer.crop_select.title"));
this.parent = parent;
}
protected void init() {
if (client == null)
return;
final int startHeight = (int) Math.floor(this.height * startHeight_multiplier) + heightOffset;
GridWidget grid = new GridWidget();
grid.getMainPositioner().marginX(5).marginBottom(4).alignHorizontalCenter();
GridWidget.Adder adder = grid.createAdder(2);
for (int i = 0; i < AutoFarmer.crops.length; i++) {
if (AutoFarmer.crops[i].seed_type != null) {
adder.add(new ToggleButton(0, 0, buttonWidth, buttonHeight,
AutoFarmer.crops[i].seed_type.getName(), options.autoFarmer.seeds_enabled[i]));
} else {
adder.add(new EmptyWidget(0, 0));
}
if (AutoFarmer.crops[i].crop_type != null) {
adder.add(new ToggleButton(0, 0, buttonWidth, buttonHeight,
AutoFarmer.crops[i].crop_type.getName(), options.autoFarmer.crops_enabled[i]));
} else {
adder.add(new EmptyWidget(0, 0));
}
}
adder.add(ButtonWidget.builder(ScreenTexts.DONE, button -> client.setScreen(parent))
.width(doneButtonWidth).build(), 2, adder.copyPositioner().marginTop(doneButtonRowIncrement));
grid.refreshPositions();
SimplePositioningWidget.setPos(grid, 0, startHeight, this.width, this.height, 0.5f, 0.0f);
grid.forEachChild(this::addDrawableChild);
}
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
super.render(context, mouseX, mouseY, delta);
final int column1 = width / 2 + column1_offset;
final int column2 = width / 2 + column2_offset;
final int startHeight = (int) Math.floor(height * startHeight_multiplier) + heightOffset;
// this.renderBackground(context, mouseX, mouseY, delta);
context.drawCenteredTextWithShadow(textRenderer, Text.translatable("haxxor.options.farmer.crop_select.seeds"),
column1 + buttonWidth / 2, startHeight - rowIncrement, 0xffffff);
context.drawCenteredTextWithShadow(textRenderer, title, width / 2, 15, 0xffffff);
context.drawCenteredTextWithShadow(textRenderer, Text.translatable("haxxor.options.farmer.crop_select.blocks"),
column2 + buttonWidth / 2, startHeight - rowIncrement, 0xffffff);
}
public void removed() {
global_options.save();
}
}

View File

@ -1,4 +1,4 @@
package cmods.haxxor.client.ui; package cmods.haxxor.ui;
import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.text.Text; import net.minecraft.text.Text;
@ -10,11 +10,12 @@ public class CycleButtonWidget extends ButtonWidget {
public CycleButtonWidget(int x, int y, int width, int height, Text[] options, int startIndex, CycleAction onCycle) { public CycleButtonWidget(int x, int y, int width, int height, Text[] options, int startIndex, CycleAction onCycle) {
this(x, y, width, height, options, startIndex, onCycle, EMPTY); this(x, y, width, height, options, startIndex, onCycle, DEFAULT_NARRATION_SUPPLIER);
} }
public CycleButtonWidget(int x, int y, int width, int height, Text[] options, int startIndex, CycleAction onCycle, TooltipSupplier tooltipSupplier) { public CycleButtonWidget(int x, int y, int width, int height, Text[] options, int startIndex, CycleAction onCycle,
super(x, y, width, height, options[startIndex], onCycle, tooltipSupplier); NarrationSupplier narrationSupplier) {
super(x, y, width, height, options[startIndex], onCycle, narrationSupplier);
this.options = options; this.options = options;
this.onCycle = onCycle; this.onCycle = onCycle;
this.selectedIndex = startIndex; this.selectedIndex = startIndex;

View File

@ -0,0 +1,64 @@
package cmods.haxxor.ui;
import cmods.cmods.options.CmodsOptions;
import cmods.cmods.ui.IntegerAdjustWidget;
import cmods.cmods.ui.ToggleButton;
import cmods.haxxor.options.HaxxorOptions;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.GridWidget;
import net.minecraft.client.gui.widget.SimplePositioningWidget;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
import static cmods.cmods.ui.Constants.*;
public class ElevatorOptionsScreen extends Screen {
private final Screen parent;
private final CmodsOptions global_options = CmodsOptions.getInstance();
private final HaxxorOptions.ElevatorOptions options = HaxxorOptions.getInstance().elevatorOptions;
public ElevatorOptionsScreen(Screen parent) {
super(Text.translatable("haxxor.options.elevator.title"));
this.parent = parent;
}
protected void init() {
if (client == null)
return;
final int startHeight = (int) Math.floor(this.height * startHeight_multiplier);
GridWidget grid = new GridWidget();
grid.getMainPositioner().marginX(5).marginBottom(4).alignHorizontalCenter();
GridWidget.Adder adder = grid.createAdder(2);
adder.add(new ToggleButton(0, 0, buttonWidth, buttonHeight,
Text.translatable("haxxor.options.elevator.too_far"), options.send_too_far_message));
adder.add(new ToggleButton(0, 0, buttonWidth, buttonHeight,
Text.translatable("haxxor.options.elevator.tp_message"), options.send_tp_message));
adder.add(new IntegerAdjustWidget(Text.translatable("haxxor.options.elevator.max_tp_up"), options.max_tp_up));
adder.add(new IntegerAdjustWidget(Text.translatable("haxxor.options.elevator.max_tp_down"), options.max_tp_down));
adder.add(ButtonWidget.builder(ScreenTexts.DONE, button -> client.setScreen(parent))
.width(doneButtonWidth).build(), 2, adder.copyPositioner().marginTop(doneButtonRowIncrement));
grid.refreshPositions();
SimplePositioningWidget.setPos(grid, 0, startHeight, this.width, this.height, 0.5f, 0.0f);
grid.forEachChild(this::addDrawableChild);
}
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
// this.renderBackground(context, mouseX, mouseY, delta);
super.render(context, mouseX, mouseY, delta);
context.drawCenteredTextWithShadow(textRenderer, title, width / 2, 15, 0xffffff);
}
public void removed() {
global_options.save();
}
}

View File

@ -0,0 +1,88 @@
package cmods.haxxor.ui;
import cmods.cmods.options.CmodsOptions;
import cmods.cmods.ui.IntegerAdjustWidget;
import cmods.cmods.ui.ToggleButton;
import cmods.haxxor.HaxxorClient;
import cmods.haxxor.options.HaxxorOptions;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.GridWidget;
import net.minecraft.client.gui.widget.SimplePositioningWidget;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
import static cmods.cmods.ui.Constants.*;
public class FarmerOptionsScreen extends Screen {
private final Screen parent;
private final CmodsOptions global_options = CmodsOptions.getInstance();
private final HaxxorOptions options = HaxxorOptions.getInstance();
public FarmerOptionsScreen(Screen parent) {
super(Text.translatable("haxxor.options.farmer.title"));
this.parent = parent;
}
protected void init() {
if (client == null)
return;
final Text enabledText = Text.translatable("haxxor.state.enabled");
final Text disabledText = Text.translatable("haxxor.state.disabled");
final int column1 = this.width / 2 + column1_offset;
final int column2 = this.width / 2 + column2_offset;
final int startHeight = (int) Math.floor(this.height * startHeight_multiplier);
GridWidget grid = new GridWidget();
grid.getMainPositioner().marginX(5).marginBottom(4).alignHorizontalCenter();
GridWidget.Adder adder = grid.createAdder(2);
adder.add(ButtonWidget.builder(options.autoFarmer.enabled.get() ? enabledText : disabledText,
button -> button.setMessage(HaxxorClient.toggleAutoFarmer() ? enabledText : disabledText))
.position(column1, startHeight).build());
adder.add(new ToggleButton(0, 0, buttonWidth, buttonHeight,
Text.translatable("haxxor.options.ui.show_farmer"), options.uiOptions.show_auto_farmer));
adder.add(new ToggleButton(0, 0, buttonWidth,
buttonHeight, Text.literal("Move Seeds"), options.autoFarmer.move_seeds));
adder.add(ButtonWidget.builder(Text.translatable("haxxor.options.farmer.edit_actions"),
button -> client.setScreen(new CropSelectScreen(this)))
.position(column2, startHeight).build());
// adder.add(new EmptyWidget(0, 0));
adder.add(new IntegerAdjustWidget(Text.translatable("haxxor.options.farmer.min_y"),
options.autoFarmer.min_y));
adder.add(new IntegerAdjustWidget(Text.translatable("haxxor.options.farmer.max_y"),
options.autoFarmer.max_y));
adder.add(new IntegerAdjustWidget(Text.translatable("haxxor.options.farmer.reach"),
options.autoFarmer.horizontal_reach));
adder.add(new IntegerAdjustWidget(Text.translatable("haxxor.options.farmer.actions_per_tick"),
options.autoFarmer.max_actions_per_tick, 5));
adder.add(ButtonWidget.builder(ScreenTexts.DONE, button -> client.setScreen(parent))
.width(doneButtonWidth).build(), 2, adder.copyPositioner().marginTop(doneButtonRowIncrement));
grid.refreshPositions();
SimplePositioningWidget.setPos(grid, 0, startHeight, this.width, this.height, 0.5f, 0.0f);
grid.forEachChild(this::addDrawableChild);
}
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
// this.renderBackground(context, mouseX, mouseY, delta);
super.render(context, mouseX, mouseY, delta);
context.drawCenteredTextWithShadow(textRenderer, title, width / 2, 15, 0xffffff);
}
public void removed() {
global_options.save();
}
}

View File

@ -0,0 +1,67 @@
package cmods.haxxor.ui;
import cmods.cmods.options.CmodsOptions;
import cmods.cmods.ui.ToggleButton;
import cmods.haxxor.HaxxorClient;
import cmods.haxxor.options.HaxxorOptions;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.GridWidget;
import net.minecraft.client.gui.widget.SimplePositioningWidget;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
import static cmods.cmods.ui.Constants.*;
public class GlowOptionsScreen extends Screen {
private final Screen parent;
private final CmodsOptions global_options = CmodsOptions.getInstance();
private final HaxxorOptions.GlowOptions options = HaxxorOptions.getInstance().glow;
public GlowOptionsScreen(Screen parent) {
super(Text.translatable("haxxor.options.glow.title"));
this.parent = parent;
}
protected void init() {
if (client == null)
return;
final int startHeight = (int) Math.floor(this.height * startHeight_multiplier);
GridWidget grid = new GridWidget();
grid.getMainPositioner().marginX(5).marginBottom(4).alignHorizontalCenter();
GridWidget.Adder adder = grid.createAdder(2);
adder.add(ButtonWidget.builder(
Text.translatable("haxxor.options.glow.enabled", options.enabled.get() ?
Text.translatable("haxxor.state.enabled") :
Text.translatable("haxxor.state.disabled")),
button -> button.setMessage(
Text.translatable("haxxor.options.glow.enabled", HaxxorClient.toggleGlow() ?
Text.translatable("haxxor.state.enabled") :
Text.translatable("haxxor.state.disabled"))
)).build());
adder.add(new ToggleButton(0, 0, buttonWidth, buttonHeight,
Text.translatable("haxxor.options.glow.include_non_living"), options.include_non_living));
adder.add(ButtonWidget.builder(ScreenTexts.DONE, button -> client.setScreen(parent))
.width(doneButtonWidth).build(), 2, adder.copyPositioner().marginTop(doneButtonRowIncrement));
grid.refreshPositions();
SimplePositioningWidget.setPos(grid, 0, startHeight, this.width, this.height, 0.5f, 0.0f);
grid.forEachChild(this::addDrawableChild);
}
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
// this.renderBackground(context, mouseX, mouseY, delta);
super.render(context, mouseX, mouseY, delta);
context.drawCenteredTextWithShadow(textRenderer, title, width / 2, 15, 0xffffff);
}
public void removed() {
global_options.save();
}
}

View File

@ -0,0 +1,74 @@
package cmods.haxxor.ui;
import cmods.cmods.options.CmodsOptions;
import cmods.cmods.ui.ToggleButton;
import cmods.haxxor.HaxxorClient;
import cmods.haxxor.options.HaxxorOptions;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.GridWidget;
import net.minecraft.client.gui.widget.SimplePositioningWidget;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
import static cmods.cmods.ui.Constants.*;
public class HaxxorOptionsScreen extends Screen {
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"));
this.parent = parent;
}
protected void init() {
if (client == null)
return;
final int startHeight = (int) Math.floor(this.height * startHeight_multiplier);
GridWidget grid = new GridWidget();
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(ButtonWidget.builder(Text.translatable("haxxor.options.elevator"),
button -> this.client.setScreen(new ElevatorOptionsScreen(this))).build());
adder.add((ButtonWidget.builder(Text.translatable("haxxor.options.glow"),
button -> client.setScreen(new GlowOptionsScreen(this))).build()));
adder.add(new ToggleButton(0, 0, buttonWidth, buttonHeight,
Text.translatable("haxxor.options.fall_damage"), options.cancelFallDamage));
adder.add(ButtonWidget.builder(ScreenTexts.DONE, button -> client.setScreen(parent))
.width(doneButtonWidth).build(), 2, adder.copyPositioner().marginTop(doneButtonRowIncrement));
grid.refreshPositions();
SimplePositioningWidget.setPos(grid, 0, startHeight, this.width, this.height, 0.5f, 0.0f);
grid.forEachChild(this::addDrawableChild);
}
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
// renderBackground(context, mouseX, mouseY, delta);
super.render(context, mouseX, mouseY, delta);
Text versionText = Text.literal("v" + HaxxorClient.version);
context.drawCenteredTextWithShadow(textRenderer, title, width / 2, 15, 0xffffff);
context.drawTextWithShadow(textRenderer, versionText, width - textRenderer.getWidth(versionText) - 2,
this.height - textRenderer.fontHeight - 2, 0xffffff);
}
public void removed() {
global_options.save();
}
}

View File

@ -0,0 +1,39 @@
package cmods.haxxor.ui;
import cmods.cmods.options.IntegerOption;
import net.minecraft.client.gui.widget.SliderWidget;
import net.minecraft.text.Text;
public class OptionsSlideWidget extends SliderWidget {
private final IntegerOption option;
private final String messagePrefix;
private final int min;
private final int max;
private final int step;
public OptionsSlideWidget(int x, int y, int min, int max, Text text, IntegerOption option) {
this(x, y, min, max, 1, text, option);
}
public OptionsSlideWidget(int x, int y, int min, int max, int step, Text text, IntegerOption option) {
super(x, y, 150, 20, text, ((double) option.get() - min) / (max - min));
this.min = min;
this.max = max;
this.step = step;
this.option = option;
messagePrefix = text.getString() + ": ";
updateMessage();
}
@Override
protected void updateMessage() {
setMessage(Text.literal(messagePrefix + option.get()));
}
@Override
protected void applyValue() {
option.set((int) (((value * ((max - min) / step))) + (min / step)) * step);
}
}

View File

@ -0,0 +1,62 @@
package cmods.haxxor.ui;
import cmods.cmods.options.CmodsOptions;
import cmods.cmods.ui.ToggleButton;
import cmods.haxxor.options.HaxxorOptions;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.GridWidget;
import net.minecraft.client.gui.widget.SimplePositioningWidget;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
import static cmods.cmods.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) {
super(Text.translatable("haxxor.options.ui.title"));
this.parent = parent;
}
protected void init() {
if (client == null)
return;
final int startHeight = (int) Math.floor(this.height * startHeight_multiplier);
GridWidget grid = new GridWidget();
grid.getMainPositioner().marginX(5).marginBottom(4).alignHorizontalCenter();
GridWidget.Adder adder = grid.createAdder(2);
adder.add(new ToggleButton(0, 0, buttonWidth, buttonHeight,
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));
adder.add(new ToggleButton(0, 0, buttonWidth, buttonHeight,
Text.translatable("haxxor.options.ui.show_fly_hack"), options.uiOptions.show_fly_hack));
adder.add(ButtonWidget.builder(ScreenTexts.DONE, button -> client.setScreen(parent))
.width(doneButtonWidth).build(), 2, adder.copyPositioner().marginTop(doneButtonRowIncrement));
grid.refreshPositions();
SimplePositioningWidget.setPos(grid, 0, startHeight, this.width, this.height, 0.5f, 0.0f);
grid.forEachChild(this::addDrawableChild);
}
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
// this.renderBackground(context, mouseX, mouseY, delta);
super.render(context, mouseX, mouseY, delta);
context.drawCenteredTextWithShadow(textRenderer, title, width / 2, 15, 0xffffff);
}
public void removed() {
global_options.save();
}
}

View File

@ -4,12 +4,10 @@
"package": "cmods.haxxor.mixin", "package": "cmods.haxxor.mixin",
"compatibilityLevel": "JAVA_17", "compatibilityLevel": "JAVA_17",
"mixins": [ "mixins": [
"GlobalGlow",
"GlobalGlowAll"
], ],
"client": [ "client": [],
"HudMixin",
"OptionsMixin",
"PauseMixin"
],
"injectors": { "injectors": {
"defaultRequire": 1 "defaultRequire": 1
} }

View File

@ -1,98 +0,0 @@
package cmods.haxxor.client;
import java.util.prefs.Preferences;
public final class HaxxorOptions {
private static HaxxorOptions instance = null;
public final AutoFarmerOptions autoFarmer;
public final FlyHackOptions flyHack;
public boolean cancel_fall_damage = true;
public static HaxxorOptions getInstance() {
if (instance == null)
instance = new HaxxorOptions();
return instance;
}
private HaxxorOptions() {
autoFarmer = new AutoFarmerOptions();
flyHack = new FlyHackOptions();
load();
}
public void load() {
autoFarmer.load();
}
public void save() {
autoFarmer.save();
}
public static class AutoFarmerOptions {
private final Preferences prefs = Preferences.userNodeForPackage(AutoFarmerOptions.class);
public boolean enabled;
public boolean move_seeds;
public int min_y = -2;
public int max_y = 1;
public int horizontal_reach = 4;
public int max_actions_per_tick = 30;
public final boolean[] seeds_enabled = new boolean[AutoFarmer.crops.length];
public final boolean[] crops_enabled = new boolean[AutoFarmer.crops.length];
public AutoFarmerOptions() { }
private void load() {
move_seeds = prefs.getBoolean("move_seeds", move_seeds);
min_y = prefs.getInt("min_y", min_y);
max_y = prefs.getInt("max_y", max_y);
horizontal_reach = prefs.getInt("horizontal_reach", horizontal_reach);
max_actions_per_tick = prefs.getInt("max_actions_per_tick", max_actions_per_tick);
for (int i = 0; i < AutoFarmer.crops.length; i++) {
if (AutoFarmer.crops[i].seed_type != null) {
seeds_enabled[i] = prefs.getBoolean("seed_" + AutoFarmer.crops[i].seed_type.getName().getString(),
seeds_enabled[i]);
}
if (AutoFarmer.crops[i].crop_type != null) {
crops_enabled[i] = prefs.getBoolean("crop_" + AutoFarmer.crops[i].crop_type.getName().getString(),
crops_enabled[i]);
}
}
}
private void save() {
prefs.putBoolean("move_seeds", move_seeds);
prefs.putInt("min_y", min_y);
prefs.putInt("max_y", max_y);
prefs.putInt("horizontal_reach", horizontal_reach);
prefs.putInt("max_actions_per_tick", max_actions_per_tick);
for (int i = 0; i < AutoFarmer.crops.length; i++) {
if (AutoFarmer.crops[i].seed_type != null) {
prefs.putBoolean("seed_" + AutoFarmer.crops[i].seed_type.getName().getString(), seeds_enabled[i]);
}
if (AutoFarmer.crops[i].crop_type != null) {
prefs.putBoolean("crop_" + AutoFarmer.crops[i].crop_type.getName().getString(), crops_enabled[i]);
}
}
}
}
public static class FlyHackOptions {
public boolean enabled;
}
}

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,80 +0,0 @@
package cmods.haxxor.client.ui;
import cmods.haxxor.client.AutoFarmer;
import cmods.haxxor.client.HaxxorOptions;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
import static cmods.haxxor.client.ui.Constants.*;
public class CropSelectScreen extends Screen {
private final HaxxorOptions options;
private final Screen parent;
private final int heightOffset = 10;
protected CropSelectScreen(Screen parent) {
super(Text.translatable("haxxor.options.farmer.crop_select.title"));
this.parent = parent;
options = HaxxorOptions.getInstance();
}
protected void init() {
if (client == null)
return;
final int column1 = this.width / 2 + column1_offset;
final int column2 = this.width / 2 + column2_offset;
final int startHeight = (int) Math.floor(this.height * startHeight_multiplier) + heightOffset;
final int doneButtonX = this.width / 2 + doneButtonX_offset;
int y = startHeight;
for (int i = 0; i < AutoFarmer.crops.length; i++) {
int finalI = i;
if (AutoFarmer.crops[i].seed_type != null) {
addDrawableChild(new ToggleEnableButtonWidget(column1, y, buttonWidth, buttonHeight,
AutoFarmer.crops[i].seed_type.getName(), options.autoFarmer.seeds_enabled[i],
(button, enable) -> options.autoFarmer.seeds_enabled[finalI] = enable));
}
if (AutoFarmer.crops[i].crop_type != null) {
addDrawableChild(new ToggleEnableButtonWidget(column2, y, buttonWidth, buttonHeight,
AutoFarmer.crops[i].crop_type.getName(), options.autoFarmer.crops_enabled[i],
(button, enable) -> options.autoFarmer.crops_enabled[finalI] = enable));
}
y += rowIncrement;
}
addDrawableChild(new ButtonWidget(doneButtonX, y + doneButtonRowIncrement, doneButtonWidth, buttonHeight,
ScreenTexts.DONE, button -> {
options.save();
client.setScreen(parent);
}));
}
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
final int column1 = this.width / 2 + column1_offset;
final int column2 = this.width / 2 + column2_offset;
final int startHeight = (int) Math.floor(this.height * startHeight_multiplier) + heightOffset;
this.renderBackground(matrices);
drawCenteredText(matrices, this.textRenderer, Text.translatable("haxxor.options.farmer.crop_select.seeds"),
column1 + buttonWidth / 2, startHeight - rowIncrement, 0xffffff);
drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 15, 0xffffff);
drawCenteredText(matrices, this.textRenderer, Text.translatable("haxxor.options.farmer.crop_select.blocks"),
column2 + buttonWidth / 2, startHeight - rowIncrement, 0xffffff);
super.render(matrices, mouseX, mouseY, delta);
}
public void removed() {
options.save();
}
}

View File

@ -1,115 +0,0 @@
package cmods.haxxor.client.ui;
import cmods.haxxor.client.HaxxorClient;
import cmods.haxxor.client.HaxxorOptions;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
import org.jetbrains.annotations.NotNull;
import static cmods.haxxor.client.ui.Constants.*;
public class FarmerOptionsScreen extends Screen {
private final Screen parent;
private final HaxxorOptions options = HaxxorOptions.getInstance();
protected FarmerOptionsScreen(Screen parent) {
super(Text.translatable("haxxor.options.farmer.title"));
this.parent = parent;
}
protected void init() {
if (client == null)
return;
final Text enabledText = Text.translatable("haxxor.state.enabled");
final Text disabledText = Text.translatable("haxxor.state.disabled");
final int column1 = this.width / 2 + column1_offset;
final int column2 = this.width / 2 + column2_offset;
final int startHeight = (int) Math.floor(this.height * startHeight_multiplier);
final int doneButtonX = this.width / 2 + doneButtonX_offset;
int row = 0;
addDrawableChild(new ButtonWidget(column1, startHeight, buttonWidth, buttonHeight,
options.autoFarmer.enabled ? enabledText : disabledText,
button -> button.setMessage(HaxxorClient.toggleAutoFarmer() ? enabledText : disabledText)));
addDrawableChild(new ButtonWidget(column2, startHeight, buttonWidth, buttonHeight,
Text.translatable("haxxor.options.farmer.edit_actions"),
button -> client.setScreen(new CropSelectScreen(this))));
row++;
addDrawableChild(new ToggleEnableButtonWidget(column1, startHeight + (rowIncrement * row), buttonWidth,
buttonHeight, Text.literal("Move Seeds"), options.autoFarmer.move_seeds,
(button, isEnabled) -> options.autoFarmer.move_seeds = isEnabled));
row++;
addVariableAdjust(column1, startHeight + (rowIncrement * row), buttonWidth, buttonHeight, options.autoFarmer.min_y,
Text.translatable("haxxor.options.farmer.min_y"),
() -> --options.autoFarmer.min_y,
() -> ++options.autoFarmer.min_y);
addVariableAdjust(column2, startHeight + (rowIncrement * row), buttonWidth, buttonHeight, options.autoFarmer.max_y,
Text.translatable("haxxor.options.farmer.max_y"),
() -> --options.autoFarmer.max_y,
() -> ++options.autoFarmer.max_y);
row++;
addVariableAdjust(column1, startHeight + (rowIncrement * row), buttonWidth, buttonHeight, options.autoFarmer.horizontal_reach,
Text.translatable("haxxor.options.farmer.reach"),
() -> --options.autoFarmer.horizontal_reach,
() -> ++options.autoFarmer.horizontal_reach);
addVariableAdjust(column2, startHeight + (rowIncrement * row), buttonWidth, buttonHeight, options.autoFarmer.max_actions_per_tick,
Text.translatable("haxxor.options.farmer.actions_per_tick"),
() -> options.autoFarmer.max_actions_per_tick -= 5,
() -> options.autoFarmer.max_actions_per_tick += 5);
row++;
this.addDrawableChild(new ButtonWidget(doneButtonX,
startHeight + (rowIncrement * row) + doneButtonRowIncrement, doneButtonWidth, buttonHeight,
ScreenTexts.DONE, button -> client.setScreen(parent)));
}
@SuppressWarnings("SameParameterValue")
private void addVariableAdjust(int x, int y, int width, int height, int initialValue, @NotNull Text label,
UpdateTextAction minus, UpdateTextAction add) {
final int button_width = height + height / 4;
final String labelStr = label.getString() + ": ";
ButtonWidget middle = new ButtonWidget(x + button_width - 1, y, width - (button_width * 2) + 2, height,
Text.literal(labelStr + initialValue), button -> {});
this.addDrawableChild(middle);
this.addDrawableChild(new ButtonWidget(x, y, button_width, height, Text.literal("-"),
button -> middle.setMessage(Text.literal(labelStr + minus.onUpdate()))));
this.addDrawableChild(new ButtonWidget(x + width - button_width + 1, y, button_width, height, Text.literal("+"),
button -> middle.setMessage(Text.literal(labelStr + add.onUpdate()))));
}
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
this.renderBackground(matrices);
drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 15, 0xffffff);
super.render(matrices, mouseX, mouseY, delta);
}
public void removed() {
options.save();
}
@Environment(EnvType.CLIENT)
private interface UpdateTextAction {
int onUpdate();
}
}

View File

@ -1,53 +0,0 @@
package cmods.haxxor.client.ui;
import cmods.haxxor.client.HaxxorClient;
import cmods.haxxor.client.HaxxorOptions;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
import static cmods.haxxor.client.ui.Constants.*;
public class HaxxorOptionsScreen extends Screen {
private final HaxxorOptions options = HaxxorOptions.getInstance();
private final Screen parent;
public HaxxorOptionsScreen(Screen parent) {
super(Text.translatable("haxxor.options.title"));
this.parent = parent;
}
protected void init() {
if (client == null)
return;
final int column1 = this.width / 2 + column1_offset;
final int column2 = this.width / 2 + column2_offset;
final int startHeight = (int) Math.floor(this.height * startHeight_multiplier);
final int doneButtonX = this.width / 2 + doneButtonX_offset;
this.addDrawableChild(new ButtonWidget(column1, startHeight, buttonWidth, buttonHeight,
Text.translatable("haxxor.options.farmer"),
button -> this.client.setScreen(new FarmerOptionsScreen(this))));
this.addDrawableChild(new ToggleEnableButtonWidget(column2, startHeight, buttonWidth, buttonHeight,
Text.translatable("haxxor.options.fall_damage"), options.cancel_fall_damage,
(button, isEnabled) -> options.cancel_fall_damage = isEnabled));
this.addDrawableChild(new ButtonWidget(doneButtonX, startHeight + rowIncrement + doneButtonRowIncrement,
doneButtonWidth, buttonHeight, ScreenTexts.DONE, button -> this.client.setScreen(this.parent)));
}
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
renderBackground(matrices);
Text versionText = Text.literal("v" + HaxxorClient.version);
drawCenteredText(matrices, textRenderer, title, this.width / 2, 15, 0xffffff);
drawTextWithShadow(matrices, textRenderer, versionText, this.width - textRenderer.getWidth(versionText) - 2,
this.height - textRenderer.fontHeight - 2, 0xffffff);
super.render(matrices, mouseX, mouseY, delta);
}
}

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,51 +0,0 @@
package cmods.haxxor.client.ui;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
public class ToggleEnableButtonWidget extends ButtonWidget {
private final String name;
private boolean enabled;
private final ToggleAction onToggle;
private final String enabledText = Text.translatable("haxxor.state.enabled").getString();
private final String disabledText = Text.translatable("haxxor.state.disabled").getString();
public ToggleEnableButtonWidget(int x, int y, int width, int height, Text name, boolean startEnabled,
ToggleAction onToggle) {
this(x, y, width, height, name, startEnabled, onToggle, EMPTY);
}
public ToggleEnableButtonWidget(int x, int y, int width, int height, Text name, boolean startEnabled,
ToggleAction onToggle, TooltipSupplier tooltipSupplier) {
super(x, y, width, height, name, onToggle, tooltipSupplier);
this.name = name.getString() + ": ";
this.enabled = startEnabled;
this.onToggle = onToggle;
}
private void updateText() {
setMessage(Text.literal(name + (enabled ? enabledText : disabledText)));
}
@Override
public void onPress() {
onToggle.onToggle(this, enabled = !enabled);
}
@Override
public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
updateText();
super.renderButton(matrices, mouseX, mouseY, delta);
}
public interface ToggleAction extends PressAction {
void onToggle(ButtonWidget button, boolean isEnabled);
@Override
default void onPress(ButtonWidget button) { }
}
}

View File

@ -1,71 +0,0 @@
package cmods.haxxor.mixin;
import cmods.haxxor.client.AutoFarmer;
import cmods.haxxor.client.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 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) {
if (this.client.options.debugEnabled || client.player == null)
return;
HaxxorOptions options = HaxxorOptions.getInstance();
TextRenderer textRenderer = this.getTextRenderer();
ArrayList<Line> lines = new ArrayList<>();
int x = 5;
int y = 5;
int red = 0xff0000;
int green = 0x00ff00;
if (options.autoFarmer.enabled) {
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.flyHack.enabled) {
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 (Line line: lines) {
DrawableHelper.drawTextWithShadow(matrices, textRenderer, line.text(), x + (5 * line.indent()), y,
line.color());
y += 10;
}
}
}

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;
this.addDrawableChild(new ButtonWidget(20, 20, 100, 20,
Text.translatable("haxxor.options"), (button) ->
client.setScreen(new HaxxorOptionsScreen(this))));
}
}

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;
this.addDrawableChild(new ButtonWidget(20, 20, 100, 20,
Text.translatable("haxxor.options"), (button) ->
client.setScreen(new HaxxorOptionsScreen(this))));
}
}

View File

@ -10,9 +10,22 @@
"haxxor.actions.available": "Actions available", "haxxor.actions.available": "Actions available",
"haxxor.actions.unavailable": "Actions unavailable", "haxxor.actions.unavailable": "Actions unavailable",
"haxxor.message.elevator": "Teleporting to: [%.2f, %.2f, %.2f]",
"haxxor.message.elevator.too_far": "Too far!",
"haxxor.options": "Haxxor", "haxxor.options": "Haxxor",
"haxxor.options.title": "Haxxor Options", "haxxor.options.title": "Haxxor Options",
"haxxor.options.fall_damage": "Fall Damage Cancel", "haxxor.options.fall_damage": "Fall Damage Cancel",
"haxxor.options.fall_damage.title": "Fall Damage Cancel Options",
"haxxor.options.ui": "UI",
"haxxor.options.ui.title": "UI Options",
"haxxor.options.ui.hud_enabled": "Show HUD",
"haxxor.options.ui.show_coordinates": "Show Coordinates",
"haxxor.options.ui.show_farmer": "Auto Farmer UI",
"haxxor.options.ui.show_fly_hack": "Fly Hack UI",
"haxxor.options.farmer": "Auto Farm", "haxxor.options.farmer": "Auto Farm",
"haxxor.options.farmer.title": "Auto Farm Options", "haxxor.options.farmer.title": "Auto Farm Options",
"haxxor.options.farmer.max_y": "Max Y Offset", "haxxor.options.farmer.max_y": "Max Y Offset",
@ -24,7 +37,22 @@
"haxxor.options.farmer.crop_select.seeds": "Seeds to Plant", "haxxor.options.farmer.crop_select.seeds": "Seeds to Plant",
"haxxor.options.farmer.crop_select.blocks": "Crops to Break", "haxxor.options.farmer.crop_select.blocks": "Crops to Break",
"haxxor.options.elevator": "Elevator",
"haxxor.options.elevator.title": "Elevator Options",
"haxxor.options.elevator.too_far": "Too Far Message",
"haxxor.options.elevator.tp_message": "Teleport Message",
"haxxor.options.elevator.max_tp_up": "Max Tp Up",
"haxxor.options.elevator.max_tp_down": "Max Tp Down",
"haxxor.options.glow": "Glow",
"haxxor.options.glow.title": "Glow Options",
"haxxor.options.glow.enabled": "Glow: %s",
"haxxor.options.glow.include_non_living": "Include Non-Living",
"category.haxxor.options": "Haxxor", "category.haxxor.options": "Haxxor",
"key.haxxor.auto_farm": "Auto Farm Toggle", "key.haxxor.auto_farm": "Auto Farm",
"key.haxxor.fly": "Fly Hack Toggle" "key.haxxor.fly": "Fly Hack",
"key.haxxor.glow": "Global Glow",
"key.haxxor.elevator.up": "Teleport Up",
"key.haxxor.elevator.down": "Teleport Down"
} }

View File

@ -2,7 +2,7 @@
"schemaVersion": 1, "schemaVersion": 1,
"id": "haxxor", "id": "haxxor",
"version": "${version}", "version": "${version}",
"name": "Haxxor", "name": "Cmods - Haxxor",
"description": "A collection of hacks because yes", "description": "A collection of hacks because yes",
"authors": [ "authors": [
"Cameron Reed" "Cameron Reed"
@ -15,9 +15,11 @@
"environment": "client", "environment": "client",
"entrypoints": { "entrypoints": {
"client": [ "client": [
"cmods.haxxor.client.HaxxorClient" "cmods.haxxor.HaxxorClient"
], ],
"modmenu": ["cmods.haxxor.client.ModMenuConfig"] "modmenu": [
"cmods.haxxor.ModMenuConfig"
]
}, },
"mixins": [ "mixins": [
"haxxor.mixins.json" "haxxor.mixins.json"
@ -25,6 +27,7 @@
"depends": { "depends": {
"fabricloader": ">=0.14.10", "fabricloader": ">=0.14.10",
"fabric": "*", "fabric": "*",
"minecraft": "1.19.2" "minecraft": "1.21.0",
"cmods": "1.2.2"
} }
} }