فهرست منبع

大幅度重构diamond的物品掉落

HerobrineXia 5 سال پیش
والد
کامیت
130564d354

+ 0 - 13
data/mini/functions/diamond/game/drop_diamond.mcfunction

@@ -1,13 +0,0 @@
-# 处理钻石总数
-execute at @s as @e[type=item,nbt={Item:{id:"minecraft:diamond"}},tag=death_drop,distance=..100] store result score @s temp run data get entity @s Item.Count
-execute at @s as @e[type=item,nbt={Item:{id:"minecraft:diamond"}},tag=death_drop,distance=..100] run scoreboard players operation #diamond_count temp += @s temp
-# 相应减少掉落总数(单独处理了钻石)
-execute at @s as @e[type=item,nbt={Item:{id:"minecraft:diamond"}},tag=death_drop,distance=..100] run scoreboard players remove #total_drop temp 1
-# 处理掉落物数量(除以2/向上取整)
-execute at @s as @e[type=item,nbt={Item:{id:"minecraft:diamond"}},tag=death_drop,distance=..100] run scoreboard players add @s temp 1
-execute at @s as @e[type=item,nbt={Item:{id:"minecraft:diamond"}},tag=death_drop,distance=..100] store result entity @s Item.Count byte 0.5 run scoreboard players get @s temp
-# 处理钻石标签
-execute at @s as @e[type=item,nbt={Item:{id:"minecraft:diamond"}},tag=death_drop,distance=..100] run tag @s remove death_drop
-# 给予玩家钻石(除以2/向下取整)
-scoreboard players operation #diamond_count temp /= #const_2 mem
-execute if score #diamond_count temp matches 1.. run function mini:diamond/game/give_diamond

+ 2 - 2
data/mini/functions/diamond/game/give_diamond.mcfunction

@@ -1,3 +1,3 @@
-give @s diamond 1
+give @s diamond
 scoreboard players remove #diamond_count temp 1
-execute if score #diamond_count temp matches 1.. run function mini:diamond/game/give_diamond
+execute if score #diamond_count temp matches 1.. run function mini:diamond/game/give_diamond

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

@@ -1,3 +0,0 @@
-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

+ 84 - 0
data/mini/functions/diamond/game/pop_slot.mcfunction

@@ -0,0 +1,84 @@
+execute if block 1000 0 5001 minecraft:bedrock run scoreboard players set @s item_slot 0
+execute if block 1000 0 5001 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1000 0 5002 minecraft:bedrock run scoreboard players set @s item_slot 1
+execute if block 1000 0 5002 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1000 0 5003 minecraft:bedrock run scoreboard players set @s item_slot 2
+execute if block 1000 0 5003 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1000 0 5004 minecraft:bedrock run scoreboard players set @s item_slot 3
+execute if block 1000 0 5004 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1001 0 5001 minecraft:bedrock run scoreboard players set @s item_slot 4
+execute if block 1001 0 5001 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1001 0 5002 minecraft:bedrock run scoreboard players set @s item_slot 5
+execute if block 1001 0 5002 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1001 0 5003 minecraft:bedrock run scoreboard players set @s item_slot 6
+execute if block 1001 0 5003 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1001 0 5004 minecraft:bedrock run scoreboard players set @s item_slot 7
+execute if block 1001 0 5004 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1002 0 5001 minecraft:bedrock run scoreboard players set @s item_slot 8
+execute if block 1002 0 5001 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1002 0 5002 minecraft:bedrock run scoreboard players set @s item_slot 9
+execute if block 1002 0 5002 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1002 0 5003 minecraft:bedrock run scoreboard players set @s item_slot 10
+execute if block 1002 0 5003 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1002 0 5004 minecraft:bedrock run scoreboard players set @s item_slot 11
+execute if block 1002 0 5004 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1003 0 5001 minecraft:bedrock run scoreboard players set @s item_slot 12
+execute if block 1003 0 5001 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1003 0 5002 minecraft:bedrock run scoreboard players set @s item_slot 13
+execute if block 1003 0 5002 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1003 0 5003 minecraft:bedrock run scoreboard players set @s item_slot 14
+execute if block 1003 0 5003 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1003 0 5004 minecraft:bedrock run scoreboard players set @s item_slot 15
+execute if block 1003 0 5004 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1004 0 5001 minecraft:bedrock run scoreboard players set @s item_slot 16
+execute if block 1004 0 5001 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1004 0 5002 minecraft:bedrock run scoreboard players set @s item_slot 17
+execute if block 1004 0 5002 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1004 0 5003 minecraft:bedrock run scoreboard players set @s item_slot 18
+execute if block 1004 0 5003 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1004 0 5004 minecraft:bedrock run scoreboard players set @s item_slot 19
+execute if block 1004 0 5004 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1005 0 5001 minecraft:bedrock run scoreboard players set @s item_slot 20
+execute if block 1005 0 5001 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1005 0 5002 minecraft:bedrock run scoreboard players set @s item_slot 21
+execute if block 1005 0 5002 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1005 0 5003 minecraft:bedrock run scoreboard players set @s item_slot 22
+execute if block 1005 0 5003 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1005 0 5004 minecraft:bedrock run scoreboard players set @s item_slot 23
+execute if block 1005 0 5004 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1006 0 5001 minecraft:bedrock run scoreboard players set @s item_slot 24
+execute if block 1006 0 5001 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1006 0 5002 minecraft:bedrock run scoreboard players set @s item_slot 25
+execute if block 1006 0 5002 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1006 0 5003 minecraft:bedrock run scoreboard players set @s item_slot 26
+execute if block 1006 0 5003 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1006 0 5004 minecraft:bedrock run scoreboard players set @s item_slot 27
+execute if block 1006 0 5004 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1007 0 5001 minecraft:bedrock run scoreboard players set @s item_slot 28
+execute if block 1007 0 5001 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1007 0 5002 minecraft:bedrock run scoreboard players set @s item_slot 29
+execute if block 1007 0 5002 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1007 0 5003 minecraft:bedrock run scoreboard players set @s item_slot 30
+execute if block 1007 0 5003 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1007 0 5004 minecraft:bedrock run scoreboard players set @s item_slot 31
+execute if block 1007 0 5004 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1008 0 5001 minecraft:bedrock run scoreboard players set @s item_slot 32
+execute if block 1008 0 5001 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1008 0 5002 minecraft:bedrock run scoreboard players set @s item_slot 33
+execute if block 1008 0 5002 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1008 0 5003 minecraft:bedrock run scoreboard players set @s item_slot 34
+execute if block 1008 0 5003 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1008 0 5004 minecraft:bedrock run scoreboard players set @s item_slot 35
+execute if block 1008 0 5004 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1009 0 5001 minecraft:bedrock run scoreboard players set @s item_slot 100
+execute if block 1009 0 5001 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1009 0 5002 minecraft:bedrock run scoreboard players set @s item_slot 101
+execute if block 1009 0 5002 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1009 0 5003 minecraft:bedrock run scoreboard players set @s item_slot 102
+execute if block 1009 0 5003 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute if block 1009 0 5004 minecraft:bedrock run scoreboard players set @s item_slot 103
+execute if block 1009 0 5004 minecraft:bedrock at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item
+execute store result score #fill_count temp run fill 1000 0 5001 1009 0 5004 air
+scoreboard players operation #fill_count temp %= #const_2 temp
+execute if score #fill_count temp matches 1 run scoreboard players set @s item_slot -106
+execute if score #fill_count temp matches 1 at @e[type=armor_stand,tag=dead_marker,limit=1] run function item:pop_slot/pop_item

+ 4 - 0
data/mini/functions/diamond/game/random_slot.mcfunction

@@ -0,0 +1,4 @@
+setblock 1000 0 5000 minecraft:structure_block{posX:0,posY:0,posZ:1,mode:"LOAD",name:"item:inventory",integrity:0.5f}
+fill 1000 0 5001 1009 0 5004 air
+setblock 1000 1 5000 air
+setblock 1000 1 5000 redstone_block

+ 1 - 1
data/mini/functions/diamond/game_init.mcfunction

@@ -28,6 +28,6 @@ gamerule drowningDamage true
 
 # Gamerule 调整
 gamerule doLimitedCrafting false
-gamerule keepInventory false
+gamerule keepInventory true
 gamerule doTileDrops true
 gamerule doEntityDrops true

+ 7 - 0
data/mini/functions/diamond/init.mcfunction

@@ -1,3 +1,10 @@
 # 重置计分板
 scoreboard objectives remove diamond
 scoreboard objectives add diamond dummy "持有钻石数"
+
+scoreboard objectives remove posX
+scoreboard objectives add posX dummy "坐标X"
+scoreboard objectives remove posY
+scoreboard objectives add posY dummy "坐标Y"
+scoreboard objectives remove posZ
+scoreboard objectives add posZ dummy "坐标Z"

+ 21 - 14
data/mini/functions/diamond/player_death.mcfunction

@@ -6,17 +6,24 @@ execute as @a at @s run function lib:sounds/error
 effect give @s blindness 3 0 true
 
 # 处理玩家掉落物品
-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
-execute as @e[type=item,tag=death_drop] run data modify entity @s Invulnerable set value 1b
-scoreboard players reset @e[type=item] temp
-# 单独处理钻石还没写
-function mini:diamond/game/drop_diamond 
-# 掉落数量向上取整
-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
+# 获取玩家死亡位置
+kill @e[type=armor_stand,tag=dead_marker]
+summon armor_stand 1000 0 5000 {Marker:1b,Invisible:1b,Invulnerable:1b,Small:1b,NoGravity:1b,Tags:["dead_marker"]}
+execute store result entity @e[type=armor_stand,tag=dead_marker,limit=1] Pos[0] double 1 run scoreboard players get @s posX
+execute store result entity @e[type=armor_stand,tag=dead_marker,limit=1] Pos[1] double 1 run scoreboard players get @s posY
+execute store result entity @e[type=armor_stand,tag=dead_marker,limit=1] Pos[2] double 1 run scoreboard players get @s posZ
+# 单独处理钻石
+execute store result score #diamond_count temp run clear @s diamond
+scoreboard players add #diamond_count temp 1
+execute at @e[type=armor_stand,tag=dead_marker,limit=1] run summon item ~ ~ ~ {Tags:["temp_diamond"],Item:{id:"minecraft:diamond",Count:1b}}
+execute as @e[type=item,tag=temp_diamond,limit=1] store result entity @s Item.Count byte 0.5 run scoreboard players get #diamond_count temp
+tag @e[type=item,tag=temp_diamond,limit=1] remove temp_diamond
+# 随机槽位掉落
+function mini:diamond/game/random_slot
+function mini:diamond/game/pop_slot
+# 返还钻石
+scoreboard players remove #diamond_count temp 1
+scoreboard players operation #diamond_count temp /= #const_2 mem
+execute if score #diamond_count temp matches 1.. run function mini:diamond/game/give_diamond
+# 删除marker
+kill @e[type=armor_stand,tag=dead_marker]

+ 3 - 0
data/mini/functions/diamond/tick2.mcfunction

@@ -0,0 +1,3 @@
+execute as @a[team=playing] unless score @s death matches 1.. store result score @s posX run data get entity @s Pos[0]
+execute as @a[team=playing] unless score @s death matches 1.. store result score @s posY run data get entity @s Pos[1]
+execute as @a[team=playing] unless score @s death matches 1.. store result score @s posZ run data get entity @s Pos[2]

+ 2 - 1
data/mini/functions/main/tick2.mcfunction

@@ -3,4 +3,5 @@ execute if score $mini_type mem matches 1 run function mini:parkour/tick2
 execute if score $mini_type mem matches 2 run function mini:tntrun/tick2
 execute if score $mini_type mem matches 3 run function mini:hotpm/tick2
 execute if score $mini_type mem matches 4 run function mini:colormatch/tick2
-execute if score $mini_type mem matches 5 run function mini:phantom/tick2
+execute if score $mini_type mem matches 5 run function mini:phantom/tick2
+execute if score $mini_type mem matches 6 run function mini:diamond/tick2