diff --git a/gradle.properties b/gradle.properties index a30cca6..ddbe22c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ yarn_mappings=1.21+build.9 loader_version=0.16.9 # Mod Properties -mod_version= 1.2.1 +mod_version= 1.2.3 maven_group=org.snail archives_base_name=Snail++ diff --git a/src/main/java/org/snail/plus/mixins/FakePlayerMixin.java b/src/main/java/org/snail/plus/mixins/FakePlayerMixin.java index e525a3d..165459c 100644 --- a/src/main/java/org/snail/plus/mixins/FakePlayerMixin.java +++ b/src/main/java/org/snail/plus/mixins/FakePlayerMixin.java @@ -7,20 +7,17 @@ import meteordevelopment.meteorclient.gui.widgets.containers.WVerticalList; import meteordevelopment.meteorclient.gui.widgets.pressable.WButton; import meteordevelopment.meteorclient.settings.BoolSetting; -import meteordevelopment.meteorclient.settings.IntSetting; import meteordevelopment.meteorclient.settings.Setting; import meteordevelopment.meteorclient.settings.SettingGroup; import meteordevelopment.meteorclient.systems.modules.player.FakePlayer; import meteordevelopment.meteorclient.utils.entity.fakeplayer.FakePlayerEntity; import meteordevelopment.meteorclient.utils.entity.fakeplayer.FakePlayerManager; +import meteordevelopment.meteorclient.utils.player.ChatUtils; import meteordevelopment.orbit.EventHandler; -import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.util.math.Direction; import org.snail.plus.utils.PlayerMovement; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -34,15 +31,13 @@ @Mixin(FakePlayer.class) public class FakePlayerMixin { - @Final - private SettingGroup sgGeneral; - @Unique private final List recordedMovements = new ArrayList<>(); + @Final + private SettingGroup sgGeneral; @Unique private Setting loop = null; - @Unique private boolean recording = false; @Unique @@ -67,11 +62,20 @@ private void onGetWidget(GuiTheme theme, CallbackInfoReturnable info) { WButton start = wHorizontalList.add(theme.button("Start Recording")).widget(); WButton stop = wHorizontalList.add(theme.button("Stop Recording")).widget(); WButton play = wHorizontalList.add(theme.button("Play Recording")).widget(); + WButton clear = wHorizontalList.add(theme.button("Clear all recordings")).widget(); start.action = () -> { stopRecording(); startRecording(); + + }; + + clear.action = () -> { + stopRecording(); + recordedMovements.clear(); + stopLooping(); }; + stop.action = this::stopRecording; play.action = this::startLooping; @@ -85,27 +89,35 @@ private void onGetWidget(GuiTheme theme, CallbackInfoReturnable info) { @Unique @EventHandler private void onTick(TickEvent.Post event) { - for (FakePlayerEntity fakePlayer : FakePlayerManager.getFakePlayers()) { - for(PlayerEntity FakePlayer : mc.world.getPlayers()) { - if (FakePlayer == fakePlayer) { - if (recording) { - recordedMovements.add(new PlayerMovement(mc.player.getX(), mc.player.getY(), mc.player.getZ(), mc.player.getYaw(), mc.player.getPitch())); - } - if (looping && !recordedMovements.isEmpty()) { - PlayerMovement movement = recordedMovements.get(loopIndex); - FakePlayer.updatePosition(movement.x, movement.y, movement.z); - FakePlayer.setVelocity(mc.player.getVelocity().x, mc.player.getVelocity().y, mc.player.getVelocity().z); - loopIndex = (loopIndex + 1) % recordedMovements.size(); - if (loopIndex == 0) { - if (loop.get()) { - startLooping(); - } else { - stopLooping(); + synchronized (this) { + mc.execute(() -> { + try { + for (FakePlayerEntity fakePlayer : FakePlayerManager.getFakePlayers()) { + for (PlayerEntity FakePlayer : mc.world.getPlayers()) { + if (FakePlayer == fakePlayer) { + if (recording) { + recordedMovements.add(new PlayerMovement(mc.player.getX(), mc.player.getY(), mc.player.getZ(), mc.player.getYaw(), mc.player.getPitch())); + } + if (looping && !recordedMovements.isEmpty()) { + PlayerMovement movement = recordedMovements.get(loopIndex); + FakePlayer.updatePosition(movement.x, movement.y, movement.z); + FakePlayer.setVelocity(mc.player.getVelocity().x, mc.player.getVelocity().y, mc.player.getVelocity().z); + loopIndex = (loopIndex + 1) % recordedMovements.size(); + if (loopIndex == 0) { + if (loop.get()) { + startLooping(); + } else { + stopLooping(); + } + } + } } } } + } catch (Exception e) { + ChatUtils.error("An error occurred while playing the recording."); } - } + }); } } diff --git a/src/main/java/org/snail/plus/modules/chat/AutoEZ.java b/src/main/java/org/snail/plus/modules/chat/AutoEZ.java index 841495e..763debf 100644 --- a/src/main/java/org/snail/plus/modules/chat/AutoEZ.java +++ b/src/main/java/org/snail/plus/modules/chat/AutoEZ.java @@ -8,6 +8,7 @@ import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.utils.player.ChatUtils; import meteordevelopment.orbit.EventHandler; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import org.snail.plus.Addon; import org.snail.plus.utils.WorldUtils; @@ -39,7 +40,7 @@ public class AutoEZ extends Module { }); public AutoEZ() { - super(Addon.Snail, "Auto EZ+", "sends a custom message when a player you've killed dies"); + super(Addon.Snail, "Auto EZ+", "sends a custom message when a player dies"); } @Override diff --git a/src/main/java/org/snail/plus/modules/chat/VisualRange.java b/src/main/java/org/snail/plus/modules/chat/VisualRange.java index d043e87..1ee6d25 100644 --- a/src/main/java/org/snail/plus/modules/chat/VisualRange.java +++ b/src/main/java/org/snail/plus/modules/chat/VisualRange.java @@ -50,7 +50,6 @@ public class VisualRange extends Module { private final List entitiesList = new ArrayList<>(); private final Random random = new Random(); - Runnable reset = () -> mc.execute(() -> { entitiesList.clear(); x = 0; @@ -83,9 +82,8 @@ private void onTick(TickEvent.Post event) { if (entities.get().contains(entity.getType()) && !entitiesList.contains(entity)) { if (checkUuid.get() && entity.getUuid() != null) { if (entitiesList.size() < maxAmount.get()) { - if (!soundList.isEmpty()) { - WorldUtils.playSound(soundList.get(random.nextInt(soundList.size())), 1.0f); - } + if (!soundList.isEmpty()) WorldUtils.playSound(soundList.get(random.nextInt(soundList.size())), 1.0f); + warning("Entity spotted %s", entity.getName().getString() + " at " + WorldUtils.getCoords((PlayerEntity) entity)); entitiesList.add(entity); } @@ -93,6 +91,8 @@ private void onTick(TickEvent.Post event) { } } else { if (entities.get().contains(entity.getType()) && entitiesList.contains(entity)) { + if (!soundList.isEmpty()) WorldUtils.playSound(soundList.get(random.nextInt(soundList.size())), 1.0f); + warning("Entity left %s", entity.getName().getString() + " at " + WorldUtils.getCoords((PlayerEntity) entity)); entitiesList.remove(entity); } diff --git a/src/main/java/org/snail/plus/modules/combat/AutoAnchor.java b/src/main/java/org/snail/plus/modules/combat/AutoAnchor.java index ccd4caa..b1e5453 100644 --- a/src/main/java/org/snail/plus/modules/combat/AutoAnchor.java +++ b/src/main/java/org/snail/plus/modules/combat/AutoAnchor.java @@ -23,6 +23,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Box; import net.minecraft.util.math.Vec3d; +import net.minecraft.world.explosion.Explosion; import org.joml.Vector3d; import org.snail.plus.Addon; import org.snail.plus.utils.CombatUtils; @@ -123,6 +124,12 @@ public class AutoAnchor extends Module { .sliderRange(0.0, 36.0) .build()); + private final Setting strictDmg = sgDamage.add(new BoolSetting.Builder() + .name("strict damage") + .description("only place if the damage is exact. No exceptions.") + .defaultValue(false) + .build()); + private final Setting pauseHealth = sgDamage.add(new DoubleSetting.Builder() .name("pause health") .description("Pauses the module when your health is below this value.") @@ -310,6 +317,9 @@ private List positions(PlayerEntity entity, BlockPos start) { selfDamage = DamageUtils.bedDamage(mc.player, vec); targetDamage = DamageUtils.bedDamage(entity, vec); + //immediately return false if self dmg or target dmg is bad + if (strictDmg.get() && selfDamage > maxSelfDamage.get() || targetDamage < minDamage.get()) return false; + if (!airPlace.get() && WorldUtils.isAir(pos.down(1))) return false; if (selfDamage <= maxSelfDamage.get() && targetDamage >= minDamage.get() && WorldUtils.hitBoxCheck(pos, true) && WorldUtils.isAir(pos)) { @@ -329,38 +339,40 @@ private List positions(PlayerEntity entity, BlockPos start) { @EventHandler private void onTick(TickEvent.Post event) { resetDamageValues.run(); - try { - mc.executeTask(() -> { - if (updateEat()) return; - targetDamage = 0; - selfDamage = 0; - if (executor == null || executor.isShutdown() || executor.isTerminated()) { - executor = Executors.newSingleThreadExecutor(); - } - executor.submit(() -> { - if (mc.world.getDimension().respawnAnchorWorks()) { - error("You are in the wrong dimension!"); - return; + synchronized (this) { + try { + mc.executeSync(() -> { + if (updateEat()) return; + targetDamage = 0; + selfDamage = 0; + if (executor == null || executor.isShutdown() || executor.isTerminated()) { + executor = Executors.newSingleThreadExecutor(); } - long currentTime = System.currentTimeMillis(); - if (currentTime - lastUpdateTime < (1000 / updateSpeed.get())) return; + executor.submit(() -> { + if (mc.world.getDimension().respawnAnchorWorks()) { + error("You are in the wrong dimension!"); + return; + } + long currentTime = System.currentTimeMillis(); + if (currentTime - lastUpdateTime < (1000 / updateSpeed.get())) return; - PlayerEntity player = CombatUtils.filter(mc.world.getPlayers(), targetMode.get(), range.get()); - AnchorPos = positions(player, player.getBlockPos()); + PlayerEntity player = CombatUtils.filter(mc.world.getPlayers(), targetMode.get(), range.get()); + AnchorPos = positions(player, player.getBlockPos()); - BestTarget = player; + BestTarget = player; - lock.lock(); - try { - doBreak.run(); - } finally { - lock.unlock(); - } - lastUpdateTime = currentTime; + lock.lock(); + try { + doBreak.run(); + } finally { + lock.unlock(); + } + lastUpdateTime = currentTime; + }); }); - }); - } catch (Exception e) { - error("An error occurred while updating the module: " + e.getMessage()); + } catch (Exception e) { + error("An error occurred while updating the module: " + e.getMessage()); + } } } diff --git a/src/main/java/org/snail/plus/modules/misc/autoXP.java b/src/main/java/org/snail/plus/modules/misc/autoXP.java index a98af32..8542f12 100644 --- a/src/main/java/org/snail/plus/modules/misc/autoXP.java +++ b/src/main/java/org/snail/plus/modules/misc/autoXP.java @@ -9,7 +9,9 @@ import meteordevelopment.orbit.EventHandler; import net.minecraft.item.Items; import net.minecraft.util.Hand; +import net.minecraft.util.math.BlockPos; import org.snail.plus.Addon; +import org.snail.plus.utils.MathUtils; import org.snail.plus.utils.WorldUtils; import org.snail.plus.utils.swapUtils; @@ -23,6 +25,14 @@ public class autoXP extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); + + private final Setting pitch = sgGeneral.add(new DoubleSetting.Builder() + .name("pitch") + .description("Pitch to look at when using XP bottles.") + .defaultValue(-90.0) + .sliderRange(-90.0, 90.0) + .build()); + public final Setting pauseHealth = sgGeneral.add(new DoubleSetting.Builder() .name("pause-health") .description("Pauses when you go below a certain health.") @@ -41,7 +51,8 @@ public class autoXP extends Module { .description("the slot to move the xp to") .defaultValue(0) .sliderRange(0, 10) - .visible(() -> autoSwitch.get().equals(swapUtils.swapMode.silent) || autoSwitch.get().equals(swapUtils.swapMode.normal) || autoSwitch.get().equals(swapUtils.swapMode.Move)) + .visible(() -> autoSwitch.get().equals(swapUtils.swapMode.silent) || autoSwitch.get().equals(swapUtils.swapMode.normal) + || autoSwitch.get().equals(swapUtils.swapMode.Move)) .build()); private final Setting handSwing = sgGeneral.add(new EnumSetting.Builder() @@ -50,6 +61,12 @@ public class autoXP extends Module { .defaultValue(WorldUtils.HandMode.MainHand) .build()); + private final Setting pauseUse = sgGeneral.add(new BoolSetting.Builder() + .name("pause-use") + .description("Pause using xp bottles when using other items.") + .defaultValue(false) + .build()); + private final Setting cooldownTime = sgGeneral.add(new IntSetting.Builder() .name("cooldown-time") .description("Cooldown time between using XP bottles (in ticks).") @@ -90,7 +107,7 @@ public class autoXP extends Module { }; private final Runnable interact = () -> { - Rotations.rotate(mc.player.getYaw(), Rotations.getPitch(mc.player.getBlockPos().down(1)), this::interact); + interact(); mc.player.swingHand(WorldUtils.swingHand(handSwing.get())); }; @@ -110,7 +127,8 @@ public void onDeactivate() { @EventHandler private void onTick(TickEvent.Post event) { - mc.executeSync(() -> { + mc.executeSync(() -> { + if (pauseUse.get() && mc.player.isUsingItem()) return; if (autoDisable.get() && isArmorFullDurability()) { toggle(); return; @@ -128,7 +146,8 @@ private void onTick(TickEvent.Post event) { if (currentTime - lastUseTime < cooldownTime.get() * 50) return; slot = item.slot(); - interact.run(); + Rotations.rotate(mc.player.getYaw(), pitch.get(), 100, interact); + lastUseTime = currentTime; }); } diff --git a/src/main/java/org/snail/plus/modules/render/BurrowEsp.java b/src/main/java/org/snail/plus/modules/render/BurrowEsp.java index d8858c9..05eca55 100644 --- a/src/main/java/org/snail/plus/modules/render/BurrowEsp.java +++ b/src/main/java/org/snail/plus/modules/render/BurrowEsp.java @@ -90,14 +90,16 @@ public void onDeactivate() { @EventHandler private void onTick(TickEvent.Pre event) { - synchronized (burrowedPlayers) { - burrowedPlayers.clear(); - mc.world.getPlayers().stream() - .filter(player -> !(ignoreFriends.get() && Friends.get().isFriend(player))) - .filter(player -> CombatUtils.isBurrowed(player) && mc.player.distanceTo(player) <= range.get()) - .limit(performance.get() ? maxPlayers.get() : Long.MAX_VALUE) - .forEach(burrowedPlayers::add); - } + mc.executeSync(() -> { + synchronized (this.burrowedPlayers) { + burrowedPlayers.clear(); + mc.world.getPlayers().stream() + .filter(player -> !(ignoreFriends.get() && Friends.get().isFriend(player))) + .filter(player -> CombatUtils.isBurrowed(player) && mc.player.distanceTo(player) <= range.get()) + .limit(performance.get() ? maxPlayers.get() : Long.MAX_VALUE) + .forEach(burrowedPlayers::add); + } + }); } @EventHandler