Ver código fonte

diamond小游戏掉落一半背包物品

HerobrineXia 5 anos atrás
pai
commit
fee78baf0a

+ 3 - 0
data/mini/functions/diamond/game/item_drop.mcfunction

@@ -0,0 +1,3 @@
+tag @e[type=item,limit=1,tag=death_drop,sort=random] remove death_drop
+scoreboard players remove #total_drop temp 1
+execute if score #total_drop temp matches 1.. run function mini:diamond/game/item_drop

+ 15 - 1
data/mini/functions/diamond/player_death.mcfunction

@@ -6,4 +6,18 @@ function mini:diamond/game/respawn1
 execute as @a at @s run function lib:sounds/error
 effect give @s blindness 3 5 true
 effect give @s weakness 30 1
-give @s wooden_pickaxe
+
+# 处理玩家掉落物品
+execute at @s as @e[type=item,distance=..100] store result score @s temp run data get entity @s Age
+execute at @s store result score #total_drop temp run tag @e[type=item,scores={temp=..5}] add death_drop
+scoreboard players reset @e[type=item] temp
+# 单独处理钻石还没写
+# 掉落数量向上取整
+scoreboard players add #total_drop temp 1
+scoreboard players operation #total_drop temp /= #const_2 mem
+execute if score #total_drop temp matches 1.. run function mini:diamond/game/item_drop
+# 其余物品丢回背包
+tag @s add dead_player
+execute as @e[type=item,tag=death_drop] run data modify entity @s Thrower set from entity @a[tag=dead_player,limit=1] UUID
+tag @s remove dead_player
+execute as @e[type=item,tag=death_drop] run function item:disable_throw