From cc6fc66be289498b7ba525b049269a32bb5fbfd5 Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Tue, 15 Oct 2024 17:03:51 -0500 Subject: [PATCH] fixed a couple bugs --- src/agent/commands/index.js | 8 ++++---- src/utils/mcdata.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/agent/commands/index.js b/src/agent/commands/index.js index 1529dbe..cc2c847 100644 --- a/src/agent/commands/index.js +++ b/src/agent/commands/index.js @@ -2,7 +2,7 @@ import { getBlockId, getItemId } from "../../utils/mcdata.js"; import { actionsList } from './actions.js'; import { queryList } from './queries.js'; -const suppressNoDomainWarning = false; +let suppressNoDomainWarning = false; const commandList = queryList.concat(actionsList); const commandMap = {}; @@ -114,7 +114,7 @@ function parseCommandMessage(message) { case 'int': arg = Number.parseInt(arg); break; case 'float': - arg = Number.parseInt(arg); break; + arg = Number.parseFloat(arg); break; case 'boolean': arg = parseBoolean(arg); break; case 'BlockName': @@ -127,7 +127,7 @@ function parseCommandMessage(message) { throw new Error(`Command '${commandName}' parameter '${paramNames[i]}' has an unknown type: ${param.type}`); } if(arg === null || Number.isNaN(arg)) - return `${paramNames[i]} must be of type ${param.type}.` + return `Error: Param '${paramNames[i]}' must be of type ${param.type}.` if(typeof arg === 'number') { //Check the domain of numbers const domain = param.domain; @@ -139,7 +139,7 @@ function parseCommandMessage(message) { if (!domain[2]) domain[2] = '[)'; //By default, lower bound is included. Upper is not. if(!checkInInterval(arg, ...domain)) { - return `${paramNames[i]} must be an element of ${domain[2][0]}${domain[0]}, ${domain[1]}${domain[2][1]}.`; // search_range must be an element of [1,64]. + return `Error: Param '${paramNames[i]}' must be an element of ${domain[2][0]}${domain[0]}, ${domain[1]}${domain[2][1]}.`; //Alternatively arg could be set to the nearest value in the domain. } } else if (!suppressNoDomainWarning) { diff --git a/src/utils/mcdata.js b/src/utils/mcdata.js index 429719c..377b1c7 100644 --- a/src/utils/mcdata.js +++ b/src/utils/mcdata.js @@ -259,14 +259,14 @@ export function ingredientsFromPrismarineRecipe(recipe) { if (recipe.inShape) for (const ingredient of recipe.inShape.flat()) { if(ingredient.id<0) continue; //prismarine-recipe uses id -1 as an empty crafting slot - const ingredientName = mc.getItemName(ingredient.id); + const ingredientName = getItemName(ingredient.id); requiredIngedients[ingredientName] ??=0; requiredIngedients[ingredientName] += ingredient.count; } if (recipe.ingredients) for (const ingredient of recipe.ingredients) { if(ingredient.id<0) continue; - const ingredientName = mc.getItemName(ingredient.id); + const ingredientName = getItemName(ingredient.id); requiredIngedients[ingredientName] ??=0; requiredIngedients[ingredientName] -= ingredient.count; //Yes, the `-=` is intended.