I want to make a PvP data pack for a Minecraft server, and I want it to function as follows: if a player is killed within half a minute of him hitting another player, they should drop all their items, but if they're killed without hitting another player they should keep their inventory. Is this possible? Also, if possible, I would want to do this without using command blocks.
The gamerule keepInventory
can only be applied to the whole Minecraft world. But luckily there's also the /clear
command. You can set /gamerule keepInventory true
and then handle the inventory clearing with commands:
You can detect players who hit someone/got hit like this: Detect when player attacks another player
Then you can use a scoreboard of the deathCount
type to find players who have died (and respawned) and use /clear
to clear their inventory.
If you also want to clear their XP, you can use /xp set <player> 0
.
-
Thanks, but I'm trying to do this without the use of command blocks, and even then I want them to drop their items, not delete them. – Kazek Ciaś Feb 13 '19 at 15:54
-
Without using commands or without using command blocks? You can of course just make a function with the same commands. Without commands, it's impossible, just like keeping the inventory in general. – Fabian Röling Feb 14 '19 at 9:22
-
I was thinking about doing that with a data pack and I'm pretty sure it is possible, but I don't know how. – Kazek Ciaś Feb 14 '19 at 18:32
-
Yes, functions, as I said. They are part of data packs. But what's your reason for not wanting to use command blocks? Performance? – Fabian Röling Feb 14 '19 at 18:37