Solved Custom heads regen on mine

  • 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!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

MartinOdum

Member
Jan 26, 2017
112
13
18
Hello everyone, I'm trying to figure out how I can get custom heads to regen after being mined, here is a screenshot of what I mean

edbb9bd4757d4aeda1f4c3abec425d04.png


I want them to dissapear for a couple of seconds after being mined and them have them come back after a couple of seconds, that code I can make my problem is I can't figure out how to get them to reappear in the same position with the same skin

I've tried alot of variations of code but this is my latest and I haven't had any luck:
Any help would be appreciated, thanks!

code_language.skript:
on mine:
  if player is in region "greenorbmine":
    set {_block} to event-block
    set {_nbt} to nbt of event-block
    cancel the event
    give player {_block} with NBT {_nbt}
    set event-block to air
    wait 3 seconds
    set event-block to {_block} with NBT {_nbt}
 
So i don't know how to do this with the skin. Without the skin it should work like this:

code_language.skript:
on mine of head:
    if "%region at player%" is "greenorbmine":
        cancel the event
        set {_type} to type of event-block
        set {_location} to location of event-block
        give player {_type}
        set block at {_location} to air
        wait 3 seconds
        set block at {_location} to {_type}
        clear {_location}
        clear {_type}
    stop
 
This is reaallllyy tricky to do.
I'll try it (again) tomorrow.

What I've got until now:
- You cannot give a head with the nbt of what was in the ground (it gets really huge and doesn't work), but you can get the owner by splitting it, then using {SkullOwner<something>:%split you have done%} in the nbt of player's item.
- To put the head back in the ground, all you gotta do is save the nbt, and then set head:3 in the ground with the nbt you saved (if the nbt is <none> it will crash).
 
This is reaallllyy tricky to do.
I'll try it (again) tomorrow.

What I've got until now:
- You cannot give a head with the nbt of what was in the ground (it gets really huge and doesn't work), but you can get the owner by splitting it, then using {SkullOwner<something>:%split you have done%} in the nbt of player's item.
- To put the head back in the ground, all you gotta do is save the nbt, and then set head:3 in the ground with the nbt you saved (if the nbt is <none> it will crash).
Awesome! Thanks for looking into it, I'll keep trying stuff out with the info you've gathered
 
So I couldn't really figure out how to do it but I did manage to achieve essentially the same thing with vanilla commands, this is the code I currently have

code_language.skript:
on mine:
  if "%region at player%" contains "greenorbmine":
    cancel event
    set {_wait} to a random number between 20 and 80
    set {_nbt} to nbt of event-block
    set {_location} to location of event-block
    set block at {_location} to air
    set {_item} to player head with custom nbt "{display:{Name:""Geen Orb""},SkullOwner:{Id:""948d2211-0eec-4bd9-a7b7-8679892f13b5"",Properties:{textures:[{Value:""eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGM2YmFjZDM2ZWQ2MGY1MzMxMzhlNzU5YzQyNTk0NjIyMmI3OGVkYTZiNjE2MjE2ZjZkY2MwOGU5MGQzM2UifX19""}]}}}" named "&2Green Ore"
    drop {_item} at {_location}
    loop {_wait} times:
      wait 1 second
    execute console command "/setblock %{_location}'s x-coordinate% %{_location}'s y-coordinate% %{_location}'s z-coordinate% minecraft:skull 5 replace %{_nbt}%"

It works great for the most part except "minecraft:skull 5" represents the way the skull is facing I think/the rotation and I couldn't really think of an easy way to gather the information while mining it, I don't know where it is stored, I thought "Rot:x" in the nbt was it but I'm just not sure to be honest, I decided to just leave it as is, the mine works fairly well and the illusion that the ore is regenerating slowly is there so I'm happy with it
 
Code:
on break:
    event-block is mob head block
    cancel event
    give mob head item:3 with nbt "{SkullOwner:%tag ""Owner"" of nbt of event-block%}" named "&aTricky" with lore "&7Use it for the trickiest things||&7you can think about..." to player
    set {_nbtsave} to "%nbt of event-block%"
    set event-block to air
    wait "%a random number between 20 and 60% seconds" parsed as timespan
    set block at event-location to mob head block:1
    add {_nbtsave} to nbt of block at event-location

Works 100% with rotation, no external commands, gives everything without bigger problems. The only problem is if the head has no name, then the SkullOwner will be <none> (it is pretty easy to fix that).

Hope I've helped ;P
 
  • Like
Reactions: Spirit1998HD
Code:
on break:
    event-block is mob head block
    cancel event
    give mob head item:3 with nbt "{SkullOwner:%tag ""Owner"" of nbt of event-block%}" named "&aTricky" with lore "&7Use it for the trickiest things||&7you can think about..." to player
    set {_nbtsave} to "%nbt of event-block%"
    set event-block to air
    wait "%a random number between 20 and 60% seconds" parsed as timespan
    set block at event-location to mob head block:1
    add {_nbtsave} to nbt of block at event-location

Works 100% with rotation, no external commands, gives everything without bigger problems. The only problem is if the head has no name, then the SkullOwner will be <none> (it is pretty easy to fix that).

Hope I've helped ;P
Amazing! Works like a charm, thanks alot for the help!
 
Status
Not open for further replies.