Skip to content

Commit

Permalink
Ugly fix for MC 1.21+ enchantment becomes data-driven changes
Browse files Browse the repository at this point in the history
Signed-off-by: Hendrix-Shen <HendrixShen@hendrixshen.top>
  • Loading branch information
Hendrix-Shen committed Aug 2, 2024
1 parent 08b33cb commit 496ca1c
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
import top.hendrixshen.magiclib.impl.render.context.RenderGlobal;

import java.util.List;

//#if MC > 11605
//$$ import com.mojang.blaze3d.systems.RenderSystem;
//#endif

//#if MC > 11404
import net.minecraft.client.renderer.MultiBufferSource;
import top.hendrixshen.magiclib.util.minecraft.render.RenderUtil;
Expand All @@ -33,8 +35,15 @@

//#if MC > 11904
//$$ import net.minecraft.client.gui.GuiGraphics;
//$$
//#if MC > 12006
//$$ import fi.dy.masa.malilib.util.WorldUtils;
//$$ import net.minecraft.world.item.Item;
//$$ import net.minecraft.world.item.TooltipFlag;
//#else
//$$ import net.minecraft.client.gui.screens.Screen;
//#endif
//#endif

//#if MC > 11605
//$$ import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
Expand Down Expand Up @@ -270,7 +279,19 @@ private void renderSlotHighlight(@NotNull RenderContext renderContext, int x, in
private void renderTooltip(RenderContext renderContext, @NotNull ItemStack itemStack, int x, int y) {
Minecraft mc = Minecraft.getInstance();
//#if MC > 11904
//$$ renderContext.getGuiComponent().renderTooltip(mc.font, Screen.getTooltipFromItem(mc, itemStack), itemStack.getTooltipImage(), x, y);
//$$ renderContext.getGuiComponent().renderTooltip(
//$$ mc.font,
//#if MC > 12006
// TODO: Consider how to treat this after the PCA protocol rewrite.
// Ugly fix for MC 1.21+ enchantment becomes data-driven changes (Use Registry Sync).
// Note: This will not work if Tweakeroo changes the way it fetches item data.
// Registry Sync must be encoded and decoded using the same registries.
// Otherwise, the codec will not be able to parse the data correctly.
//$$ itemStack.getTooltipLines(Item.TooltipContext.of(WorldUtils.getBestWorld(mc)), mc.player, mc.options.advancedItemTooltips ? TooltipFlag.Default.ADVANCED : TooltipFlag.Default.NORMAL),
//#else
//$$ Screen.getTooltipFromItem(mc, itemStack),
//#endif
//$$ itemStack.getTooltipImage(), x, y);
//#else
List<Component> tooltipLines = itemStack.getTooltipLines(mc.player, mc.options.advancedItemTooltips ?
TooltipFlag.Default.ADVANCED : TooltipFlag.Default.NORMAL);
Expand Down

0 comments on commit 496ca1c

Please sign in to comment.