Skip to content

Commit

Permalink
0.5.1, add drop, dropAll, fix crash on command block notice
Browse files Browse the repository at this point in the history
  • Loading branch information
qsef1256 committed Oct 24, 2024
1 parent d2dd4dd commit 49e9bc4
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.ko-KR.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ Node.js를 깐 후 cmd.exe에서 각각 패키지마다 `npm install (package)`
| close | close | 봇의 인벤토리를 닫습니다. <br />(GUI인 경우 브라우저에 반영되지 않을 수 있습니다. 새로고침 하세요.) | - |
| click | click [slot] | 인벤토리 슬롯을 클릭합니다. | - |
| inv | inv [slot1] [slot2] | 봇의 인벤토리에 있는 두 슬롯의 아이템을 바꿉니다. | swap |
| drop | drop | 봇이 들고 있는 아이템을 버립니다. | - |
| dropAll | dropAll | 봇이 가지고 있는 아이템을 모두 버립니다. | - |
| webinv | webinv | 크롬으로 인벤토리 뷰를 엽니다. | showinv |
| hand | hand [slot] | 봇의 퀵바(현재 들고 있는 아이템)를 변경합니다. | hotbar |
| unequip | unequip | 모든 갑옷과 장비를 해제합니다. | - |
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ Type without / in a whisper or console.
| close | close | Close the bot's inventory. <br />(It is not automatically updated on the web) | - |
| click | click [slot] | The bot clicks on the bot's inventory. | - |
| inv | inv [slot1] [slot2] | The bot exchanges items between the two slots. | swap |
| drop | drop | Drop item on bot's quick slot. | - |
| dropAll | dropAll | Drop all inventory items of bot. | - |
| webinv | webinv | Open web inventory as Chrome. | showinv |
| hand | hand [slot] | The bot switches the quickbar. | hotbar |
| unequip | unequip | The bot will unequip all equipment. | - |
Expand Down
28 changes: 26 additions & 2 deletions diabot.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const options = {

const bot = mineflayer.createBot(options)
const owner = 'qsef1256'
const version = '0.5.0'
const version = '0.5.1'

const inventoryViewer = require('mineflayer-web-inventory')
const { pathfinder, Movements } = require('mineflayer-pathfinder')
Expand Down Expand Up @@ -149,6 +149,18 @@ function botCommand(username, message) {
return
}

if (cmd == 'drop') {
botDrop()

return
}

if (cmd == 'dropAll') {
botDropAll()

return
}

if (cmd == 'webinv' || cmd == 'showinv') {
botOutput(username, "Open web inventory")
openWeb('http://localhost:' + bot.webInventory.options.port)
Expand Down Expand Up @@ -313,6 +325,18 @@ async function botUnequip() {
await bot.unequip("off-hand")
}

// 템 버리기
async function botDrop() {
bot.tossStack(bot.inventory.slots[bot.QUICK_BAR_START + bot.quickBarSlot]);
}

async function botDropAll() {
const items = bot.inventory.items()
for (let i = 0; i < items.length; i++) {
await bot.tossStack(items[i])
}
}

function schedule(task, targetDate) {
const now = new Date();
const delay = targetDate - now;
Expand Down Expand Up @@ -358,7 +382,7 @@ bot.on('message', (message, position) => {
if (position == 'gameinfo') return

let result = ''
let playerName = message.extra?.[0].json[''] // idk but player name from message is corrupted
let playerName = message.extra?.[0]?.json?.[''] // idk but player name from message is corrupted

if (playerName) result += playerName
result += message.toAnsi()
Expand Down
2 changes: 1 addition & 1 deletion install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ node -v 2> Nul
if not "%ERRORLEVEL%" == "0" goto errNode

cd %~dp0
set ver=0.5.0
set ver=0.5.1
set link=https://github.com/qsef1256/DiaBot/
title Diabot Installer %ver%
echo.
Expand Down
6 changes: 3 additions & 3 deletions start.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
rem Diabot Starter by qsef1256

@setlocal
title Diabot 0.5.0
title Diabot 0.5.1
set /p user="Enter username : "
set /p online="Online Mode [y/n] : "
set /p fast="Do you want start bot with fast start mode? [y/n] : "
Expand All @@ -13,10 +13,10 @@ if /i "%fast%"=="n" (
)

if "%online%"=="y" (
echo start Diabot 0.5.0 with Online mode
echo start Diabot 0.5.1 with Online mode
set auth="microsoft"
) else (
echo start Diabot 0.5.0 with Offline mode
echo start Diabot 0.5.1 with Offline mode
set auth="offline"
)

Expand Down

0 comments on commit 49e9bc4

Please sign in to comment.