Skip to content

Commit

Permalink
VanillaRecipe v3
Browse files Browse the repository at this point in the history
  • Loading branch information
MineExplorer committed Oct 21, 2021
1 parent bdc1892 commit 0f5d575
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 30 deletions.
18 changes: 2 additions & 16 deletions library/VanillaRecipe.js
Expand Up @@ -113,29 +113,15 @@ var VanillaRecipe;
return 0;
}
VanillaRecipe.getNumericID = getNumericID;
var nativeConvertNameID = ModAPI.requireGlobal("requireMethodFromNativeAPI('api.NativeAPI', 'convertNameId')");
var __isValid__ = true;
function convertToVanillaID(stringID) {
var newID = "";
if (!getNumericID(stringID)) {
Logger.Log("ID " + stringID + " is invalid", "ERROR");
__isValid__ = false;
return null;
}
stringID = stringID.replace(":", "_");
var wasLowerCase = false;
for (var i = 0; i < stringID.length; i++) {
if (stringID[i] == stringID[i].toUpperCase()) {
if (wasLowerCase && stringID[i] != "_")
newID += "_";
newID += stringID[i].toLowerCase();
wasLowerCase = false;
}
else {
newID += stringID[i];
wasLowerCase = true;
}
}
return "minecraft:" + newID;
return "minecraft:" + nativeConvertNameID(stringID.replace(":", "_"));
}
VanillaRecipe.convertToVanillaID = convertToVanillaID;
function generateBlankFile(recipeName) {
Expand Down
17 changes: 3 additions & 14 deletions source/VanillaRecipe/VanillaRecipe.ts
Expand Up @@ -119,27 +119,16 @@ namespace VanillaRecipe {
return 0;
}

const nativeConvertNameID = ModAPI.requireGlobal("requireMethodFromNativeAPI('api.NativeAPI', 'convertNameId')");

let __isValid__ = true;
export function convertToVanillaID(stringID: string): string {
let newID = "";
if (!getNumericID(stringID)) {
Logger.Log("ID " + stringID + " is invalid", "ERROR");
__isValid__ = false;
return null;
}
stringID = stringID.replace(":", "_");
let wasLowerCase = false;
for (let i = 0; i < stringID.length; i++) {
if (stringID[i] == stringID[i].toUpperCase()) {
if (wasLowerCase && stringID[i] != "_") newID += "_";
newID += stringID[i].toLowerCase();
wasLowerCase = false;
} else {
newID += stringID[i];
wasLowerCase = true;
}
}
return "minecraft:" + newID;
return "minecraft:" + nativeConvertNameID(stringID.replace(":", "_"));
}

function generateBlankFile(recipeName: string): void {
Expand Down

0 comments on commit 0f5d575

Please sign in to comment.