mirror of
https://github.com/guilhermewerner/tcc
synced 2025-06-15 14:35:16 +00:00
Add server and multi bots
This commit is contained in:
9
.gitignore
vendored
9
.gitignore
vendored
@ -1 +1,10 @@
|
||||
node_modules/
|
||||
server/*
|
||||
|
||||
!server/bukkit.yml
|
||||
!server/eula.txt
|
||||
!server/paper-1.20.4-496.jar
|
||||
!server/run.bat
|
||||
!server/run.sh
|
||||
!server/server.properties
|
||||
!server/spigot.yml
|
||||
|
@ -5,12 +5,10 @@
|
||||
"author": "Guilherme Werner <guilhermewerner@tribufu.com>",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "node ./src/bot.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"mineflayer": "^4.20.1",
|
||||
"prismarine-viewer": "^1.28.0"
|
||||
"prismarine-viewer": "^1.28.0",
|
||||
"vec3": "^0.1.10"
|
||||
},
|
||||
"devDependencies": {
|
||||
"cross-env": "^7.0.3"
|
||||
|
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@ -11,6 +11,9 @@ dependencies:
|
||||
prismarine-viewer:
|
||||
specifier: ^1.28.0
|
||||
version: 1.28.0
|
||||
vec3:
|
||||
specifier: ^0.1.10
|
||||
version: 0.1.10
|
||||
|
||||
devDependencies:
|
||||
cross-env:
|
||||
|
32
server/bukkit.yml
Normal file
32
server/bukkit.yml
Normal file
@ -0,0 +1,32 @@
|
||||
settings:
|
||||
allow-end: true
|
||||
warn-on-overload: true
|
||||
permissions-file: permissions.yml
|
||||
update-folder: update
|
||||
plugin-profiling: false
|
||||
connection-throttle: 0
|
||||
query-plugins: true
|
||||
deprecated-verbose: default
|
||||
shutdown-message: Server closed
|
||||
minimum-api: none
|
||||
use-map-color-cache: true
|
||||
spawn-limits:
|
||||
monsters: 70
|
||||
animals: 10
|
||||
water-animals: 5
|
||||
water-ambient: 20
|
||||
water-underground-creature: 5
|
||||
axolotls: 5
|
||||
ambient: 15
|
||||
chunk-gc:
|
||||
period-in-ticks: 600
|
||||
ticks-per:
|
||||
animal-spawns: 400
|
||||
monster-spawns: 1
|
||||
water-spawns: 1
|
||||
water-ambient-spawns: 1
|
||||
water-underground-creature-spawns: 1
|
||||
axolotl-spawns: 1
|
||||
ambient-spawns: 1
|
||||
autosave: 6000
|
||||
aliases: now-in-commands.yml
|
3
server/eula.txt
Normal file
3
server/eula.txt
Normal file
@ -0,0 +1,3 @@
|
||||
#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA).
|
||||
#Fri May 17 14:43:48 BRT 2024
|
||||
eula=true
|
BIN
server/paper-1.20.4-496.jar
Normal file
BIN
server/paper-1.20.4-496.jar
Normal file
Binary file not shown.
10
server/run.bat
Normal file
10
server/run.bat
Normal file
@ -0,0 +1,10 @@
|
||||
@echo off
|
||||
|
||||
|
||||
set JAVA=java
|
||||
set JAR=paper-1.20.4-496.jar
|
||||
set RAM=8192M
|
||||
set FLAGS=-XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Daikars.new.flags=true -Dusing.aikars.flags=https://mcflags.emc.gs
|
||||
|
||||
echo Launching server...
|
||||
%JAVA% -Xmx%RAM% %FLAGS% -jar %JAR%
|
9
server/run.sh
Normal file
9
server/run.sh
Normal file
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
JAVA="java"
|
||||
JAR="paper-1.20.4-496.jar"
|
||||
RAM="8192M"
|
||||
FLAGS="-XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Daikars.new.flags=true -Dusing.aikars.flags=https://mcflags.emc.gs"
|
||||
|
||||
echo "Launching server..."
|
||||
${JAVA} -Xms${RAM} ${FLAGS} -jar ${JAR} --nogui
|
61
server/server.properties
Normal file
61
server/server.properties
Normal file
@ -0,0 +1,61 @@
|
||||
#Minecraft server properties
|
||||
#Fri May 17 15:36:55 BRT 2024
|
||||
enable-jmx-monitoring=false
|
||||
rcon.port=25575
|
||||
level-seed=
|
||||
gamemode=survival
|
||||
enable-command-block=false
|
||||
enable-query=false
|
||||
generator-settings={}
|
||||
enforce-secure-profile=true
|
||||
level-name=world
|
||||
motd=A Minecraft Server
|
||||
query.port=25565
|
||||
pvp=true
|
||||
generate-structures=true
|
||||
max-chained-neighbor-updates=1000000
|
||||
difficulty=easy
|
||||
network-compression-threshold=256
|
||||
max-tick-time=60000
|
||||
require-resource-pack=false
|
||||
use-native-transport=true
|
||||
max-players=10000
|
||||
online-mode=false
|
||||
enable-status=true
|
||||
allow-flight=true
|
||||
initial-disabled-packs=
|
||||
broadcast-rcon-to-ops=true
|
||||
view-distance=10
|
||||
server-ip=
|
||||
resource-pack-prompt=
|
||||
allow-nether=true
|
||||
server-port=25565
|
||||
enable-rcon=false
|
||||
sync-chunk-writes=true
|
||||
resource-pack-id=
|
||||
op-permission-level=4
|
||||
prevent-proxy-connections=false
|
||||
hide-online-players=false
|
||||
resource-pack=
|
||||
entity-broadcast-range-percentage=100
|
||||
simulation-distance=10
|
||||
rcon.password=
|
||||
player-idle-timeout=0
|
||||
debug=false
|
||||
force-gamemode=false
|
||||
rate-limit=0
|
||||
hardcore=false
|
||||
white-list=false
|
||||
broadcast-console-to-ops=true
|
||||
spawn-npcs=true
|
||||
spawn-animals=true
|
||||
log-ips=true
|
||||
function-permission-level=2
|
||||
initial-enabled-packs=vanilla
|
||||
level-type=minecraft\:normal
|
||||
text-filtering-config=
|
||||
spawn-monsters=true
|
||||
enforce-whitelist=false
|
||||
spawn-protection=16
|
||||
resource-pack-sha1=
|
||||
max-world-size=29999984
|
178
server/spigot.yml
Normal file
178
server/spigot.yml
Normal file
@ -0,0 +1,178 @@
|
||||
# This is the main configuration file for Spigot.
|
||||
# As you can see, there's tons to configure. Some options may impact gameplay, so use
|
||||
# with caution, and make sure you know what each option does before configuring.
|
||||
# For a reference for any variable inside this file, check out the Spigot wiki at
|
||||
# http://www.spigotmc.org/wiki/spigot-configuration/
|
||||
#
|
||||
# If you need help with the configuration or have any questions related to Spigot,
|
||||
# join us at the Discord or drop by our forums and leave a post.
|
||||
#
|
||||
# Discord: https://www.spigotmc.org/go/discord
|
||||
# Forums: http://www.spigotmc.org/
|
||||
|
||||
settings:
|
||||
debug: false
|
||||
bungeecord: false
|
||||
moved-too-quickly-multiplier: 10.0
|
||||
moved-wrongly-threshold: 0.0625
|
||||
timeout-time: 60
|
||||
restart-on-crash: true
|
||||
restart-script: ./start.sh
|
||||
save-user-cache-on-stop-only: false
|
||||
sample-count: 12
|
||||
player-shuffle: 0
|
||||
user-cache-size: 1000
|
||||
netty-threads: 4
|
||||
attribute:
|
||||
maxHealth:
|
||||
max: 2048.0
|
||||
movementSpeed:
|
||||
max: 2048.0
|
||||
attackDamage:
|
||||
max: 2048.0
|
||||
log-villager-deaths: true
|
||||
log-named-deaths: true
|
||||
messages:
|
||||
whitelist: You are not whitelisted on this server!
|
||||
unknown-command: Unknown command. Type "/help" for help.
|
||||
server-full: The server is full!
|
||||
outdated-client: Outdated client! Please use {0}
|
||||
outdated-server: Outdated server! I'm still on {0}
|
||||
restart: Server is restarting
|
||||
advancements:
|
||||
disable-saving: false
|
||||
disabled:
|
||||
- minecraft:story/disabled
|
||||
players:
|
||||
disable-saving: false
|
||||
commands:
|
||||
silent-commandblock-console: false
|
||||
tab-complete: 0
|
||||
send-namespaced: true
|
||||
spam-exclusions:
|
||||
- /skill
|
||||
log: true
|
||||
replace-commands:
|
||||
- setblock
|
||||
- summon
|
||||
- testforblock
|
||||
- tellraw
|
||||
world-settings:
|
||||
default:
|
||||
below-zero-generation-in-existing-chunks: true
|
||||
hanging-tick-frequency: 100
|
||||
zombie-aggressive-towards-villager: true
|
||||
enable-zombie-pigmen-portal-spawns: true
|
||||
wither-spawn-sound-radius: 0
|
||||
end-portal-sound-radius: 0
|
||||
dragon-death-sound-radius: 0
|
||||
merge-radius:
|
||||
item: 2.5
|
||||
exp: 3.0
|
||||
view-distance: default
|
||||
mob-spawn-range: 8
|
||||
item-despawn-rate: 6000
|
||||
simulation-distance: default
|
||||
arrow-despawn-rate: 1200
|
||||
trident-despawn-rate: 1200
|
||||
nerf-spawner-mobs: false
|
||||
growth:
|
||||
cactus-modifier: 100
|
||||
cane-modifier: 100
|
||||
melon-modifier: 100
|
||||
mushroom-modifier: 100
|
||||
pumpkin-modifier: 100
|
||||
sapling-modifier: 100
|
||||
beetroot-modifier: 100
|
||||
carrot-modifier: 100
|
||||
potato-modifier: 100
|
||||
torchflower-modifier: 100
|
||||
wheat-modifier: 100
|
||||
netherwart-modifier: 100
|
||||
vine-modifier: 100
|
||||
cocoa-modifier: 100
|
||||
bamboo-modifier: 100
|
||||
sweetberry-modifier: 100
|
||||
kelp-modifier: 100
|
||||
twistingvines-modifier: 100
|
||||
weepingvines-modifier: 100
|
||||
cavevines-modifier: 100
|
||||
glowberry-modifier: 100
|
||||
pitcherplant-modifier: 100
|
||||
thunder-chance: 100000
|
||||
entity-activation-range:
|
||||
animals: 32
|
||||
monsters: 32
|
||||
raiders: 48
|
||||
misc: 16
|
||||
water: 16
|
||||
villagers: 32
|
||||
flying-monsters: 32
|
||||
wake-up-inactive:
|
||||
animals-max-per-tick: 4
|
||||
animals-every: 1200
|
||||
animals-for: 100
|
||||
monsters-max-per-tick: 8
|
||||
monsters-every: 400
|
||||
monsters-for: 100
|
||||
villagers-max-per-tick: 4
|
||||
villagers-every: 600
|
||||
villagers-for: 100
|
||||
flying-monsters-max-per-tick: 8
|
||||
flying-monsters-every: 200
|
||||
flying-monsters-for: 100
|
||||
villagers-work-immunity-after: 100
|
||||
villagers-work-immunity-for: 20
|
||||
villagers-active-for-panic: true
|
||||
tick-inactive-villagers: true
|
||||
ignore-spectators: false
|
||||
seed-village: 10387312
|
||||
seed-desert: 14357617
|
||||
seed-igloo: 14357618
|
||||
seed-jungle: 14357619
|
||||
seed-swamp: 14357620
|
||||
seed-monument: 10387313
|
||||
seed-shipwreck: 165745295
|
||||
seed-ocean: 14357621
|
||||
seed-outpost: 165745296
|
||||
seed-endcity: 10387313
|
||||
seed-slime: 987234911
|
||||
seed-nether: 30084232
|
||||
seed-mansion: 10387319
|
||||
seed-fossil: 14357921
|
||||
seed-portal: 34222645
|
||||
seed-ancientcity: 20083232
|
||||
seed-trailruins: 83469867
|
||||
seed-trialchambers: 94251327
|
||||
seed-buriedtreasure: 10387320
|
||||
seed-mineshaft: default
|
||||
seed-stronghold: default
|
||||
entity-tracking-range:
|
||||
players: 48
|
||||
animals: 48
|
||||
monsters: 48
|
||||
misc: 32
|
||||
display: 128
|
||||
other: 64
|
||||
ticks-per:
|
||||
hopper-transfer: 8
|
||||
hopper-check: 1
|
||||
hopper-amount: 1
|
||||
hopper-can-load-chunks: false
|
||||
max-tnt-per-tick: 100
|
||||
hunger:
|
||||
jump-walk-exhaustion: 0.05
|
||||
jump-sprint-exhaustion: 0.2
|
||||
combat-exhaustion: 0.1
|
||||
regen-exhaustion: 6.0
|
||||
swim-multiplier: 0.01
|
||||
sprint-multiplier: 0.1
|
||||
other-multiplier: 0.0
|
||||
max-tick-time:
|
||||
tile: 50
|
||||
entity: 50
|
||||
verbose: false
|
||||
config-version: 12
|
||||
stats:
|
||||
disable-saving: false
|
||||
forced-stats: {}
|
47
src/bot.js
47
src/bot.js
@ -1,24 +1,43 @@
|
||||
// Copyright (c) 2024 Guilherme Werner
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import mineflayer from "mineflayer";
|
||||
import { mineflayer as mineflayerViewer } from "prismarine-viewer";
|
||||
import mineflayer from 'mineflayer';
|
||||
import { parentPort, workerData } from 'worker_threads';
|
||||
|
||||
const bot = mineflayer.createBot({
|
||||
const { startBotIndex, endBotIndex } = workerData;
|
||||
const movements = ['left', 'right'];
|
||||
|
||||
function getRandomMovement() {
|
||||
return movements[Math.floor(Math.random() * movements.length)];
|
||||
}
|
||||
|
||||
for (let i = startBotIndex; i < endBotIndex; i++) {
|
||||
const bot = mineflayer.createBot({
|
||||
host: 'localhost',
|
||||
port: 25565,
|
||||
username: 'Bot',
|
||||
username: `Bot${i}`,
|
||||
auth: 'offline'
|
||||
})
|
||||
});
|
||||
|
||||
bot.once('spawn', () => {
|
||||
mineflayerViewer(bot, { port: 3000, firstPerson: true })
|
||||
})
|
||||
bot.on('time2', () => {
|
||||
const movement = getRandomMovement();
|
||||
const action = Math.random() > 0.5;
|
||||
bot.setControlState(movement, action);
|
||||
bot.setControlState('forward', true);
|
||||
bot.setControlState('sprint', true);
|
||||
bot.setControlState('jump', true);
|
||||
});
|
||||
|
||||
bot.on('chat', (username, message) => {
|
||||
if (username === bot.username) return
|
||||
bot.chat(message)
|
||||
})
|
||||
bot.on('chat', (username, message) => {
|
||||
if (username === bot.username) return;
|
||||
bot.chat(message);
|
||||
});
|
||||
|
||||
bot.on('kicked', console.log)
|
||||
bot.on('error', console.log)
|
||||
bot.on('kicked', (reason, loggedIn) => {
|
||||
parentPort.postMessage(`Bot${i} foi expulso por: ${reason} | LoggedIn: ${loggedIn}`);
|
||||
});
|
||||
|
||||
bot.on('error', (err) => {
|
||||
parentPort.postMessage(`Bot${i} encontrou um erro: ${err}`);
|
||||
});
|
||||
}
|
||||
|
32
src/multi.js
Normal file
32
src/multi.js
Normal file
@ -0,0 +1,32 @@
|
||||
// Copyright (c) 2024 Guilherme Werner
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { Worker } from 'worker_threads';
|
||||
import path from 'path';
|
||||
|
||||
const numBots = 100;
|
||||
const botsPerThread = 10;
|
||||
const numThreads = Math.ceil(numBots / botsPerThread);
|
||||
|
||||
for (let i = 0; i < numThreads; i++) {
|
||||
const startBotIndex = i * botsPerThread;
|
||||
const endBotIndex = Math.min(startBotIndex + botsPerThread, numBots);
|
||||
|
||||
const worker = new Worker(path.resolve('src/bot.js'), {
|
||||
workerData: { startBotIndex, endBotIndex }
|
||||
});
|
||||
|
||||
worker.on('message', (message) => {
|
||||
console.log(`Worker message: ${message}`);
|
||||
});
|
||||
|
||||
worker.on('error', (error) => {
|
||||
console.error(`Worker error: ${error}`);
|
||||
});
|
||||
|
||||
worker.on('exit', (code) => {
|
||||
if (code !== 0) {
|
||||
console.error(`Worker stopped with exit code ${code}`);
|
||||
}
|
||||
});
|
||||
}
|
25
src/single.js
Normal file
25
src/single.js
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright (c) 2024 Guilherme Werner
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import mineflayer from "mineflayer";
|
||||
import { mineflayer as mineflayerViewer } from "prismarine-viewer";
|
||||
|
||||
const bot = mineflayer.createBot({
|
||||
host: 'localhost',
|
||||
port: 25565,
|
||||
username: 'Bot',
|
||||
auth: 'offline'
|
||||
})
|
||||
|
||||
bot.once('spawn', () => {
|
||||
bot.setControlState('forward', true)
|
||||
mineflayerViewer(bot, { port: 3000, firstPerson: true })
|
||||
})
|
||||
|
||||
bot.on('chat', (username, message) => {
|
||||
if (username === bot.username) return
|
||||
bot.chat(message)
|
||||
})
|
||||
|
||||
bot.on('kicked', console.log)
|
||||
bot.on('error', console.log)
|
Reference in New Issue
Block a user