Skip to content

Commit 92550e5

Browse files
committed
feat(ux): golems now persist their state even when dropped as item
1 parent 4c12773 commit 92550e5

19 files changed

+171
-43
lines changed

Diff for: data/bot/functions/entity/activate.mcfunction

-3
This file was deleted.

Diff for: data/bot/functions/entity/kill.mcfunction

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
execute as @s[tag=bot.golem.display] run loot spawn ~ ~ ~ loot bot:spawn
1+
execute as @s[tag=bot.golem.brain] if data entity @s data{waxed:true} run loot spawn ~ ~ ~ loot bot:drop/waxed
2+
execute as @s[tag=bot.golem.brain] unless data entity @s data{waxed:true} run loot spawn ~ ~ ~ loot bot:drop/unwaxed
23

34
kill @e[type=item,sort=nearest,limit=1,nbt={Item:{id:"minecraft:chest_minecart"}}]
45
kill @s

Diff for: data/bot/functions/entity/spawn.mcfunction

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
execute at @s run function bot:entity/summon
1+
function bot:entity/summon
2+
data modify entity @e[type=marker,tag=bot.golem.brain,sort=nearest,limit=1] data set from entity @s data
3+
24
kill @s

Diff for: data/bot/functions/entity/tick/brain.mcfunction

+15-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
data modify storage bot:private temp.golem.program set from entity @s data.program
1+
data modify storage bot:private temp.golem set from entity @s data
2+
execute store result score @s bot.golem.oxidisation run data get storage bot:private temp.golem.oxidisation
23

3-
execute unless data entity @s data{status:"rusted"} unless data entity @s data{status:"deoxidise"} unless data entity @s data{waxed:true} run function bot:entity/tick/brain/oxidisation
4-
execute if data entity @s data{waxed:true} run scoreboard players reset @s bot.golem.execute
4+
execute unless data storage bot:private temp.golem{status:"rusted"} unless data storage bot:private temp.golem{status:"deoxidise"} unless data storage bot:private temp.golem{waxed:true} run function bot:entity/tick/brain/oxidisation
5+
execute if data storage bot:private temp.golem{waxed:true} run scoreboard players reset @s bot.golem.execute
56

6-
execute if data entity @s data{status:"stopped"} run function bot:entity/tick/brain/stopped
7-
execute if data entity @s data{status:"active"} run function bot:entity/tick/brain/active
8-
execute if data entity @s data{status:"parse_error"} run function bot:entity/tick/brain/error
9-
execute if data entity @s data{status:"runtime_error"} run function bot:entity/tick/brain/error
10-
execute if data entity @s data{status:"rusted"} run function bot:entity/tick/brain/rusted
11-
execute if data entity @s data{status:"deoxidise"} unless data entity @s data{waxed:true} run function bot:entity/tick/brain/deoxidise
12-
execute if data entity @s data{status:"deoxidise"} if data entity @s data{waxed:true} run function bot:entity/tick/brain/unwax
7+
execute if data storage bot:private temp.golem{status:"stopped"} run function bot:entity/tick/brain/stopped
8+
execute if data storage bot:private temp.golem{status:"active"} run function bot:entity/tick/brain/active
9+
execute if data storage bot:private temp.golem{status:"parse_error"} run function bot:entity/tick/brain/error
10+
execute if data storage bot:private temp.golem{status:"runtime_error"} run function bot:entity/tick/brain/error
11+
execute if data storage bot:private temp.golem{status:"rusted"} run function bot:entity/tick/brain/rusted
12+
execute if data storage bot:private temp.golem{status:"deoxidise"} unless data storage bot:private temp.golem{waxed:true} run function bot:entity/tick/brain/deoxidise
13+
execute if data storage bot:private temp.golem{status:"deoxidise"} if data storage bot:private temp.golem{waxed:true} run function bot:entity/tick/brain/unwax
1314

14-
execute store result storage bot:private temp.oxidisation byte 1 run scoreboard players get @s bot.golem.oxidisation
15-
execute unless data entity @s data.compiled run data modify storage bot:private temp.text set value '[{"keybind":"key.use"},{"text":" with a book to give it a program"}]'
15+
execute unless data storage bot:private temp.golem.compiled unless data storage bot:private temp.golem{status:"rusted"} run data modify storage bot:private temp.text set value '[{"keybind":"key.use"},{"text":" with a book to give it a program"}]'
16+
17+
execute store result storage bot:private temp.golem.oxidisation byte 1 run scoreboard players get @s bot.golem.oxidisation
18+
data modify entity @s data set from storage bot:private temp.golem
+5-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
data modify storage bot:private temp.text set value '[{"keybind":"key.attack"},{"text":" to stop"}]'
22

3-
execute unless data entity @s data.interpreter.stack[] run function bot:entity/activate
3+
execute unless data storage bot:private temp.golem.interpreter.stack[] run function bot:entity/tick/brain/active/activate
44

55
scoreboard players add @s bot.golem.execute 1
66

7-
data modify storage glm:api/interpreter init set from entity @s data.interpreter
7+
data modify storage glm:api/interpreter init set from storage bot:private temp.golem.interpreter
88

9-
execute if data entity @s data.interpreter.stack[] on vehicle run function glm:api/interpreter/init
9+
execute if data storage bot:private temp.golem.interpreter.stack[] on vehicle run function glm:api/interpreter/init
1010

1111
execute if data storage glm:api/interpreter stdio.out[] run function bot:entity/tick/brain/active/print
1212

1313
execute if data storage glm:api/interpreter stdio.error[] run function bot:entity/tick/brain/active/error
1414
execute if data storage glm:api/interpreter stdio.error[] run return -1
1515

16-
data modify entity @s data.interpreter set from storage glm:api/interpreter init.output
16+
data modify storage bot:private temp.golem.interpreter set from storage glm:api/interpreter init.output
1717

18-
execute unless data entity @s data.interpreter.stack[] if data entity @s data{status:"active"} run data modify entity @s data.status set value "stopped"
18+
execute unless data storage bot:private temp.golem.interpreter.stack[] if data storage bot:private temp.golem{status:"active"} run data modify storage bot:private temp.golem.status set value "stopped"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
data modify storage bot:private temp.golem.interpreter set value {stack: [], variables: [], functions: [], scope: 0}
2+
data modify storage bot:private temp.golem.interpreter.stack append from storage bot:private temp.golem.compiled
3+
execute if data storage bot:private temp.golem.compiled on vehicle on passengers as @s[tag=bot.golem.hitbox] on target run advancement grant @s only bot:progression/first_execution
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
data modify entity @s data.status set value "runtime_error"
2-
data modify entity @s data.error set from storage glm:api/interpreter stdio.error[0]
3-
data remove entity @s data.interpreter
1+
data modify storage bot:private temp.golem.status set value "runtime_error"
2+
data modify storage bot:private temp.golem.error set from storage glm:api/interpreter stdio.error[0]
3+
data remove storage bot:private temp.golem.interpreter

Diff for: data/bot/functions/entity/tick/brain/deoxidise.mcfunction

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ execute at @s[scores={bot.golem.oxidisation=1..}] run particle scrape ~ ~1 ~ 0.2
22
execute at @s[scores={bot.golem.oxidisation=1..}] run playsound minecraft:item.axe.scrape neutral @a ~ ~ ~
33
execute if score @s bot.golem.oxidisation matches 3.. on vehicle on passengers as @s[tag=bot.golem.hitbox] on target run tag @s add bot.progression.advance
44
scoreboard players set @s[scores={bot.golem.oxidisation=1..}] bot.golem.oxidisation 0
5-
data modify entity @s data.status set value "stopped"
5+
data modify storage bot:private temp.golem.status set value "stopped"
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
data modify storage bot:private temp.error set from entity @s data.error
1+
data modify storage bot:private temp.error set from storage bot:private temp.golem.error
22
data modify storage bot:private temp.text set value '{"nbt":"temp.error","storage":"bot:private","interpret":true,"color":"red"}'
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
execute if score @s bot.golem.execute matches 100.. unless score @s bot.golem.oxidisation matches 3.. run scoreboard players add @s bot.golem.oxidisation 1
22
execute if score @s bot.golem.execute matches 100.. run scoreboard players reset @s bot.golem.execute
3-
execute if score @s bot.golem.oxidisation matches 3.. run data modify entity @s data.status set value "rusted"
3+
execute if score @s bot.golem.oxidisation matches 3.. run data modify storage bot:private temp.golem.status set value "rusted"
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
data modify entity @s data.interpreter.evaluate.stack set value []
1+
data modify storage bot:private temp.golem.interpreter.evaluate.stack set value []
22
data modify storage bot:private temp.text set value '[{"keybind":"key.use"},{"text":" with an axe to scrape off oxidisation"}]'
3-
execute unless score @s bot.golem.oxidisation matches 3.. run data modify entity @s data.status set value "stopped"
3+
execute unless score @s bot.golem.oxidisation matches 3.. run data modify storage bot:private temp.golem.status set value "stopped"
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
data modify entity @s data.interpreter.evaluate.stack set value []
1+
data modify storage bot:private temp.golem.interpreter.evaluate.stack set value []
22
data modify storage bot:private temp.text set value '[[{"keybind":"key.use"},{"text":" to run "},{"color":"gold","storage":"bot:private","nbt":"temp.golem.program","interpret":true},"\\n"],[{"keybind":"key.sneak"},{"text":" + "},{"keybind":"key.use"},{"text":" to open"}]]'
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
execute at @s run particle wax_off ~ ~1 ~ 0.2 0.2 0.2 1 8 normal @a
22
execute at @s run playsound minecraft:item.axe.wax_off neutral @a ~ ~ ~
33
execute on vehicle on passengers as @s[tag=bot.golem.hitbox] on target run advancement grant @s only bot:progression/unwax_golem
4-
data modify entity @s data.status set value "stopped"
5-
data modify entity @s data.waxed set value false
4+
data modify storage bot:private temp.golem.status set value "stopped"
5+
data modify storage bot:private temp.golem.waxed set value false

Diff for: data/bot/functions/entity/tick/display.mcfunction

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
execute if data storage bot:private temp{oxidisation:0b} run data modify entity @s item.tag.CustomModelData set value 807001
2-
execute if data storage bot:private temp{oxidisation:1b} run data modify entity @s item.tag.CustomModelData set value 807002
3-
execute if data storage bot:private temp{oxidisation:2b} run data modify entity @s item.tag.CustomModelData set value 807003
4-
execute if data storage bot:private temp{oxidisation:3b} run data modify entity @s item.tag.CustomModelData set value 807004
1+
execute if data storage bot:private temp.golem{oxidisation:0b} run data modify entity @s item.tag.CustomModelData set value 807001
2+
execute if data storage bot:private temp.golem{oxidisation:1b} run data modify entity @s item.tag.CustomModelData set value 807002
3+
execute if data storage bot:private temp.golem{oxidisation:2b} run data modify entity @s item.tag.CustomModelData set value 807003
4+
execute if data storage bot:private temp.golem{oxidisation:3b} run data modify entity @s item.tag.CustomModelData set value 807004

Diff for: data/bot/functions/entity/tick/text.mcfunction

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
data modify entity @s text set from storage bot:private temp.text
2-
execute if data storage bot:private temp{oxidisation:0b} run data modify entity @s background set value 1086881382
3-
execute if data storage bot:private temp{oxidisation:1b} run data modify entity @s background set value 1085187465
4-
execute if data storage bot:private temp{oxidisation:2b} run data modify entity @s background set value 1083620250
5-
execute if data storage bot:private temp{oxidisation:3b} run data modify entity @s background set value 1078500483
2+
execute if data storage bot:private temp.golem{oxidisation:0b} run data modify entity @s background set value 1086881382
3+
execute if data storage bot:private temp.golem{oxidisation:1b} run data modify entity @s background set value 1085187465
4+
execute if data storage bot:private temp.golem{oxidisation:2b} run data modify entity @s background set value 1083620250
5+
execute if data storage bot:private temp.golem{oxidisation:3b} run data modify entity @s background set value 1078500483

Diff for: data/bot/functions/tick.mcfunction

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ scoreboard players set $tile_drop_guard bot.interpreter 0
33

44
execute as @e[type=chest_minecart,tag=bot.golem] run function bot:entity/golem
55
execute as @e[type=#bot:command,tag=bot.golem] run function bot:entity/markers
6-
execute as 259ba3bd-fde8-4439-87e7-627092c882c7 run function bot:entity/spawn
6+
execute as 259ba3bd-fde8-4439-87e7-627092c882c7 at @s run function bot:entity/spawn
77

88
execute as @e[type=chest_minecart,tag=bot.golem.base] run function bot:entity/tick
99

Diff for: data/bot/loot_tables/drop/unwaxed.json

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
{
2+
"pools": [
3+
{
4+
"rolls": 1,
5+
"entries": [
6+
{
7+
"type": "minecraft:loot_table",
8+
"name": "bot:spawn",
9+
"functions": [
10+
{
11+
"function": "minecraft:set_count",
12+
"count": 1
13+
},
14+
{
15+
"function": "minecraft:set_nbt",
16+
"tag": "{CustomModelData:807002}",
17+
"conditions": [
18+
{
19+
"condition": "minecraft:entity_scores",
20+
"entity": "this",
21+
"scores": {
22+
"bot.golem.oxidisation": 1
23+
}
24+
}
25+
]
26+
},
27+
{
28+
"function": "minecraft:set_nbt",
29+
"tag": "{CustomModelData:807003}",
30+
"conditions": [
31+
{
32+
"condition": "minecraft:entity_scores",
33+
"entity": "this",
34+
"scores": {
35+
"bot.golem.oxidisation": 2
36+
}
37+
}
38+
]
39+
},
40+
{
41+
"function": "minecraft:set_nbt",
42+
"tag": "{CustomModelData:807004}",
43+
"conditions": [
44+
{
45+
"condition": "minecraft:entity_scores",
46+
"entity": "this",
47+
"scores": {
48+
"bot.golem.oxidisation": 3
49+
}
50+
}
51+
]
52+
},
53+
{
54+
"function": "minecraft:copy_nbt",
55+
"source": "this",
56+
"ops": [
57+
{
58+
"source": "data",
59+
"target": "EntityTag.data",
60+
"op": "merge"
61+
}
62+
]
63+
},
64+
{
65+
"function": "minecraft:set_lore",
66+
"entity": "this",
67+
"lore": [
68+
{
69+
"nbt": "data.program",
70+
"entity": "@s",
71+
"interpret": true,
72+
"color": "gray",
73+
"italic": false
74+
}
75+
],
76+
"conditions": [
77+
{
78+
"condition": "minecraft:entity_properties",
79+
"entity": "this",
80+
"predicate": {
81+
"nbt": "{data:{compiled:{}}}"
82+
}
83+
}
84+
]
85+
}
86+
]
87+
}
88+
]
89+
}
90+
]
91+
}

Diff for: data/bot/loot_tables/drop/waxed.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"pools": [
3+
{
4+
"rolls": 1,
5+
"entries": [
6+
{
7+
"type": "minecraft:loot_table",
8+
"name": "bot:drop/unwaxed",
9+
"functions": [
10+
{
11+
"function": "minecraft:set_nbt",
12+
"tag": "{EntityTag:{data:{waxed:true}}}"
13+
},
14+
{
15+
"function": "minecraft:set_lore",
16+
"entity": "this",
17+
"lore": [
18+
{
19+
"text": "Waxed",
20+
"italic": false,
21+
"color": "gold"
22+
}
23+
],
24+
"replace": false
25+
}
26+
]
27+
}
28+
]
29+
}
30+
]
31+
}

Diff for: data/bot/loot_tables/spawn.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
{
1616
"function": "set_nbt",
17-
"tag": "{CustomModelData:807001,EntityTag:{id:\"minecraft:marker\",UUID:[I;630956989,-35109831,-2014879120,-1832353081]},bot:{id:\"golem_spawn\"}}"
17+
"tag": "{CustomModelData:807001,EntityTag:{id:\"minecraft:marker\",UUID:[I;630956989,-35109831,-2014879120,-1832353081],data:{oxidisation:0b}},bot:{id:\"golem_spawn\"}}"
1818
},
1919
{
2020
"function": "set_name",

0 commit comments

Comments
 (0)