maruohon / litematica

A modern client-side schematic mod for Minecraft
GNU Lesser General Public License v3.0
687 stars 190 forks source link

Item Pick from Shulkerbox #777

Closed Astronomy20 closed 8 months ago

Astronomy20 commented 8 months ago

In one of the constructions in my world, which required many different blocks, I had to use many shulker boxes and place them on the ground. I was wondering if it's possible to introduce/modify the function that allows you to retrieve items from the inventories of shulker boxes, similar to how it works with the player's inventory with the easyplaceMode.

maruohon commented 8 months ago

It's not possible to directly take items out of shulker boxes in the player inventory in a client side mod (except of course in single player, where the mod has access to the server side code as well).

So the next step from that would be to automatically place down the box, take the item, and then break the box. But that brings many issues with trying to decide where to place the box so that it doesn't update any redstone stuff or interfere with something else, and should the box be broken automatically at all, and how to make sure that the broken box item doesn't drop somewhere and get lost... basically I don't want to deal with all those issues. Plus personally I don't even want the base Litematica mod to offer that much automation/shortcuts for survival play. Personally I don't even really like Easy Place mode, it already feels a step too far for me.

There are two options to make it easier to find and grab the box that has the item from your inventory though. One option is just for highlighting the item or the shulker box that has the item for the schematic block you are currently looking at (Generic -> highlightBlockInInventory), and the other is for "pick blocking the shulker" i.e. moving the box to your hand so you can place it yourself to take out the required item (Generic -> pickBlockShulkers).

Astronomy20 commented 8 months ago

And how can I implement this function in an addon for single player world?

tr7zw commented 8 months ago

Since I just noticed that issue while looking for something else, https://github.com/tr7zw/ItemSwapper does implement this exact behavior. Currently looking into fixing some pick block logic I apparently overwrite on litematicas end.

Astronomy20 commented 8 months ago

So @tr7zw are you working on an addon that do what I searching for?

tr7zw commented 8 months ago

I made a mod based on xisumas idea of being quickly able to swap to similar items, even when in shulkers inside the inventory. And a later request was making that work with pick block, also on litematica holograms. So yes, you can pick block litematica hologram blocks from shulkers with it(assuming the server supports it).

Astronomy20 commented 8 months ago

Ok fantastic! Now I just want to know why need the server support for interact with shulkerbox inventory. It’s like a game feature?

maruohon commented 8 months ago

The server manages all the world data, including player inventories. The client can't just modify a shulker box item in the player inventory directly (well it can on the client side ofc... but that doesn't accomplish anything except a desynced inventory). If it could, then any client (mod) could just fill the boxes with whatever items you want. It would be an obvious easy exploit.

So if you have a mod that allows taking out or putting in items to the boxes directly in the inventory, then it needs a server side component that handles doing it on the server side, where the actual player inventory is stored.

Astronomy20 commented 8 months ago

Ok now everything is clear. Thanks to you all