Skip to content

Commit

Permalink
impl AutoXPModule Rotate and Rotate Pitch
Browse files Browse the repository at this point in the history
  • Loading branch information
hockeyl8 committed Apr 14, 2024
1 parent 6ff47d1 commit 122e4bd
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 50 deletions.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_version}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
//modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "cabaletta:baritone-api:${baritone_api_version}"
// modImplementation "cabaletta:baritone-deobf-unoptimized-mcp-dev:1.2"
}

processResources {
Expand Down
3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ loader_version=0.15.7

mod_version=1.0
build_number=6
# b = beta, d = dev
build_identifier=b
build_identifier=dev
maven_group=net.shoreline
archives_base_name=shoreline

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/shoreline/client/ShorelineMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public class ShorelineMod implements ClientModInitializer {
public static final String MOD_NAME = "Shoreline";
public static final String MOD_VER = BuildConfig.VERSION;
public static final String MOD_BUILD_NUMBER = BuildConfig.BUILD_IDENTIFIER + BuildConfig.BUILD_NUMBER;
public static final String MOD_BUILD_NUMBER = BuildConfig.BUILD_IDENTIFIER + "-" + BuildConfig.BUILD_NUMBER;
public static final String MOD_MC_VER = "1.20.4";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.shoreline.client.api.config.setting.NumberConfig;
import net.shoreline.client.api.event.listener.EventListener;
import net.shoreline.client.api.module.ModuleCategory;
import net.shoreline.client.api.module.RotationModule;
import net.shoreline.client.api.module.ToggleModule;
import net.shoreline.client.impl.event.network.PlayerTickEvent;
import net.shoreline.client.impl.module.exploit.PhaseModule;
Expand All @@ -26,23 +27,25 @@
* @author hockeyl8
* @since 1.0
*/
public class AutoXPModule extends ToggleModule {
public class AutoXPModule extends RotationModule {

Config<Float> delay = new NumberConfig<>("Delay", "Delay to throw xp in ticks.", 1.0f, 1.0f, 10.0f, NumberDisplay.DEFAULT);
Config<Float> delayConfig = new NumberConfig<>("Delay", "Delay to throw xp in ticks.", 1.0f, 1.0f, 10.0f, NumberDisplay.DEFAULT);
Config<Boolean> durabilityCheckConfig = new BooleanConfig("DurabilityCheck", "Check if your armor and held item durability is full then disables if it is.", true);
Config<Boolean> rotateConfig = new BooleanConfig("Rotate", "Rotates the player while throwing xp.", false);
Config<Float> rotatePitchConfig = new NumberConfig<>("RotatePitch", "Delay to throw xp in ticks.", 1.0f, 90.0f, 90.0f, NumberDisplay.DEFAULT);
Config<Boolean> swingConfig = new BooleanConfig("Swing", "Swings hand while throwing xp.", false);

private final TickTimer delayTimer = new TickTimer();


public AutoXPModule() {
super("AutoXP", "Automatically throws xp silently.", ModuleCategory.COMBAT);
super("AutoXP", "Automatically throws xp silently.", ModuleCategory.COMBAT, 850);
}

@EventListener
public void onPlayerTick(PlayerTickEvent event) {

if (mc.player == null || !delayTimer.passed(delay.getValue())) return;
if (mc.player == null || !delayTimer.passed(delayConfig.getValue())) return;

if (durabilityCheckConfig.getValue() && areItemsFullDura(mc.player)) {
disable();
Expand All @@ -62,12 +65,20 @@ public void onPlayerTick(PlayerTickEvent event) {
disable();
return;
}

float prevYaw = mc.player.getYaw();
float prevPitch = mc.player.getPitch();

Managers.INVENTORY.setSlot(slot);
if (rotateConfig.getValue()) {
setRotation(mc.player.getYaw(), rotatePitchConfig.getValue());
}
Managers.NETWORK.sendSequencedPacket(id -> new PlayerInteractItemC2SPacket(Hand.MAIN_HAND, id));
if (swingConfig.getValue()) {
mc.player.swingHand(Hand.MAIN_HAND);
}
Managers.INVENTORY.setSlot(prev);
setRotationClient(prevYaw, prevPitch);
delayTimer.reset();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,46 +83,46 @@ public void hookRender(final DrawContext context, final int mouseX, final int mo
}

// Autism
@Inject(method = "init", at = @At(value = "HEAD"), cancellable = true)
private void hookInit(CallbackInfo ci) {
ci.cancel();
if (this.splashText == null) {
this.splashText = this.client.getSplashTextLoader().get();
}
int i = this.textRenderer.getWidth(COPYRIGHT);
int j = this.width - i - 2;
int k = 24;
int l = this.height / 4 + 48;
if (this.client.isDemo()) {
this.initWidgetsDemo(l, 24);
} else {
this.initWidgetsNormal(l, 24);
}
TextIconButtonWidget textIconButtonWidget = this.addDrawableChild(AccessibilityOnboardingButtons.createLanguageButton(20, button -> this.client.setScreen(new LanguageOptionsScreen((Screen)this, this.client.options, this.client.getLanguageManager())), true));
textIconButtonWidget.setPosition(this.width / 2 - 124, l + 72 + 24);
this.addDrawableChild(ButtonWidget.builder(Text.translatable("menu.options"), button -> this.client.setScreen(new OptionsScreen(this, this.client.options))).dimensions(this.width / 2 - 100, l + 72 + 24, 98, 20).build());
this.addDrawableChild(ButtonWidget.builder(Text.translatable("menu.quit"), button -> this.client.scheduleStop()).dimensions(this.width / 2 + 2, l + 72 + 24, 98, 20).build());
TextIconButtonWidget textIconButtonWidget2 = this.addDrawableChild(AccessibilityOnboardingButtons.createAccessibilityButton(20, button -> this.client.setScreen(new AccessibilityOptionsScreen(this, this.client.options)), true));
textIconButtonWidget2.setPosition(this.width / 2 + 104, l + 72 + 24);
this.addDrawableChild(new PressableTextWidget(j, this.height - 10, i, 10, COPYRIGHT, button -> this.client.setScreen(new CreditsAndAttributionScreen(this)), this.textRenderer));
if (this.realmsNotificationGui == null) {
this.realmsNotificationGui = new RealmsNotificationsScreen();
}
if (this.isRealmsNotificationsGuiDisplayed()) {
this.realmsNotificationGui.init(this.client, this.width, this.height);
}
}
// @Inject(method = "init", at = @At(value = "HEAD"), cancellable = true)
// private void hookInit(CallbackInfo ci) {
// ci.cancel();
// if (this.splashText == null) {
// this.splashText = this.client.getSplashTextLoader().get();
// }
// int i = this.textRenderer.getWidth(COPYRIGHT);
// int j = this.width - i - 2;
// int k = 24;
// int l = this.height / 4 + 48;
// if (this.client.isDemo()) {
// this.initWidgetsDemo(l, 24);
// } else {
// this.initWidgetsNormal(l, 24);
// }
// TextIconButtonWidget textIconButtonWidget = this.addDrawableChild(AccessibilityOnboardingButtons.createLanguageButton(20, button -> this.client.setScreen(new LanguageOptionsScreen((Screen)this, this.client.options, this.client.getLanguageManager())), true));
// textIconButtonWidget.setPosition(this.width / 2 - 124, l + 72 + 24);
// this.addDrawableChild(ButtonWidget.builder(Text.translatable("menu.options"), button -> this.client.setScreen(new OptionsScreen(this, this.client.options))).dimensions(this.width / 2 - 100, l + 72 + 24, 98, 20).build());
// this.addDrawableChild(ButtonWidget.builder(Text.translatable("menu.quit"), button -> this.client.scheduleStop()).dimensions(this.width / 2 + 2, l + 72 + 24, 98, 20).build());
// TextIconButtonWidget textIconButtonWidget2 = this.addDrawableChild(AccessibilityOnboardingButtons.createAccessibilityButton(20, button -> this.client.setScreen(new AccessibilityOptionsScreen(this, this.client.options)), true));
// textIconButtonWidget2.setPosition(this.width / 2 + 104, l + 72 + 24);
// this.addDrawableChild(new PressableTextWidget(j, this.height - 10, i, 10, COPYRIGHT, button -> this.client.setScreen(new CreditsAndAttributionScreen(this)), this.textRenderer));
// if (this.realmsNotificationGui == null) {
// this.realmsNotificationGui = new RealmsNotificationsScreen();
// }
// if (this.isRealmsNotificationsGuiDisplayed()) {
// this.realmsNotificationGui.init(this.client, this.width, this.height);
// }
// }

@Inject(method = "initWidgetsNormal", at = @At(
target = "Lnet/minecraft/client/gui/screen/TitleScreen;addDrawableChild(Lnet/minecraft/client/gui/Element;)Lnet/minecraft/client/gui/Element;",
value = "INVOKE", shift = At.Shift.AFTER, ordinal = 2))
public void hookInit(int y, int spacingY, CallbackInfo ci) {
// parameters from when the method initWidgetsNormal is called
final ButtonWidget widget = ButtonWidget.builder(Text.of("Account Manager"), (action) -> client.setScreen(new AccountSelectorScreen((Screen) (Object) this)))
.dimensions(this.width / 2 - 100, y + spacingY * 3, 200, 20)
.tooltip(Tooltip.of(Text.of("Allows you to switch your in-game account")))
.build();
widget.active = true;
addDrawableChild(widget);
}
// @Inject(method = "initWidgetsNormal", at = @At(
// target = "Lnet/minecraft/client/gui/screen/TitleScreen;addDrawableChild(Lnet/minecraft/client/gui/Element;)Lnet/minecraft/client/gui/Element;",
// value = "INVOKE", shift = At.Shift.AFTER, ordinal = 2))
// public void hookInit(int y, int spacingY, CallbackInfo ci) {
// // parameters from when the method initWidgetsNormal is called
// final ButtonWidget widget = ButtonWidget.builder(Text.of("Account Manager"), (action) -> client.setScreen(new AccountSelectorScreen((Screen) (Object) this)))
// .dimensions(this.width / 2 - 100, y + spacingY * 3, 200, 20)
// .tooltip(Tooltip.of(Text.of("Allows you to switch your in-game account")))
// .build();
// widget.active = true;
// addDrawableChild(widget);
// }
}

0 comments on commit 122e4bd

Please sign in to comment.