-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from moonfather1/emi_support
EMI support
- Loading branch information
Showing
15 changed files
with
469 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/growthcraft/cellar/compat/emi/EmiBarrelRecipe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package growthcraft.cellar.compat.emi; | ||
|
||
import dev.emi.emi.api.recipe.BasicEmiRecipe; | ||
import dev.emi.emi.api.render.EmiTexture; | ||
import dev.emi.emi.api.stack.EmiIngredient; | ||
import dev.emi.emi.api.stack.EmiStack; | ||
import dev.emi.emi.api.widget.WidgetHolder; | ||
import growthcraft.cellar.recipe.FermentationBarrelRecipe; | ||
import net.minecraft.world.item.crafting.Ingredient; | ||
|
||
public class EmiBarrelRecipe extends BasicEmiRecipe | ||
{ | ||
public EmiBarrelRecipe(FermentationBarrelRecipe recipe) | ||
{ | ||
super(EmiPlugin.BARREL_RECIPE_CATEGORY, recipe.getId(), 125, 18); | ||
this.inputs.add(EmiStack.of(recipe.getIngredientFluidStack().getFluid())); | ||
this.inputs.add(EmiIngredient.of(Ingredient.of(recipe.getIngredientItemStack()))); | ||
this.outputs.add(EmiStack.of(recipe.getResultingFluid().getFluid().getBucket())); | ||
this.outputs.add(EmiStack.of(recipe.getResultingFluid().getFluid())); | ||
} | ||
|
||
@Override | ||
public void addWidgets(WidgetHolder widgetHolder) | ||
{ | ||
// Add plus and arrow textures | ||
widgetHolder.addTexture(EmiTexture.PLUS, 27, 3); | ||
widgetHolder.addTexture(EmiTexture.EMPTY_ARROW, 75, 1); | ||
// Adds an input slot 1 | ||
widgetHolder.addSlot(inputs.get(0), 0, 0); | ||
// Adds an input slot 2 | ||
widgetHolder.addSlot(inputs.get(1), 49, 0); | ||
// Adds an output slot on the right | ||
// Note that output slots need to call `recipeContext` to inform EMI about their recipe context | ||
// This includes being able to resolve recipe trees, favorite stacks with recipe context, and more | ||
widgetHolder.addSlot(outputs.get(1), 107, 0).recipeContext(this); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/growthcraft/cellar/compat/emi/EmiFarmingRecipe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package growthcraft.cellar.compat.emi; | ||
|
||
import dev.emi.emi.api.recipe.BasicEmiRecipe; | ||
import dev.emi.emi.api.recipe.VanillaEmiRecipeCategories; | ||
import dev.emi.emi.api.render.EmiTexture; | ||
import dev.emi.emi.api.stack.EmiIngredient; | ||
import dev.emi.emi.api.stack.EmiStack; | ||
import dev.emi.emi.api.widget.WidgetHolder; | ||
import growthcraft.cellar.shared.Reference; | ||
import growthcraft.core.init.GrowthcraftItems; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.Items; | ||
import net.minecraft.world.item.crafting.Ingredient; | ||
import net.minecraft.world.level.ItemLike; | ||
import net.minecraft.world.level.block.Blocks; | ||
|
||
public class EmiFarmingRecipe extends BasicEmiRecipe | ||
{ | ||
private static final ResourceLocation WIDGETS = new ResourceLocation("growthcraft:textures/gui/widgets.png"); | ||
private static final EmiTexture SMALL_PLUS = new EmiTexture(WIDGETS, 83, 1, 10, 10); | ||
private static final EmiTexture SMALL_ARROW = new EmiTexture(WIDGETS, 44, 0, 20, 15); | ||
private static final EmiIngredient SLOT0 = EmiIngredient.of(Ingredient.of(Blocks.FARMLAND)); | ||
private static final EmiIngredient SLOT2 = EmiIngredient.of(Ingredient.of(GrowthcraftItems.ROPE_LINEN.get())); | ||
private static int counter = 1; | ||
private final EmiIngredient SLOT1, SLOT3; | ||
|
||
public EmiFarmingRecipe(ItemLike input, ItemLike output) | ||
{ | ||
super(VanillaEmiRecipeCategories.WORLD_INTERACTION, new ResourceLocation(Reference.MODID, "f"+counter), 125, 18); | ||
counter++; | ||
SLOT1 = EmiIngredient.of(Ingredient.of(input)); | ||
SLOT3 = EmiIngredient.of(Ingredient.of(output)); | ||
this.inputs.add(SLOT1); | ||
this.inputs.add(SLOT2); | ||
this.outputs.add(EmiStack.of(output)); | ||
} | ||
|
||
@Override | ||
public void addWidgets(WidgetHolder widgetHolder) | ||
{ | ||
widgetHolder.addSlot(SLOT0, 0, 0); | ||
widgetHolder.addTexture(SMALL_PLUS, 20, 3); | ||
widgetHolder.addSlot(SLOT1, 32, 0); | ||
widgetHolder.addTexture(SMALL_PLUS, 52, 3); | ||
widgetHolder.addSlot(SLOT2, 64, 0); | ||
widgetHolder.addTexture(SMALL_ARROW, 83, 1); | ||
// Adds an output slot on the right | ||
// Note that output slots need to call `recipeContext` to inform EMI about their recipe context | ||
// This includes being able to resolve recipe trees, favorite stacks with recipe context, and more | ||
widgetHolder.addSlot(SLOT3, 106, 0).recipeContext(this); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/growthcraft/cellar/compat/emi/EmiJarRecipe1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package growthcraft.cellar.compat.emi; | ||
|
||
import dev.emi.emi.api.recipe.BasicEmiRecipe; | ||
import dev.emi.emi.api.render.EmiTexture; | ||
import dev.emi.emi.api.stack.EmiIngredient; | ||
import dev.emi.emi.api.stack.EmiStack; | ||
import dev.emi.emi.api.widget.WidgetHolder; | ||
import growthcraft.cellar.recipe.CultureJarRecipe; | ||
import growthcraft.cellar.recipe.CultureJarStarterRecipe; | ||
import net.minecraft.world.item.crafting.Ingredient; | ||
|
||
public class EmiJarRecipe1 extends BasicEmiRecipe | ||
{ | ||
public EmiJarRecipe1(CultureJarStarterRecipe recipe) | ||
{ | ||
super(EmiPlugin.JAR_RECIPE_CATEGORY1, recipe.getId(), 125, 18); | ||
this.inputs.add(EmiStack.of(recipe.getInputFluidStack().getFluid(), recipe.getInputFluidStack().getAmount())); | ||
this.outputs.add(EmiStack.of(recipe.getInputItemStack())); | ||
} | ||
|
||
@Override | ||
public void addWidgets(WidgetHolder widgetHolder) | ||
{ | ||
// Add an arrow texture to indicate processing | ||
widgetHolder.addTexture(EmiTexture.EMPTY_ARROW, 26, 1); | ||
// Adds an input slot on the left | ||
widgetHolder.addSlot(inputs.get(0), 0, 0); | ||
// Adds an output slot on the right | ||
// Note that output slots need to call `recipeContext` to inform EMI about their recipe context | ||
// This includes being able to resolve recipe trees, favorite stacks with recipe context, and more | ||
widgetHolder.addSlot(outputs.get(0), 58, 0).recipeContext(this); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/growthcraft/cellar/compat/emi/EmiJarRecipe2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package growthcraft.cellar.compat.emi; | ||
|
||
import dev.emi.emi.api.recipe.BasicEmiRecipe; | ||
import dev.emi.emi.api.render.EmiTexture; | ||
import dev.emi.emi.api.stack.EmiIngredient; | ||
import dev.emi.emi.api.stack.EmiStack; | ||
import dev.emi.emi.api.widget.WidgetHolder; | ||
import growthcraft.cellar.recipe.CultureJarRecipe; | ||
import growthcraft.cellar.recipe.FermentationBarrelRecipe; | ||
import net.minecraft.world.item.crafting.Ingredient; | ||
|
||
public class EmiJarRecipe2 extends BasicEmiRecipe | ||
{ | ||
public EmiJarRecipe2(CultureJarRecipe recipe) | ||
{ | ||
super(EmiPlugin.JAR_RECIPE_CATEGORY2, recipe.getId(), 125, 18); | ||
this.inputs.add(EmiStack.of(recipe.getInputFluidStack().getFluid(), recipe.getInputFluidStack().getAmount())); | ||
this.inputs.add(EmiStack.of(recipe.getInputItemStack())); | ||
this.outputs.add(EmiStack.of(recipe.getInputItemStack())); | ||
} | ||
|
||
@Override | ||
public void addWidgets(WidgetHolder widgetHolder) | ||
{ | ||
// Add plus and arrow textures | ||
widgetHolder.addTexture(EmiTexture.PLUS, 27, 3); | ||
widgetHolder.addTexture(EmiTexture.EMPTY_ARROW, 75, 1); | ||
// Adds an input slot 1 | ||
widgetHolder.addSlot(inputs.get(0), 0, 0); | ||
// Adds an input slot 2 | ||
widgetHolder.addSlot(inputs.get(1), 49, 0); | ||
// Adds an output slot on the right | ||
// Note that output slots need to call `recipeContext` to inform EMI about their recipe context | ||
// This includes being able to resolve recipe trees, favorite stacks with recipe context, and more | ||
widgetHolder.addSlot(outputs.get(0), 107, 0).recipeContext(this); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
src/main/java/growthcraft/cellar/compat/emi/EmiKettleRecipe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package growthcraft.cellar.compat.emi; | ||
|
||
import dev.emi.emi.api.recipe.BasicEmiRecipe; | ||
import dev.emi.emi.api.render.EmiTexture; | ||
import dev.emi.emi.api.stack.EmiIngredient; | ||
import dev.emi.emi.api.stack.EmiStack; | ||
import dev.emi.emi.api.widget.WidgetHolder; | ||
import growthcraft.cellar.recipe.BrewKettleRecipe; | ||
import growthcraft.cellar.recipe.FermentationBarrelRecipe; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.crafting.Ingredient; | ||
|
||
import java.util.List; | ||
|
||
public class EmiKettleRecipe extends BasicEmiRecipe | ||
{ | ||
private final boolean hasByproduct, isSteaming; | ||
private final int chanceForByproduct; | ||
|
||
public EmiKettleRecipe(BrewKettleRecipe recipe) { | ||
super(EmiPlugin.KETTLE_RECIPE_CATEGORY, recipe.getId(), 125, 18); | ||
this.inputs.add(EmiIngredient.of(recipe.getIngredients().isEmpty() ? Ingredient.EMPTY : recipe.getIngredients().get(0))); | ||
this.inputs.add(EmiStack.of(recipe.getInputFluidStack().getFluid(), recipe.getInputFluidStack().getAmount())); | ||
this.outputs.add(EmiStack.of(recipe.getOutputFluidStack().getFluid().getBucket())); | ||
this.outputs.add(EmiStack.of(recipe.getOutputFluidStack().getFluid(),recipe.getOutputFluidStack().getAmount())); | ||
this.outputs.add(EmiStack.of(recipe.getByProduct())); | ||
this.hasByproduct = ! recipe.getByProduct().isEmpty() && recipe.getByProductChance() > 0; | ||
this.chanceForByproduct = recipe.getByProductChance(); | ||
this.isSteaming = recipe.isLidRequired(); | ||
} | ||
|
||
@Override | ||
public void addWidgets(WidgetHolder widgetHolder) { | ||
// Adds input slot 1 | ||
widgetHolder.addSlot(inputs.get(1), 0, 0); | ||
// Add texture | ||
widgetHolder.addTexture(SMALL_PLUS, 20, 3); | ||
// Adds input slot 2 | ||
widgetHolder.addSlot(inputs.get(0), 32, 0); | ||
// Add texture | ||
widgetHolder.addTexture(SMALL_ARROW, 52, 1); | ||
String key = this.isSteaming ? "message.growthcraft_cellar.kettle.jei_info_need_lid" : "message.growthcraft_cellar.kettle.jei_info_no_lid"; | ||
widgetHolder.addTooltipText(List.of(Component.translatable(key)), 50, 0, 24, 17); | ||
// Adds an output slot on the right | ||
// Note that output slots need to call `recipeContext` to inform EMI about their recipe context | ||
// This includes being able to resolve recipe trees, favorite stacks with recipe context, and more | ||
widgetHolder.addSlot(outputs.get(1), 74, 0).recipeContext(this); | ||
if (this.hasByproduct) { | ||
// Add texture | ||
widgetHolder.addTexture(SMALL_PLUS, 94, 3); | ||
// Adds output slot 2 | ||
widgetHolder.addSlot(outputs.get(2), 107, 0); | ||
widgetHolder.addTooltipText(List.of(Component.literal("%d%%".formatted(this.chanceForByproduct))), 92, 1, 14, 14); | ||
} | ||
} | ||
private static final ResourceLocation WIDGETS = new ResourceLocation("growthcraft:textures/gui/widgets.png"); | ||
private static final EmiTexture SMALL_PLUS = new EmiTexture(WIDGETS, 83, 1, 10, 10); | ||
private static final EmiTexture SMALL_ARROW = new EmiTexture(WIDGETS, 44, 0, 20, 15); | ||
} |
Oops, something went wrong.