mkremins / fanciful

Fancy Bukkit message formatting
MIT License
95 stars 82 forks source link

API for hoverEvent show_entity action #39

Open mkremins opened 10 years ago

mkremins commented 10 years ago

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.

glen3b commented 9 years ago

(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

mkremins commented 9 years ago

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.

glen3b commented 9 years ago

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 commented 9 years ago

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.

mkremins commented 9 years ago

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

glen3b commented 9 years ago

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.

MiniDigger commented 9 years ago

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

mkremins commented 9 years ago

@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.

glen3b commented 9 years ago

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

glen3b commented 9 years ago

@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 commented 9 years ago

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.

MiniDigger commented 9 years ago

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.

glen3b commented 9 years ago

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

MiniDigger commented 9 years ago

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.

glen3b commented 9 years ago

JIRA issue ticket created.