fanciful icon indicating copy to clipboard operation
fanciful copied to clipboard

API for hoverEvent show_entity action

Open mkremins opened this issue 10 years ago • 15 comments

Example /tellraw:

/tellraw @a {
  text:"Hover.",
  hoverEvent:{
    action:show_entity,
    value:"{name:\"Bob\",type:Creeper,id:00000000-0000-0000-0000-000000000000}"
  }
}

Apparently, all keys within value (name, type and id) are optional.

mkremins avatar Jul 20 '14 18:07 mkremins

(Looking at this issue am on my phone, so hard to browse code)

So is this all possible keys or not? How would we decide what to serialize (given a Bukkit Entity)?I

glen3b avatar Jan 04 '15 02:01 glen3b

This does seem to be all possible keys – check this post and scroll down to the section on show_entity. Given a Bukkit Entity, I'm thinking type corresponds to #getType(), id corresponds to #getUniqueId(), and name corresponds to LivingEntity#getCustomName() where applicable.

mkremins avatar Jan 04 '15 14:01 mkremins

I will assume that post is accurate, and your function names look right. I'll write a PR for it when I get to my PC later today.

glen3b avatar Jan 04 '15 19:01 glen3b

I got back and tested the command, and it appears that your example command does not work as intended. I placed it in a command block, and it showed the hover message, however hovering over it did nothing, both in a 1.8 vanilla client and a 1.8 OptiFine client.

I'd like to figure out why this is before I start developing so I don't do anything extremely wrong.

glen3b avatar Jan 05 '15 01:01 glen3b

Hmm. Perhaps the information in the linked post is out of date or otherwise incorrect? IIRC I borrowed the example command straight from there.

mkremins avatar Jan 05 '15 01:01 mkremins

I know, I saw that, that's why I am confused, I tried both commands. Any thoughts?

/tellraw @a { text:"Hover.", hoverEvent:{ action:show_entity, value:{name:"Bob",type:Creeper,id:"00000000-0000-0000-0000-000000000000"} } }

Both with and without the quotes around the ID, this command gives a blank invalid JSON error within Minecraft.

glen3b avatar Jan 05 '15 01:01 glen3b

Well, idk what you did, but it works for me. Tested it in the lastest version (1.8.1) and it worked as expected (see here http://i.gyazo.com/9a05d9a7aed389c55d0c3fdf61dd3696.gif). I used the command from the forum thread: /tellraw @a {text:"Hover.",hoverEvent:{action:show_entity,value:"{name:\"Bob\",type:Creeper,id:00000000-0000-0000-0000-000000000000}"}} The value needs to be quoted, the id don't. EDIT: Also works in 1.8

MiniDigger avatar Jan 05 '15 12:01 MiniDigger

@glen3b On closer inspection it looks like you left out the quotes around the value. Really wish Mojang would stick to standard JSON for this stuff – it makes no sense whatsoever that value has to be wrapped in a string, but that appears to be exactly what's going on.

mkremins avatar Jan 05 '15 13:01 mkremins

I know, I tried the command with and without quotes around value.

glen3b avatar Jan 05 '15 19:01 glen3b

@MiniDigger I tried the same exact command, in a command block, copy pasted. Nothing funny is appearing in my client logs, but the hover still doesn't work. At this point I am only testing this stuff in 1.8.1 vanilla (no OptiFine, but that shouldn't make a difference).

glen3b avatar Jan 05 '15 19:01 glen3b

Also tested this command with referencing an entity that actually exists in the world, no luck. Can't seem to find an issue ticket for this on JIRA.

glen3b avatar Jan 05 '15 19:01 glen3b

That's strange. Maybe you are using a texture pack or a strange language? Else I have no idea what could cause this. I tried it with a few diferent texture packs and languages, and it worked fine.

MiniDigger avatar Jan 05 '15 19:01 MiniDigger

English (US), no resource packs in use, no mods in use.

glen3b avatar Jan 05 '15 19:01 glen3b

Having no problems with that setup. Maybe its the os? I am using windows 7 home premium 64bit with java 1.8.0_25 (the one that comes with the new launcher (1.6.5)) I think you need to head over to JIRA and open a ticket.

MiniDigger avatar Jan 05 '15 19:01 MiniDigger