Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/meteor/master' into master…
Browse files Browse the repository at this point in the history
…-ame

# Conflicts:
#	src/main/java/meteordevelopment/meteorclient/commands/Commands.java
#	src/main/java/meteordevelopment/meteorclient/mixin/ChatInputSuggestorMixin.java
#	src/main/java/meteordevelopment/meteorclient/mixin/ClientPlayNetworkHandlerMixin.java
#	src/main/resources/meteor-client.mixins.json
  • Loading branch information
JFronny committed May 10, 2024
2 parents 642c682 + fd1d98b commit 4b640ef
Show file tree
Hide file tree
Showing 16 changed files with 258 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,34 @@
import com.mojang.brigadier.arguments.ArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.systems.config.Config;
import meteordevelopment.meteorclient.utils.Utils;
import meteordevelopment.meteorclient.utils.player.ChatUtils;
import net.minecraft.client.MinecraftClient;
import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.command.CommandSource;
import net.minecraft.registry.BuiltinRegistries;
import net.minecraft.server.command.CommandManager;
import net.minecraft.text.Text;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public abstract class Command {
protected static final CommandRegistryAccess REGISTRY_ACCESS = CommandManager.createRegistryAccess(BuiltinRegistries.createWrapperLookup());
protected static final int SINGLE_SUCCESS = com.mojang.brigadier.Command.SINGLE_SUCCESS;
protected static final MinecraftClient mc = MeteorClient.mc;

private final String name;
private final String title;
private final String description;
private final List<String> aliases = new ArrayList<>();
private final List<String> aliases;

public Command(String name, String description, String... aliases) {
this.name = name;
this.title = Utils.nameToTitle(name);
this.description = description;
Collections.addAll(this.aliases, aliases);
this.aliases = List.of(aliases);
}

// Helper methods to painlessly infer the CommandSource generic type argument
Expand Down

This file was deleted.

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 com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.render.BetterTooltips;
import net.minecraft.item.trim.ArmorTrim;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(ArmorTrim.class)
public class ArmorTrimMixin {
@ModifyExpressionValue(method = "appendTooltip", at = @At(value = "FIELD", target = "Lnet/minecraft/item/trim/ArmorTrim;showInTooltip:Z"))
private boolean modifyShowInTooltip(boolean original) {
BetterTooltips bt = Modules.get().get(BetterTooltips.class);
return (bt.isActive() && bt.upgrades.get()) || original;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
* Copyright (c) Meteor Development.
*/

package meteordevelopment.meteorclient.mixin;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.render.BetterTooltips;
import net.minecraft.item.BundleItem;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(BundleItem.class)
public class BundleItemMixin {
@ModifyExpressionValue(method = "getTooltipData", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;contains(Lnet/minecraft/component/DataComponentType;)Z", ordinal = 0))
private boolean modifyContains1(boolean original) {
BetterTooltips bt = Modules.get().get(BetterTooltips.class);
return !(bt.isActive() && bt.tooltip.get()) && original;
}

@ModifyExpressionValue(method = "getTooltipData", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;contains(Lnet/minecraft/component/DataComponentType;)Z", ordinal = 1))
private boolean modifyContains2(boolean original) {
BetterTooltips bt = Modules.get().get(BetterTooltips.class);
return !(bt.isActive() && bt.additional.get()) && original;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private void onItemPickupAnimation(ItemPickupAnimationS2CPacket packet, Callback
private void onSendChatMessage(String message, CallbackInfo ci) {
if (ignoreChatMessage) return;

if (BaritoneUtils.IS_AVAILABLE || !message.startsWith(BaritoneUtils.getPrefix())) {
if (!(BaritoneUtils.IS_AVAILABLE && message.startsWith(BaritoneUtils.getPrefix()))) {
SendMessageEvent event = MeteorClient.EVENT_BUS.post(SendMessageEvent.get(message));

if (!event.isCancelled()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* This file is part of the Meteor Client distribution (https://github.com/MeteorDevelopment/meteor-client).
* Copyright (c) Meteor Development.
*/

package meteordevelopment.meteorclient.mixin;

import net.minecraft.component.type.ContainerComponent;
import net.minecraft.item.ItemStack;
import net.minecraft.util.collection.DefaultedList;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(ContainerComponent.class)
public interface ContainerComponentAccessor {
@Accessor
DefaultedList<ItemStack> getStacks();
}
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 com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.render.BetterTooltips;
import net.minecraft.component.type.DyedColorComponent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(DyedColorComponent.class)
public class DyedColorComponentMixin {
@ModifyExpressionValue(method = "appendTooltip", at = @At(value = "FIELD", target = "Lnet/minecraft/component/type/DyedColorComponent;showInTooltip:Z"))
private boolean modifyShowInTooltip(boolean original) {
BetterTooltips bt = Modules.get().get(BetterTooltips.class);
return (bt.isActive() && bt.dye.get()) || original;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
import meteordevelopment.meteorclient.utils.Utils;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.BookScreen;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.gui.screen.ingame.ScreenHandlerProvider;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.screen.ScreenHandler;
Expand Down Expand Up @@ -57,6 +59,9 @@ public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen
@Shadow
protected abstract void onMouseClick(Slot slot, int invSlot, int clickData, SlotActionType actionType);

@Shadow
public abstract void close();

@Unique
private static final ItemStack[] ITEMS = new ItemStack[27];

Expand Down Expand Up @@ -104,6 +109,11 @@ private void mouseClicked(double mouseX, double mouseY, int button, CallbackInfo
if (Utils.hasItems(itemStack) || itemStack.getItem() == Items.ENDER_CHEST) {
cir.setReturnValue(Utils.openContainer(focusedSlot.getStack(), ITEMS, false));
}
else if (itemStack.get(DataComponentTypes.WRITTEN_BOOK_CONTENT) != null || itemStack.get(DataComponentTypes.WRITABLE_BOOK_CONTENT) != null) {
close();
mc.setScreen(new BookScreen(BookScreen.Contents.create(itemStack)));
cir.setReturnValue(true);
}
}
}

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 com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.render.BetterTooltips;
import net.minecraft.component.type.ItemEnchantmentsComponent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(ItemEnchantmentsComponent.class)
public class ItemEnchantmentsComponentMixin {
@ModifyExpressionValue(method = "appendTooltip", at = @At(value = "FIELD", target = "Lnet/minecraft/component/type/ItemEnchantmentsComponent;showInTooltip:Z"))
private boolean modifyShowInTooltip(boolean original) {
BetterTooltips bt = Modules.get().get(BetterTooltips.class);
return (bt.isActive() && bt.enchantments.get()) || original;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@

package meteordevelopment.meteorclient.mixin;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.events.entity.player.FinishUsingItemEvent;
import meteordevelopment.meteorclient.events.entity.player.StoppedUsingItemEvent;
import meteordevelopment.meteorclient.events.game.ItemStackTooltipEvent;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.render.BetterTooltips;
import meteordevelopment.meteorclient.utils.Utils;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -37,6 +40,30 @@ private List<Text> onGetTooltip(List<Text> original) {
return original;
}

@ModifyExpressionValue(method = "getTooltip", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/BlockPredicatesChecker;showInTooltip()Z", ordinal = 0))
private boolean modifyCanBreakText(boolean original) {
BetterTooltips bt = Modules.get().get(BetterTooltips.class);
return (bt.isActive() && bt.canDestroy.get()) || original;
}

@ModifyExpressionValue(method = "getTooltip", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/BlockPredicatesChecker;showInTooltip()Z", ordinal = 1))
private boolean modifyCanPlaceText(boolean original) {
BetterTooltips bt = Modules.get().get(BetterTooltips.class);
return (bt.isActive() && bt.canPlaceOn.get()) || original;
}

@ModifyExpressionValue(method = "getTooltip", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;contains(Lnet/minecraft/component/DataComponentType;)Z", ordinal = 0))
private boolean modifyContainsTooltip(boolean original) {
BetterTooltips bt = Modules.get().get(BetterTooltips.class);
return !(bt.isActive() && bt.tooltip.get()) && original;
}

@ModifyExpressionValue(method = "getTooltip", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;contains(Lnet/minecraft/component/DataComponentType;)Z", ordinal = 3))
private boolean modifyContainsAdditional(boolean original) {
BetterTooltips bt = Modules.get().get(BetterTooltips.class);
return !(bt.isActive() && bt.additional.get()) && original;
}

@Inject(method = "finishUsing", at = @At("HEAD"))
private void onFinishUsing(World world, LivingEntity user, CallbackInfoReturnable<ItemStack> info) {
if (user == mc.player) {
Expand All @@ -50,4 +77,10 @@ private void onStoppedUsing(World world, LivingEntity user, int remainingUseTick
MeteorClient.EVENT_BUS.post(StoppedUsingItemEvent.get((ItemStack) (Object) this));
}
}

@ModifyExpressionValue(method = "appendAttributeModifiersTooltip", at = @At(value = "INVOKE", target = "Lnet/minecraft/component/type/AttributeModifiersComponent;showInTooltip()Z"))
private boolean modifyShowInTooltip(boolean original) {
BetterTooltips bt = Modules.get().get(BetterTooltips.class);
return (bt.isActive() && bt.modifiers.get()) || original;
}
}
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 com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.render.BetterTooltips;
import net.minecraft.component.type.UnbreakableComponent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(UnbreakableComponent.class)
public class UnbreakableComponentMixin {
@ModifyExpressionValue(method = "appendTooltip", at = @At(value = "FIELD", target = "Lnet/minecraft/component/type/UnbreakableComponent;showInTooltip:Z"))
private boolean modifyShowInTooltip(boolean original) {
BetterTooltips bt = Modules.get().get(BetterTooltips.class);
return (bt.isActive() && bt.unbreakable.get()) || original;
}
}
Loading

0 comments on commit 4b640ef

Please sign in to comment.