Solved Holographic Names on Dropped Items

  • 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.
Well, for some reason, it doesn't work. I get the exact same errors as what @MCProHost has; even the else statement error.
 
So..? That means what? This is the problem:
[21:19:06 ERROR]: [Skript] There's no item stack in an on item spawn event (dropped items have names.sk, line 2: if name of event-item is set:')

Code once again:

On item spawn:
if name of event-item is set:
Add "{CustomName:""%name of event-item%"",CustomNameVisible:1}" To nbt of event-entity
else:
Add "{CustomName:""%event-item%"",CustomNameVisible:1}" To nbt of event-entity
 

Try:

code_language.skript:
On item spawn:
    if name of event-entity is set:
        Add "{CustomName:""%name of event-entity%"",CustomNameVisible:1}" To nbt of event-entity
    else:
        Add "{CustomName:""%event-entity%"",CustomNameVisible:1}" To nbt of event-entity

And try:

code_language.skript:
On item spawn:
    if name of event item is set:
        Add "{CustomName:""%name of event-item%"",CustomNameVisible:1}" To nbt of event-entity
    else:
        Add "{CustomName:""%event-item%"",CustomNameVisible:1}" To nbt of event-entity

and try:

code_language.skript:
On item spawn:
    if "%name of event-item%" is not "<none>":
        Add "{CustomName:""%name of event-item%"",CustomNameVisible:1}" To nbt of event-entity
    else:
        Add "{CustomName:""%event-item%"",CustomNameVisible:1}" To nbt of event-entity
 
Last edited:
When I get home from school I'll update you, thanks :emoji_grinning:
[doublepost=1505938840,1505922588][/doublepost]It worked... Well sort of, the name of the item is dropped item...
aULXxXe.png
 
ill do that right now :emoji_grinning:
[doublepost=1505939048,1505938997][/doublepost]2nd has an error:
[15:22:05 ERROR]: 'event item' is not a slot (dropped items have names.sk, line 2: if name of event item is set:')
[15:22:05 ERROR]: 'else' has to be placed just after an 'if' or 'else if' section (dropped items have names.sk, line 4: else:')
3rd also has an error:
[15:22:32 ERROR]: There's no item stack in an on item spawn event (dropped items have names.sk, line 2: if "%name of event-item%" is not "<none>":')
[15:22:32 ERROR]: 'else' has to be placed just after an 'if' or 'else if' section (dropped items have names.sk, line 4: else:')
 
ill do that right now :emoji_grinning:
[doublepost=1505939048,1505938997][/doublepost]2nd has an error:
[15:22:05 ERROR]: 'event item' is not a slot (dropped items have names.sk, line 2: if name of event item is set:')
[15:22:05 ERROR]: 'else' has to be placed just after an 'if' or 'else if' section (dropped items have names.sk, line 4: else:')
3rd also has an error:
[15:22:32 ERROR]: There's no item stack in an on item spawn event (dropped items have names.sk, line 2: if "%name of event-item%" is not "<none>":')
[15:22:32 ERROR]: 'else' has to be placed just after an 'if' or 'else if' section (dropped items have names.sk, line 4: else:')
i am working on something might have found a workaround
[doublepost=1505940764][/doublepost]
ill do that right now :emoji_grinning:
[doublepost=1505939048,1505938997][/doublepost]2nd has an error:
[15:22:05 ERROR]: 'event item' is not a slot (dropped items have names.sk, line 2: if name of event item is set:')
[15:22:05 ERROR]: 'else' has to be placed just after an 'if' or 'else if' section (dropped items have names.sk, line 4: else:')
3rd also has an error:
[15:22:32 ERROR]: There's no item stack in an on item spawn event (dropped items have names.sk, line 2: if "%name of event-item%" is not "<none>":')
[15:22:32 ERROR]: 'else' has to be placed just after an 'if' or 'else if' section (dropped items have names.sk, line 4: else:')

this might work it does for me

code_language.skript:
On item spawn:
    set {_nbt} to tag "Item" of nbt of event-entity
    set {_nbt} to "%{_nbt}%"
    set {_tags::*} to {_nbt} split at ","
    loop {_tags::*}:
        if loop-value contains "id:":
            set {_item} to loop-value
            replace every "{" with "" in {_item}
            replace every "}" with "" in {_item}
            replace every "id:""minecraft:" with "" in {_item}
            replace every """" with "" in {_item}
        if loop-value contains "tag:":
            set {_name} to loop-value
            replace every "{" with "" in {_name}
            replace every "}" with "" in {_name}
            replace every "tag:display:Name:""" with "" in {_name}
            replace every """" with "" in {_name}
    if {_name} is set:
        Add "{CustomName:""%{_name}%"",CustomNameVisible:1}" To nbt of event-entity
    else:
        Add "{CustomName:""%{_item}%"",CustomNameVisible:1}" To nbt of event-entity

if it doesn't

use this and tell me the output if you drop a NAMED item.

code_language.skript:
On item spawn:
    set {_nbt} to tag "Item" of nbt of event-entity
    broadcast "%{_nbt}%"
 
Im not sure, I'm not going to use this for my server anymore. Thanks for the help though!
[doublepost=1505959872,1505952044][/doublepost]I changed my mind:
I need this on my server xD

The output I get when I dropped and named item and a normal item:

JB5ArDr.jpg

[doublepost=1505959952][/doublepost]When the NAMED item is dropped:

Fw6TU67.jpg
 
Im not sure, I'm not going to use this for my server anymore. Thanks for the help though!
[doublepost=1505959872,1505952044][/doublepost]I changed my mind:
I need this on my server xD

The output I get when I dropped and named item and a normal item:

JB5ArDr.jpg

[doublepost=1505959952][/doublepost]When the NAMED item is dropped:

Fw6TU67.jpg

Can you try this And give me THE outputs wenn you drop a normal item.

code_language.skript:
Code (Skript):
On item spawn:
    set {_nbt} to tag "Item" of nbt of event-entity
    set {_nbt} to "%{_nbt}%"
    set {_tags::*} to {_nbt} split at ","
    loop {_tags::*}:
        if loop-value contains "id:":
            set {_item} to loop-value
            Message "1: %{_item}%"
            replace every "{" with "" in {_item}
            Message "2: %{_item}%"
            replace every "}" with "" in {_item}
            Message "3: %{_item}%"
            replace every "id:""minecraft:" with "" in {_item}
            Message "4: %{_item}%"
            replace every """" with "" in {_item}
            Message "5: %{_item}%"
        if loop-value contains "tag:":
            set {_name} to loop-value
            replace every "{" with "" in {_name}
            replace every "}" with "" in {_name}
            replace every "tag:display:Name:""" with "" in {_name}
            replace every """" with "" in {_name}
    if {_name} is set:
        Add "{CustomName:""%{_name}%"",CustomNameVisible:1}" To nbt of event-entity
    else:
        Add "{CustomName:""%{_item}%"",CustomNameVisible:1}" To nbt of event-entity
 
I'll try it when I get home
[doublepost=1506089688,1505997415][/doublepost]Edit: ended up re creating this in Java.
 
Any help will be greatly appreciated guys! Thanks! (Bump)

(Any help with the error I have! See above for more information. Thanks)
 
They said it worked for them previously, so yeah, it should be possible with skript. It is a little annoying when you really need help on something, so your hopes are up when you see a reply on your thread and then when you read it, it is just a comment saying, "It's definitely possible with skript." Thanks for the help man. Couldn't have figured that out without you.

I don't want to offend you, @Pikachu, but please post something that can be used to help solve the problem.

Any help is much appreciated. If you didn't know, the problem I would like fixed is the following: I have this code which works perfectly for others, but when I do it, I get two errors that shouldn't be there.

Skript:
code_language.skript:
On item spawn:
    if name of event-item is set:
        Add "{CustomName:""%name of event-item%"",CustomNameVisible:1}" To nbt of event-entity
    else:
        Add "{CustomName:""%event-item%"",CustomNameVisible:1}" To nbt of event-entity

Error:
code_language.skript:
[20:57:20 ERROR]: There's no item stack in an on item spawn event (dropped items have names.sk, line 2: if name of event-item is set:')
[20:57:20 ERROR]: 'else' has to be placed just after an 'if' or 'else if' section (dropped items have names.sk, line 4: else:')

(The error I provided above was not from my console as it was from another user's console that was involved in this thread as well. I still get the same error message, but the fine details such as: "name.sk, line 4: else:'" is not mine, but would be something like: "scripts.sk, line 47: else:" I know that it doesn't matter at all, but I just wanted to state it so that if anyone needs to know that, it is there.)

Thank you!
Best Regards,
@LoneElf
 
They said it worked for them previously, so yeah, it should be possible with skript. It is a little annoying when you really need help on something, so your hopes are up when you see a reply on your thread and then when you read it, it is just a comment saying, "It's definitely possible with skript." Thanks for the help man. Couldn't have figured that out without you.

I don't want to offend you, @Pikachu, but please post something that can be used to help solve the problem.

Any help is much appreciated. If you didn't know, the problem I would like fixed is the following: I have this code which works perfectly for others, but when I do it, I get two errors that shouldn't be there.

Skript:
code_language.skript:
On item spawn:
    if name of event-item is set:
        Add "{CustomName:""%name of event-item%"",CustomNameVisible:1}" To nbt of event-entity
    else:
        Add "{CustomName:""%event-item%"",CustomNameVisible:1}" To nbt of event-entity

Error:
code_language.skript:
[20:57:20 ERROR]: There's no item stack in an on item spawn event (dropped items have names.sk, line 2: if name of event-item is set:')
[20:57:20 ERROR]: 'else' has to be placed just after an 'if' or 'else if' section (dropped items have names.sk, line 4: else:')

(The error I provided above was not from my console as it was from another user's console that was involved in this thread as well. I still get the same error message, but the fine details such as: "name.sk, line 4: else:'" is not mine, but would be something like: "scripts.sk, line 47: else:" I know that it doesn't matter at all, but I just wanted to state it so that if anyone needs to know that, it is there.)

Thank you!
Best Regards,
@LoneElf
If you read the docs, it's not event-item. It's event-entity. https://skunity.com/search?search=item+spawn
 
You guys are doing an awful lot of work for something that could have been done in 3 lines
code_language.skript:
on item spawn:
  event-entity.setCustomNameVisible(true);
  event-entity.setCustomName(event-entity.getItemStack().getItemMeta().getDisplayName() ? "%event-entity.getItemStack()%");
skript-mirror, skQuery
 
Last edited:
Thanks @Pikachu! It works! Thanks to everyone who offered their assistance as I really do appreciate it! The method @Pikachu offered worked 100% fine and is one I am very happy with! Thanks guys!
[doublepost=1506265051,1506183261][/doublepost]I am just curious as I might use this in the future, but does the code that you provided, @Pikachu, work with blocks too, I am guessing?

EDIT: So, I tried it and it didn't work. Here is my code:
code_language.skript:
on block place:
        if event-block is a 91:0:
                event-block.setCustomNameVisible(true);
                event-block.setCustomName(event-block.getItemStack().getItemMeta().getDisplayName() ? "&d&lHALLOWEEN LOOT")

Thanks!
(By the way, don't call me out for my spacing as my skript is kind of messed up, but I found to work around it.)
 
Last edited:
Thanks @Pikachu! It works! Thanks to everyone who offered their assistance as I really do appreciate it! The method @Pikachu offered worked 100% fine and is one I am very happy with! Thanks guys!
[doublepost=1506265051,1506183261][/doublepost]I am just curious as I might use this in the future, but does the code that you provided, @Pikachu, work with blocks too, I am guessing?

EDIT: So, I tried it and it didn't work. Here is my code:
code_language.skript:
on block place:
        if event-block is a 91:0:
                event-block.setCustomNameVisible(true);
                event-block.setCustomName(event-block.getItemStack().getItemMeta().getDisplayName() ? "&d&lHALLOWEEN LOOT")

Thanks!
(By the way, don't call me out for my spacing as my skript is kind of messed up, but I found to work around it.)
i dont know for sure but im guessing it only works with entities not blocks
 
Thanks @Pikachu! It works! Thanks to everyone who offered their assistance as I really do appreciate it! The method @Pikachu offered worked 100% fine and is one I am very happy with! Thanks guys!
[doublepost=1506265051,1506183261][/doublepost]I am just curious as I might use this in the future, but does the code that you provided, @Pikachu, work with blocks too, I am guessing?

EDIT: So, I tried it and it didn't work. Here is my code:
code_language.skript:
on block place:
        if event-block is a 91:0:
                event-block.setCustomNameVisible(true);
                event-block.setCustomName(event-block.getItemStack().getItemMeta().getDisplayName() ? "&d&lHALLOWEEN LOOT")

Thanks!
(By the way, don't call me out for my spacing as my skript is kind of messed up, but I found to work around it.)
Blocks can't do that, only entities. To make it similar to entities, spawn an invisible armor stand with a name.
 
Status
Not open for further replies.