Skip to content

Commit

Permalink
Merge branch 'MeteorDevelopment:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Funtimes909 committed Sep 12, 2024
2 parents cb5ebe9 + e4fc59e commit ab063cf
Show file tree
Hide file tree
Showing 11 changed files with 208 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.commands.Command;
import meteordevelopment.meteorclient.mixin.MapRendererAccessor;
import net.minecraft.client.render.MapRenderer;
Expand All @@ -18,15 +20,13 @@
import net.minecraft.item.Items;
import net.minecraft.item.map.MapState;
import net.minecraft.text.Text;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.BufferUtils;
import org.lwjgl.PointerBuffer;
import org.lwjgl.system.MemoryUtil;
import org.lwjgl.util.tinyfd.TinyFileDialogs;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
Expand All @@ -52,55 +52,43 @@ public SaveMapCommand() {
@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.executes(context -> {

MapState state = getMapState();
if (state == null) throw MAP_NOT_FOUND.create();
ItemStack map = getMap();

String path = getPath();
if (path == null) throw OOPS.create();

saveMap(map, state, path, 128);
saveMap(128);

return SINGLE_SUCCESS;
}).then(argument("scale", IntegerArgumentType.integer(1)).executes(context -> {
int scale = IntegerArgumentType.getInteger(context, "scale");

MapState state = getMapState();
if (state == null) throw MAP_NOT_FOUND.create();
ItemStack map = getMap();

String path = getPath();
if (path == null) throw OOPS.create();

saveMap(map, state, path, scale);
saveMap(IntegerArgumentType.getInteger(context, "scale"));

return SINGLE_SUCCESS;
}));
}

private void saveMap(@NotNull ItemStack map, MapState state, String path, int scale) {
//this is horrible code but it somehow works
private void saveMap(int scale) throws CommandSyntaxException {
ItemStack map = getMap();
MapState state = getMapState();
if (map == null || state == null) throw MAP_NOT_FOUND.create();

File path = getPath();
if (path == null) throw OOPS.create();

MapRenderer mapRenderer = mc.gameRenderer.getMapRenderer();
MapRenderer.MapTexture texture = ((MapRendererAccessor) mapRenderer).invokeGetMapTexture(map.get(DataComponentTypes.MAP_ID), state);
if (texture.texture.getImage() == null) throw OOPS.create();

int[] data = texture.texture.getImage().makePixelArray();
BufferedImage image = new BufferedImage(128, 128, 2);
image.setRGB(0, 0, image.getWidth(), image.getHeight(), data, 0, 128);
try {
if (scale == 128) texture.texture.getImage().writeTo(path);
else {
int[] data = texture.texture.getImage().makePixelArray();
BufferedImage image = new BufferedImage(128, 128, BufferedImage.TYPE_INT_ARGB);
image.setRGB(0, 0, image.getWidth(), image.getHeight(), data, 0, 128);

BufferedImage scaledImage = new BufferedImage(scale, scale, 2);
if (scale != 128) {
Graphics2D g = scaledImage.createGraphics();
g.setComposite(AlphaComposite.Src);
g.drawImage(image, 0, 0, scale, scale, null);
g.dispose();
}
BufferedImage scaledImage = new BufferedImage(scale, scale, 2);
scaledImage.createGraphics().drawImage(image, 0, 0, scale, scale, null);

try {
ImageIO.write((scale == 128 ? image : scaledImage), "png", new File(path));
ImageIO.write(scaledImage, "png", path);
}
} catch (IOException e) {
e.printStackTrace();
error("Error writing map texture");
MeteorClient.LOG.error(e.toString());
}
}

Expand All @@ -111,12 +99,12 @@ private void saveMap(@NotNull ItemStack map, MapState state, String path, int sc
return FilledMapItem.getMapState(map.get(DataComponentTypes.MAP_ID), mc.world);
}

private @Nullable String getPath() {
private @Nullable File getPath() {
String path = TinyFileDialogs.tinyfd_saveFileDialog("Save image", null, filters, null);
if (path == null) return null;
if (!path.endsWith(".png")) path += ".png";

return path;
return new File(path);
}

private @Nullable ItemStack getMap() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import meteordevelopment.meteorclient.systems.config.Config;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.player.FastUse;
import meteordevelopment.meteorclient.systems.modules.player.Multitask;
import meteordevelopment.meteorclient.systems.modules.render.UnfocusedCPU;
import meteordevelopment.meteorclient.utils.Utils;
import meteordevelopment.meteorclient.utils.misc.CPSUtils;
Expand All @@ -28,6 +29,7 @@
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.Mouse;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.network.ClientPlayerInteractionManager;
import net.minecraft.client.option.GameOptions;
import net.minecraft.client.util.Window;
Expand Down Expand Up @@ -74,6 +76,10 @@ public abstract class MinecraftClientMixin implements IMinecraftClient {
@Shadow
private int itemUseCooldown;

@Shadow
@Nullable
public ClientPlayerEntity player;

@Inject(method = "<init>", at = @At("TAIL"))
private void onInit(CallbackInfo info) {
MeteorClient.INSTANCE.onInitializeClient();
Expand Down Expand Up @@ -186,10 +192,35 @@ private void onRender(CallbackInfo info) {
lastTime = time;
}

// multitask

@ModifyExpressionValue(method = "doItemUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;isBreakingBlock()Z"))
private boolean doItemUseModifyIsBreakingBlock(boolean original) {
return !Modules.get().isActive(Multitask.class) && original;
}

@ModifyExpressionValue(method = "handleBlockBreaking", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isUsingItem()Z"))
private boolean handleBlockBreakingModifyIsUsingItem(boolean original) {
return !Modules.get().isActive(Multitask.class) && original;
}

@ModifyExpressionValue(method = "handleInputEvents", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isUsingItem()Z", ordinal = 0))
private boolean handleInputEventsModifyIsUsingItem(boolean original) {
return !Modules.get().get(Multitask.class).attackingEntities() && original;
}

@Inject(method = "handleInputEvents", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isUsingItem()Z", ordinal = 0, shift = At.Shift.BEFORE))
private void handleInputEventsInjectStopUsingItem(CallbackInfo info) {
if (Modules.get().get(Multitask.class).attackingEntities() && player.isUsingItem()) {
if (!options.useKey.isPressed()) interactionManager.stopUsingItem(player);
while (options.useKey.wasPressed());
}
}

// Interface

@Override
public void rightClick() {
public void meteor_client$rightClick() {
rightClick = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package meteordevelopment.meteorclient.mixin;

import com.mojang.brigadier.exceptions.CommandSyntaxException;
import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.commands.Commands;
import meteordevelopment.meteorclient.systems.config.Config;
import meteordevelopment.meteorclient.systems.modules.Modules;
Expand All @@ -30,8 +31,8 @@

@Mixin(value = Screen.class, priority = 500) // needs to be before baritone
public abstract class ScreenMixin {
@Inject(method = "renderBackground", at = @At("HEAD"), cancellable = true)
private void onRenderBackground(CallbackInfo info) {
@Inject(method = "renderInGameBackground", at = @At("HEAD"), cancellable = true)
private void onRenderInGameBackground(CallbackInfo info) {
if (Utils.canUpdate() && Modules.get().get(NoRender.class).noGuiBackground())
info.cancel();
}
Expand All @@ -51,7 +52,7 @@ private void onRunCommand(Style style, CallbackInfoReturnable<Boolean> cir) {
Commands.dispatch(style.getClickEvent().getValue().substring(Config.get().prefix.get().length()));
cir.setReturnValue(true);
} catch (CommandSyntaxException e) {
e.printStackTrace();
MeteorClient.LOG.error("Failed to run command", e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
* Copyright (c) Meteor Development.
*/

package meteordevelopment.meteorclient.mixin;

import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.misc.ServerSpoof;
import net.minecraft.client.resource.server.ServerResourcePackLoader;
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(ServerResourcePackLoader.class)
public class ServerResourcePackLoaderMixin {
@Inject(method = "onReloadSuccess", at = @At("TAIL"))
private void removeInactivePacksTail(CallbackInfo ci) {
Modules.get().get(ServerSpoof.class).silentAcceptResourcePack = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
package meteordevelopment.meteorclient.mixininterface;

public interface IMinecraftClient {
void rightClick();
void meteor_client$rightClick();
}
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,13 @@ private void initCombat() {
private void initPlayer() {
add(new AntiHunger());
add(new AutoEat());
add(new AutoClicker());
add(new AutoFish());
add(new AutoGap());
add(new AutoMend());
add(new AutoReplenish());
add(new AutoTool());
add(new BreakDelay());
add(new ChestSwap());
add(new EXPThrower());
add(new FakePlayer());
Expand All @@ -443,12 +445,11 @@ private void initPlayer() {
add(new InstantRebreak());
add(new LiquidInteract());
add(new MiddleClickExtra());
add(new BreakDelay());
add(new Multitask());
add(new NoInteract());
add(new NoMiningTrace());
add(new NoRotate());
add(new OffhandCrash());
add(new PacketMine());
add(new Portals());
add(new PotionSaver());
add(new PotionSpoof());
Expand Down Expand Up @@ -538,7 +539,6 @@ private void initRender() {
private void initWorld() {
add(new AirPlace());
add(new Ambience());
add(new Collisions());
add(new AutoBreed());
add(new AutoBrewer());
add(new AutoMount());
Expand All @@ -547,18 +547,20 @@ private void initWorld() {
add(new AutoSign());
add(new AutoSmelter());
add(new BuildHeight());
add(new Collisions());
add(new EChestFarmer());
add(new EndermanLook());
add(new Flamethrower());
add(new HighwayBuilder());
add(new LiquidFiller());
add(new MountBypass());
add(new NoGhostBlocks());
add(new Nuker());
add(new PacketMine());
add(new StashFinder());
add(new SpawnProofer());
add(new Timer());
add(new VeinMiner());
add(new HighwayBuilder());

if (BaritoneUtils.IS_AVAILABLE) {
add(new Excavator());
Expand All @@ -569,23 +571,22 @@ private void initWorld() {
private void initMisc() {
add(new Swarm());
add(new AntiPacketKick());
add(new AutoClicker());
add(new AutoLog());
add(new AutoReconnect());
add(new AutoRespawn());
add(new BetterBeacons());
add(new BetterChat());
add(new BookBot());
add(new DiscordPresence());
add(new InventoryTweaks());
add(new MessageAura());
add(new NameProtect());
add(new Notebot());
add(new Notifier());
add(new PacketCanceller());
add(new ServerSpoof());
add(new SoundBlocker());
add(new Spam());
add(new ServerSpoof());
add(new InventoryTweaks());
}

public static class ModuleRegistry extends SimpleRegistry<Module> {
Expand Down
Loading

0 comments on commit ab063cf

Please sign in to comment.