1. Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Cancel Despawning

Discussion in 'Requests' started by Aberforth, May 30, 2020.

  1. Aberforth

    Aberforth Member

    Joined:
    Jun 14, 2019
    Messages:
    40
    Likes Received:
    2
    Hello,
    I need a script that would stop mobs from despawning, specifically I need it for Giants.

    As far as I know, there's no "on despawn" event, so I don't know how to do this.

    Any help appreciated.
     
  2. rustedst

    rustedst Active Member

    Joined:
    Apr 24, 2020
    Messages:
    97
    Likes Received:
    4
    I'm not sure if Giants are normally despawning. If so, just apply them nametags. It will prevent them from despawning.

    For the event, there's no on despawn event even in java.
     
  3. Aberforth

    Aberforth Member

    Joined:
    Jun 14, 2019
    Messages:
    40
    Likes Received:
    2
    I tried giving them nametags or even the {PersistenceRequired:1} tag, but they still despawn.
    That's why I was looking for a script. I don't know why do they despawn though, it seems to work fine with any other mob.
     
  4. rustedst

    rustedst Active Member

    Joined:
    Apr 24, 2020
    Messages:
    97
    Likes Received:
    4
    I'm not sure if this will work at all, you can get an error even while parsing, but I'm sure I can fix any problems about that. This is the first form of the script and it can be improved, that's the script:
    Code (Text):
    1. variables:
    2.     {giantid::1} = 1
    3. every 5 seconds:
    4.     loop all giants:
    5.         set {_count} to 1
    6.         loop (last element of {giantid::*}) times:
    7.             if display name of loop-entity contains "Giant  %{_count}%":
    8.                 set location of loop-entity to {giant::%{_count}%}
    9.                 exit 1 loop
    10.             add 1 to {_count}
    11.     loop all giants:
    12.         if display name of loop-entity doesn't contain "Giant":
    13.             add ((last element of {giantid::*}) + 1)) to {giantid::*}
    14.             set display name of loop-entity to "Giant %(last element of {giantid::*})%"
    15.     set {_test} to 1
    16.     loop all giants:
    17.         set {_name} to display name of loop-entity
    18.         replace all "Giant " with "" in {_name}
    19.         set {_name} to ({_name} parsed as integer)
    20.         add {_name} to {giants::*}
    21.     loop {giantid::*}:
    22.         if contains({giants::*}, loop-value) is false:
    23.             spawn a giant at {giant::%loop-value%}
    24.             set display name of last spawned giant to  "Giant %loop-value%"
    This can cause TPS drop but giant despawning is a bug of Minecraft and only way to fix it is replacing them
     
  5. Aberforth

    Aberforth Member

    Joined:
    Jun 14, 2019
    Messages:
    40
    Likes Received:
    2
    I got 2 errors:
    - the location of loop-entity can't be set to anything (line 8)
    - functions cannot be used here (or there is a problem with your arguments) (line 22)

    There was also an extra bracket in line 13 but I removed it.

    Also, I need the Giants to keep their attributes, like name, rotation etc... I don't know if this would be a problem.
     
  6. rustedst

    rustedst Active Member

    Joined:
    Apr 24, 2020
    Messages:
    97
    Likes Received:
    4
    Code (Text):
    1. variables:
    2.     {giantid::1} = 1
    3. every 5 seconds:
    4.     loop all giants:
    5.         set {_count} to 1
    6.         loop (last element of {giantid::*}) times:
    7.             if display name of loop-entity contains "Giant  %{_count}%":
    8.                 set {giant::%{_count}%} location of loop-entity
    9.                 exit 1 loop
    10.             add 1 to {_count}
    11.     loop all giants:
    12.         if display name of loop-entity doesn't contain "Giant":
    13.             add ((last element of {giantid::*}) + 1)) to {giantid::*}
    14.             set display name of loop-entity to "Giant %(last element of {giantid::*})%"
    15.     set {_test} to 1
    16.     loop all giants:
    17.         set {_name} to display name of loop-entity
    18.         replace all "Giant " with "" in {_name}
    19.         set {_name} to ({_name} parsed as integer)
    20.         add {_name} to {giants::*}
    21.     loop {giantid::*}:
    22.         set {_lv} to loop-value
    23.         if contains({giants::*}, {_lv}) is false:
    24.             spawn a giant at {giant::%loop-value%}
    25.             set display name of last spawned giant to  "Giant %loop-value%"
    For the attributes, you can store them like I did with location: "set {giant::%{_count}%} location of loop-entity" and then assign them to the spawned giants with that variable (line 23)
     
  7. Aberforth

    Aberforth Member

    Joined:
    Jun 14, 2019
    Messages:
    40
    Likes Received:
    2
    Hmm, there are still some problems with the code,
    - loop-entity is neither an item stack nor an entity type (line 8)
    - functions cannot be used here (line 23)

    And that extra bracket in line 13 but I removed it again.
     
  8. rustedst

    rustedst Active Member

    Joined:
    Apr 24, 2020
    Messages:
    97
    Likes Received:
    4
    Code (Text):
    1. variables:
    2.     {giantid::1} = 1
    3. every 5 seconds:
    4.     loop all giants:
    5.         set {_count} to 1
    6.         loop (last element of {giantid::*}) times:
    7.             if display name of loop-entity contains "Giant  %{_count}%":
    8.                 set {giant::%{_count}%} to location of loop-entity
    9.                 exit 1 loop
    10.             add 1 to {_count}
    11.     loop all giants:
    12.         if display name of loop-entity doesn't contain "Giant":
    13.             add ((last element of {giantid::*}) + 1)) to {giantid::*}
    14.             set display name of loop-entity to "Giant %(last element of {giantid::*})%"
    15.     set {_test} to 1
    16.     loop all giants:
    17.         set {_name} to display name of loop-entity
    18.         replace all "Giant " with "" in {_name}
    19.         set {_name} to ({_name} parsed as integer)
    20.         add {_name} to {giants::*}
    21.     loop {giantid::*}:
    22.         set {_lv} to loop-value
    23.         set {_boo} to contains({giants::*}, {_lv})
    24.         if {_boo} is false:
    25.             spawn a giant at {giant::%loop-value%}
    26.             set display name of last spawned giant to  "Giant %loop-value%"
    --- Double Post Merged, Jun 1, 2020, Original Post Date: Jun 1, 2020 ---
    again forgot to remove that bracket thing
     
  9. Aberforth

    Aberforth Member

    Joined:
    Jun 14, 2019
    Messages:
    40
    Likes Received:
    2
    There's still a problem with line 23, "functions cannot be used here (or there is a problem with your arguments)"
     
  10. bl_k

    bl_k Member

    Joined:
    May 4, 2021
    Messages:
    2
    Likes Received:
    0

Share This Page

Loading...