Chest with permanent item(s)

New member
Posts: 1
Joined: Thu Nov 21, 2019 19:38

Chest with permanent item(s)

by Darthon12 » Thu Nov 21, 2019 19:44

Looking for a way or what to edit in the code of a mod(more chests, copy chest) to give a chest a permanent item that all can grab. Anyone ever done this??

Posts: 156
Joined: Mon May 22, 2017 20:27

Re: Chest with permanent item(s)

by micheal65536 » Thu Nov 21, 2019 20:39

This is definitely possible. You'll need to add/change allow_metadata_inventory_take in the chest's node definition to return -1 for the items/slots that you want to be "permanent". If you want to make only certain slots/items permanent then you'll need to check which slot the item is being taken from and/or what item is being taken.

You'll probably also want to make allow_metadata_inventory_put require a privilege for adding items to the chest, so that the chest can be set up by the server admin but other players can't add their own items and end up creating infinite copies of them (and you might also want to return -1 from this function too so that the item isn't consumed from the player's inventory when added to the chest). For that matter, you should probably make allow_metadata_inventory_take remove the items from the chest (return stack:get_count() rather than -1) if the player has the same privilege, otherwise there will be no way for the server admin to take away a "permanent" item once they've added it. You might also want to make allow_metadata_inventory_move disallow moving items around inside the chest, particularly if you only want the items in certain slots to be permanent.

If you could give more information about your use-case then someone might be able to give more specific advice. Is this supposed to be something that's set up once by the server admin and then played normally by players? Do you want anyone on the server to be able to create and configure their own "permanent item" chests? Do you want the chest to have a mixture of permanent and non-permanent items, or only permanent ones? A "permanent" item is simple to do at a basic level but there are a lot of intricacies to take into consideration (such as how to make it possible to reconfigure the chest, how to prevent misuse/abuse on a server, and so on).

Posts: 3951
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine

Re: Chest with permanent item(s)

by Sokomine » Sun Nov 24, 2019 18:18

The barkhouse server had a treasure mod installed that showed diffrent content for each player. You could pick up your treasure (even partly iirrc), and the next player could pick up his/hers. I don't remember the exact mod name.
A list of my mods can be found here.

User avatar
Posts: 180
Joined: Sun Feb 12, 2017 14:08
Location: Germany
GitHub: theFox6
In-game: theFox

Re: Chest with permanent item(s)

by theFox » Mon Nov 25, 2019 07:56

Darthon12 wrote:Looking for a way or what to edit in the code of a mod(more chests, copy chest) to give a chest a permanent item that all can grab. Anyone ever done this??

Q: Can this be done?
A: It's certainly possible.

Q: Anyone ever done this??
A: I haven't done exactly that, but I have already worked with inventories and chests.

I can make a mod doing this if you wish...
my mods and subgames (ง'̀-'́)ง

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 4 guests