Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/main/java/com/lambda/mixin/items/BlockItemMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2025 Lambda
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.lambda.mixin.items;

import com.lambda.module.modules.render.ContainerPreview;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.tooltip.TooltipData;
import org.spongepowered.asm.mixin.Mixin;

import java.util.Optional;

@Mixin(BlockItem.class)
public class BlockItemMixin extends Item {
public BlockItemMixin(Settings settings) {
super(settings);
}

@Override
public Optional<TooltipData> getTooltipData(ItemStack stack) {
if (ContainerPreview.INSTANCE.isEnabled() && ContainerPreview.isPreviewableContainer(stack)) {
return Optional.of(new ContainerPreview.ContainerComponent(stack));
}
return super.getTooltipData(stack);
}
}
57 changes: 57 additions & 0 deletions src/main/java/com/lambda/mixin/render/DrawContextMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright 2025 Lambda
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.lambda.mixin.render;

import com.lambda.module.modules.render.ContainerPreview;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.tooltip.TooltipComponent;
import net.minecraft.client.gui.tooltip.TooltipPositioner;
import net.minecraft.item.ItemStack;
import net.minecraft.item.tooltip.TooltipData;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;
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;

import java.util.List;
import java.util.Optional;

@Mixin(DrawContext.class)
public class DrawContextMixin {
@Inject(method = "drawTooltip(Lnet/minecraft/client/font/TextRenderer;Ljava/util/List;Ljava/util/Optional;IILnet/minecraft/util/Identifier;)V", at = @At("HEAD"), cancellable = true)
private void onDrawTooltip(TextRenderer textRenderer, List<Text> text, Optional<TooltipData> data, int x, int y, @Nullable Identifier texture, CallbackInfo ci) {
if (!ContainerPreview.INSTANCE.isEnabled()) return;

if (ContainerPreview.isRenderingSubTooltip()) return;

if (ContainerPreview.isLocked()) {
ci.cancel();
ContainerPreview.renderLockedTooltip((DrawContext)(Object)this, textRenderer);
return;
}

if (data.isPresent() && data.get() instanceof ContainerPreview.ContainerComponent component) {
ci.cancel();
ContainerPreview.renderShulkerTooltip((DrawContext)(Object)this, textRenderer, component, x, y);
}
}
}
46 changes: 46 additions & 0 deletions src/main/java/com/lambda/mixin/render/HandledScreenMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2025 Lambda
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.lambda.mixin.render;

import com.lambda.module.modules.render.ContainerPreview;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
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.CallbackInfoReturnable;

@Mixin(HandledScreen.class)
public class HandledScreenMixin {
@Inject(method = "mouseClicked", at = @At("HEAD"), cancellable = true)
private void onMouseClicked(double mouseX, double mouseY, int button, CallbackInfoReturnable<Boolean> cir) {
if (ContainerPreview.INSTANCE.isEnabled() && ContainerPreview.isLocked()) {
if (ContainerPreview.isMouseOverLockedTooltip((int) mouseX, (int) mouseY)) {
cir.setReturnValue(true);
}
}
}

@Inject(method = "mouseReleased", at = @At("HEAD"), cancellable = true)
private void onMouseReleased(double mouseX, double mouseY, int button, CallbackInfoReturnable<Boolean> cir) {
if (ContainerPreview.INSTANCE.isEnabled() && ContainerPreview.isLocked()) {
if (ContainerPreview.isMouseOverLockedTooltip((int) mouseX, (int) mouseY)) {
cir.setReturnValue(true);
}
}
}
}
13 changes: 13 additions & 0 deletions src/main/java/com/lambda/mixin/render/ScreenMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
package com.lambda.mixin.render;

import com.lambda.gui.components.QuickSearch;
import com.lambda.module.modules.render.ContainerPreview;
import com.lambda.module.modules.render.NoRender;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import org.lwjgl.glfw.GLFW;
Expand All @@ -42,4 +46,13 @@ private void onKeyPressed(int keyCode, int scanCode, int modifiers, CallbackInfo
private void injectRenderInGameBackground(DrawContext context, CallbackInfo ci) {
if (NoRender.INSTANCE.isEnabled() && NoRender.getNoGuiShadow()) ci.cancel();
}

@WrapOperation(method = "renderWithTooltip", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;render(Lnet/minecraft/client/gui/DrawContext;IIF)V"))
private void wrapRender(Screen instance, DrawContext context, int mouseX, int mouseY, float deltaTicks, Operation<Void> original) {
original.call(instance, context, mouseX, mouseY, deltaTicks);

if (ContainerPreview.INSTANCE.isEnabled() && ContainerPreview.isLocked()) {
ContainerPreview.renderLockedTooltip(context, MinecraftClient.getInstance().textRenderer);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package com.lambda.mixin.render;

import com.lambda.module.modules.render.ContainerPreview;
import com.lambda.module.modules.render.MapPreview;
import net.minecraft.client.gui.tooltip.BundleTooltipComponent;
import net.minecraft.client.gui.tooltip.ProfilesTooltipComponent;
Expand All @@ -32,6 +33,11 @@
public interface TooltipComponentMixin {
@Inject(method = "of(Lnet/minecraft/item/tooltip/TooltipData;)Lnet/minecraft/client/gui/tooltip/TooltipComponent;", at = @At("HEAD"), cancellable = true)
private static void of(TooltipData tooltipData, CallbackInfoReturnable<TooltipComponent> cir) {
if (ContainerPreview.INSTANCE.isEnabled() && tooltipData instanceof ContainerPreview.ContainerComponent containerComponent) {
cir.setReturnValue(containerComponent);
return;
}

if (MapPreview.INSTANCE.isEnabled()) cir.setReturnValue((switch (tooltipData) {
case MapPreview.MapComponent mapComponent -> mapComponent;
case BundleTooltipData bundleTooltipData -> new BundleTooltipComponent(bundleTooltipData.contents());
Expand Down
Loading
Loading