Advertisement
YTMango

Full AE2 Recipe support

Jan 5th, 2024
858
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // required: ae2
  2.  
  3. /**
  4.  * @author chiefarug (Discord)
  5.  * @link https://discord.com/channels/303440391124942858/1186645078610034768
  6.  *
  7.  */
  8.  
  9. const $EntropyMode = Java.loadClass("appeng.recipes.entropy.EntropyMode");
  10. const $RecipeSchema = Java.loadClass("dev.latvian.mods.kubejs.recipe.schema.RecipeSchema");
  11. const $MapRecipeComponent = Java.loadClass("dev.latvian.mods.kubejs.recipe.component.MapRecipeComponent");
  12. const $RecipeComponentBuilderMap = Java.loadClass("dev.latvian.mods.kubejs.recipe.component.RecipeComponentBuilderMap");
  13.  
  14. StartupEvents.recipeSchemaRegistry((event) => {
  15.   const Component = event.components.get.bind(event.components);
  16.   const Builder = Component("bool")().builder;
  17.  
  18.   let fluidStateComponent = Builder(
  19.     Component("registryObject")({ registry: "fluid" }).key("id"),
  20.     new $MapRecipeComponent(
  21.       Component("nonBlankString")(),
  22.       Component("nonBlankString")(),
  23.       false
  24.     )
  25.       .key("properties")
  26.       .defaultOptional()
  27.   );
  28.  
  29.   event.register(
  30.     "ae2:entropy",
  31.     new $RecipeSchema(
  32.       Builder(
  33.         Component("outputBlockState")()
  34.           .simpleMap({ id: "Name", properties: "Properties" })
  35.           .key("block")
  36.           .defaultOptional(),
  37.         fluidStateComponent.key("fluid").defaultOptional(),
  38.         Component("outputItemArray")().key("drops").optional([])
  39.       )
  40.         .outputRole()
  41.         .key("output"),
  42.       Builder(
  43.         Component("inputBlockState")()
  44.           .simpleMap({ id: "Name", properties: "Properties" })
  45.           .key("block")
  46.           .defaultOptional(),
  47.         fluidStateComponent.key("fluid").defaultOptional()
  48.       )
  49.         .inputRole()
  50.         .key("input"),
  51.       Component("enum")({ class: $EntropyMode }).key("mode")
  52.     )
  53.   );
  54.  
  55.   event.register(
  56.     "ae2:charger",
  57.     new $RecipeSchema(
  58.       Component("outputItem")().key("result"),
  59.       Component("inputItem")().key("ingredient")
  60.     )
  61.   );
  62.  
  63.   let ic0, ic1, ic2, ic3, ic4, ic5;
  64.   event.register(
  65.     "ae2:inscriber",
  66.     new $RecipeSchema(
  67.       (ic0 = Component("outputItem")().key("result")),
  68.       (ic1 = Builder(
  69.         (ic2 = Component("inputItem")().key("top").optional("air")),
  70.         (ic3 = Component("inputItem")().key("middle")),
  71.         (ic4 = Component("inputItem")().key("bottom").optional("air"))
  72.       ).key("ingredients")),
  73.       (ic5 = Component("enum")({
  74.         class: "appeng.recipes.handlers.InscriberProcessType",
  75.       })
  76.         .key("mode")
  77.         .optional("inscriber"))
  78.     )
  79.       .addConstructor(
  80.         (recipe, _st, _k, source) => {
  81.           recipe.setValue(ic0, source.getValue(recipe, ic0));
  82.           recipe.setValue(ic1, new $RecipeComponentBuilderMap(ic1.component));
  83.           recipe.getValue(ic1).put(ic3, source.getValue(recipe, ic3));
  84.         },
  85.         ic0,
  86.         ic3
  87.       )
  88.       .addConstructor(
  89.         (recipe, _st, _k, source) => {
  90.           recipe.setValue(ic0, source.getValue(recipe, ic0));
  91.           recipe.setValue(ic1, new $RecipeComponentBuilderMap(ic1.component));
  92.           recipe.getValue(ic1).put(ic2, source.getValue(recipe, ic2));
  93.           recipe.getValue(ic1).put(ic3, source.getValue(recipe, ic3));
  94.         },
  95.         ic0,
  96.         ic2,
  97.         ic3
  98.       )
  99.       .addConstructor(
  100.         (recipe, _st, _k, source) => {
  101.           recipe.setValue(ic0, source.getValue(recipe, ic0));
  102.           recipe.setValue(ic1, new $RecipeComponentBuilderMap(ic1.component));
  103.           recipe.getValue(ic1).put(ic2, source.getValue(recipe, ic2));
  104.           recipe.getValue(ic1).put(ic3, source.getValue(recipe, ic3));
  105.           recipe.getValue(ic1).put(ic4, source.getValue(recipe, ic4));
  106.         },
  107.         ic0,
  108.         ic2,
  109.         ic3,
  110.         ic4
  111.       )
  112.   );
  113.  
  114.   event.register(
  115.     "ae2:matter_cannon",
  116.     new $RecipeSchema(
  117.       Component("inputItem")().key("ammo"),
  118.       Component("floatNumber")().key("weight")
  119.     )
  120.   );
  121.  
  122.   event.register(
  123.     "ae2:transform",
  124.     new $RecipeSchema(
  125.       Component("outputItem")().key("result"),
  126.       Component("inputItemArray")().key("ingredients"),
  127.       Builder(
  128.         Component("filteredString")({
  129.           error: "Transform type must be one of explosion or fluid!",
  130.           filter: (s) => s == "fluid",
  131.         }).key("type"),
  132.         Component("fluidTag")().key("tag")
  133.       )
  134.         .inputRole()
  135.         .or(
  136.           Builder(
  137.             Component("filteredString")({
  138.               error: "Transform type must be one of explosion or fluid!",
  139.               filter: (s) => s == "explosion",
  140.             }).key("type")
  141.           )
  142.         )
  143.         .key("circumstance")
  144.         .optional({ type: "fluid", tag: "water" })
  145.     )
  146.   );
  147. });
  148.  
Tags: kubejs
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement