Compare commits

..

15 Commits
v2.0.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
25 changed files with 544 additions and 157 deletions

1
.gitignore vendored
View File

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

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,53 +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.0.0-dev.jar")
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.13
minecraft_version=1.21
yarn_mappings=1.21+build.7
loader_version=0.15.11
# Mod Properties
mod_version=2.0.0
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,7 +1,10 @@
package cmods.haxxor.client;
package cmods.haxxor;
import cmods.haxxor.HaxxorModule;
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;
@ -22,6 +25,7 @@ public class HaxxorClient implements ClientModInitializer {
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
@ -46,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);
}
@ -58,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.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

@ -3,11 +3,13 @@ package cmods.haxxor;
import cmods.cmods.api.ButtonBuilder;
import cmods.cmods.api.Module;
import cmods.cmods.api.ModuleOptions;
import cmods.cmods.client.ui.Line;
import cmods.cmods.client.ui.ToggleButton;
import cmods.haxxor.client.AutoFarmer;
import cmods.haxxor.client.options.HaxxorOptions;
import cmods.haxxor.client.ui.FarmerOptionsScreen;
import 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;
@ -15,8 +17,8 @@ import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.function.Consumer;
import static cmods.cmods.client.ui.Constants.buttonHeight;
import static cmods.cmods.client.ui.Constants.buttonWidth;
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;
@ -27,14 +29,20 @@ public class HaxxorModule extends Module {
}
public static void init() {
HaxxorOptions options = HaxxorOptions.getInstance();
ArrayList<ButtonBuilder> optionButtons = new ArrayList<>(2);
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));

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;

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;
@ -16,7 +16,7 @@ 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.flyHackEnabled.get();

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

@ -1,27 +1,25 @@
package cmods.haxxor.client.options;
package cmods.haxxor.options;
import cmods.cmods.api.ModuleOptions;
import cmods.cmods.client.options.BooleanOption;
import cmods.cmods.client.options.CmodsOptions;
import cmods.cmods.client.options.IntegerOption;
import cmods.haxxor.client.AutoFarmer;
import net.fabricmc.loader.api.FabricLoader;
import cmods.cmods.options.BooleanOption;
import cmods.cmods.options.IntegerOption;
import cmods.haxxor.hacks.AutoFarmer;
import org.jetbrains.annotations.Nullable;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Path;
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.";
private final Path properties_file = FabricLoader.getInstance().getConfigDir().resolve("Haxxor.properties");
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);
@ -30,7 +28,6 @@ public final class HaxxorOptions extends ModuleOptions {
public static HaxxorOptions getInstance() {
if (instance == null) {
instance = new HaxxorOptions();
CmodsOptions.addOptions(instance);
}
return instance;
@ -39,12 +36,16 @@ public final class HaxxorOptions extends ModuleOptions {
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);
@ -54,30 +55,13 @@ public final class HaxxorOptions extends ModuleOptions {
// 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());
try {
properties.store(new FileWriter(properties_file.toFile()), "Haxxor Properties");
} catch (IOException e) {
System.out.println("[Haxxor]: Failed to save properties");
}
}
private static boolean getBooleanProperty(@Nullable Properties properties, String key, Boolean default_value) {
if (properties == null)
return default_value;
return Boolean.parseBoolean(properties.getProperty(key, default_value.toString()));
}
private static int getIntegerProperty(@Nullable Properties properties, String key, Integer default_value) {
if (properties == null)
return default_value;
return Integer.parseInt(properties.getProperty(key, default_value.toString()));
}
public static class AutoFarmerOptions {
private final String PREFIX = MODULE_PREFIX + "auto_farmer.";
@ -155,8 +139,8 @@ public final class HaxxorOptions extends ModuleOptions {
private void load(@Nullable Properties properties) {
show_auto_farmer.value = getBooleanProperty(properties, PREFIX + "show_auto_farmer", true);
show_fly_hack.value = getBooleanProperty(properties, PREFIX + "show_fly_hack", true);
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) {
@ -164,4 +148,49 @@ public final class HaxxorOptions extends ModuleOptions {
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,19 +1,19 @@
package cmods.haxxor.client.ui;
package cmods.haxxor.ui;
import cmods.cmods.client.options.CmodsOptions;
import cmods.cmods.client.ui.ToggleButton;
import cmods.haxxor.client.AutoFarmer;
import cmods.haxxor.client.options.HaxxorOptions;
import 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.cmods.client.ui.Constants.*;
import static cmods.cmods.ui.Constants.*;
public class CropSelectScreen extends Screen {
private final CmodsOptions global_options = CmodsOptions.getInstance();
@ -56,25 +56,25 @@ public class CropSelectScreen 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) {
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() {

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,19 +1,19 @@
package cmods.haxxor.client.ui;
package cmods.haxxor.ui;
import cmods.cmods.client.options.CmodsOptions;
import cmods.cmods.client.ui.IntegerAdjustWidget;
import cmods.cmods.client.ui.ToggleButton;
import cmods.haxxor.client.HaxxorClient;
import cmods.haxxor.client.options.HaxxorOptions;
import 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.client.util.math.MatrixStack;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
import static cmods.cmods.client.ui.Constants.*;
import static cmods.cmods.ui.Constants.*;
public class FarmerOptionsScreen extends Screen {
private final Screen parent;
@ -71,15 +71,15 @@ 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() {

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,18 +1,18 @@
package cmods.haxxor.client.ui;
package cmods.haxxor.ui;
import cmods.cmods.client.options.CmodsOptions;
import cmods.cmods.client.ui.ToggleButton;
import cmods.haxxor.client.HaxxorClient;
import cmods.haxxor.client.options.HaxxorOptions;
import 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.cmods.client.ui.Constants.*;
import static cmods.cmods.ui.Constants.*;
public class HaxxorOptionsScreen extends Screen {
private final Screen parent;
@ -40,26 +40,32 @@ public class HaxxorOptionsScreen extends Screen {
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.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() {

View File

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

View File

@ -1,17 +1,17 @@
package cmods.haxxor.client.ui;
package cmods.haxxor.ui;
import cmods.cmods.client.options.CmodsOptions;
import cmods.cmods.client.ui.ToggleButton;
import cmods.haxxor.client.options.HaxxorOptions;
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.client.util.math.MatrixStack;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
import static cmods.cmods.client.ui.Constants.*;
import static cmods.cmods.ui.Constants.*;
public class UIOptionsScreen extends Screen {
private final Screen parent;
@ -45,15 +45,15 @@ public class UIOptionsScreen 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() {

View File

@ -4,6 +4,8 @@
"package": "cmods.haxxor.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"GlobalGlow",
"GlobalGlowAll"
],
"client": [],
"injectors": {

View File

@ -10,6 +10,9 @@
"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",
@ -34,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

@ -14,16 +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",
"cmods": "1.0.0"
"minecraft": "1.21.0",
"cmods": "1.2.2"
}
}