Skip to content

Commit 19cd002

Browse files
committed
MapPreview enabled check
1 parent 4a5eda0 commit 19cd002

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/main/java/com/lambda/mixin/items/FilledMapItemMixin.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public FilledMapItemMixin(Item.Settings settings) {
3434

3535
@Override
3636
public Optional<TooltipData> getTooltipData(ItemStack stack) {
37-
return Optional.of(new MapPreview.MapComponent(stack));
37+
return MapPreview.INSTANCE.isEnabled()
38+
? Optional.of(new MapPreview.MapComponent(stack))
39+
: super.getTooltipData(stack);
3840
}
3941
}

src/main/java/com/lambda/mixin/render/TooltipComponentMixin.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,11 @@
2828
import org.spongepowered.asm.mixin.injection.Inject;
2929
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
3030

31-
import java.util.Objects;
32-
3331
@Mixin(TooltipComponent.class)
3432
public interface TooltipComponentMixin {
3533
@Inject(method = "of(Lnet/minecraft/item/tooltip/TooltipData;)Lnet/minecraft/client/gui/tooltip/TooltipComponent;", at = @At("HEAD"), cancellable = true)
3634
private static void of(TooltipData tooltipData, CallbackInfoReturnable<TooltipComponent> cir) {
37-
cir.setReturnValue((switch (tooltipData) {
35+
if (MapPreview.INSTANCE.isEnabled()) cir.setReturnValue((switch (tooltipData) {
3836
case MapPreview.MapComponent mapComponent -> mapComponent;
3937
case BundleTooltipData bundleTooltipData -> new BundleTooltipComponent(bundleTooltipData.contents());
4038
case ProfilesTooltipComponent.ProfilesData profilesData -> new ProfilesTooltipComponent(profilesData);

0 commit comments

Comments
 (0)