[1.15.2]Minecraft数据包---玩家头颅ID显示

该数据包使得玩家放置的玩家头颅能够以悬浮字形式在上方显示其用户ID,并支持使用彩色羊毛对其染色。
该数据包隶属于 cAsual woRk (1/99)

效果演示

B站视频演示:

演示1

演示2

演示3

大致原理

首先是通过进度判断玩家放下头颅,要注意的是头颅放在地上和墙上的id不同,当时我就被这个坑了好久(

1
2
3
4
5
6
7
8
9
10
11
12
13
{
"criteria": {
"put_head": {
"trigger": "minecraft:placed_block",
"conditions": {
"block": "minecraft:player_head"
}
}
},
"rewards": {
"function": "skull:reset"
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
{
"criteria": {
"put_head": {
"trigger": "minecraft:placed_block",
"conditions": {
"block": "minecraft:player_wall_head"
}
}
},
"rewards": {
"function": "skull:reset"
}
}

然后通过视线追踪在头颅位置生成maker,并对齐方块中央。

1
2
execute if entity @s[distance=..6] if block ~ ~ ~ #player_head positioned ^ ^ ^ run summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,Marker:1b,Tags:["skull-name"],Small:1b}
execute if entity @s[distance=..6] unless block ~ ~ ~ #player_head positioned ^ ^ ^0.005 run function skull:ray

然后通过牌子获取到头颅的用户ID,使用interpret拍扁

1
2
execute as @e[type=armor_stand,tag=skull-name,tag=!b] at @s if block ~ ~ ~ #player_head run setblock ~ ~2 ~ minecraft:oak_sign{Text1:"{\"block\":\"~ ~-2 ~\",\"nbt\":\"Owner.Name\",\"interpret\":false}",Text2:"{\"text\":\"\"}",Text3:"{\"text\":\"\"}",Text4:"{\"text\":\"\"}"}
execute as @e[type=armor_stand,tag=skull-name,tag=!b] at @s if block ~ ~ ~ #player_head run data modify entity @s CustomName set from block ~ ~2 ~ Text1

最后是羊毛染色的相关处理,偷懒直接改了队伍color。

鸣谢

  • 黑洞群的bcb大佬和黑猫大佬提供技术支持
  • kc提供了他的头(?)
  • dhp真好用

datapack

链接:https://pan.baidu.com/s/1EvwPPwuBLD-FEjmrnktelA
提取码:t9qq

  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
  • Copyrights © 2020-2021 Argon_gas

请我喝杯咖啡吧~