Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to make custom recipe categories to KubeJS #2347

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.gregtechceu.gtceu.api.recipe.condition.RecipeConditionType;
import com.gregtechceu.gtceu.api.recipe.content.Content;
import com.gregtechceu.gtceu.api.recipe.content.ContentModifier;
import com.gregtechceu.gtceu.common.data.GTRecipeTypes;
import com.gregtechceu.gtceu.data.recipe.builder.GTRecipeBuilder;

import net.minecraft.MethodsReturnNonnullByDefault;
Expand Down Expand Up @@ -121,7 +122,11 @@ public GTRecipe(GTRecipeType recipeType,
this.data = data;
this.duration = duration;
this.isFuel = isFuel;
this.recipeCategory = recipeCategory;
this.recipeCategory = (recipeCategory == GTRecipeCategory.EMPTY) ? GTRecipeCategory.of(recipeType) :
recipeCategory;
if(this.recipeCategory.getRecipeType() == GTRecipeTypes.CENTRIFUGE_RECIPES) {
System.out.println("hi");
}
}

public Map<RecipeCapability<?>, List<Content>> copyContents(Map<RecipeCapability<?>, List<Content>> contents,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ private static Codec<GTRecipe> makeCodec(boolean isKubeLoaded) {
CompoundTag.CODEC.optionalFieldOf("data", new CompoundTag()).forGetter(val -> val.data),
ExtraCodecs.NON_NEGATIVE_INT.fieldOf("duration").forGetter(val -> val.duration),
Codec.BOOL.optionalFieldOf("isFuel", false).forGetter(val -> val.isFuel),
GTRegistries.RECIPE_CATEGORIES.codec().fieldOf("category").forGetter(val -> val.recipeCategory))
GTRegistries.RECIPE_CATEGORIES.codec().optionalFieldOf("category", GTRecipeCategory.EMPTY).forGetter(val -> val.recipeCategory))
.apply(instance, (type,
inputs, outputs, tickInputs, tickOutputs,
inputChanceLogics, outputChanceLogics, tickInputChanceLogics, tickOutputChanceLogics,
Expand Down Expand Up @@ -241,7 +241,7 @@ private static Codec<GTRecipe> makeCodec(boolean isKubeLoaded) {
CompoundTag.CODEC.optionalFieldOf("data", new CompoundTag()).forGetter(val -> val.data),
ExtraCodecs.NON_NEGATIVE_INT.fieldOf("duration").forGetter(val -> val.duration),
Codec.BOOL.optionalFieldOf("isFuel", false).forGetter(val -> val.isFuel),
GTRegistries.RECIPE_CATEGORIES.codec().fieldOf("category").forGetter(val -> val.recipeCategory))
GTRegistries.RECIPE_CATEGORIES.codec().optionalFieldOf("category", GTRecipeCategory.EMPTY).forGetter(val -> val.recipeCategory))
.apply(instance, GTRecipe::new));
}
// @formatter:on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.gregtechceu.gtceu.GTCEu;
import com.gregtechceu.gtceu.api.recipe.GTRecipeType;
import com.gregtechceu.gtceu.api.registry.GTRegistries;
import com.gregtechceu.gtceu.common.data.GTRecipeTypes;

import net.minecraft.resources.ResourceLocation;

Expand All @@ -17,6 +18,8 @@
public class GTRecipeCategory {

private static final Map<String, GTRecipeCategory> categories = new Object2ObjectOpenHashMap<>();
public static final GTRecipeCategory EMPTY = GTRecipeCategory
.of(GTCEu.MOD_ID, "empty_category", "", GTRecipeTypes.DUMMY_RECIPES);

@Getter
private final String modid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ public void registerBindings(BindingsEvent event) {
event.add("GCYMMachines", GCYMMachines.class);
event.add("GTItems", GTItems.class);
event.add("GTRecipeTypes", GTRecipeTypes.class);
event.add("GTRecipeCategories", GTRecipeCategories.class);
event.add("GTMedicalConditions", GTMedicalConditions.class);
event.add("TagPrefix", TagPrefix.class);
event.add("ItemGenerationCondition", TagPrefix.Conditions.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.gregtechceu.gtceu.api.recipe.RecipeCondition;
import com.gregtechceu.gtceu.api.recipe.ResearchData;
import com.gregtechceu.gtceu.api.recipe.ResearchRecipeBuilder;
import com.gregtechceu.gtceu.api.recipe.category.GTRecipeCategory;
import com.gregtechceu.gtceu.api.recipe.chance.logic.ChanceLogic;
import com.gregtechceu.gtceu.api.recipe.content.Content;
import com.gregtechceu.gtceu.api.recipe.ingredient.*;
Expand Down Expand Up @@ -135,6 +136,12 @@ public GTRecipeJS addCondition(RecipeCondition condition) {
return this;
}

public GTRecipeJS recipeCategory(GTRecipeCategory category) {
setValue(CATEGORY, category.getResourceLocation());
save();
return this;
}

public GTRecipeJS inputEU(long eu) {
return input(EURecipeCapability.CAP, eu);
}
Expand Down Expand Up @@ -946,6 +953,7 @@ public InputFluid readInputFluid(Object from) {
RecipeKey<RecipeCondition[]> CONDITIONS = GTRecipeComponents.RECIPE_CONDITION.asArray().key("recipeConditions")
.defaultOptional();
RecipeKey<Boolean> IS_FUEL = BooleanComponent.BOOLEAN.key("isFuel").optional(false);
RecipeKey<ResourceLocation> CATEGORY = GTRecipeComponents.RESOURCE_LOCATION.key("category").defaultOptional();

RecipeKey<CapabilityMap> ALL_INPUTS = GTRecipeComponents.IN.key("inputs").defaultOptional();
RecipeKey<CapabilityMap> ALL_TICK_INPUTS = GTRecipeComponents.TICK_IN.key("tickInputs").defaultOptional();
Expand All @@ -965,7 +973,7 @@ public InputFluid readInputFluid(Object from) {
RecipeSchema SCHEMA = new RecipeSchema(GTRecipeJS.class, GTRecipeJS::new, DURATION, DATA, CONDITIONS,
ALL_INPUTS, ALL_TICK_INPUTS, ALL_OUTPUTS, ALL_TICK_OUTPUTS,
INPUT_CHANCE_LOGICS, OUTPUT_CHANCE_LOGICS, TICK_INPUT_CHANCE_LOGICS, TICK_OUTPUT_CHANCE_LOGICS,
IS_FUEL)
IS_FUEL, CATEGORY)
.constructor((recipe, schemaType, keys, from) -> recipe.id(from.getValue(recipe, ID)), ID)
.constructor(DURATION, CONDITIONS, ALL_INPUTS, ALL_OUTPUTS, ALL_TICK_INPUTS, ALL_TICK_OUTPUTS);
}
Loading