From 4199621b0d8fe356b62a50a18535d2a351426d43 Mon Sep 17 00:00:00 2001 From: CrossVas Date: Tue, 21 Jan 2025 13:23:32 +0900 Subject: [PATCH] [1.20.1] Added the rest of JEI compat (#2) * 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 --- .../17bf486417190b9b075888bd20665b89993b9d5d | 4 +- .../9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e | 22 ++++---- .../assets/gendustry/lang/en_us.json | 1 + .../recipes/{protein => dna}/butterfly.json | 0 .../recipes/{protein => dna}/caterpillar.json | 0 .../recipes/{protein => dna}/cocoon.json | 0 .../recipes/{protein => dna}/drone.json | 0 .../recipes/{protein => dna}/larvae.json | 0 .../recipes/{protein => dna}/pollen.json | 0 .../recipes/{protein => dna}/princess.json | 0 .../recipes/{protein => dna}/queen.json | 0 .../recipes/{protein => dna}/sapling.json | 0 .../recipes/{protein => dna}/serum.json | 0 .../compat/jei/GendustryJeiPlugin.java | 39 ++++++++++++-- .../compat/jei/GendustryRecipeType.java | 18 +++++++ .../producers/DNAExtractorRecipeCategory.java | 51 ++++++++++++++++++ .../jei/producers/MutagenRecipeCategory.java | 33 ++++++++++++ .../ProducerGuiContainerHandler.java | 29 ++++++++++ .../jei/producers/ProducerRecipeCategory.java | 54 +++++++++++++++++++ .../ProteinProducerRecipeCategory.java | 33 ++++++++++++ .../thedarkcolour/gendustry/data/English.java | 1 + .../thedarkcolour/gendustry/data/Recipes.java | 2 +- 22 files changed, 269 insertions(+), 18 deletions(-) rename src/generated/resources/data/gendustry/recipes/{protein => dna}/butterfly.json (100%) rename src/generated/resources/data/gendustry/recipes/{protein => dna}/caterpillar.json (100%) rename src/generated/resources/data/gendustry/recipes/{protein => dna}/cocoon.json (100%) rename src/generated/resources/data/gendustry/recipes/{protein => dna}/drone.json (100%) rename src/generated/resources/data/gendustry/recipes/{protein => dna}/larvae.json (100%) rename src/generated/resources/data/gendustry/recipes/{protein => dna}/pollen.json (100%) rename src/generated/resources/data/gendustry/recipes/{protein => dna}/princess.json (100%) rename src/generated/resources/data/gendustry/recipes/{protein => dna}/queen.json (100%) rename src/generated/resources/data/gendustry/recipes/{protein => dna}/sapling.json (100%) rename src/generated/resources/data/gendustry/recipes/{protein => dna}/serum.json (100%) create mode 100644 src/main/java/thedarkcolour/gendustry/compat/jei/GendustryRecipeType.java create mode 100644 src/main/java/thedarkcolour/gendustry/compat/jei/producers/DNAExtractorRecipeCategory.java create mode 100644 src/main/java/thedarkcolour/gendustry/compat/jei/producers/MutagenRecipeCategory.java create mode 100644 src/main/java/thedarkcolour/gendustry/compat/jei/producers/ProducerGuiContainerHandler.java create mode 100644 src/main/java/thedarkcolour/gendustry/compat/jei/producers/ProducerRecipeCategory.java create mode 100644 src/main/java/thedarkcolour/gendustry/compat/jei/producers/ProteinProducerRecipeCategory.java diff --git a/src/generated/resources/.cache/17bf486417190b9b075888bd20665b89993b9d5d b/src/generated/resources/.cache/17bf486417190b9b075888bd20665b89993b9d5d index 3defa9b..9e77d94 100644 --- a/src/generated/resources/.cache/17bf486417190b9b075888bd20665b89993b9d5d +++ b/src/generated/resources/.cache/17bf486417190b9b075888bd20665b89993b9d5d @@ -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 diff --git a/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e b/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e index 2f6ce99..96f1df2 100644 --- a/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e +++ b/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e @@ -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 @@ -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 @@ -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 diff --git a/src/generated/resources/assets/gendustry/lang/en_us.json b/src/generated/resources/assets/gendustry/lang/en_us.json index 4d0bb6d..f98d4f8 100644 --- a/src/generated/resources/assets/gendustry/lang/en_us.json +++ b/src/generated/resources/assets/gendustry/lang/en_us.json @@ -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", diff --git a/src/generated/resources/data/gendustry/recipes/protein/butterfly.json b/src/generated/resources/data/gendustry/recipes/dna/butterfly.json similarity index 100% rename from src/generated/resources/data/gendustry/recipes/protein/butterfly.json rename to src/generated/resources/data/gendustry/recipes/dna/butterfly.json diff --git a/src/generated/resources/data/gendustry/recipes/protein/caterpillar.json b/src/generated/resources/data/gendustry/recipes/dna/caterpillar.json similarity index 100% rename from src/generated/resources/data/gendustry/recipes/protein/caterpillar.json rename to src/generated/resources/data/gendustry/recipes/dna/caterpillar.json diff --git a/src/generated/resources/data/gendustry/recipes/protein/cocoon.json b/src/generated/resources/data/gendustry/recipes/dna/cocoon.json similarity index 100% rename from src/generated/resources/data/gendustry/recipes/protein/cocoon.json rename to src/generated/resources/data/gendustry/recipes/dna/cocoon.json diff --git a/src/generated/resources/data/gendustry/recipes/protein/drone.json b/src/generated/resources/data/gendustry/recipes/dna/drone.json similarity index 100% rename from src/generated/resources/data/gendustry/recipes/protein/drone.json rename to src/generated/resources/data/gendustry/recipes/dna/drone.json diff --git a/src/generated/resources/data/gendustry/recipes/protein/larvae.json b/src/generated/resources/data/gendustry/recipes/dna/larvae.json similarity index 100% rename from src/generated/resources/data/gendustry/recipes/protein/larvae.json rename to src/generated/resources/data/gendustry/recipes/dna/larvae.json diff --git a/src/generated/resources/data/gendustry/recipes/protein/pollen.json b/src/generated/resources/data/gendustry/recipes/dna/pollen.json similarity index 100% rename from src/generated/resources/data/gendustry/recipes/protein/pollen.json rename to src/generated/resources/data/gendustry/recipes/dna/pollen.json diff --git a/src/generated/resources/data/gendustry/recipes/protein/princess.json b/src/generated/resources/data/gendustry/recipes/dna/princess.json similarity index 100% rename from src/generated/resources/data/gendustry/recipes/protein/princess.json rename to src/generated/resources/data/gendustry/recipes/dna/princess.json diff --git a/src/generated/resources/data/gendustry/recipes/protein/queen.json b/src/generated/resources/data/gendustry/recipes/dna/queen.json similarity index 100% rename from src/generated/resources/data/gendustry/recipes/protein/queen.json rename to src/generated/resources/data/gendustry/recipes/dna/queen.json diff --git a/src/generated/resources/data/gendustry/recipes/protein/sapling.json b/src/generated/resources/data/gendustry/recipes/dna/sapling.json similarity index 100% rename from src/generated/resources/data/gendustry/recipes/protein/sapling.json rename to src/generated/resources/data/gendustry/recipes/dna/sapling.json diff --git a/src/generated/resources/data/gendustry/recipes/protein/serum.json b/src/generated/resources/data/gendustry/recipes/dna/serum.json similarity index 100% rename from src/generated/resources/data/gendustry/recipes/protein/serum.json rename to src/generated/resources/data/gendustry/recipes/dna/serum.json diff --git a/src/main/java/thedarkcolour/gendustry/compat/jei/GendustryJeiPlugin.java b/src/main/java/thedarkcolour/gendustry/compat/jei/GendustryJeiPlugin.java index 67a96a1..46edb3e 100644 --- a/src/main/java/thedarkcolour/gendustry/compat/jei/GendustryJeiPlugin.java +++ b/src/main/java/thedarkcolour/gendustry/compat/jei/GendustryJeiPlugin.java @@ -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 { @@ -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 @@ -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()); } } diff --git a/src/main/java/thedarkcolour/gendustry/compat/jei/GendustryRecipeType.java b/src/main/java/thedarkcolour/gendustry/compat/jei/GendustryRecipeType.java new file mode 100644 index 0000000..438204e --- /dev/null +++ b/src/main/java/thedarkcolour/gendustry/compat/jei/GendustryRecipeType.java @@ -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 MUTAGEN_PRODUCER = create("mutagen_producer", MutagenRecipe.class); + public static final RecipeType DNA_EXTRACTOR = create("dna_extractor", DnaRecipe.class); + public static final RecipeType PROTEIN_LIQUEFIER = create("protein_liquefier", ProteinRecipe.class); + + private static RecipeType create(String uid, Class recipeClass) { + return RecipeType.create(Gendustry.ID, uid, recipeClass); + } +} diff --git a/src/main/java/thedarkcolour/gendustry/compat/jei/producers/DNAExtractorRecipeCategory.java b/src/main/java/thedarkcolour/gendustry/compat/jei/producers/DNAExtractorRecipeCategory.java new file mode 100644 index 0000000..eb3aea7 --- /dev/null +++ b/src/main/java/thedarkcolour/gendustry/compat/jei/producers/DNAExtractorRecipeCategory.java @@ -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 { + + 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 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); + } +} diff --git a/src/main/java/thedarkcolour/gendustry/compat/jei/producers/MutagenRecipeCategory.java b/src/main/java/thedarkcolour/gendustry/compat/jei/producers/MutagenRecipeCategory.java new file mode 100644 index 0000000..4493d3a --- /dev/null +++ b/src/main/java/thedarkcolour/gendustry/compat/jei/producers/MutagenRecipeCategory.java @@ -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 { + + 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 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()); + } +} diff --git a/src/main/java/thedarkcolour/gendustry/compat/jei/producers/ProducerGuiContainerHandler.java b/src/main/java/thedarkcolour/gendustry/compat/jei/producers/ProducerGuiContainerHandler.java new file mode 100644 index 0000000..abd573c --- /dev/null +++ b/src/main/java/thedarkcolour/gendustry/compat/jei/producers/ProducerGuiContainerHandler.java @@ -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 { + + @Override + public Collection 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(); + } +} diff --git a/src/main/java/thedarkcolour/gendustry/compat/jei/producers/ProducerRecipeCategory.java b/src/main/java/thedarkcolour/gendustry/compat/jei/producers/ProducerRecipeCategory.java new file mode 100644 index 0000000..a8f184d --- /dev/null +++ b/src/main/java/thedarkcolour/gendustry/compat/jei/producers/ProducerRecipeCategory.java @@ -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 extends ForestryRecipeCategory { + + 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)); + } +} diff --git a/src/main/java/thedarkcolour/gendustry/compat/jei/producers/ProteinProducerRecipeCategory.java b/src/main/java/thedarkcolour/gendustry/compat/jei/producers/ProteinProducerRecipeCategory.java new file mode 100644 index 0000000..f85c18d --- /dev/null +++ b/src/main/java/thedarkcolour/gendustry/compat/jei/producers/ProteinProducerRecipeCategory.java @@ -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 { + + 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 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()); + } +} diff --git a/src/main/java/thedarkcolour/gendustry/data/English.java b/src/main/java/thedarkcolour/gendustry/data/English.java index 95df657..f0e751b 100644 --- a/src/main/java/thedarkcolour/gendustry/data/English.java +++ b/src/main/java/thedarkcolour/gendustry/data/English.java @@ -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."); diff --git a/src/main/java/thedarkcolour/gendustry/data/Recipes.java b/src/main/java/thedarkcolour/gendustry/data/Recipes.java index 8706559..2b4629b 100644 --- a/src/main/java/thedarkcolour/gendustry/data/Recipes.java +++ b/src/main/java/thedarkcolour/gendustry/data/Recipes.java @@ -515,6 +515,6 @@ private static void protein(Consumer writer, Item input, int pro } private static void dna(Consumer 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)); } }