Skip to content

Commit ee24b7d

Browse files
committed
Initial commit
0 parents  commit ee24b7d

7 files changed

+1733
-0
lines changed

.gitattributes

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.gitignore

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
.pnpm-debug.log*
9+
10+
# Diagnostic reports (https://nodejs.org/api/report.html)
11+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
12+
13+
# Runtime data
14+
pids
15+
*.pid
16+
*.seed
17+
*.pid.lock
18+
19+
# Directory for instrumented libs generated by jscoverage/JSCover
20+
lib-cov
21+
22+
# Coverage directory used by tools like istanbul
23+
coverage
24+
*.lcov
25+
26+
# nyc test coverage
27+
.nyc_output
28+
29+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
30+
.grunt
31+
32+
# Bower dependency directory (https://bower.io/)
33+
bower_components
34+
35+
# node-waf configuration
36+
.lock-wscript
37+
38+
# Compiled binary addons (https://nodejs.org/api/addons.html)
39+
build/Release
40+
41+
# Dependency directories
42+
!node_modules/mineflayer/lib/plugins/entities.js
43+
node_modules/
44+
jspm_packages/
45+
46+
# Snowpack dependency directory (https://snowpack.dev/)
47+
web_modules/
48+
49+
# TypeScript cache
50+
*.tsbuildinfo
51+
52+
# Optional npm cache directory
53+
.npm
54+
55+
# Optional eslint cache
56+
.eslintcache
57+
58+
# Optional stylelint cache
59+
.stylelintcache
60+
61+
# Microbundle cache
62+
.rpt2_cache/
63+
.rts2_cache_cjs/
64+
.rts2_cache_es/
65+
.rts2_cache_umd/
66+
67+
# Optional REPL history
68+
.node_repl_history
69+
70+
# Output of 'npm pack'
71+
*.tgz
72+
73+
# Yarn Integrity file
74+
.yarn-integrity
75+
76+
# dotenv environment variable files
77+
.env
78+
.env.development.local
79+
.env.test.local
80+
.env.production.local
81+
.env.local
82+
83+
# parcel-bundler cache (https://parceljs.org/)
84+
.cache
85+
.parcel-cache
86+
87+
# Next.js build output
88+
.next
89+
out
90+
91+
# Nuxt.js build / generate output
92+
.nuxt
93+
dist
94+
95+
# Gatsby files
96+
.cache/
97+
# Comment in the public line in if your project uses Gatsby and not Next.js
98+
# https://nextjs.org/blog/next-9-1#public-directory-support
99+
# public
100+
101+
# vuepress build output
102+
.vuepress/dist
103+
104+
# vuepress v2.x temp and cache directory
105+
.temp
106+
.cache
107+
108+
# Docusaurus cache and generated files
109+
.docusaurus
110+
111+
# Serverless directories
112+
.serverless/
113+
114+
# FuseBox cache
115+
.fusebox/
116+
117+
# DynamoDB Local files
118+
.dynamodb/
119+
120+
# TernJS port file
121+
.tern-port
122+
123+
# Stores VSCode versions used for testing VSCode extensions
124+
.vscode-test
125+
126+
# yarn v2
127+
.yarn/cache
128+
.yarn/unplugged
129+
.yarn/build-state.yml
130+
.yarn/install-state.gz
131+
.pnp.*

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Azures
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

client.js

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
const { Authflow } = require("prismarine-auth")
2+
const { RealmAPI } = require("prismarine-realms")
3+
const fs = require("node:fs")
4+
const input = require("input")
5+
const uuid = require("uuid")
6+
const foods = require("./foods.json")
7+
const mineflayer = require("mineflayer")
8+
require("colors")
9+
10+
async function main() {
11+
const authflow = new Authflow(uuid.v4())
12+
const user = await authflow.getMinecraftJavaToken({ fetchProfile: true })
13+
console.clear()
14+
console.log("Joueur :", user.profile.name.magenta)
15+
const minecraftEdition = await input.select("Edition du jeu :", ["Java", "Bedrock"])
16+
const api = RealmAPI.from(authflow, minecraftEdition.toLowerCase())
17+
const realms = await api.getRealms()
18+
if (realms.length === 0) {
19+
console.log("Aucun realm trouvé")
20+
return
21+
} else if (realms.length === 1) {
22+
const realm = realms[0]
23+
console.log("? ".green + "Realm : ".bold + realm.name.cyan)
24+
console.log("Connexion au realm...".yellow)
25+
connectToRealm(await realm.getAddress(), user)
26+
} else {
27+
const realm = await input.select("Realm :", realms.map(r => r.name))
28+
connectToRealm(await realms.find($realm => $realm.name == realm).getAddress(), user)
29+
console.log("Connexion au realm...".yellow)
30+
}
31+
32+
}
33+
34+
function connectToRealm(realm) {
35+
try {
36+
const client = mineflayer.createBot({
37+
auth: "microsoft",
38+
logErrors: true,
39+
version: "1.21.4",
40+
host: realm.host,
41+
port: realm.port,
42+
})
43+
client.on("login", () => {
44+
console.log("Connecté au realm".green)
45+
client.chat("Auto-AFK Connecté")
46+
})
47+
client.on("death", () => {
48+
console.log("Joeur mort".red)
49+
})
50+
client.on("health", async () => {
51+
console.log("=====================================")
52+
console.log("Santé du joueur : " + client.health)
53+
console.log("Nourriture anté du joueur : " + client.food)
54+
if (client.food < 20) {
55+
if (client.heldItem && foods.includes(client.heldItem.name)) {
56+
client.activateItem()
57+
} else {
58+
let hasFood = false
59+
let food = undefined
60+
for (const item of client.inventory.items()) {
61+
if (foods.includes(item.name)) {
62+
hasFood = true
63+
food = item
64+
break
65+
}
66+
}
67+
if (hasFood) {
68+
await client.equip(food, "hand")
69+
client.activateItem()
70+
}
71+
}
72+
}
73+
if (client.health < 2) {
74+
console.log("=====================================")
75+
client.chat("Joueur en mauvaise posture")
76+
client.chat("Déconnexion...")
77+
client.quit()
78+
}
79+
})
80+
client.on("kicked", (reason) => {
81+
console.log("=====================================")
82+
console.log("Expulsé du serveur : " + reason.red)
83+
})
84+
client.on("end", () => {
85+
console.log("=====================================")
86+
console.log("Déconnexion du serveur".red)
87+
})
88+
client.on("error", (error) => {
89+
console.log("=====================================")
90+
console.log("Erreur : " + error.red)
91+
fs.writeFileSync(`error-${Date.now()}.log`, error)
92+
})
93+
setInterval(() => {
94+
client.setControlState("jump", true)
95+
}, 780000)
96+
} catch (error) {
97+
console.error("Erreur de connexion au realm".red)
98+
console.error(error)
99+
}
100+
}
101+
102+
main()

foods.json

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
[
2+
"apple",
3+
"mushroom_stew",
4+
"bread",
5+
"porkchop",
6+
"cooked_porkchop",
7+
"golden_apple",
8+
"enchanted_golden_apple",
9+
"golden_apple",
10+
"cod",
11+
"fish",
12+
"salmon",
13+
"fish",
14+
"tropical_fish",
15+
"fish",
16+
"pufferfish",
17+
"fish",
18+
"cooked_cod",
19+
"cooked_fish",
20+
"cooked_salmon",
21+
"cooked_fish",
22+
"cake",
23+
"cookie",
24+
"melon_slice",
25+
"melon",
26+
"dried_kelp",
27+
"beef",
28+
"cooked_beef",
29+
"chicken",
30+
"cooked_chicken",
31+
"rotten_flesh",
32+
"carrot",
33+
"potato",
34+
"baked_potato",
35+
"poisonous_potato",
36+
"golden_carrot",
37+
"carrot_on_a_stick",
38+
"pumpkin_pie",
39+
"rabbit",
40+
"cooked_rabbit",
41+
"rabbit_stew",
42+
"mutton",
43+
"cooked_mutton",
44+
"chorus_fruit",
45+
"beetroot",
46+
"beetroot_soup",
47+
"suspicious_stew",
48+
"sweet_berries",
49+
"honey_bottle",
50+
"glow_berries",
51+
"apple",
52+
"mushroom_stew",
53+
"bread",
54+
"porkchop",
55+
"cooked_porkchop",
56+
"golden_apple",
57+
"enchanted_golden_apple",
58+
"golden_apple",
59+
"cod",
60+
"fish",
61+
"salmon",
62+
"fish",
63+
"tropical_fish",
64+
"fish",
65+
"pufferfish",
66+
"fish",
67+
"cooked_cod",
68+
"cooked_fish",
69+
"cooked_salmon",
70+
"cooked_fish",
71+
"cake",
72+
"cookie",
73+
"melon_slice",
74+
"melon",
75+
"dried_kelp",
76+
"beef",
77+
"cooked_beef",
78+
"chicken",
79+
"cooked_chicken",
80+
"rotten_flesh",
81+
"carrot",
82+
"potato",
83+
"baked_potato",
84+
"poisonous_potato",
85+
"golden_carrot",
86+
"carrot_on_a_stick",
87+
"pumpkin_pie",
88+
"rabbit",
89+
"cooked_rabbit",
90+
"rabbit_stew",
91+
"mutton",
92+
"cooked_mutton",
93+
"chorus_fruit",
94+
"beetroot",
95+
"beetroot_soup",
96+
"suspicious_stew",
97+
"sweet_berries",
98+
"honey_bottle",
99+
"glow_berries"
100+
]

0 commit comments

Comments
 (0)