Skip to content

Commit

Permalink
PacketMine rewrite (works), Gradient setting crashing, Mixin priority…
Browse files Browse the repository at this point in the history
… compatibility, HoleUtils optimisation, NoSlow actually works now, More strict sprint checks, AutoTotem changes, and some better rendering, removed ModMenu dependency.
  • Loading branch information
tanishisherewithhh committed Sep 24, 2024
1 parent d1e1182 commit ce4d26d
Show file tree
Hide file tree
Showing 34 changed files with 433 additions and 255 deletions.
4 changes: 0 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ repositories {
includeGroupByRegex 'dev\\.onyxstudios.*'
}
}
maven { url "https://maven.terraformersmc.com/releases/" }
maven {
name = "meteor-maven"
url = "https://maven.meteordev.org/releases"
Expand Down Expand Up @@ -76,9 +75,6 @@ dependencies {
// LuaJ library
modInclude("org.luaj:luaj-jse:3.0.1")

// ModMenu
modApi "com.terraformersmc:modmenu:${project.modmenu_version}"

// Discord GameSDK
modInclude('com.github.JnCrMx:discord-game-sdk4j:v0.5.5')

Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ archives_base_name = heliosclient

# Dependencies
fabric_version=0.91.1+1.20.4
modmenu_version=9.0.0
baritone_version=1.20.4-SNAPSHOT
12 changes: 0 additions & 12 deletions src/main/java/dev/heliosclient/ModMenuIntegration.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,6 @@ public void renderElement(DrawContext drawContext, TextRenderer textRenderer) {
int yOffset = this.y; // Start rendering from this.y

for (Module_ m : enabledModules) {
if (!m.showInModulesList.value) continue;

String info = m.getInfoString();

float nameWidth = Renderer2D.getStringWidth(m.name) + getInfoStringWidth(info);
Expand All @@ -239,11 +237,12 @@ public void renderElement(DrawContext drawContext, TextRenderer textRenderer) {
}
}

if (sideLines.value)
if (sideLines.value) {
// Draw a vertical separator line
Renderer2D.drawRectangle(drawContext.getMatrices().peek().getPositionMatrix(),
x - 2.3f + width, yOffset, 2,
Math.round(Renderer2D.getStringHeight()) + 3, colorToRenderIn.getRGB());
}

// Draw the module name
Renderer2D.drawString(drawContext.getMatrices(), m.name,
Expand Down Expand Up @@ -282,6 +281,7 @@ private float getInfoStringWidth(String infoString) {
@SubscribeEvent
public void update(TickEvent.CLIENT event) {
enabledModules = ModuleManager.getEnabledModules();
enabledModules.removeIf(module -> !module.showInModulesList.value);
enabledModules.sort(getComparator());


Expand Down
19 changes: 17 additions & 2 deletions src/main/java/dev/heliosclient/mixin/ClientPlayerEntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import dev.heliosclient.module.modules.render.Freecam;
import dev.heliosclient.module.modules.world.BetterPortals;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.entity.MovementType;
Expand All @@ -26,7 +25,7 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(value = ClientPlayerEntity.class, priority = 600)
@Mixin(value = ClientPlayerEntity.class, priority = 620)
public abstract class ClientPlayerEntityMixin {

@Unique
Expand All @@ -38,6 +37,8 @@ public abstract class ClientPlayerEntityMixin {
@Shadow
protected abstract void sendMovementPackets();

@Shadow public abstract boolean isSneaking();

@Inject(method = "move", at = @At(value = "HEAD"), cancellable = true)
public void onMove(MovementType type, Vec3d movement, CallbackInfo ci) {
PlayerMotionEvent event = new PlayerMotionEvent(type, movement);
Expand Down Expand Up @@ -79,6 +80,20 @@ private float onHunger(float constant) {
return constant;
}

@Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isUsingItem()Z"), require = 0)
private boolean tickMovementHook(ClientPlayerEntity player) {
if (NoSlow.get().items.value && NoSlow.get().isActive())
return false;
return player.isUsingItem();
}

@Inject(method = "shouldSlowDown", at = @At("HEAD"), cancellable = true)
public void shouldSlowDownHook(CallbackInfoReturnable<Boolean> cir) {
if(NoSlow.get().isActive() && (NoSlow.get().sneak.value || NoSlow.get().crawl.value)) {
cir.setReturnValue(false);
}
}

@Inject(method = "tick", at = @At(value = "HEAD"), cancellable = true)
public void onTick(CallbackInfo ci) {
if (HeliosClient.MC.player != null) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/heliosclient/mixin/MixinChatScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(value = ChatScreen.class, priority = 1001)
@Mixin(value = ChatScreen.class, priority = 100)
public abstract class MixinChatScreen {
@Shadow
protected TextFieldWidget chatField;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public abstract class MixinItemRenderer {
)
)
private void modifyEnchant(Args args, ItemStack stack, ModelTransformationMode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model) {
if (NoRender.get().isActive() && !NoRender.get().noEnchantGlint.value) return;
if (NoRender.enchantGlint()) return;
boolean bl = (renderMode == ModelTransformationMode.GUI || renderMode.isFirstPerson() || !(stack.getItem() instanceof BlockItem blockItem) || !(blockItem.getBlock() instanceof TransparentBlock) && !(blockItem.getBlock() instanceof StainedGlassPaneBlock));
args.set(5, vertexConsumers.getBuffer(RenderLayers.getItemLayer(stack, bl)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

import static dev.heliosclient.util.render.textures.ClientTexture.CLIENT_LOGO_TEXTURE;

@Mixin(value = SplashOverlay.class, priority = 3000)
@Mixin(value = SplashOverlay.class, priority = 3001)
public abstract class MixinSplashScreen {

@Unique
Expand Down
34 changes: 8 additions & 26 deletions src/main/java/dev/heliosclient/module/Module_.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import dev.heliosclient.HeliosClient;
import dev.heliosclient.event.SubscribeEvent;
import dev.heliosclient.event.events.TickEvent;
import dev.heliosclient.event.events.player.PlayerMotionEvent;
import dev.heliosclient.event.events.render.RenderEvent;
import dev.heliosclient.event.listener.Listener;
import dev.heliosclient.managers.EventManager;
import dev.heliosclient.managers.ModuleManager;
Expand Down Expand Up @@ -37,12 +35,12 @@ public abstract class Module_ implements Listener, ISettingChange, ISaveAndLoad
public Set<SettingGroup> settingGroups;
public Set<Setting<?>> quickSettings;
public boolean settingsOpen = false;
public SettingGroup sgbind = new SettingGroup("Bind");
public SettingGroup sgBind = new SettingGroup("Bind");

/**
* Setting indicating if chat feedback for this module should be shown. Don't remove, that will cause crash.
*/
public BooleanSetting chatFeedback = sgbind.add(new BooleanSetting.Builder()
public BooleanSetting chatFeedback = sgBind.add(new BooleanSetting.Builder()
.name("Enable chat feedback")
.description("Toggles feedback in chat.")
.onSettingChange(this)
Expand All @@ -53,7 +51,7 @@ public abstract class Module_ implements Listener, ISettingChange, ISaveAndLoad
/**
* Setting that will tell module list if it should be shown. Don't remove, that will cause crash.
*/
public BooleanSetting showInModulesList = sgbind.add(new BooleanSetting.Builder()
public BooleanSetting showInModulesList = sgBind.add(new BooleanSetting.Builder()
.name("Show in Modules List")
.description("If this module should show up in Module List.")
.onSettingChange(this)
Expand All @@ -64,7 +62,7 @@ public abstract class Module_ implements Listener, ISettingChange, ISaveAndLoad
/**
* Key-bind setting. Don't remove, that will cause crash.
*/
public KeyBind keyBind = sgbind.add(new KeyBind.Builder()
public KeyBind keyBind = sgBind.add(new KeyBind.Builder()
.name("Keybind")
.description("Key to toggle this module.")
.onSettingChange(this)
Expand All @@ -75,7 +73,7 @@ public abstract class Module_ implements Listener, ISettingChange, ISaveAndLoad
/**
* Key-bind setting. Don't remove, that will cause crash.
*/
public BooleanSetting toggleOnBindRelease = sgbind.add(new BooleanSetting.Builder()
public BooleanSetting toggleOnBindRelease = sgBind.add(new BooleanSetting.Builder()
.name("Toggle On Bind Release")
.description("Toggle on if key is being held and off if key is released")
.onSettingChange(this)
Expand All @@ -87,7 +85,7 @@ public abstract class Module_ implements Listener, ISettingChange, ISaveAndLoad
/**
* Value indicating if module is enabled. Don't remove, that will cause crash.
*/
public BooleanSetting active = sgbind.add(new BooleanSetting.Builder()
public BooleanSetting active = sgBind.add(new BooleanSetting.Builder()
.name("Active")
.description("State of this module.")
.onSettingChange(this)
Expand Down Expand Up @@ -157,7 +155,6 @@ public void addQuickSettings(List<Setting<?>> setting) {
public void onEnable() {
active.value = true;
if (chatFeedback.value) {
assert mc.player != null;
ChatUtils.sendHeliosMsg(this.name + " was enabled.");
}
EventManager.register(this);
Expand All @@ -176,33 +173,18 @@ public boolean isActive() {
public void onDisable() {
active.value = false;
if (chatFeedback.value) {
assert mc.player != null;
ChatUtils.sendHeliosMsg(this.name + " was disabled.");
}
EventManager.unregister(this);
}

/**
* Called on player motion.
*/
@SubscribeEvent
public void onMotion(PlayerMotionEvent event) {
}

/**
* Called on tick.
*/
@SubscribeEvent
public void onTick(TickEvent.CLIENT event) {
}

/**
* Called on render.
*/
@SubscribeEvent
public void render(RenderEvent event) {
}

/**
* Toggles the module.
*/
Expand All @@ -220,7 +202,7 @@ public void toggle() {
public void sendNotification(boolean enabled) {
String description = enabled ? "was enabled!" : "was disabled!";

if (ModuleManager.get(NotificationModule.class).moduleNotification.value && HeliosClient.shouldSendNotification()) {
if (ModuleManager.get(NotificationModule.class).displayModuleNotification()) {
NotificationManager.addNotification(new InfoNotification(this.name, description, 2000, SoundUtils.TING_SOUNDEVENT, enabled ? 1f : 0.5f));
}
}
Expand All @@ -245,7 +227,7 @@ public void setKeybind(Integer keycode) {
* Called on load. Override to remove default settings.
*/
public void onLoad() {
addSettingGroup(sgbind);
addSettingGroup(sgBind);
}

public String getNameWithInfo() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void onDisable() {

@SubscribeEvent
public void onKey(KeyPressedEvent e){
if(e.getKey() == totemSwitchKey.value){
if(e.getKey() == totemSwitchKey.value && mc.currentScreen == null){
doAutoTotem();
timer.restartTimer();
}
Expand All @@ -118,10 +118,10 @@ public void onTick(TickEvent.WORLD event) {
return;
}
if(always.value || didTotemPop || isPlayerLow()) {
doAutoTotem();
boolean status = doAutoTotem();
didTotemPop = false;

if(log.value){
if(log.value && status){
ChatUtils.sendHeliosMsg("Restocked Totem, Totems left: " + InventoryUtils.getItemCountInInventory(Items.TOTEM_OF_UNDYING));
}
}
Expand All @@ -132,11 +132,11 @@ public void onTick(TickEvent.WORLD event) {
}
}

public void doAutoTotem(){
public boolean doAutoTotem(){
boolean offhandHasItem = !mc.player.getOffHandStack().isEmpty();
int itemSlot = InventoryUtils.findItemInInventory(Items.TOTEM_OF_UNDYING);
if(itemSlot == -1 || itemSlot == InventoryUtils.OFFHAND){
return;
if(itemSlot == -1 || itemSlot == InventoryUtils.OFFHAND || mc.player.getOffHandStack().getItem() == Items.TOTEM_OF_UNDYING){
return false;
}

//if is hotbar then swap item with offhand super-fast.
Expand All @@ -151,6 +151,7 @@ public void doAutoTotem(){
mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId,itemSlot,0,SlotActionType.PICKUP,mc.player);
}
}
return true;
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.heliosclient.module.modules.misc;

import dev.heliosclient.HeliosClient;
import dev.heliosclient.managers.NotificationManager;
import dev.heliosclient.module.Categories;
import dev.heliosclient.module.Module_;
Expand Down Expand Up @@ -91,6 +92,10 @@ public void onDisable() {
NotificationManager.INSTANCE.clear();
}

public boolean displayModuleNotification(){
return HeliosClient.shouldSendNotification() && moduleNotification.value;
}

@Override
public void onSettingChange(Setting<?> setting) {
super.onSettingChange(setting);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,16 @@ public GuiMove() {
}

public boolean dontMove() {
return mc.currentScreen == null || mc.currentScreen instanceof AbstractCommandBlockScreen || mc.currentScreen instanceof CreativeInventoryScreen || mc.currentScreen instanceof ChatScreen || mc.currentScreen instanceof AnvilScreen || mc.currentScreen instanceof StructureBlockScreen || mc.currentScreen instanceof SignEditScreen || ClickGUIScreen.INSTANCE.searchBar.isFocused() || mc.currentScreen instanceof AbstractSettingScreen || mc.currentScreen instanceof HudEditorScreen;
return mc.currentScreen == null ||
mc.currentScreen instanceof AbstractCommandBlockScreen ||
mc.currentScreen instanceof CreativeInventoryScreen ||
mc.currentScreen instanceof ChatScreen ||
mc.currentScreen instanceof AnvilScreen ||
mc.currentScreen instanceof StructureBlockScreen ||
mc.currentScreen instanceof SignEditScreen ||
ClickGUIScreen.INSTANCE.searchBar.isFocused() ||
mc.currentScreen instanceof AbstractSettingScreen ||
mc.currentScreen instanceof HudEditorScreen;
}

@SubscribeEvent
Expand Down
19 changes: 16 additions & 3 deletions src/main/java/dev/heliosclient/module/modules/movement/NoSlow.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class NoSlow extends Module_ {

public BooleanSetting items = sgGeneral.add(new BooleanSetting.Builder()
.name("Items")
.description("Should item use slow you down?")
.description("Should item use slow you down? (any item like food, bow, crossbow, trident,shield, etc.)")
.onSettingChange(this)
.defaultValue(true)
.build()
Expand Down Expand Up @@ -48,7 +48,7 @@ public class NoSlow extends Module_ {
.name("Fluid drag")
.description("Should fluid push slow you down?")
.onSettingChange(this)
.defaultValue(true)
.defaultValue(false)
.build()
);
public BooleanSetting hunger = sgGeneral.add(new BooleanSetting.Builder()
Expand All @@ -58,13 +58,26 @@ public class NoSlow extends Module_ {
.defaultValue(true)
.build()
);
public BooleanSetting sneak = sgGeneral.add(new BooleanSetting.Builder()
.name("Sneak")
.description("Should sneaking slow you down?")
.onSettingChange(this)
.defaultValue(true)
.build()
);
public BooleanSetting crawl = sgGeneral.add(new BooleanSetting.Builder()
.name("Crawl")
.description("Should crawling slow you down?")
.onSettingChange(this)
.defaultValue(true)
.build()
);


public NoSlow() {
super("NoSlow", "Removes slowness due to some actions or blocks", Categories.MOVEMENT);
addSettingGroup(sgGeneral);
addQuickSettings(sgGeneral.getSettings());

}

public static NoSlow get() {
Expand Down
Loading

0 comments on commit ce4d26d

Please sign in to comment.