Reciepies known

Created mandag 19 juni 2023

Make all recipies known

Here is a simple script runner mod to do this. I also removed all custom naming because I don't like that either. If you want to leave the naming remove the code between the two comments.



To use this:

  1. Copy the code in the white box inside the spoiler.
  2. Paste into a text editor program (notepad, wordpad, notepad++, ....).
  3. Save as a something with .js extension.
  4. Put that file in the appropriate folder: Wurm Unlimited Dedicated Server\mods\scriptrunner\scripts\ onServerStarted.




Hide contents


//****************************
var removePlayerNaming = true; // prevent recipes from being nameable. Apparently for default WU there aren't any nameable recipes.
var removeSpecialNaming = true; // foods named after the developers who worked on the food system and couple contest winner's names.
//****************************

var Recipes = Packages.com.wurmonline.server.items.Recipes;
var ReflectionUtil = Packages.org.gotti.wurmunlimited.modloader.ReflectionUtil;
var Class = Packages.java.lang.Class;
var Logger = Packages.java.util.logging.Logger;
var logger = Logger.getLogger("com.joedobo27.scriptRunnerMods.make-all-recipes-known");

function onServerStarted(){

recipes = Recipes.getAllRecipes();
var fieldKnown = ReflectionUtil.getField(Class.forName("com.wurmonline.server.items.Recipe"), "known");
var fieldName = ReflectionUtil.getField(Class.forName("com.wurmonline.server.items.Recipe"), "name");
var fieldNameable = ReflectionUtil.getField(Class.forName("com.wurmonline.server.items.Recipe"), "nameable");

for (i = 0; i < recipes.length; i++) {
ReflectionUtil.setPrivateField(recipes[i], fieldKnown, true);
ReflectionUtil.setPrivateField(recipes[i], fieldNameable, false);

if (removePlayerNaming){
var name = recipes[i].getRecipeName();
}
if (removeSpecialNaming){
if (name == "Belrindor's maple bacon pancakes"){
ReflectionUtil.setPrivateField(recipes[i], fieldName, "maple bacon pancakes");
}
if (name == "Budda's terrible pasta dish"){
ReflectionUtil.setPrivateField(recipes[i], fieldName, "terrible pasta dish");
}
if (name == "Cerber's triple hops"){
ReflectionUtil.setPrivateField(recipes[i], fieldName, "triple hops");
}
if (name == "Lisabet's corned beef and cabbage"){
ReflectionUtil.setPrivateField(recipes[i], fieldName, "corned beef and cabbage");
}
if (name == "marine's stew"){
ReflectionUtil.setPrivateField(recipes[i], fieldName, "fish and corn stew");
}
if (name == "Nicrolis' gingerbeer"){
ReflectionUtil.setPrivateField(recipes[i], fieldName, "gingerbeer");
}
if (name == "Pandalet's one true pizza"){
ReflectionUtil.setPrivateField(recipes[i], fieldName, "one true pizza");
}
if (name == "Retrograde pie"){
ReflectionUtil.setPrivateField(recipes[i], fieldName, "snake pie");
}
if (name == "Robbycrusoe's poutine"){
ReflectionUtil.setPrivateField(recipes[i], fieldName, "poutine");
}
if (name == "Rolf's favourite sandwich"){
ReflectionUtil.setPrivateField(recipes[i], fieldName, "cucumber and cheese sandwich");
}
if (name == "Thor's Austrian dream schnitzel"){
ReflectionUtil.setPrivateField(recipes[i], fieldName, "dream schnitzel");
}
if (name == "Tich's game jalfrezi"){
ReflectionUtil.setPrivateField(recipes[i], fieldName, "game jalfrezi");
}
}
}
if(removeSpecialNaming){
logger.info("All special named foods renamed.");
}
if(removePlayerNaming){
logger.info("Any nameable recipes are no longer nameable.");
}
logger.info("All recipes are now known.");
}

https://forum.wurmonline.com/index.php?/topic/152799-released-make-all-recipies-known/




Backlinks: WU General:Mods:General Server modding Info:2. Serverscripts