in survival with op
ilobilo opened this issue ยท 5 comments
There isn't currently a way to do this. The main issue is that (server-side) commands are limited in characters, so automatically calling a command like /item replace entity @s inventory.<slot> with <item>
would be restricted to very simple items. In theory it could automatically call /gamemode creative
, then send the item set packet, then /gamemode survival
, but that isn't ideal.
While anything that modifies your inventory doesn't work, the mod currently already supports the client chest, which would allow you to transfer items from a survival server (no op required), but not to a survival server. I believe you can also edit items within the client chest, but I haven't tried it. In theory it should work though. Obviously that isn't really what your looking for.
In theory nbt can be "built" by running successive /data modify|merge
commands on nbt storage. However it would probably be very slow. It would also require a container or entity as an intermediary to transfer the item from nbt storage back into your inventory. Basically this would be automated:
/data modify storage nbteditor:username_rand item set from entity @s Inventory[{Slot:<slot>}]
- Repeatedly, keeping chars under limit:
/data modify storage nbteditor:username_rand <changes in nbt here>
/data remove storage nbteditor:username_rand item.Slot
/summon pig ~ ~ ~ {"nbteditor:username_rand":1b}
/item replace @e[type=pig,nbt={"nbteditor:username_rand":1b},sort=nearest,limit=1] armor.head with stone
/data modify entity @e[type=pig,nbt={"nbteditor:username_rand":1b},sort=nearest,limit=1] Inventory[0] merge from storage nbteditor:username_rand item
/data remove storage nbteditor:username_rand item
/item replace entity @s inventory.<slot> from entity @e[type=pig,nbt={"nbteditor:username_rand":1b},sort=nearest,limit=1] armor.head
/kill @e[type=pig,nbt={"nbteditor:username_rand":1b},sort=nearest,limit=1]
This also doesn't work if the entire path and value of a single tag is longer than the limit (mainly a problem in long strings).
Is there a particular technique mentioned above that you want me to try implementing?
I found another nbt editor plugin: https://github.com/qyl27/NBTEdit, it's not as easy to use but it just needs op and can edit items in survival mode. I don't know much of java and can't find how they do it but i think it could be useful to you.
It looks like that mod is both client-side and server-side, so it only works on modded servers that include that mod (or singleplayer). Mods that are on both the client and server are much more powerful, as they can have things like a custom survival mode item editing packet. Generally I would like to keep this mod fully client-side, as it gives more flexibility to where it can be used; it works in vanilla servers, and even forge servers that don't require client side mods.
I have been considering making this mod server-side optionally, meaning that all of the current features still work, but special features like survival-mode editing, entity editing, etc. would be added. I'll look into the concept some more, but I can't guarantee it will come out soon; I don't have much experience with client-server communication in mods.