KubeJS

KubeJS

69M Downloads

Powah integration

Sorinstratu opened this issue ยท 2 comments

commented

Describe the feature

<package dev.latvian.mods.kubejs.recipe.mod;

import com.google.gson.JsonArray;
import dev.latvian.mods.kubejs.recipe.RecipeJS;
import dev.latvian.mods.kubejs.util.ListJS;

public class PowahEnergizingRecipeJS extends RecipeJS {
@OverRide
public void create(ListJS args) {
outputItems.add(parseResultItem(args.get(0)));
inputItems.addAll(parseIngredientItemList(args.get(1)));
json.addProperty("energy", args.size() >= 3 ? (Number) args.get(2) : 10000);
}

@Override
public void deserialize() {
	outputItems.add(parseResultItem(json.get("result")));
	inputItems.addAll(parseIngredientItemList(json.get("ingredients")));
}

public PowahEnergizingRecipeJS energy(int t) {
	json.addProperty("energy", t);
	save();
	return this;
}

@Override
public void serialize() {
	if (serializeOutputs) {
		json.add("result", outputItems.get(0).toResultJson());
	}

	if (serializeInputs) {
		var a = new JsonArray();

		for (var in : inputItems) {
			a.add(in.toJson());
		}

		json.add("ingredients", a);
	}
}

}>

Additional info

I see no reason to create a separate mod for one recipe!

commented

It is preferred for integration to be in the mod itself (so powah) or a seperate addon mod, so that if it the format changes KubeJS is not immediately incompatible with the entire mod.

commented

***Example
event.recipes.powah.energizing(output,[inputs], energy amount)