Minecraft – How to can save player potion effects after death

minecraft-java-edition

Is there some way that I can save player potion effects after death? I have already tried this command: /gamerule keepInventory True but it doesn't work. Is there any way to save player potion effects after death?

Best Answer

This problem can be solved like this:

If they obtain the potion effect via redstone switch or button, then have that switch or button set off a redstone signal leading to command block, as shown in this picture:

enter image description here

The Command block branching off to the right of the button will give the player the effect, and the one branching off to the left will place the block of redstone shown above it. This will cause an extremely rapid redstone clock updating the command block thats connected to the clock. This will check for player death. If a player death is detected, it will cause the comparator to send a signal to the connected command block and will give the player their effect back. This method works as of minecraft 1.7.10.