#Preventing certain items from being put in containers
1 messages · Page 1 of 1 (latest)
im honestly not sure if its possible
Probably on inventory click and checking the inventory type. You'd also have to account for items that could be shift clicked into containers too
is there a way to check whats in the container?
Yeah, you'd loop through the slots then see if it contains an item type
then do that and if there is anything that isnt allowed drop it on the ground no?
Yeah, then you'd set the slot to air (assuming a player put a disallowed item in a container before you coded that sorta thing)
Alright ill try that tomorrow but i hoped there would be an easier way😭 😭 🙏
This seems like a very useful feature
Thanks guys
Consider increasing someone's reputation with </reputation increase:1458495875985969212> if you found them to be helpful!
Ill let you know if it works
Look for click types or click actions whatever its called to check for shift click pr hotkey in
Also you might have to cancel the drop event for these items as i think hoppers were a headache
But idk you can give it a try
its not a problem on my server
its prisoners vs guards so all players have adventure mode and cant place anny hoppers
and theres none on the map
``on inventory click:
if event-inventory is not player's inventory:
if click type is shift+lmb:
set {_item} to clicked slot
if {_item} is enchanted with curse of vanishing:
set clicked slot to air
send "&c&lDont put COV items in containers!" to player
else:
set {_item} to cursor slot of player
if {_item} is enchanted with curse of vanishing:
set cursor item of player to air # <--- this doesnt work
send "&c&lDont put COV items in containers!" to player ``
this is what i currently have
it works pretty well outside of set cursor item of player to air not working and on shift+lmb it doesnt delete the item when its placed in the container but when the player tries to take it out of it
if you know any alternatives to set cursor item of player to air please let me know
Pretty sure ive only seen cursor slot not cursor item, but if thats also on the docs should work too
this is how i handle this issue, most likely better ways, but this works for me
Ill try this later
you'll need to add a shift-click check, i forgot to do that in the example i sent
here is the updated fix, also note this requires you to have a boolean nbt tag set on the item to deny it from being able to be moved
here is my updated approach
i gave up on checking when the item is put in a container and just decided to check when the players are taking it out
if event-inventory is not player's inventory: if group of player is not "appl" or "owner" or "coowner" or "community-manager" or "head-builder" or "sr.mod" or "dev" or "mod" or "builder": if click type is number key or shift+lmb: set {_item} to clicked slot if {_item} is enchanted with curse of vanishing: set clicked slot to air sendMessage(player, "<#FF8282>You can't put items with curse of vanishing in containers.") play sound "entity.villager.no" with pitch 0.6 to player else: set {_item} to clicked slot if {_item} is enchanted with curse of vanishing: set clicked slot to air sendMessage(player, "<#FF8282>You can't put items with curse of vanishing in containers.") play sound "entity.villager.no" with pitch 0.6 to player
ill try your version and if it works ill be glad to use it if you dont mind
mine works for me, it stops putting in but allows taking out (in case the item somehow glitches inside of an inventory)
and yes you're free to use it
I might just be missing something but why are you setting both {_canDrop} and {_canTransfer} variables to the boolean tag "canDrop" instead of having a seperate one for {_canTransfer} ?
because some items i want to be able to be transferable in inventories, but not droppable
multiple items have these tags so that's an all around workaround that affects all items how i want
I see now
I will probably modify your code because i only need them to not be transferable