mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-18 11:29:23 +00:00
Add Distilling JEI recipes
This commit is contained in:
1 parent
1d96c9d349
commit
b79b279a17
10 files changed
+194
-21
No files matched your search
@@ -13,6 +13,7 @@ import binnie.extratrees.item.ExtraTreeItems;
|
||||
import binnie.extratrees.item.Food;
|
||||
import binnie.extratrees.machines.brewery.BrewedGrainRecipe;
|
||||
import binnie.extratrees.machines.brewery.BreweryRecipes;
|
||||
import binnie.extratrees.machines.distillery.DistilleryLogic;
|
||||
import binnie.extratrees.machines.distillery.DistilleryRecipes;
|
||||
import binnie.extratrees.machines.fruitpress.FruitPressRecipes;
|
||||
import forestry.api.recipes.ISqueezerRecipe;
|
||||
@@ -133,13 +134,18 @@ public class ModuleAlcohol implements IInitializable {
|
||||
}
|
||||
|
||||
private void addDistillery(final IFluidType source, final IFluidType singleDistilled, final IFluidType doubleDistilled, final IFluidType tripleDistilled) {
|
||||
DistilleryRecipes.addRecipe(source.get(5), singleDistilled.get(4), 0);
|
||||
DistilleryRecipes.addRecipe(source.get(5), doubleDistilled.get(2), 1);
|
||||
DistilleryRecipes.addRecipe(source.get(5), tripleDistilled.get(1), 2);
|
||||
final int inAmount = DistilleryLogic.INPUT_FLUID_AMOUNT;
|
||||
final int outAmount1 = inAmount * 4 / 5;
|
||||
final int outAmount2 = inAmount * 2 / 5;
|
||||
final int outAmount3 = inAmount / 5;
|
||||
|
||||
DistilleryRecipes.addRecipe(singleDistilled.get(5), doubleDistilled.get(2), 0);
|
||||
DistilleryRecipes.addRecipe(singleDistilled.get(5), tripleDistilled.get(1), 1);
|
||||
DistilleryRecipes.addRecipe(source.get(inAmount), singleDistilled.get(outAmount1), 0);
|
||||
DistilleryRecipes.addRecipe(source.get(inAmount), doubleDistilled.get(outAmount2), 1);
|
||||
DistilleryRecipes.addRecipe(source.get(inAmount), tripleDistilled.get(outAmount3), 2);
|
||||
|
||||
DistilleryRecipes.addRecipe(doubleDistilled.get(5), tripleDistilled.get(2), 0);
|
||||
DistilleryRecipes.addRecipe(singleDistilled.get(inAmount), doubleDistilled.get(outAmount2), 0);
|
||||
DistilleryRecipes.addRecipe(singleDistilled.get(inAmount), tripleDistilled.get(outAmount3), 1);
|
||||
|
||||
DistilleryRecipes.addRecipe(doubleDistilled.get(inAmount), tripleDistilled.get(outAmount2), 0);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,9 @@ import binnie.core.integration.jei.SimpleRecipeHandler;
|
||||
import binnie.extratrees.integration.jei.brewery.BreweryRecipeCategory;
|
||||
import binnie.extratrees.integration.jei.brewery.BreweryRecipeMaker;
|
||||
import binnie.extratrees.integration.jei.brewery.BreweryRecipeWrapper;
|
||||
import binnie.extratrees.integration.jei.distillery.brewery.DistilleryRecipeCategory;
|
||||
import binnie.extratrees.integration.jei.distillery.brewery.DistilleryRecipeMaker;
|
||||
import binnie.extratrees.integration.jei.distillery.brewery.DistilleryRecipeWrapper;
|
||||
import binnie.extratrees.integration.jei.fruitpress.FruitPressRecipeCategory;
|
||||
import binnie.extratrees.integration.jei.fruitpress.FruitPressRecipeMaker;
|
||||
import binnie.extratrees.integration.jei.fruitpress.FruitPressRecipeWrapper;
|
||||
@@ -39,21 +42,25 @@ public class ExtraTreesJeiPlugin extends BlankModPlugin {
|
||||
registry.addRecipeCategories(
|
||||
new LumbermillRecipeCategory(),
|
||||
new FruitPressRecipeCategory(),
|
||||
new BreweryRecipeCategory()
|
||||
new BreweryRecipeCategory(),
|
||||
new DistilleryRecipeCategory()
|
||||
);
|
||||
|
||||
registry.addRecipeHandlers(
|
||||
new SimpleRecipeHandler<>(LumbermillRecipeWrapper.class, RecipeUids.LUMBERMILL),
|
||||
new SimpleRecipeHandler<>(FruitPressRecipeWrapper.class, RecipeUids.FRUIT_PRESS),
|
||||
new SimpleRecipeHandler<>(BreweryRecipeWrapper.class, RecipeUids.BREWING)
|
||||
new SimpleRecipeHandler<>(BreweryRecipeWrapper.class, RecipeUids.BREWING),
|
||||
new SimpleRecipeHandler<>(DistilleryRecipeWrapper.class, RecipeUids.DISTILLING)
|
||||
);
|
||||
|
||||
registry.addRecipeCategoryCraftingItem(ExtraTreeMachine.Lumbermill.get(1), RecipeUids.LUMBERMILL);
|
||||
registry.addRecipeCategoryCraftingItem(ExtraTreeMachine.Press.get(1), RecipeUids.FRUIT_PRESS);
|
||||
registry.addRecipeCategoryCraftingItem(ExtraTreeMachine.Brewery.get(1), RecipeUids.BREWING);
|
||||
registry.addRecipeCategoryCraftingItem(ExtraTreeMachine.Distillery.get(1), RecipeUids.DISTILLING);
|
||||
|
||||
registry.addRecipes(LumbermillRecipeMaker.create());
|
||||
registry.addRecipes(FruitPressRecipeMaker.create());
|
||||
registry.addRecipes(BreweryRecipeMaker.create());
|
||||
registry.addRecipes(DistilleryRecipeMaker.create());
|
||||
}
|
||||
}
|
||||
@@ -4,4 +4,5 @@ public class RecipeUids {
|
||||
public static final String LUMBERMILL = "binnie.extratrees.lumbermill";
|
||||
public static final String FRUIT_PRESS = "binnie.extratrees.fruitpress";
|
||||
public static final String BREWING = "binnie.extratrees.brewing";
|
||||
public static final String DISTILLING = "binnie.extratrees.distilling";
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package binnie.extratrees.integration.jei.distillery.brewery;
|
||||
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.core.geometry.Position;
|
||||
import binnie.craftgui.extratrees.dictionary.ControlDistilleryProgress;
|
||||
import binnie.craftgui.resource.Texture;
|
||||
import binnie.craftgui.resource.minecraft.StandardTexture;
|
||||
import binnie.extratrees.core.ExtraTreeTexture;
|
||||
import binnie.extratrees.integration.jei.ExtraTreesJeiPlugin;
|
||||
import binnie.extratrees.integration.jei.RecipeUids;
|
||||
import binnie.extratrees.machines.brewery.BreweryMachine;
|
||||
import binnie.extratrees.machines.distillery.DistilleryLogic;
|
||||
import binnie.extratrees.machines.distillery.DistilleryMachine;
|
||||
import forestry.core.tiles.ITitled;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IDrawableAnimated;
|
||||
import mezz.jei.api.gui.IGuiFluidStackGroup;
|
||||
import mezz.jei.api.gui.IGuiItemStackGroup;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.gui.ITickTimer;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.BlankRecipeCategory;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class DistilleryRecipeCategory extends BlankRecipeCategory<DistilleryRecipeWrapper> {
|
||||
private static final Texture DISTILLERY_BASE = new StandardTexture(43, 0, 58, 60, ExtraTreeTexture.Gui);
|
||||
private static final Texture LIQUID_FLOW = new StandardTexture(101, 0, 38, 60, ExtraTreeTexture.Gui);
|
||||
|
||||
private final ITickTimer progress;
|
||||
|
||||
public DistilleryRecipeCategory() {
|
||||
this.progress = ExtraTreesJeiPlugin.guiHelper.createTickTimer(200, 100, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUid() {
|
||||
return RecipeUids.DISTILLING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Distilling";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return ExtraTreesJeiPlugin.guiHelper.createBlankDrawable(84, 60);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(Minecraft minecraft) {
|
||||
CraftGUI.Render.texture(DISTILLERY_BASE, new IPoint(0.0f, 0.0f));
|
||||
CraftGUI.Render.texturePercentage(LIQUID_FLOW, new IArea(18.0f, 0.0f, 38.0f, 60.0f), Position.Left, progress.getValue() / 100f);
|
||||
|
||||
IDrawable tank = ExtraTreesJeiPlugin.drawables.getTank();
|
||||
tank.draw(minecraft, 0, 0);
|
||||
tank.draw(minecraft, 64, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, DistilleryRecipeWrapper recipeWrapper, IIngredients ingredients) {
|
||||
IDrawable tankOverlay = ExtraTreesJeiPlugin.drawables.getTankOverlay();
|
||||
IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks();
|
||||
fluidStacks.init(DistilleryMachine.TANK_INPUT, true, 1, 1, 16, 58, DistilleryLogic.INPUT_FLUID_AMOUNT, false, tankOverlay);
|
||||
fluidStacks.init(DistilleryMachine.TANK_OUTPUT, false, 65, 1, 16, 58, DistilleryLogic.INPUT_FLUID_AMOUNT, false, tankOverlay);
|
||||
fluidStacks.set(ingredients);
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package binnie.extratrees.integration.jei.distillery.brewery;
|
||||
|
||||
import binnie.extratrees.machines.distillery.DistilleryRecipes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DistilleryRecipeMaker {
|
||||
public static List<DistilleryRecipeWrapper> create() {
|
||||
List<DistilleryRecipeWrapper> recipes = new ArrayList<>();
|
||||
|
||||
for (int level = 0; level < 3; level++) {
|
||||
for (Pair<FluidStack, FluidStack> entry : DistilleryRecipes.getRecipes(level)) {
|
||||
FluidStack input = entry.getKey();
|
||||
FluidStack output = entry.getValue();
|
||||
recipes.add(new DistilleryRecipeWrapper(level, input, output));
|
||||
}
|
||||
}
|
||||
|
||||
return recipes;
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package binnie.extratrees.integration.jei.distillery.brewery;
|
||||
|
||||
import binnie.craftgui.core.CraftGUI;
|
||||
import binnie.craftgui.core.geometry.IPoint;
|
||||
import binnie.craftgui.extratrees.dictionary.ControlDistilleryProgress;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.BlankRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class DistilleryRecipeWrapper extends BlankRecipeWrapper {
|
||||
private final int level;
|
||||
private final FluidStack input;
|
||||
private final FluidStack output;
|
||||
|
||||
public DistilleryRecipeWrapper(int level, FluidStack input, FluidStack output) {
|
||||
this.level = level;
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getIngredients(IIngredients ingredients) {
|
||||
ingredients.setInput(FluidStack.class, input);
|
||||
ingredients.setOutput(FluidStack.class, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
||||
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
|
||||
|
||||
CraftGUI.Render.texture(ControlDistilleryProgress.OUTPUT, new IPoint(47.0f, 14 + level * 15));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@FieldsAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package binnie.extratrees.integration.jei.distillery.brewery;
|
||||
|
||||
import binnie.core.util.FieldsAreNonnullByDefault;
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -13,6 +13,8 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||
import java.util.Map;
|
||||
|
||||
public class DistilleryLogic extends ComponentProcessSetCost implements IProcess, INetwork.SendGuiNBT, INetwork.RecieveGuiNBT {
|
||||
public static final int INPUT_FLUID_AMOUNT = 1000;
|
||||
|
||||
public FluidStack currentFluid;
|
||||
public int level;
|
||||
|
||||
@@ -73,8 +75,7 @@ public class DistilleryLogic extends ComponentProcessSetCost implements IProcess
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
final FluidStack output = DistilleryRecipes.getOutput(this.currentFluid, this.level).copy();
|
||||
output.amount = 1000;
|
||||
final FluidStack output = DistilleryRecipes.getOutput(this.currentFluid, this.level);
|
||||
this.getUtil().fillTank(DistilleryMachine.TANK_OUTPUT, output);
|
||||
}
|
||||
|
||||
@@ -113,8 +114,8 @@ public class DistilleryLogic extends ComponentProcessSetCost implements IProcess
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
if (this.canWork() == null && this.currentFluid == null && this.getUtil().getTank(DistilleryMachine.TANK_INPUT).getFluidAmount() >= 1000) {
|
||||
this.currentFluid = this.getUtil().drainTank(DistilleryMachine.TANK_INPUT, 1000);
|
||||
if (this.canWork() == null && this.currentFluid == null && this.getUtil().getTank(DistilleryMachine.TANK_INPUT).getFluidAmount() >= INPUT_FLUID_AMOUNT) {
|
||||
this.currentFluid = this.getUtil().drainTank(DistilleryMachine.TANK_INPUT, INPUT_FLUID_AMOUNT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,6 +124,10 @@ public class DistilleryLogic extends ComponentProcessSetCost implements IProcess
|
||||
if (this.currentFluid == null) {
|
||||
return "Empty";
|
||||
}
|
||||
return "Creating " + DistilleryRecipes.getOutput(this.currentFluid, this.level).getFluid().getLocalizedName(this.currentFluid);
|
||||
FluidStack output = DistilleryRecipes.getOutput(this.currentFluid, this.level);
|
||||
if (output == null) {
|
||||
return "Empty";
|
||||
}
|
||||
return "Creating " + output.getLocalizedName();
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,18 @@ package binnie.extratrees.machines.distillery;
|
||||
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DistilleryRecipes {
|
||||
private static final List<Map<Fluid, FluidStack>> recipes = new ArrayList<>();
|
||||
private static final List<Map<Fluid, Pair<FluidStack, FluidStack>>> recipes = new ArrayList<>();
|
||||
|
||||
static {
|
||||
recipes.add(new HashMap<>());
|
||||
@@ -18,16 +21,23 @@ public class DistilleryRecipes {
|
||||
recipes.add(new HashMap<>());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static FluidStack getOutput(@Nullable final FluidStack fluid, final int level) {
|
||||
if (fluid == null) {
|
||||
return null;
|
||||
if (fluid != null) {
|
||||
Map<Fluid, Pair<FluidStack, FluidStack>> recipesForLevel = recipes.get(level);
|
||||
Pair<FluidStack, FluidStack> recipe = recipesForLevel.get(fluid.getFluid());
|
||||
if (recipe != null) {
|
||||
return recipe.getValue().copy();
|
||||
}
|
||||
}
|
||||
return recipes.get(level).get(fluid.getFluid());
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isValidInputLiquid(final FluidStack fluid) {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (recipes.get(i).containsKey(fluid.getFluid())) {
|
||||
Map<Fluid, Pair<FluidStack, FluidStack>> recipesForLevel = recipes.get(i);
|
||||
Pair<FluidStack, FluidStack> recipe = recipesForLevel.get(fluid.getFluid());
|
||||
if (recipe.getKey().isFluidEqual(fluid)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -36,8 +46,9 @@ public class DistilleryRecipes {
|
||||
|
||||
public static boolean isValidOutputLiquid(final FluidStack fluid) {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (final Map.Entry<Fluid, FluidStack> entry : recipes.get(i).entrySet()) {
|
||||
if (entry.getValue().isFluidEqual(fluid)) {
|
||||
Map<Fluid, Pair<FluidStack, FluidStack>> recipesForLevel = recipes.get(i);
|
||||
for (final Pair<FluidStack, FluidStack> recipe : recipesForLevel.values()) {
|
||||
if (recipe.getValue().isFluidEqual(fluid)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -46,6 +57,12 @@ public class DistilleryRecipes {
|
||||
}
|
||||
|
||||
public static void addRecipe(final FluidStack input, final FluidStack output, final int level) {
|
||||
recipes.get(level).put(input.getFluid(), output);
|
||||
Map<Fluid, Pair<FluidStack, FluidStack>> recipesForLevel = recipes.get(level);
|
||||
recipesForLevel.put(input.getFluid(), Pair.of(input, output));
|
||||
}
|
||||
|
||||
public static Collection<Pair<FluidStack, FluidStack>> getRecipes(int level) {
|
||||
Map<Fluid, Pair<FluidStack, FluidStack>> recipesForLevel = recipes.get(level);
|
||||
return Collections.unmodifiableCollection(recipesForLevel.values());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user