aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe/nea/firmament/mixins/feature/DisableSlotHighlights.java
blob: 0abed224254ff1e2c45c2e61a9385f143ab4c5b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package moe.nea.firmament.mixins.feature;

import moe.nea.firmament.features.fixes.Fixes;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.item.ItemStack;
import net.minecraft.screen.slot.Slot;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(Slot.class)
public abstract class DisableSlotHighlights {
	@Shadow
	public abstract ItemStack getStack();

	@Inject(method = "canBeHighlighted", at = @At("HEAD"), cancellable = true)
	private void dontHighlight(CallbackInfoReturnable<Boolean> cir) {
		if (!Fixes.TConfig.INSTANCE.getHideSlotHighlights()) return;
		var display = getStack().get(DataComponentTypes.TOOLTIP_DISPLAY);
		if (display != null && display.hideTooltip())
			cir.setReturnValue(false);
	}
}