sakura-ryoko / malilib

Library mod for masa's client-side Minecraft mods
GNU Lesser General Public License v3.0
355 stars 22 forks source link

feat: Entity simple inventory #4

Closed zly2006 closed 5 months ago

zly2006 commented 5 months ago

Previously, if the inventory is SimpleInventory, malilib thinks it is owned by a horse, that is inaccurate.

In this PR, I also added support to piglin's inventory (using villager's type).

Also made the item renderer methods accepts mouseX and mouseY, for https://github.com/sakura-ryoko/minihud/pull/8

zly2006 commented 5 months ago

I'll use this in MiniHUD's inventory preview for piglins and players' inventories.

sakura-ryoko commented 5 months ago

I know what this is referring to, since the "Entity" Inventory Overlay is pretty generic.

Let me know when these changes are finished.

zly2006 commented 5 months ago

Yes it has been finished.

One thing is noticeable:

        if (hoveredStack != null)
        {
            stack = hoveredStack;
            hoveredStack = null;
            // Some mixin / side effects can happen here, so reset hoveredStack
            drawContext.drawItemTooltip(mc.textRenderer, stack, (int) mouseX, (int) mouseY);
        }

Here I used vanilla method to render tooltip, so other mods can mixin into it and display stuff such as shulker box preview, which might cause some problem in some situations. But ccurrently it works fine (with tweakeroo's shulker preview feature)