Skip to content

Commit

Permalink
[1.20.1] Added the rest of JEI compat (#2)
Browse files Browse the repository at this point in the history
* started work on jei compat

* added clickable area for producers (dna wip)

* finished producers

* fixed recipe path typo

* finished dna labware display, moving to processing machines

* added recipe catalysts

* forgot to run data generators

* cleaned up some code, made it less congested

* moved producers code under same path
  • Loading branch information
CrossVas authored Jan 21, 2025
1 parent 32b4b7d commit 4199621
Show file tree
Hide file tree
Showing 22 changed files with 269 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.20.1 2025-01-14T18:00:20.7166039 ModKit Language: en_us for mod 'gendustry'
a67e95b70c92f62f4d94c6831fced1974ff2d8ae assets/gendustry/lang/en_us.json
// 1.20.1 2025-01-20T18:49:21.4418297 ModKit Language: en_us for mod 'gendustry'
dc3ec84cadb2f83e7e36bcc5e6e5d5be1c1ef5cb assets/gendustry/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20.1 2025-01-14T23:05:00.7044002 Recipes
// 1.20.1 2025-01-20T19:27:35.7743009 Recipes
f6e776b964531a01c7ba87ab89c7705969105cc3 data/gendustry/advancements/recipes/misc/activity_simulator_elite_upgrade.json
d10b8cb8f7e9927b0057ca12bb22cf6c25abfefa data/gendustry/advancements/recipes/misc/advanced_mutatron.json
611d8e0b68aa9b0a58559a0dfb5ceb13fd9298eb data/gendustry/advancements/recipes/misc/automation_upgrade.json
Expand Down Expand Up @@ -52,6 +52,16 @@ d6ea5ac2ddf764d1b7218e1fc11da0ead2b274aa data/gendustry/recipes/blank_gene_sampl
a4d95241e639906aab9c5c737863560401480a0b data/gendustry/recipes/climate_control_module.json
f687cc074d768e789b2d43e62fc906be97c58347 data/gendustry/recipes/combine_genetic_template.json
45a06cae1f7bab07a93086cc00a694a17a00d880 data/gendustry/recipes/cooler_upgrade.json
229f6a1cd1e8c23694c5108459f5de194efd5906 data/gendustry/recipes/dna/butterfly.json
4292d9a2976565315a4255be1f660435fa449d5a data/gendustry/recipes/dna/caterpillar.json
59c53139f3f24805e5001dd08925e8b6ecb02e27 data/gendustry/recipes/dna/cocoon.json
2c76f025619f28d4158560435440eed4e2097512 data/gendustry/recipes/dna/drone.json
222536094cf0c80e647641c30315ad6dff23749a data/gendustry/recipes/dna/larvae.json
4bc638cda6099f6b9e4ce46b024e4485f3e921bf data/gendustry/recipes/dna/pollen.json
01228d2c8433f025a6e867f67aebce5e49294af7 data/gendustry/recipes/dna/princess.json
054f9162f068c570e76337f041013d8ba9e4b4b1 data/gendustry/recipes/dna/queen.json
aeeea2c652f238e7603f6d5c6fe094ba17569d0b data/gendustry/recipes/dna/sapling.json
660c786e588fe8c87c21bdd2e1394fbea83a3559 data/gendustry/recipes/dna/serum.json
5c12ca057c9bd513560789eb97bda2bf29ab49c9 data/gendustry/recipes/dna_extractor.json
67d8b0786245d71d7b72a3cd71b55e5a07d44966 data/gendustry/recipes/dryer_upgrade.json
297c2d8e805ec336444ebd9ec5c419f19eaf4f50 data/gendustry/recipes/elite_upgrade_frame.json
Expand Down Expand Up @@ -80,21 +90,11 @@ fe09292eda4663ede6a06a734a3058c72bc5a2d9 data/gendustry/recipes/mutatron.json
f92c2071f551fb9b13c087a77707c01cc5025fad data/gendustry/recipes/productivity_elite_upgrade.json
637315de889058b0d5fa24c9813ca63053f6cf6a data/gendustry/recipes/productivity_upgrade.json
d085832ee27decbc77ba94611341566f7b9193c0 data/gendustry/recipes/protein/beef.json
229f6a1cd1e8c23694c5108459f5de194efd5906 data/gendustry/recipes/protein/butterfly.json
4292d9a2976565315a4255be1f660435fa449d5a data/gendustry/recipes/protein/caterpillar.json
59c53139f3f24805e5001dd08925e8b6ecb02e27 data/gendustry/recipes/protein/cocoon.json
252530d1cf7f4567122c422fa1b8f918db6cb0ec data/gendustry/recipes/protein/cod.json
2c76f025619f28d4158560435440eed4e2097512 data/gendustry/recipes/protein/drone.json
222536094cf0c80e647641c30315ad6dff23749a data/gendustry/recipes/protein/larvae.json
4bc638cda6099f6b9e4ce46b024e4485f3e921bf data/gendustry/recipes/protein/pollen.json
3252b0df877b4e0883ba4397aaaf5fb89fcb7fad data/gendustry/recipes/protein/porkchop.json
01228d2c8433f025a6e867f67aebce5e49294af7 data/gendustry/recipes/protein/princess.json
ca53c63c78b08871076323f9a0c7ff420bec8990 data/gendustry/recipes/protein/pufferfish.json
054f9162f068c570e76337f041013d8ba9e4b4b1 data/gendustry/recipes/protein/queen.json
553091dd7e400e6a1e40e6fa23aca2442041c2a0 data/gendustry/recipes/protein/rabbit.json
e623827b959a2409af87b8c921f6de8cd73b1d9e data/gendustry/recipes/protein/salmon.json
aeeea2c652f238e7603f6d5c6fe094ba17569d0b data/gendustry/recipes/protein/sapling.json
660c786e588fe8c87c21bdd2e1394fbea83a3559 data/gendustry/recipes/protein/serum.json
63000ab315360768fe18aa0a2bbd204cf7c81877 data/gendustry/recipes/protein/tropical_fish.json
a2c7e6c66243a7287b9aa16e01b1802314f8ec80 data/gendustry/recipes/protein_liquefier.json
82f1540f27dcebb8b282a0c78865a9414e276f78 data/gendustry/recipes/receptacle.json
Expand Down
1 change: 1 addition & 0 deletions src/generated/resources/assets/gendustry/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"for.hints.sample_usage.tag": "What are samples for?",
"for.hints.transposer_usage.desc": "The Genetic Transposer creates copies of Gene Samples and Genetic Templates.",
"for.hints.transposer_usage.tag": "How to use the Genetic Transposer?",
"gen.for.chance": "%s%% chance to be consumed!",
"item.gendustry.activity_simulator_elite_upgrade": "Activity Simulator Elite Upgrade",
"item.gendustry.activity_simulator_elite_upgrade.tooltip": "A combination of the Sky, Weatherproof, and Lighting upgrades.",
"item.gendustry.automation_upgrade": "Automation Upgrade",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
package thedarkcolour.gendustry.compat.jei;

import forestry.core.ClientsideCode;
import forestry.core.utils.RecipeUtils;
import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.registration.*;
import net.minecraft.resources.ResourceLocation;

import mezz.jei.api.IModPlugin;
import mezz.jei.api.JeiPlugin;
import mezz.jei.api.recipe.RecipeType;
import mezz.jei.api.registration.IGuiHandlerRegistration;
import mezz.jei.api.registration.ISubtypeRegistration;
import net.minecraft.world.item.crafting.RecipeManager;
import thedarkcolour.gendustry.Gendustry;
import thedarkcolour.gendustry.GendustryModule;
import thedarkcolour.gendustry.client.screen.MutatronScreen;
import thedarkcolour.gendustry.client.screen.*;
import thedarkcolour.gendustry.compat.jei.producers.DNAExtractorRecipeCategory;
import thedarkcolour.gendustry.compat.jei.producers.MutagenRecipeCategory;
import thedarkcolour.gendustry.compat.jei.producers.ProducerGuiContainerHandler;
import thedarkcolour.gendustry.compat.jei.producers.ProteinProducerRecipeCategory;
import thedarkcolour.gendustry.registry.GItems;
import thedarkcolour.gendustry.registry.GRecipeTypes;

@JeiPlugin
public class GendustryJeiPlugin implements IModPlugin {
Expand All @@ -26,6 +33,29 @@ public void registerItemSubtypes(ISubtypeRegistration registration) {
registration.registerSubtypeInterpreter(GItems.GENE_SAMPLE.item(), new GeneSampleInterpreter());
}

@Override
public void registerCategories(IRecipeCategoryRegistration registration) {
IGuiHelper guiHelper = registration.getJeiHelpers().getGuiHelper();
registration.addRecipeCategories(new MutagenRecipeCategory(guiHelper));
registration.addRecipeCategories(new ProteinProducerRecipeCategory(guiHelper));
registration.addRecipeCategories(new DNAExtractorRecipeCategory(guiHelper));
}

@Override
public void registerRecipeCatalysts(IRecipeCatalystRegistration registration) {
registration.addRecipeCatalyst(MutagenRecipeCategory.ICON_STACK, GendustryRecipeType.MUTAGEN_PRODUCER);
registration.addRecipeCatalyst(DNAExtractorRecipeCategory.ICON_STACK, GendustryRecipeType.DNA_EXTRACTOR);
registration.addRecipeCatalyst(ProteinProducerRecipeCategory.ICON_STACK, GendustryRecipeType.PROTEIN_LIQUEFIER);
}

@Override
public void registerRecipes(IRecipeRegistration registration) {
RecipeManager manager = ClientsideCode.getRecipeManager();
registration.addRecipes(GendustryRecipeType.MUTAGEN_PRODUCER, RecipeUtils.getRecipes(manager, GRecipeTypes.MUTAGEN).toList());
registration.addRecipes(GendustryRecipeType.PROTEIN_LIQUEFIER, RecipeUtils.getRecipes(manager, GRecipeTypes.PROTEIN).toList());
registration.addRecipes(GendustryRecipeType.DNA_EXTRACTOR, RecipeUtils.getRecipes(manager, GRecipeTypes.DNA).toList());
}

@Override
public void registerGuiHandlers(IGuiHandlerRegistration registration) {
// todo replace with MutationRecipe.class when Forestry makes it public
Expand All @@ -34,5 +64,6 @@ public void registerGuiHandlers(IGuiHandlerRegistration registration) {
.toArray(RecipeType[]::new);

registration.addRecipeClickArea(MutatronScreen.class, 68, 38, 55, 18, mutationTypes);
registration.addGuiContainerHandler(ProducerScreen.class, new ProducerGuiContainerHandler());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package thedarkcolour.gendustry.compat.jei;

import mezz.jei.api.recipe.RecipeType;
import thedarkcolour.gendustry.Gendustry;
import thedarkcolour.gendustry.recipe.DnaRecipe;
import thedarkcolour.gendustry.recipe.MutagenRecipe;
import thedarkcolour.gendustry.recipe.ProteinRecipe;

public class GendustryRecipeType {

public static final RecipeType<MutagenRecipe> MUTAGEN_PRODUCER = create("mutagen_producer", MutagenRecipe.class);
public static final RecipeType<DnaRecipe> DNA_EXTRACTOR = create("dna_extractor", DnaRecipe.class);
public static final RecipeType<ProteinRecipe> PROTEIN_LIQUEFIER = create("protein_liquefier", ProteinRecipe.class);

private static <T> RecipeType<T> create(String uid, Class<? extends T> recipeClass) {
return RecipeType.create(Gendustry.ID, uid, recipeClass);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package thedarkcolour.gendustry.compat.jei.producers;

import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.gui.ingredient.IRecipeSlotsView;
import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.recipe.IFocusGroup;
import mezz.jei.api.recipe.RecipeIngredientRole;
import mezz.jei.api.recipe.RecipeType;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import thedarkcolour.gendustry.block.GendustryMachineType;
import thedarkcolour.gendustry.compat.jei.GendustryRecipeType;
import thedarkcolour.gendustry.item.GendustryResourceType;
import thedarkcolour.gendustry.recipe.DnaRecipe;
import thedarkcolour.gendustry.registry.GBlocks;
import thedarkcolour.gendustry.registry.GFluids;
import thedarkcolour.gendustry.registry.GItems;

public class DNAExtractorRecipeCategory extends ProducerRecipeCategory<DnaRecipe> {

public static final ItemStack ICON_STACK = new ItemStack(GBlocks.MACHINE.get(GendustryMachineType.DNA_EXTRACTOR).block());
private final IDrawable labwareSlot;

public DNAExtractorRecipeCategory(IGuiHelper helper) {
super(helper, "block.gendustry.dna_extractor", ICON_STACK);
this.labwareSlot = helper.createDrawable(GUI, 176, 78, 18, 18);
}

@Override
public RecipeType<DnaRecipe> getRecipeType() {
return GendustryRecipeType.DNA_EXTRACTOR;
}

@Override
public void setRecipe(IRecipeLayoutBuilder builder, DnaRecipe recipe, IFocusGroup iFocusGroup) {
builder.addSlot(RecipeIngredientRole.INPUT, 1, 23).addItemStack(recipe.getSpeciesType().getDefaultSpecies().createStack(recipe.getStage()));
addFluidTank(builder, GFluids.LIQUID_DNA.fluid(), recipe.getAmount());
builder.addSlot(RecipeIngredientRole.INPUT, 51, 1).addItemStack(GItems.RESOURCE.item(GendustryResourceType.LABWARE).getDefaultInstance()).addRichTooltipCallback((recipeSlotView, tooltip) -> {
tooltip.add(Component.translatable("gen.for.chance", 10).withStyle(ChatFormatting.AQUA));
});
}

@Override
public void draw(DnaRecipe recipe, IRecipeSlotsView recipeSlotsView, GuiGraphics graphics, double mouseX, double mouseY) {
super.draw(recipe, recipeSlotsView, graphics, mouseX, mouseY);
this.labwareSlot.draw(graphics, 50, 0);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package thedarkcolour.gendustry.compat.jei.producers;

import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.recipe.IFocusGroup;
import mezz.jei.api.recipe.RecipeIngredientRole;
import mezz.jei.api.recipe.RecipeType;
import net.minecraft.world.item.ItemStack;
import thedarkcolour.gendustry.block.GendustryMachineType;
import thedarkcolour.gendustry.compat.jei.GendustryRecipeType;
import thedarkcolour.gendustry.recipe.MutagenRecipe;
import thedarkcolour.gendustry.registry.GBlocks;
import thedarkcolour.gendustry.registry.GFluids;

public class MutagenRecipeCategory extends ProducerRecipeCategory<MutagenRecipe> {

public static final ItemStack ICON_STACK = new ItemStack(GBlocks.MACHINE.get(GendustryMachineType.MUTAGEN_PRODUCER).block());

public MutagenRecipeCategory(IGuiHelper helper) {
super(helper, "block.gendustry.mutagen_producer", ICON_STACK);
}

@Override
public RecipeType<MutagenRecipe> getRecipeType() {
return GendustryRecipeType.MUTAGEN_PRODUCER;
}

@Override
public void setRecipe(IRecipeLayoutBuilder builder, MutagenRecipe recipe, IFocusGroup focuses) {
builder.addSlot(RecipeIngredientRole.INPUT, 1, 23).addIngredients(recipe.getIngredient());
addFluidTank(builder, GFluids.MUTAGEN.fluid(), recipe.getAmount());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package thedarkcolour.gendustry.compat.jei.producers;

import mezz.jei.api.gui.handlers.IGuiClickableArea;
import mezz.jei.api.gui.handlers.IGuiContainerHandler;
import net.minecraft.world.level.block.entity.BlockEntity;
import thedarkcolour.gendustry.blockentity.DnaExtractorBlockEntity;
import thedarkcolour.gendustry.blockentity.MutagenProducerBlockEntity;
import thedarkcolour.gendustry.blockentity.ProteinLiquefierBlockEntity;
import thedarkcolour.gendustry.client.screen.ProducerScreen;
import thedarkcolour.gendustry.compat.jei.GendustryRecipeType;

import java.util.Collection;
import java.util.Collections;

public class ProducerGuiContainerHandler implements IGuiContainerHandler<ProducerScreen> {

@Override
public Collection<IGuiClickableArea> getGuiClickableAreas(ProducerScreen containerScreen, double guiMouseX, double guiMouseY) {
BlockEntity blockEntity = containerScreen.getMenu().getTile();
if (blockEntity instanceof MutagenProducerBlockEntity) {
return Collections.singleton(IGuiClickableArea.createBasic(48, 40, 55, 18, GendustryRecipeType.MUTAGEN_PRODUCER));
} else if (blockEntity instanceof DnaExtractorBlockEntity) {
return Collections.singleton(IGuiClickableArea.createBasic(48, 40, 55, 18, GendustryRecipeType.DNA_EXTRACTOR));
} else if (blockEntity instanceof ProteinLiquefierBlockEntity) {
return Collections.singleton(IGuiClickableArea.createBasic(48, 40, 55, 18, GendustryRecipeType.PROTEIN_LIQUEFIER));
}
return Collections.emptyList();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package thedarkcolour.gendustry.compat.jei.producers;

import forestry.core.recipes.jei.ForestryRecipeCategory;
import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.forge.ForgeTypes;
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.gui.drawable.IDrawableAnimated;
import mezz.jei.api.gui.drawable.IDrawableStatic;
import mezz.jei.api.gui.ingredient.IRecipeSlotsView;
import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.recipe.RecipeIngredientRole;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.material.Fluid;
import net.minecraftforge.fluids.FluidStack;
import org.jetbrains.annotations.Nullable;
import thedarkcolour.gendustry.Gendustry;
import thedarkcolour.gendustry.recipe.ProcessorRecipe;

public abstract class ProducerRecipeCategory<T extends ProcessorRecipe> extends ForestryRecipeCategory<T> {

protected static final ResourceLocation GUI = new ResourceLocation(Gendustry.ID, "textures/gui/processor.png");
private final IDrawableAnimated arrow;
private final IDrawable tankOverlay;
private final IDrawable icon;

public ProducerRecipeCategory(IGuiHelper helper, String unlocalizedName, ItemStack stack) {
super(helper.createDrawable(GUI, 13, 18, 151, 60), unlocalizedName);

IDrawableStatic arrowDrawable = helper.createDrawable(GUI, 176, 60, 55, 18);
this.arrow = helper.createAnimatedDrawable(arrowDrawable, 200, IDrawableAnimated.StartDirection.LEFT, false);
this.tankOverlay = helper.createDrawable(GUI, 176, 0, 16, 58);
this.icon = helper.createDrawableIngredient(VanillaTypes.ITEM_STACK, stack);
}

@Override
public @Nullable IDrawable getIcon() {
return this.icon;
}

@Override
public void draw(T recipe, IRecipeSlotsView recipeSlotsView, GuiGraphics graphics, double mouseX, double mouseY) {
this.arrow.draw(graphics, 35, 23);
}

protected void addFluidTank(IRecipeLayoutBuilder builder, Fluid fluid, int amount) {
builder.addSlot(RecipeIngredientRole.OUTPUT, 109, 1)
.setFluidRenderer(10000, false, 16, 58)
.setOverlay(tankOverlay, 0, 0)
.addIngredient(ForgeTypes.FLUID_STACK, new FluidStack(fluid, amount));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package thedarkcolour.gendustry.compat.jei.producers;

import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.recipe.IFocusGroup;
import mezz.jei.api.recipe.RecipeIngredientRole;
import mezz.jei.api.recipe.RecipeType;
import net.minecraft.world.item.ItemStack;
import thedarkcolour.gendustry.block.GendustryMachineType;
import thedarkcolour.gendustry.compat.jei.GendustryRecipeType;
import thedarkcolour.gendustry.recipe.ProteinRecipe;
import thedarkcolour.gendustry.registry.GBlocks;
import thedarkcolour.gendustry.registry.GFluids;

public class ProteinProducerRecipeCategory extends ProducerRecipeCategory<ProteinRecipe> {

public static final ItemStack ICON_STACK = new ItemStack(GBlocks.MACHINE.get(GendustryMachineType.PROTEIN_LIQUEFIER).block());

public ProteinProducerRecipeCategory(IGuiHelper helper) {
super(helper, "block.gendustry.protein_liquefier", ICON_STACK);
}

@Override
public RecipeType<ProteinRecipe> getRecipeType() {
return GendustryRecipeType.PROTEIN_LIQUEFIER;
}

@Override
public void setRecipe(IRecipeLayoutBuilder builder, ProteinRecipe recipe, IFocusGroup iFocusGroup) {
builder.addSlot(RecipeIngredientRole.INPUT, 1, 23).addIngredients(recipe.getIngredient());
addFluidTank(builder, GFluids.PROTEIN.fluid(), recipe.getAmount());
}
}
1 change: 1 addition & 0 deletions src/main/java/thedarkcolour/gendustry/data/English.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ static void addTranslations(MKEnglishProvider lang) {
lang.add(TranslationKeys.TEMPLATE_ALLELE_COUNT, "Alleles (%1$s/%2$s)");
lang.add(TranslationKeys.UPGRADE_ENERGY_COST, "Energy Cost: %s RF");
lang.add(TranslationKeys.UPGRADE_STACK_LIMIT, "Max Count: %s");
lang.add("gen.for.chance", "%s%% chance to be consumed!");

// Machine hints
addHint(lang, TranslationKeys.HINT_MUTAGEN_USAGE, "What's Mutagen for?", "Produce Mutagen to use in other Gendustry machines.");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/thedarkcolour/gendustry/data/Recipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,6 @@ private static void protein(Consumer<FinishedRecipe> writer, Item input, int pro
}

private static void dna(Consumer<FinishedRecipe> writer, ResourceLocation speciesType, ILifeStage input, int dna) {
writer.accept(new DnaFinishedRecipe(Gendustry.loc("protein/" + input.getSerializedName()), IForestryApi.INSTANCE.getGeneticManager().getSpeciesType(speciesType), input, dna));
writer.accept(new DnaFinishedRecipe(Gendustry.loc("dna/" + input.getSerializedName()), IForestryApi.INSTANCE.getGeneticManager().getSpeciesType(speciesType), input, dna));
}
}

0 comments on commit 4199621

Please sign in to comment.