Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bot.digTime does not take into account the enchantment on the item [1.20.5+] #3589

Open
1 task done
IKorzI opened this issue Feb 19, 2025 · 3 comments
Open
1 task done
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f

Comments

@IKorzI
Copy link

IKorzI commented Feb 19, 2025

  • The FAQ doesn't contain a resolution to my issue

Versions

  • mineflayer: 4.26.0
  • server: vanilla 1.20.5+
  • node: 22.11.0

Detailed description of a problem

bot.digTime returns the time it takes to break a block. The time calculation must take into account the active item, effects, enchantments, and the block to break.
In Minecraft 1.20.4 and below, everything is taken into account.
In Minecraft 1.20.5 and above, the "Efficiency" enchantment does not affect this indicator. As a result, the bot.dig function digs the block longer than necessary.

For example:

  1. A diamond pickaxe without enchantments digs a cobblestone block in 400 milliseconds. bot.digTime returns 400 milliseconds and bot.dig digs the block in 400 milliseconds.
  2. A diamond pickaxe with the "Efficiency 5" enchantment digs a cobblestone block in 100 milliseconds. bot.digTime still returns 400 milliseconds and bot.dig digs a block of 400 milliseconds instead of the required 100 milliseconds.

What did you try yet?

I used bot.dig, bot.digTime.

Your current code

const block = bot.blockAtCursor(5)
console.log(bot.digTime = ${bot.digTime(block)} ms)
...
const block = bot.blockAtCursor(5)
bot.dig(block, 'ignore', 'raycast')

Expected behavior

bot.digTime will take into account the enchantment on the item and as a result bot.dig will start working normally

@IKorzI IKorzI added possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f labels Feb 19, 2025
@IKorzI
Copy link
Author

IKorzI commented Feb 20, 2025

In Minecraft version 1.20.4 and below, the data for a diamond pickaxe with the "Efficiency 5" enchantment looks like this:

{
	"type": 836,
	"count": 1,
	"metadata": 0,
	"nbt": {
		"type": "compound",
		"value": {
			"RepairCost": {
				"type": "int",
				"value": 1
			},
			"Damage": {
				"type": "int",
				"value": 2
			},
			"Enchantments": {
				"type": "list",
				"value": {
					"type": "compound",
					"value": [
						{
							"lvl": {
								"type": "short",
								"value": 5
							},
							"id": {
								"type": "string",
								"value": "minecraft:efficiency"
							}
						}
					]
				}
			}
		}
	},
	"stackId": null,
	"name": "diamond_pickaxe",
	"displayName": "Diamond Pickaxe",
	"stackSize": 1,
	"maxDurability": 1561,
	"slot": 36
}

In Minecraft version 1.20.5 and above, the data for a diamond pickaxe with the "Efficiency 5" enchantment looks like this:

{
	"type": 839,
	"count": 1,
	"metadata": 0,
	"nbt": {
		"type": "compound",
		"name": "",
		"value": {
			"Damage": {
				"type": "int",
				"value": 0
			}
		}
	},
	"components": [
		{
			"type": "enchantments",
			"data": {
				"enchantments": [
					{
						"id": 20,
						"level": 5
					}
				],
				"showTooltip": true
			}
		},
		{
			"type": "damage",
			"data": 1
		},
		{
			"type": "repair_cost",
			"data": 1
		}
	],
	"removedComponents": [],
	"componentMap": {},
	"stackId": null,
	"name": "diamond_pickaxe",
	"displayName": "Diamond Pickaxe",
	"stackSize": 1,
	"maxDurability": 1,
	"slot": 36
},

@IKorzI
Copy link
Author

IKorzI commented Feb 25, 2025

@IKorzI
Copy link
Author

IKorzI commented Feb 25, 2025

Now the problem is this: PrismarineJS/minecraft-data#987

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f
Projects
None yet
Development

No branches or pull requests

1 participant