YaLTeR / MouseTweaks

A Minecraft mod that enhances inventory management.
https://minecraft.curseforge.com/projects/mouse-tweaks
BSD 3-Clause "New" or "Revised" License
125 stars 35 forks source link

Mouse tweaks scrolling deletes items with Minecolonies #39

Open Raycoms opened 3 years ago

Raycoms commented 3 years ago

Initial bug report: https://github.com/ldtteam/minecolonies/issues/6078

It's because Minecolonies copies the stack on setStackInSlot.

YaLTeR commented 3 years ago

Might be better to fix in Minecolonies. Generally you don't want things like this to be possible from the client side (Mouse Tweaks is clientside-only).

Raycoms commented 3 years ago

That's strange because shift clicking etc works perfectly fine. Even shifting over several stacks which should have a similar behaviour.

Raycoms commented 3 years ago
    @Override
    public void setStackInSlot(final int slot, @Nonnull final ItemStack stack)
    {
        mainInventory.set(slot, stack.copy());
    }

Basically because we copy here, the scrolling to insert breaks.

YaLTeR commented 3 years ago

How do other inventories do it?

YaLTeR commented 3 years ago

Also FYI Mouse Tweaks doesn't (and can't) directly manipulate containers with setStackInSlot; it implements all its features by simulating button presses using handleMouseClick.

Raycoms commented 3 years ago

Vanilla mostly sets the stack directly, but they don't track inventory changes as we need it. We're tracking the contents of the inventories to avoid changing contents and us not noticing things are gone or new.