mindcraft 0.1.4-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/FAQ.md +38 -0
  2. package/LICENSE +21 -0
  3. package/README.md +255 -0
  4. package/andy.json +6 -0
  5. package/bin/mindcraft.js +80 -0
  6. package/keys.example.json +19 -0
  7. package/main.js +80 -0
  8. package/package.json +78 -0
  9. package/patches/minecraft-data+3.97.0.patch +13 -0
  10. package/patches/mineflayer+4.33.0.patch +54 -0
  11. package/patches/mineflayer-pathfinder+2.4.5.patch +265 -0
  12. package/patches/mineflayer-pvp+1.3.2.patch +13 -0
  13. package/patches/prismarine-viewer+1.33.0.patch +13 -0
  14. package/patches/protodef+1.19.0.patch +15 -0
  15. package/profiles/andy-4-reasoning.json +14 -0
  16. package/profiles/andy-4.json +7 -0
  17. package/profiles/azure.json +19 -0
  18. package/profiles/claude.json +7 -0
  19. package/profiles/claude_thinker.json +15 -0
  20. package/profiles/deepseek.json +7 -0
  21. package/profiles/defaults/_default.json +256 -0
  22. package/profiles/defaults/assistant.json +14 -0
  23. package/profiles/defaults/creative.json +14 -0
  24. package/profiles/defaults/god_mode.json +14 -0
  25. package/profiles/defaults/survival.json +14 -0
  26. package/profiles/freeguy.json +7 -0
  27. package/profiles/gemini.json +9 -0
  28. package/profiles/gpt.json +12 -0
  29. package/profiles/grok.json +7 -0
  30. package/profiles/llama.json +10 -0
  31. package/profiles/mercury.json +9 -0
  32. package/profiles/mistral.json +5 -0
  33. package/profiles/qwen.json +17 -0
  34. package/profiles/tasks/construction_profile.json +42 -0
  35. package/profiles/tasks/cooking_profile.json +11 -0
  36. package/profiles/tasks/crafting_profile.json +71 -0
  37. package/profiles/vllm.json +10 -0
  38. package/settings.js +64 -0
  39. package/src/agent/action_manager.js +177 -0
  40. package/src/agent/agent.js +561 -0
  41. package/src/agent/coder.js +229 -0
  42. package/src/agent/commands/actions.js +504 -0
  43. package/src/agent/commands/index.js +259 -0
  44. package/src/agent/commands/queries.js +347 -0
  45. package/src/agent/connection_handler.js +96 -0
  46. package/src/agent/conversation.js +353 -0
  47. package/src/agent/history.js +122 -0
  48. package/src/agent/library/full_state.js +89 -0
  49. package/src/agent/library/index.js +23 -0
  50. package/src/agent/library/lockdown.js +32 -0
  51. package/src/agent/library/skill_library.js +93 -0
  52. package/src/agent/library/skills.js +2093 -0
  53. package/src/agent/library/world.js +431 -0
  54. package/src/agent/memory_bank.js +25 -0
  55. package/src/agent/mindserver_proxy.js +136 -0
  56. package/src/agent/modes.js +446 -0
  57. package/src/agent/npc/build_goal.js +80 -0
  58. package/src/agent/npc/construction/dirt_shelter.json +38 -0
  59. package/src/agent/npc/construction/large_house.json +230 -0
  60. package/src/agent/npc/construction/small_stone_house.json +42 -0
  61. package/src/agent/npc/construction/small_wood_house.json +42 -0
  62. package/src/agent/npc/controller.js +261 -0
  63. package/src/agent/npc/data.js +50 -0
  64. package/src/agent/npc/item_goal.js +355 -0
  65. package/src/agent/npc/utils.js +126 -0
  66. package/src/agent/self_prompter.js +146 -0
  67. package/src/agent/settings.js +7 -0
  68. package/src/agent/speak.js +150 -0
  69. package/src/agent/tasks/construction_tasks.js +1104 -0
  70. package/src/agent/tasks/cooking_tasks.js +358 -0
  71. package/src/agent/tasks/tasks.js +594 -0
  72. package/src/agent/templates/execTemplate.js +6 -0
  73. package/src/agent/templates/lintTemplate.js +10 -0
  74. package/src/agent/vision/browser_viewer.js +8 -0
  75. package/src/agent/vision/camera.js +78 -0
  76. package/src/agent/vision/vision_interpreter.js +82 -0
  77. package/src/mindcraft/index.js +28 -0
  78. package/src/mindcraft/mcserver.js +154 -0
  79. package/src/mindcraft/mindcraft.js +111 -0
  80. package/src/mindcraft/mindserver.js +328 -0
  81. package/src/mindcraft/public/index.html +1253 -0
  82. package/src/mindcraft/public/settings_spec.json +145 -0
  83. package/src/mindcraft/userconfig.js +72 -0
  84. package/src/mindcraft-py/example.py +27 -0
  85. package/src/mindcraft-py/init-mindcraft.js +24 -0
  86. package/src/mindcraft-py/mindcraft.py +99 -0
  87. package/src/models/_model_map.js +89 -0
  88. package/src/models/azure.js +32 -0
  89. package/src/models/cerebras.js +61 -0
  90. package/src/models/claude.js +87 -0
  91. package/src/models/deepseek.js +59 -0
  92. package/src/models/gemini.js +176 -0
  93. package/src/models/glhf.js +71 -0
  94. package/src/models/gpt.js +147 -0
  95. package/src/models/grok.js +82 -0
  96. package/src/models/groq.js +95 -0
  97. package/src/models/huggingface.js +86 -0
  98. package/src/models/hyperbolic.js +114 -0
  99. package/src/models/lmstudio.js +74 -0
  100. package/src/models/mercury.js +95 -0
  101. package/src/models/mistral.js +94 -0
  102. package/src/models/novita.js +71 -0
  103. package/src/models/ollama.js +115 -0
  104. package/src/models/openrouter.js +77 -0
  105. package/src/models/prompter.js +366 -0
  106. package/src/models/qwen.js +80 -0
  107. package/src/models/replicate.js +60 -0
  108. package/src/models/vllm.js +81 -0
  109. package/src/process/agent_process.js +84 -0
  110. package/src/process/init_agent.js +54 -0
  111. package/src/utils/examples.js +83 -0
  112. package/src/utils/keys.js +34 -0
  113. package/src/utils/math.js +13 -0
  114. package/src/utils/mcdata.js +572 -0
  115. package/src/utils/text.js +78 -0
  116. package/src/utils/translator.js +30 -0
@@ -0,0 +1,230 @@
1
+ {
2
+ "name": "large_house",
3
+ "offset": -4,
4
+ "blocks": [
5
+ [
6
+ ["", "", "", "", "", "", "", "", "", "", ""],
7
+ ["", "", "", "", "", "", "", "", "", "", ""],
8
+ ["", "", "", "", "", "", "", "", "", "", ""],
9
+ ["", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", ""],
10
+ ["", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", ""],
11
+ ["", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", ""],
12
+ ["", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", ""],
13
+ ["", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", ""],
14
+ ["", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", ""],
15
+ ["", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", ""],
16
+ ["", "", "", "", "", "", "", "", "", "", ""],
17
+ ["", "", "", "", "", "", "", "", "", "", ""],
18
+ ["", "", "", "", "", "", "", "", "", "", ""],
19
+ ["", "", "", "", "", "", "", "", "", "", ""]
20
+ ],
21
+ [
22
+ ["", "", "", "", "", "", "", "", "", "", ""],
23
+ ["", "", "", "", "", "", "", "", "", "", ""],
24
+ ["", "", "", "", "", "", "", "", "", "", ""],
25
+ ["", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", ""],
26
+ ["", "cobblestone", "air", "air", "air", "air", "air", "air", "air", "cobblestone", ""],
27
+ ["", "cobblestone", "air", "air", "air", "air", "air", "air", "air", "cobblestone", ""],
28
+ ["", "cobblestone", "air", "air", "air", "air", "air", "air", "air", "cobblestone", ""],
29
+ ["", "cobblestone", "planks", "air", "air", "air", "air", "air", "air", "cobblestone", ""],
30
+ ["", "cobblestone", "planks", "air", "air", "air", "air", "air", "air", "cobblestone", ""],
31
+ ["", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", ""],
32
+ ["", "", "", "", "", "", "", "", "", "", ""],
33
+ ["", "", "", "", "", "", "", "", "", "", ""],
34
+ ["", "", "", "", "", "", "", "", "", "", ""],
35
+ ["", "", "", "", "", "", "", "", "", "", ""]
36
+ ],
37
+ [
38
+ ["", "", "", "", "", "", "", "", "", "", ""],
39
+ ["", "", "", "", "", "", "", "", "", "", ""],
40
+ ["", "", "", "", "", "", "", "", "", "", ""],
41
+ ["", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", ""],
42
+ ["", "cobblestone", "air", "torch", "air", "air", "air", "torch", "air", "cobblestone", ""],
43
+ ["", "cobblestone", "air", "air", "air", "air", "air", "air", "air", "cobblestone", ""],
44
+ ["", "cobblestone", "air", "air", "air", "air", "air", "air", "air", "cobblestone", ""],
45
+ ["", "cobblestone", "air", "air", "air", "air", "air", "air", "air", "cobblestone", ""],
46
+ ["", "cobblestone", "planks", "torch", "air", "air", "air", "torch", "air", "cobblestone", ""],
47
+ ["", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", ""],
48
+ ["", "", "", "", "", "", "", "", "", "", ""],
49
+ ["", "", "", "", "", "", "", "", "", "", ""],
50
+ ["", "", "", "", "", "", "", "", "", "", ""],
51
+ ["", "", "", "", "", "", "", "", "", "", ""]
52
+ ],
53
+ [
54
+ ["", "", "", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "", "", ""],
55
+ ["", "", "", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "", "", ""],
56
+ ["", "", "", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "", "", ""],
57
+ ["cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", ""],
58
+ ["cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", ""],
59
+ ["cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", ""],
60
+ ["cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", ""],
61
+ ["cobblestone", "cobblestone", "air", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "dirt"],
62
+ ["cobblestone", "cobblestone", "air", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", ""],
63
+ ["cobblestone", "cobblestone", "air", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", ""],
64
+ ["", "", "", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", ""],
65
+ ["", "", "", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", ""],
66
+ ["", "", "", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", ""],
67
+ ["", "", "", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone", ""]
68
+ ],
69
+ [
70
+ ["", "", "", "log", "planks", "planks", "planks", "log", "", "", ""],
71
+ ["", "", "", "planks", "furnace", "air", "crafting_table", "planks", "", "", ""],
72
+ ["", "", "", "planks", "air", "air", "air", "planks", "", "", ""],
73
+ ["log", "planks", "planks", "log", "planks", "air", "planks", "log", "planks", "log", ""],
74
+ ["planks", "planks", "air", "air", "air", "air", "air", "air", "air", "planks", ""],
75
+ ["planks", "planks", "air", "air", "air", "air", "air", "air", "air", "planks", ""],
76
+ ["planks", "planks", "air", "air", "air", "air", "air", "air", "air", "door", "air"],
77
+ ["planks", "planks", "air", "air", "air", "air", "air", "air", "air", "planks", ""],
78
+ ["planks", "planks", "air", "air", "air", "air", "air", "air", "air", "planks", ""],
79
+ ["log", "planks", "planks", "log", "planks", "planks", "air", "planks", "planks", "log", ""],
80
+ ["", "", "", "planks", "air", "air", "air", "", "air", "planks", ""],
81
+ ["", "", "", "planks", "chest", "air", "air", "bed", "", "planks", ""],
82
+ ["", "", "", "planks", "chest", "air", "air", "", "air", "planks", ""],
83
+ ["", "", "", "log", "planks", "planks", "planks", "planks", "planks", "log", ""]
84
+ ],
85
+ [
86
+ ["", "", "", "log", "planks", "planks", "planks", "log", "", "", ""],
87
+ ["", "", "", "planks", "air", "air", "air", "glass", "", "", ""],
88
+ ["", "", "", "planks", "air", "air", "air", "glass", "", "", ""],
89
+ ["log", "planks", "planks", "log", "planks", "air", "planks", "log", "planks", "log", ""],
90
+ ["planks", "air", "air", "air", "air", "air", "air", "air", "air", "planks", ""],
91
+ ["planks", "planks", "air", "air", "air", "air", "air", "air", "air", "planks", ""],
92
+ ["planks", "planks", "air", "air", "air", "air", "air", "air", "air", "door", "air"],
93
+ ["planks", "planks", "air", "air", "air", "air", "air", "air", "air", "planks", ""],
94
+ ["planks", "planks", "air", "air", "air", "air", "air", "air", "air", "planks", ""],
95
+ ["log", "planks", "planks", "log", "planks", "planks", "air", "planks", "planks", "log", ""],
96
+ ["", "", "", "planks", "air", "air", "air", "air", "air", "planks", ""],
97
+ ["", "", "", "planks", "air", "air", "air", "air", "air", "planks", ""],
98
+ ["", "", "", "planks", "air", "air", "air", "air", "air", "planks", ""],
99
+ ["", "", "", "log", "planks", "glass", "glass", "glass", "planks", "log", ""]
100
+ ],
101
+ [
102
+ ["", "", "", "log", "planks", "planks", "planks", "log", "", "", ""],
103
+ ["", "", "", "planks", "air", "air", "air", "glass", "", "", ""],
104
+ ["", "", "", "planks", "torch", "air", "torch", "glass", "", "", ""],
105
+ ["log", "planks", "planks", "log", "planks", "air", "planks", "log", "planks", "log", ""],
106
+ ["planks", "air", "air", "torch", "air", "air", "air", "air", "air", "planks", ""],
107
+ ["planks", "air", "air", "air", "air", "air", "air", "air", "torch", "planks", ""],
108
+ ["planks", "planks", "air", "air", "air", "air", "air", "air", "air", "planks", ""],
109
+ ["planks", "planks", "air", "air", "air", "air", "air", "air", "torch", "planks", ""],
110
+ ["planks", "planks", "air", "torch", "air", "air", "air", "air", "air", "planks", ""],
111
+ ["log", "planks", "planks", "log", "planks", "planks", "air", "planks", "planks", "log", ""],
112
+ ["", "", "", "planks", "air", "torch", "air", "torch", "air", "planks", ""],
113
+ ["", "", "", "planks", "air", "air", "air", "air", "air", "planks", ""],
114
+ ["", "", "", "planks", "air", "air", "air", "air", "air", "planks", ""],
115
+ ["", "", "", "log", "planks", "glass", "glass", "glass", "planks", "log", ""]
116
+ ],
117
+ [
118
+ ["", "", "", "log", "log", "log", "log", "log", "", "", ""],
119
+ ["", "", "", "log", "planks", "planks", "planks", "log", "", "", ""],
120
+ ["", "", "", "log", "planks", "planks", "planks", "log", "", "", ""],
121
+ ["log", "log", "log", "log", "log", "log", "log", "log", "log", "log", ""],
122
+ ["log", "air", "planks", "planks", "planks", "planks", "planks", "planks", "planks", "log", ""],
123
+ ["log", "air", "planks", "planks", "planks", "planks", "planks", "planks", "planks", "log", ""],
124
+ ["log", "air", "planks", "planks", "planks", "planks", "planks", "planks", "planks", "log", ""],
125
+ ["log", "planks", "planks", "planks", "planks", "planks", "planks", "planks", "planks", "log", ""],
126
+ ["log", "planks", "planks", "planks", "planks", "planks", "planks", "planks", "planks", "log", ""],
127
+ ["log", "log", "log", "log", "log", "log", "log", "log", "log", "log", ""],
128
+ ["", "", "", "log", "planks", "planks", "planks", "planks", "planks", "log", ""],
129
+ ["", "", "", "log", "planks", "planks", "planks", "planks", "planks", "log", ""],
130
+ ["", "", "", "log", "planks", "planks", "planks", "planks", "planks", "log", ""],
131
+ ["", "", "", "log", "log", "log", "log", "log", "log", "log", ""]
132
+ ],
133
+ [
134
+ ["", "", "", "", "", "", "", "", "", "", ""],
135
+ ["", "", "", "", "planks", "planks", "planks", "", "", "", ""],
136
+ ["", "", "", "", "planks", "planks", "planks", "", "", "", ""],
137
+ ["log", "planks", "planks", "log", "planks", "planks", "planks", "planks", "planks", "log", ""],
138
+ ["planks", "air", "bookshelf", "bookshelf", "air", "air", "air", "air", "torch", "planks", ""],
139
+ ["planks", "air", "air", "air", "air", "air", "air", "air", "air", "planks", ""],
140
+ ["planks", "air", "air", "air", "air", "air", "air", "air", "air", "planks", ""],
141
+ ["planks", "air", "air", "air", "air", "air", "air", "air", "air", "planks", ""],
142
+ ["planks", "air", "air", "air", "air", "air", "air", "air", "torch", "planks", ""],
143
+ ["log", "planks", "planks", "log", "planks", "planks", "planks", "planks", "planks", "log", ""],
144
+ ["", "", "", "", "planks", "planks", "planks", "planks", "planks", "", ""],
145
+ ["", "", "", "", "planks", "planks", "planks", "planks", "planks", "", ""],
146
+ ["", "", "", "", "planks", "planks", "planks", "planks", "planks", "", ""],
147
+ ["", "", "", "", "", "", "", "", "", "", ""]
148
+ ],
149
+ [
150
+ ["", "", "", "", "", "", "", "", "", "", ""],
151
+ ["", "", "", "", "", "", "", "", "", "", ""],
152
+ ["", "", "", "", "", "", "", "", "", "", ""],
153
+ ["log", "planks", "planks", "log", "glass", "glass", "glass", "glass", "glass", "log", ""],
154
+ ["glass", "air", "bookshelf", "bookshelf", "air", "air", "air", "air", "air", "planks", ""],
155
+ ["glass", "air", "air", "air", "air", "air", "air", "air", "air", "glass", ""],
156
+ ["glass", "air", "air", "air", "air", "air", "air", "air", "air", "glass", ""],
157
+ ["glass", "air", "air", "air", "air", "air", "air", "air", "air", "glass", ""],
158
+ ["glass", "air", "air", "air", "air", "air", "air", "air", "air", "glass", ""],
159
+ ["log", "planks", "planks", "log", "glass", "glass", "glass", "glass", "glass", "log", ""],
160
+ ["", "", "", "", "", "", "", "", "", "", ""],
161
+ ["", "", "", "", "", "", "", "", "", "", ""],
162
+ ["", "", "", "", "", "", "", "", "", "", ""],
163
+ ["", "", "", "", "", "", "", "", "", "", ""]
164
+ ],
165
+ [
166
+ ["", "", "", "", "", "", "", "", "", "", ""],
167
+ ["", "", "", "", "", "", "", "", "", "", ""],
168
+ ["", "", "", "", "", "", "", "", "", "", ""],
169
+ ["log", "planks", "planks", "log", "glass", "glass", "glass", "glass", "glass", "log", ""],
170
+ ["glass", "air", "air", "torch", "air", "air", "air", "air", "air", "glass", ""],
171
+ ["glass", "air", "air", "air", "air", "air", "air", "air", "air", "glass", ""],
172
+ ["glass", "air", "air", "air", "air", "air", "air", "air", "air", "glass", ""],
173
+ ["glass", "air", "air", "air", "air", "air", "air", "air", "air", "glass", ""],
174
+ ["glass", "air", "air", "torch", "air", "air", "air", "air", "air", "glass", ""],
175
+ ["log", "planks", "planks", "log", "glass", "glass", "glass", "glass", "glass", "log", ""],
176
+ ["", "", "", "", "", "", "", "", "", "", ""],
177
+ ["", "", "", "", "", "", "", "", "", "", ""],
178
+ ["", "", "", "", "", "", "", "", "", "", ""],
179
+ ["", "", "", "", "", "", "", "", "", "", ""]
180
+ ],
181
+ [
182
+ ["", "", "", "", "", "", "", "", "", "", ""],
183
+ ["", "", "", "", "", "", "", "", "", "", ""],
184
+ ["", "", "", "", "", "", "", "", "", "", ""],
185
+ ["log", "log", "log", "log", "log", "log", "log", "log", "log", "log", ""],
186
+ ["log", "planks", "planks", "log", "planks", "planks", "planks", "planks", "planks", "log", ""],
187
+ ["log", "planks", "planks", "log", "planks", "planks", "planks", "planks", "planks", "log", ""],
188
+ ["log", "planks", "planks", "log", "planks", "planks", "planks", "planks", "planks", "log", ""],
189
+ ["log", "planks", "planks", "log", "planks", "planks", "planks", "planks", "planks", "log", ""],
190
+ ["log", "planks", "planks", "log", "planks", "planks", "planks", "planks", "planks", "log", ""],
191
+ ["log", "log", "log", "log", "log", "log", "log", "log", "log", "log", ""],
192
+ ["", "", "", "", "", "", "", "", "", "", ""],
193
+ ["", "", "", "", "", "", "", "", "", "", ""],
194
+ ["", "", "", "", "", "", "", "", "", "", ""],
195
+ ["", "", "", "", "", "", "", "", "", "", ""]
196
+ ],
197
+ [
198
+ ["", "", "", "", "", "", "", "", "", "", ""],
199
+ ["", "", "", "", "", "", "", "", "", "", ""],
200
+ ["", "", "", "", "", "", "", "", "", "", ""],
201
+ ["", "", "", "", "", "", "", "", "", "", ""],
202
+ ["", "", "", "", "planks", "planks", "planks", "planks", "planks", "", ""],
203
+ ["", "", "", "", "planks", "planks", "planks", "planks", "planks", "", ""],
204
+ ["", "", "", "", "planks", "planks", "planks", "planks", "planks", "", ""],
205
+ ["", "", "", "", "planks", "planks", "planks", "planks", "planks", "", ""],
206
+ ["", "", "", "", "planks", "planks", "planks", "planks", "planks", "", ""],
207
+ ["", "", "", "", "", "", "", "", "", "", ""],
208
+ ["", "", "", "", "", "", "", "", "", "", ""],
209
+ ["", "", "", "", "", "", "", "", "", "", ""],
210
+ ["", "", "", "", "", "", "", "", "", "", ""],
211
+ ["", "", "", "", "", "", "", "", "", "", ""]
212
+ ],
213
+ [
214
+ ["", "", "", "", "", "", "", "", "", "", ""],
215
+ ["", "", "", "", "", "", "", "", "", "", ""],
216
+ ["", "", "", "", "", "", "", "", "", "", ""],
217
+ ["", "", "", "", "", "", "", "", "", "", ""],
218
+ ["", "", "", "", "", "", "", "", "", "", ""],
219
+ ["", "", "", "", "", "planks", "planks", "planks", "", "", ""],
220
+ ["", "", "", "", "", "planks", "planks", "planks", "", "", ""],
221
+ ["", "", "", "", "", "planks", "planks", "planks", "", "", ""],
222
+ ["", "", "", "", "", "", "", "", "", "", ""],
223
+ ["", "", "", "", "", "", "", "", "", "", ""],
224
+ ["", "", "", "", "", "", "", "", "", "", ""],
225
+ ["", "", "", "", "", "", "", "", "", "", ""],
226
+ ["", "", "", "", "", "", "", "", "", "", ""],
227
+ ["", "", "", "", "", "", "", "", "", "", ""]
228
+ ]
229
+ ]
230
+ }
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "small_stone_house",
3
+ "offset": -1,
4
+ "blocks": [
5
+ [
6
+ ["", "", "", "", ""],
7
+ ["", "planks", "planks", "planks", ""],
8
+ ["", "planks", "planks", "planks", ""],
9
+ ["", "planks", "planks", "planks", ""],
10
+ ["", "planks", "planks", "planks", ""],
11
+ ["", "", "planks", "", ""],
12
+ ["", "", "", "", ""]
13
+ ],
14
+ [
15
+ ["cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone"],
16
+ ["cobblestone", "chest", "bed", "air", "cobblestone"],
17
+ ["cobblestone", "air", "bed", "air", "cobblestone"],
18
+ ["cobblestone", "air", "air", "air", "cobblestone"],
19
+ ["cobblestone", "air", "air", "air", "cobblestone"],
20
+ ["cobblestone", "cobblestone", "door", "cobblestone", "cobblestone"],
21
+ ["", "air", "air", "air", ""]
22
+ ],
23
+ [
24
+ ["cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone"],
25
+ ["cobblestone", "torch", "air", "torch", "cobblestone"],
26
+ ["cobblestone", "air", "air", "air", "cobblestone"],
27
+ ["cobblestone", "air", "air", "air", "cobblestone"],
28
+ ["cobblestone", "torch", "air", "torch", "cobblestone"],
29
+ ["cobblestone", "cobblestone", "door", "cobblestone", "cobblestone"],
30
+ ["", "air", "air", "air", ""]
31
+ ],
32
+ [
33
+ ["air", "air", "air", "air", "air"],
34
+ ["air", "cobblestone", "cobblestone", "cobblestone", "air"],
35
+ ["cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone"],
36
+ ["cobblestone", "cobblestone", "cobblestone", "cobblestone", "cobblestone"],
37
+ ["air", "cobblestone", "cobblestone", "cobblestone", "air"],
38
+ ["air", "air", "air", "air", "air"],
39
+ ["", "air", "air", "air", ""]
40
+ ]
41
+ ]
42
+ }
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "small_wood_house",
3
+ "offset": -1,
4
+ "blocks": [
5
+ [
6
+ ["", "", "", "", ""],
7
+ ["", "planks", "planks", "planks", ""],
8
+ ["", "planks", "planks", "planks", ""],
9
+ ["", "planks", "planks", "planks", ""],
10
+ ["", "planks", "planks", "planks", ""],
11
+ ["", "", "planks", "", ""],
12
+ ["", "", "", "", ""]
13
+ ],
14
+ [
15
+ ["log", "planks", "planks", "planks", "log"],
16
+ ["planks", "chest", "bed", "air", "planks"],
17
+ ["planks", "air", "bed", "air", "planks"],
18
+ ["planks", "air", "air", "air", "planks"],
19
+ ["planks", "air", "air", "air", "planks"],
20
+ ["log", "planks", "door", "planks", "log"],
21
+ ["", "air", "air", "air", ""]
22
+ ],
23
+ [
24
+ ["log", "planks", "planks", "planks", "log"],
25
+ ["planks", "torch", "air", "torch", "planks"],
26
+ ["planks", "air", "air", "air", "planks"],
27
+ ["planks", "air", "air", "air", "planks"],
28
+ ["planks", "torch", "air", "torch", "planks"],
29
+ ["log", "planks", "door", "planks", "log"],
30
+ ["", "air", "air", "air", ""]
31
+ ],
32
+ [
33
+ ["air", "air", "air", "air", "air"],
34
+ ["air", "planks", "planks", "planks", "air"],
35
+ ["planks", "planks", "planks", "planks", "planks"],
36
+ ["planks", "planks", "planks", "planks", "planks"],
37
+ ["air", "planks", "planks", "planks", "air"],
38
+ ["air", "air", "air", "air", "air"],
39
+ ["", "air", "air", "air", ""]
40
+ ]
41
+ ]
42
+ }
@@ -0,0 +1,261 @@
1
+ import { readdirSync, readFileSync } from 'fs';
2
+ import { NPCData } from './data.js';
3
+ import { ItemGoal } from './item_goal.js';
4
+ import { BuildGoal } from './build_goal.js';
5
+ import { itemSatisfied, rotateXZ } from './utils.js';
6
+ import * as skills from '../library/skills.js';
7
+ import * as world from '../library/world.js';
8
+ import * as mc from '../../utils/mcdata.js';
9
+
10
+
11
+ export class NPCContoller {
12
+ constructor(agent) {
13
+ this.agent = agent;
14
+ this.data = NPCData.fromObject(agent.prompter.profile.npc);
15
+ this.temp_goals = [];
16
+ this.item_goal = new ItemGoal(agent, this.data);
17
+ this.build_goal = new BuildGoal(agent);
18
+ this.constructions = {};
19
+ this.last_goals = {};
20
+ }
21
+
22
+ getBuiltPositions() {
23
+ let positions = [];
24
+ for (let name in this.data.built) {
25
+ let position = this.data.built[name].position;
26
+ let offset = this.constructions[name].offset;
27
+ let sizex = this.constructions[name].blocks[0][0].length;
28
+ let sizez = this.constructions[name].blocks[0].length;
29
+ let sizey = this.constructions[name].blocks.length;
30
+ for (let y = offset; y < sizey+offset; y++) {
31
+ for (let z = 0; z < sizez; z++) {
32
+ for (let x = 0; x < sizex; x++) {
33
+ positions.push({x: position.x + x, y: position.y + y, z: position.z + z});
34
+ }
35
+ }
36
+ }
37
+ }
38
+ return positions;
39
+ }
40
+
41
+ init() {
42
+ try {
43
+ for (let file of readdirSync('src/agent/npc/construction')) {
44
+ if (file.endsWith('.json')) {
45
+ this.constructions[file.slice(0, -5)] = JSON.parse(readFileSync('src/agent/npc/construction/' + file, 'utf8'));
46
+ }
47
+ }
48
+ } catch (e) {
49
+ console.log('Error reading construction file');
50
+ }
51
+
52
+ for (let name in this.constructions) {
53
+ let sizez = this.constructions[name].blocks[0].length;
54
+ let sizex = this.constructions[name].blocks[0][0].length;
55
+ let max_size = Math.max(sizex, sizez);
56
+ for (let y = 0; y < this.constructions[name].blocks.length; y++) {
57
+ for (let z = 0; z < max_size; z++) {
58
+ if (z >= this.constructions[name].blocks[y].length)
59
+ this.constructions[name].blocks[y].push([]);
60
+ for (let x = 0; x < max_size; x++) {
61
+ if (x >= this.constructions[name].blocks[y][z].length)
62
+ this.constructions[name].blocks[y][z].push('');
63
+ }
64
+ }
65
+ }
66
+ }
67
+
68
+ this.agent.bot.on('idle', async () => {
69
+ if (this.data.goals.length === 0 && !this.data.curr_goal) return;
70
+ // Wait a while for inputs before acting independently
71
+ await new Promise((resolve) => setTimeout(resolve, 5000));
72
+ if (!this.agent.isIdle()) return;
73
+
74
+ // Persue goal
75
+ if (!this.agent.actions.resume_func) {
76
+ this.executeNext();
77
+ this.agent.history.save();
78
+ }
79
+ });
80
+ }
81
+
82
+ async setGoal(name=null, quantity=1) {
83
+ this.data.curr_goal = null;
84
+ this.last_goals = {};
85
+ if (name) {
86
+ this.data.curr_goal = {name: name, quantity: quantity};
87
+ return;
88
+ }
89
+
90
+ if (!this.data.do_set_goal) return;
91
+
92
+ let past_goals = {...this.last_goals};
93
+ for (let goal in this.data.goals) {
94
+ if (past_goals[goal.name] === undefined) past_goals[goal.name] = true;
95
+ }
96
+ let res = await this.agent.prompter.promptGoalSetting(this.agent.history.getHistory(), past_goals);
97
+ if (res) {
98
+ this.data.curr_goal = res;
99
+ console.log('Set new goal: ', res.name, ' x', res.quantity);
100
+ } else {
101
+ console.log('Error setting new goal.');
102
+ }
103
+ }
104
+
105
+ async executeNext() {
106
+ if (!this.agent.isIdle()) return;
107
+ await this.agent.actions.runAction('npc:moveAway', async () => {
108
+ await skills.moveAway(this.agent.bot, 2);
109
+ });
110
+
111
+ if (!this.data.do_routine || this.agent.bot.time.timeOfDay < 13000) {
112
+ // Exit any buildings
113
+ let building = this.currentBuilding();
114
+ if (building == this.data.home) {
115
+ let door_pos = this.getBuildingDoor(building);
116
+ if (door_pos) {
117
+ await this.agent.actions.runAction('npc:exitBuilding', async () => {
118
+ await skills.useDoor(this.agent.bot, door_pos);
119
+ await skills.moveAway(this.agent.bot, 2); // If the bot is too close to the building it will try to enter again
120
+ });
121
+ }
122
+ }
123
+
124
+ // Work towards goals
125
+ await this.executeGoal();
126
+
127
+ } else {
128
+ // Reset goal at the end of the day
129
+ this.data.curr_goal = null;
130
+
131
+ // Return to home
132
+ let building = this.currentBuilding();
133
+ if (this.data.home !== null && (building === null || building != this.data.home)) {
134
+ let door_pos = this.getBuildingDoor(this.data.home);
135
+ await this.agent.actions.runAction('npc:returnHome', async () => {
136
+ await skills.useDoor(this.agent.bot, door_pos);
137
+ });
138
+ }
139
+
140
+ // Go to bed
141
+ await this.agent.actions.runAction('npc:bed', async () => {
142
+ await skills.goToBed(this.agent.bot);
143
+ });
144
+ }
145
+
146
+ if (this.agent.isIdle())
147
+ this.agent.bot.emit('idle');
148
+ }
149
+
150
+ async executeGoal() {
151
+ // If we need more blocks to complete a building, get those first
152
+ let goals = this.temp_goals.concat(this.data.goals);
153
+ if (this.data.curr_goal)
154
+ goals = goals.concat([this.data.curr_goal])
155
+ this.temp_goals = [];
156
+
157
+ let acted = false;
158
+ for (let goal of goals) {
159
+
160
+ // Obtain goal item or block
161
+ if (this.constructions[goal.name] === undefined) {
162
+ if (!itemSatisfied(this.agent.bot, goal.name, goal.quantity)) {
163
+ let res = await this.item_goal.executeNext(goal.name, goal.quantity);
164
+ this.last_goals[goal.name] = res;
165
+ acted = true;
166
+ break;
167
+ }
168
+ }
169
+
170
+ // Build construction goal
171
+ else {
172
+ let res = null;
173
+ if (this.data.built.hasOwnProperty(goal.name)) {
174
+ res = await this.build_goal.executeNext(
175
+ this.constructions[goal.name],
176
+ this.data.built[goal.name].position,
177
+ this.data.built[goal.name].orientation
178
+ );
179
+ } else {
180
+ res = await this.build_goal.executeNext(this.constructions[goal.name]);
181
+ this.data.built[goal.name] = {
182
+ name: goal.name,
183
+ position: res.position,
184
+ orientation: res.orientation
185
+ };
186
+ }
187
+ if (Object.keys(res.missing).length === 0) {
188
+ this.data.home = goal.name;
189
+ }
190
+ for (let block_name in res.missing) {
191
+ this.temp_goals.push({
192
+ name: block_name,
193
+ quantity: res.missing[block_name]
194
+ })
195
+ }
196
+ if (res.acted) {
197
+ acted = true;
198
+ this.last_goals[goal.name] = Object.keys(res.missing).length === 0;
199
+ break;
200
+ }
201
+ }
202
+ }
203
+
204
+ if (!acted && this.data.do_set_goal)
205
+ await this.setGoal();
206
+ }
207
+
208
+ currentBuilding() {
209
+ let bot_pos = this.agent.bot.entity.position;
210
+ for (let name in this.data.built) {
211
+ let pos = this.data.built[name].position;
212
+ let offset = this.constructions[name].offset;
213
+ let sizex = this.constructions[name].blocks[0][0].length;
214
+ let sizez = this.constructions[name].blocks[0].length;
215
+ let sizey = this.constructions[name].blocks.length;
216
+ if (this.data.built[name].orientation % 2 === 1) [sizex, sizez] = [sizez, sizex];
217
+ if (bot_pos.x >= pos.x && bot_pos.x < pos.x + sizex &&
218
+ bot_pos.y >= pos.y + offset && bot_pos.y < pos.y + sizey + offset &&
219
+ bot_pos.z >= pos.z && bot_pos.z < pos.z + sizez) {
220
+ return name;
221
+ }
222
+ }
223
+ return null;
224
+ }
225
+
226
+ getBuildingDoor(name) {
227
+ if (name === null || this.data.built[name] === undefined) return null;
228
+ let door_x = null;
229
+ let door_z = null;
230
+ let door_y = null;
231
+ for (let y = 0; y < this.constructions[name].blocks.length; y++) {
232
+ for (let z = 0; z < this.constructions[name].blocks[y].length; z++) {
233
+ for (let x = 0; x < this.constructions[name].blocks[y][z].length; x++) {
234
+ if (this.constructions[name].blocks[y][z][x] !== null &&
235
+ this.constructions[name].blocks[y][z][x].includes('door')) {
236
+ door_x = x;
237
+ door_z = z;
238
+ door_y = y;
239
+ break;
240
+ }
241
+ }
242
+ if (door_x !== null) break;
243
+ }
244
+ if (door_x !== null) break;
245
+ }
246
+ if (door_x === null) return null;
247
+
248
+ let sizex = this.constructions[name].blocks[0][0].length;
249
+ let sizez = this.constructions[name].blocks[0].length;
250
+ let orientation = 4 - this.data.built[name].orientation; // this conversion is opposite
251
+ if (orientation == 4) orientation = 0;
252
+ [door_x, door_z] = rotateXZ(door_x, door_z, orientation, sizex, sizez);
253
+ door_y += this.constructions[name].offset;
254
+
255
+ return {
256
+ x: this.data.built[name].position.x + door_x,
257
+ y: this.data.built[name].position.y + door_y,
258
+ z: this.data.built[name].position.z + door_z
259
+ };
260
+ }
261
+ }