Compare commits

..

18 Commits
v1.2.1 ... 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
35 changed files with 849 additions and 557 deletions

View File

@ -1,11 +1,15 @@
plugins {
id 'fabric-loom' version '1.0-SNAPSHOT'
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'maven-publish'
}
version = project.mod_version
group = project.maven_group
base {
archivesName = project.archives_base_name
}
repositories {
// Add repositories to retrieve artifacts from in here.
// 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 {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
@ -26,52 +41,43 @@ 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.2.2-dev.jar")
modCompileOnly "com.terraformersmc:modmenu:4.1.1"
}
processResources {
inputs.property "version", project.version
filteringCharset "UTF-8"
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
def targetJavaVersion = 17
tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// 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
}
it.options.release = 21
}
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
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}" }
rename { "${it}_${project.base.archivesName.get()}"}
}
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
create("mavenJava", MavenPublication) {
artifactId = project.archives_base_name
from components.java
}
}

View File

@ -2,13 +2,13 @@
org.gradle.jvmargs=-Xmx2G
# Fabric Properties
# 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
minecraft_version=1.21
yarn_mappings=1.21+build.7
loader_version=0.15.11
# Mod Properties
mod_version=1.2.1
mod_version=2.4.2
maven_group=cmods
archives_base_name=haxxor
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.68.1+1.19.3
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,6 +1,10 @@
package cmods.haxxor.client;
package cmods.haxxor;
import cmods.haxxor.client.options.HaxxorOptions;
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.EnvType;
import net.fabricmc.api.Environment;
@ -16,11 +20,12 @@ 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;
private static StickyKeyBinding fly_hack_key;
private static StickyKeyBinding glow_key;
private static final HaxxorOptions options = HaxxorOptions.getInstance();
@Override
@ -29,6 +34,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,
@ -43,7 +50,15 @@ public class HaxxorClient implements ClientModInitializer {
() -> true
));
glow_key = (StickyKeyBinding) KeyBindingHelper.registerKeyBinding(new StickyKeyBinding(
"key.haxxor.glow",
-1,
"category.haxxor.options",
() -> true
));
AutoFarmer.init();
Elevator.init();
ClientTickEvents.END_CLIENT_TICK.register(this::tick);
}
@ -55,11 +70,20 @@ public class HaxxorClient implements ClientModInitializer {
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) {
options.autoFarmer.enabled.set(auto_farm_key.isPressed());
options.flyHack.enabled.set(fly_hack_key.isPressed());
options.flyHackEnabled.set(fly_hack_key.isPressed());
options.glow.enabled.set(glow_key.isPressed());
AutoFarmer.tick(client);
Elevator.tick(client);
FlyHack.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.ModMenuApi;
import net.minecraft.client.gui.screen.Screen;

View File

@ -1,6 +1,6 @@
package cmods.haxxor.client;
package cmods.haxxor.hacks;
import cmods.haxxor.client.options.HaxxorOptions;
import cmods.haxxor.options.HaxxorOptions;
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import net.minecraft.block.*;
@ -31,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.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.SUGAR_CANE, null, GROWTH_PATTERN.LEAVE_BASE, null)
new AutoFarmerCropType(Blocks.SUGAR_CANE, Items.SUGAR_CANE, GROWTH_PATTERN.LEAVE_BASE, null)
};
@ -43,7 +43,7 @@ public class AutoFarmer { // Really just a namespace and needed to separate thin
PLACE_OFF_HAND
}
private enum GROWTH_PATTERN {
public enum GROWTH_PATTERN {
BASIC,
LEAVE_BASE
}
@ -61,14 +61,14 @@ public class AutoFarmer { // Really just a namespace and needed to separate thin
}
public static boolean canFarm() {
return queuedActions.size() > 0;
return !queuedActions.isEmpty();
}
public static void tick(MinecraftClient client) {
if (client.player == null)
return;
if (queuedStopPackets.size() > 0)
if (!queuedStopPackets.isEmpty())
sendStopPackets(client);
scanBlocks(client);
@ -199,7 +199,11 @@ public class AutoFarmer { // Really just a namespace and needed to separate thin
if (cropType.growth_pattern == GROWTH_PATTERN.LEAVE_BASE && block.isOf(cropType.crop_type) &&
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) &&
@ -261,7 +265,7 @@ public class AutoFarmer { // Really just a namespace and needed to separate thin
if (block.getBlock() instanceof CropBlock)
return ((CropBlock) block.getBlock()).isMature(block);
if (blockType == NetherWartBlock.class)
return block.get(NetherWartBlock.AGE) >= NetherWartBlock.field_31199;
return block.get(NetherWartBlock.AGE) >= NetherWartBlock.MAX_AGE;
return false;
}
@ -271,6 +275,10 @@ public class AutoFarmer { // Really just a namespace and needed to separate thin
!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) {
if (client.world == null || client.player == null)
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,6 +1,6 @@
package cmods.haxxor.client;
package cmods.haxxor.hacks;
import cmods.haxxor.client.options.HaxxorOptions;
import cmods.haxxor.options.HaxxorOptions;
import net.minecraft.client.MinecraftClient;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import net.minecraft.util.math.BlockPos;
@ -10,18 +10,17 @@ import java.util.Objects;
public class FallDamageCancel {
private static final HaxxorOptions options = HaxxorOptions.getInstance();
private static final int triggerHeight = 6;
private static final int triggerHeight = 5;
private static final float heightAdjust = 0.5f;
public static void tick(MinecraftClient client) {
if (!options.cancel_fall_damage.get() || client.world == null || client.player == null ||
if (!options.cancelFallDamage.get() || client.world == null || client.player == null ||
client.player.isCreative() || client.player.isOnGround() || client.player.getVelocity().getY() >= 0)
return;
BlockPos playerPos = client.player.getBlockPos();
if (!client.world.getBlockState(playerPos.up()).isAir() ||
!client.world.getBlockState(playerPos.up(2)).isAir()) {
if (!client.world.isSpaceEmpty(client.player.getBoundingBox().expand(0, heightAdjust, 0))) {
return;
}

View File

@ -1,6 +1,6 @@
package cmods.haxxor.client;
package cmods.haxxor.hacks;
import cmods.haxxor.client.options.HaxxorOptions;
import cmods.haxxor.options.HaxxorOptions;
import net.minecraft.client.MinecraftClient;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
@ -8,7 +8,7 @@ import java.util.Objects;
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 waitTicks = 5;
private static final float fallDist = 0.5f;
@ -16,12 +16,12 @@ public class FlyHack {
private static int tickCounter = ticksToFirst;
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;
client.player.getAbilities().allowFlying = options.enabled.get();
client.player.getAbilities().allowFlying = options.flyHackEnabled.get();
if (!options.enabled.get() && client.player.getAbilities().flying) {
if (!options.flyHackEnabled.get() && client.player.getAbilities().flying) {
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

@ -1,20 +1,23 @@
package cmods.haxxor.client.ui;
package cmods.haxxor.ui;
import cmods.haxxor.client.AutoFarmer;
import cmods.haxxor.client.options.HaxxorOptions;
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.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.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() {
@ -51,31 +53,31 @@ public class CropSelectScreen extends Screen {
}
}
adder.add(ButtonWidget.builder(ScreenTexts.DONE, button -> { options.save(); client.setScreen(parent); })
adder.add(ButtonWidget.builder(ScreenTexts.DONE, button -> client.setScreen(parent))
.width(doneButtonWidth).build(), 2, adder.copyPositioner().marginTop(doneButtonRowIncrement));
grid.recalculateDimensions();
grid.refreshPositions();
SimplePositioningWidget.setPos(grid, 0, startHeight, this.width, this.height, 0.5f, 0.0f);
addDrawableChild(grid);
grid.forEachChild(this::addDrawableChild);
}
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;
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
super.render(context, mouseX, mouseY, delta);
this.renderBackground(matrices);
final int column1 = width / 2 + column1_offset;
final int column2 = width / 2 + column2_offset;
final int startHeight = (int) Math.floor(height * startHeight_multiplier) + heightOffset;
drawCenteredText(matrices, this.textRenderer, Text.translatable("haxxor.options.farmer.crop_select.seeds"),
// this.renderBackground(context, mouseX, mouseY, delta);
context.drawCenteredTextWithShadow(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"),
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);
super.render(matrices, mouseX, mouseY, delta);
}
public void removed() {
options.save();
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.text.Text;
@ -10,7 +10,7 @@ public class CycleButtonWidget extends ButtonWidget {
public CycleButtonWidget(int x, int y, int width, int height, Text[] options, int startIndex, CycleAction onCycle) {
this(x, y, width, height, options, startIndex, onCycle, ButtonWidget.DEFAULT_NARRATION_SUPPLIER);
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,

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

@ -1,23 +1,26 @@
package cmods.haxxor.client.ui;
package cmods.haxxor.ui;
import cmods.haxxor.client.HaxxorClient;
import cmods.haxxor.client.options.HaxxorOptions;
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.EmptyWidget;
import net.minecraft.client.gui.widget.GridWidget;
import net.minecraft.client.gui.widget.SimplePositioningWidget;
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.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;
}
@ -41,14 +44,17 @@ public class FarmerOptionsScreen extends Screen {
button -> button.setMessage(HaxxorClient.toggleAutoFarmer() ? enabledText : disabledText))
.position(column1, startHeight).build());
adder.add(ButtonWidget.builder(Text.translatable("haxxor.options.farmer.edit_actions"),
button -> client.setScreen(new CropSelectScreen(this)))
.position(column2, 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(new EmptyWidget(0, 0));
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));
@ -65,18 +71,18 @@ public class FarmerOptionsScreen extends Screen {
adder.add(ButtonWidget.builder(ScreenTexts.DONE, button -> client.setScreen(parent))
.width(doneButtonWidth).build(), 2, adder.copyPositioner().marginTop(doneButtonRowIncrement));
grid.recalculateDimensions();
grid.refreshPositions();
SimplePositioningWidget.setPos(grid, 0, startHeight, this.width, this.height, 0.5f, 0.0f);
addDrawableChild(grid);
grid.forEachChild(this::addDrawableChild);
}
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 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() {
options.save();
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

@ -1,20 +1,23 @@
package cmods.haxxor.client.ui;
package cmods.haxxor.ui;
import cmods.haxxor.client.HaxxorClient;
import cmods.haxxor.client.options.HaxxorOptions;
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.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.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,28 +34,41 @@ 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(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.cancel_fall_damage));
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.recalculateDimensions();
grid.refreshPositions();
SimplePositioningWidget.setPos(grid, 0, startHeight, this.width, this.height, 0.5f, 0.0f);
addDrawableChild(grid);
grid.forEachChild(this::addDrawableChild);
}
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
renderBackground(matrices);
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);
drawCenteredText(matrices, textRenderer, title, this.width / 2, 15, 0xffffff);
drawTextWithShadow(matrices, textRenderer, versionText, this.width - textRenderer.getWidth(versionText) - 2,
context.drawCenteredTextWithShadow(textRenderer, title, width / 2, 15, 0xffffff);
context.drawTextWithShadow(textRenderer, versionText, width - textRenderer.getWidth(versionText) - 2,
this.height - textRenderer.fontHeight - 2, 0xffffff);
super.render(matrices, mouseX, mouseY, delta);
}
public void removed() {
global_options.save();
}
}

View File

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

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",
"compatibilityLevel": "JAVA_17",
"mixins": [
"GlobalGlow",
"GlobalGlowAll"
],
"client": [
"HudMixin",
"OptionsMixin",
"PauseMixin"
],
"client": [],
"injectors": {
"defaultRequire": 1
}

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 void toggle() {
value = !value;
}
}

View File

@ -1,105 +0,0 @@
package cmods.haxxor.client.options;
import cmods.haxxor.client.AutoFarmer;
import java.util.prefs.Preferences;
public final class HaxxorOptions {
private static HaxxorOptions instance = null;
public final AutoFarmerOptions autoFarmer;
public final FlyHackOptions flyHack;
public BooleanOption cancel_fall_damage = new BooleanOption(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 BooleanOption enabled = new BooleanOption(false);
public BooleanOption move_seeds = new BooleanOption(true);
public IntegerOption min_y = new IntegerOption(-2);
public IntegerOption max_y = new IntegerOption(1);
public IntegerOption horizontal_reach = new IntegerOption(4);
public 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() { }
private void load() {
move_seeds.value = prefs.getBoolean("move_seeds", move_seeds.value);
min_y.value = prefs.getInt("min_y", min_y.value);
max_y.value = prefs.getInt("max_y", max_y.value);
horizontal_reach.value = prefs.getInt("horizontal_reach", horizontal_reach.value);
max_actions_per_tick.value = prefs.getInt("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 = prefs.getBoolean("seed_" + AutoFarmer.crops[i].seed_type.getName().getString(),
seeds_enabled[i].value);
}
if (AutoFarmer.crops[i].crop_type != null) {
crops_enabled[i].value = prefs.getBoolean("crop_" + AutoFarmer.crops[i].crop_type.getName().getString(),
crops_enabled[i].value);
}
}
}
private void save() {
prefs.putBoolean("move_seeds", move_seeds.value);
prefs.putInt("min_y", min_y.value);
prefs.putInt("max_y", max_y.value);
prefs.putInt("horizontal_reach", horizontal_reach.value);
prefs.putInt("max_actions_per_tick", max_actions_per_tick.value);
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].value);
}
if (AutoFarmer.crops[i].crop_type != null) {
prefs.putBoolean("crop_" + AutoFarmer.crops[i].crop_type.getName().getString(),
crops_enabled[i].value);
}
}
}
}
public static class FlyHackOptions {
public BooleanOption enabled = new BooleanOption(false);
}
}

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,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,42 +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;
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 = 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,79 +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 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 || this.client.isPaused() || 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.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.flyHack.enabled.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

@ -10,9 +10,22 @@
"haxxor.actions.available": "Actions available",
"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.title": "Haxxor Options",
"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.title": "Auto Farm Options",
"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.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",
"key.haxxor.auto_farm": "Auto Farm Toggle",
"key.haxxor.fly": "Fly Hack Toggle"
"key.haxxor.auto_farm": "Auto Farm",
"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,
"id": "haxxor",
"version": "${version}",
"name": "Haxxor",
"name": "Cmods - Haxxor",
"description": "A collection of hacks because yes",
"authors": [
"Cameron Reed"
@ -14,15 +14,20 @@
"icon": "assets/haxxor/icon.png",
"environment": "client",
"entrypoints": {
"client": ["cmods.haxxor.client.HaxxorClient"],
"modmenu": ["cmods.haxxor.client.ModMenuConfig"]
"client": [
"cmods.haxxor.HaxxorClient"
],
"modmenu": [
"cmods.haxxor.ModMenuConfig"
]
},
"mixins": [
"haxxor.mixins.json"
],
"depends": {
"fabricloader": ">=0.14.11",
"fabricloader": ">=0.14.10",
"fabric": "*",
"minecraft": "1.19.3"
"minecraft": "1.21.0",
"cmods": "1.2.2"
}
}