Skip to content

Commit

Permalink
large fixes and improvements to better tooltips
Browse files Browse the repository at this point in the history
- fix hide flags
- fix container previews
- peek screens can be closed with your inventory key
- fix book previews crashing
- add middle click open for books
  • Loading branch information
Wide-Cat committed May 4, 2024
1 parent ea2e026 commit 89a4454
Show file tree
Hide file tree
Showing 14 changed files with 250 additions and 73 deletions.

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
@@ -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 89a4454

Please sign in to comment.