4

Best way to freeze a player/mob in place

RADI0R's Avatar RADI0R4/9/22 8:00 am
4 emeralds 124 5
5/5/2022 11:03 am
GrimWitherYT's Avatar GrimWitherYT
I am currently making a datapack, where a tool can make any mob or player freeze in place unable to move or escape.

I originally made an armor stand spawn in the entity's place and execute a command every tick that teleported the tagged "frozen" entity to this armor stand. This proved to work very well. Every mob I tested this on got not only frozen in it's curent position, but they also got frozen mid-air!

However, when I tried this datapack on my multiplayer server, players could easily just walk away from being frozen, which broke the loop and unfroze them. My current theory is that there are way too many other datapacks running on this server every tick, making the function to teleport them unreliable.

Now I'm trying to think of a better option to freeze them both in-place AND hopefully mid-air. It should work more reliably than the teleport function, so it has to execute once and not every tick.
I'm not sure if that's possible so here are my current ideas of options:

  1. Give the entity extreme slowness and jump-boost lvl 128, which makes anything unable to jump (but this way things won't ever freeze mid-air)
  2. Stick to the armor stand method and make mobs freeze mid-air, but players get an exception and intentionally don't freeze mid-air
  3. Setblock a barrier block under the frozen entity and give it slowness like in Option 1, but then I need a reliable way to delete this barrier block
  4. Setblock a cobweb into the frozen entity and use the armor stand method, but then replace back any non-hitbox block that the entity was standing in (which I have no idea how to do)
I don't really care at this point if players get frozen mid-air or not, but in case there is an easy solution please let me know. In any case I just want something which works reliably and freezes mobs or players. Any ideas or suggestions are welcome :)
    Posted by RADI0R's Avatar
    RADI0R
    Level 42 : Master Loremaster
    58

    Create an account or sign in to comment.

    5

    3
    04/09/2022 9:53 am
    Level 41 : Master Nerd
    Kefaku
    Kefaku's Avatar
    For any entity except players you can just remove their AI and gravity to freeze them and give it back, to make the move again.
    Freeze nearest non-player entity:

    tag @e[​limit=1,sort=nearest,type=!minecraft:player] add frozen
    data merge entity @e[tag=frozen] {NoAI:1b,NoGravity:1b}

    Unfreeze nearest non-player entity with tag frozen:

    data merge entity @e[limit=1,sort=nearest,tag=frozen,type=!minecraft:player] {NoAI:0b,NoGravity:0b}
    tag @e[​limit=1,sort=nearest] remove frozen

    This is way more efficient, because you only need to execute the commands once when an entity is frozen/unfrozen and not permanently, like in your example. NOTE: If someone summons an entity with {NoAI:1b} or {NoGravity:1b}, that entity would still regain AI/Gravity after being frozen and then unfrozen with my method. That is something you might have to consider.
    Since player data can't be modified with /data there is no really good way for players to be frozen. There are multiple methods, which all have disadvantages (if you are interested, 3 of them are explained in this youtube video) and I personally think you should just use the one you also suggested with slowness/jumpboost. Freezing the player mid-air is just not worth the very high amount of effort you'd need to put in, if teleportation is not reliable.
    2
    04/09/2022 10:32 am
    Level 42 : Master Loremaster
    RADI0R
    RADI0R's Avatar
    Once again you blew my mind. Thanks, this has helped me immensely.
    3
    04/11/2022 5:02 am
    Level 55 : Grandmaster Blacksmith
    elidhan
    elidhan's Avatar
    For players, have you considered changing their gamemode to specator then forcing them to spectate an armorstand?
    2
    04/11/2022 6:20 am
    Level 42 : Master Loremaster
    RADI0R
    RADI0R's Avatar
    I have but sadly that's not what I'm looking for. I need them to stay vulnerable and visible to others.
    1
    05/05/2022 11:03 am
    Level 37 : Artisan Engineer
    GrimWitherYT
    GrimWitherYT's Avatar
    you could just give the an extreme slowness effect, it would easily work on players and mobs.
    Planet Minecraft

    Website

    © 2010 - 2024
    www.planetminecraft.com

    Welcome