Refactor Brewing Recipes

This commit is contained in:
mezz committed 2017-01-22 21:51:59 -08:00
1 parent f0d8d6b89d
commit 427f030110
21 files changed
+753 -632

No files matched your search

@@ -12,6 +12,7 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidTank;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -108,6 +109,7 @@ public class MachineUtil {
return this.getTank(tankInput).getFluidAmount() == 0;
}
@Nullable
public FluidStack getFluid(final int tankInput) {
return (this.getTank(tankInput).getFluid() == null) ? null : this.getTank(tankInput).getFluid();
}
@@ -0,0 +1,39 @@
package binnie.core.util;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
public class OreDictionaryUtil {
private OreDictionaryUtil() {
}
public static List<ItemStack> getOres(int oreId) {
String oreName = OreDictionary.getOreName(oreId);
if (OreDictionary.doesOreNameExist(oreName)) {
return OreDictionary.getOres(oreName);
} else {
return Collections.emptyList();
}
}
public static boolean hasOreId(@Nonnull ItemStack itemStack, int oreId) {
int[] oreIds = OreDictionary.getOreIDs(itemStack);
return contains(oreIds, oreId);
}
private static boolean contains(int[] array, int value) {
for (int arrayValue : array) {
if (arrayValue == value) {
return true;
}
}
return false;
}
}
@@ -12,7 +12,8 @@ import binnie.craftgui.minecraft.control.ControlProgressBase;
import binnie.craftgui.resource.Texture;
import binnie.craftgui.resource.minecraft.StandardTexture;
import binnie.extratrees.core.ExtraTreeTexture;
import binnie.extratrees.machines.Brewery;
import binnie.extratrees.machines.brewery.BreweryLogic;
import binnie.extratrees.machines.brewery.BreweryRecipes;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
@@ -26,28 +27,28 @@ public class ControlBreweryProgress extends ControlProgressBase {
@Override
public void onRenderBackground() {
CraftGUI.Render.texture(ControlBreweryProgress.Brewery, new IPoint(0.0f, 0.0f));
final Brewery.ComponentBreweryLogic logic = Machine.getInterface(Brewery.ComponentBreweryLogic.class, Window.get(this).getInventory());
if (logic == null || logic.currentCrafting == null || logic.currentCrafting.currentInput == null) {
final BreweryLogic logic = Machine.getInterface(BreweryLogic.class, Window.get(this).getInventory());
if (logic == null || logic.currentCrafting == null || logic.currentCrafting.inputFluid == null) {
return;
}
final int fermentedHeight = (int) (32.0f * logic.getProgress() / 100.0f);
CraftGUI.Render.limitArea(new IArea(new IPoint(1.0f, 6.0f).add(this.getAbsolutePosition()), new IPoint(32.0f, 32 - fermentedHeight)));
GL11.glEnable(3089);
this.renderFluid(logic.currentCrafting.currentInput, new IPoint(1.0f, 6.0f));
this.renderFluid(logic.currentCrafting.currentInput, new IPoint(17.0f, 6.0f));
this.renderFluid(logic.currentCrafting.currentInput, new IPoint(1.0f, 22.0f));
this.renderFluid(logic.currentCrafting.currentInput, new IPoint(17.0f, 22.0f));
this.renderFluid(logic.currentCrafting.inputFluid, new IPoint(1.0f, 6.0f));
this.renderFluid(logic.currentCrafting.inputFluid, new IPoint(17.0f, 6.0f));
this.renderFluid(logic.currentCrafting.inputFluid, new IPoint(1.0f, 22.0f));
this.renderFluid(logic.currentCrafting.inputFluid, new IPoint(17.0f, 22.0f));
GL11.glDisable(3089);
CraftGUI.Render.limitArea(new IArea(new IPoint(1.0f, 38 - fermentedHeight).add(this.getAbsolutePosition()), new IPoint(32.0f, fermentedHeight)));
GL11.glEnable(3089);
this.renderFluid(binnie.extratrees.machines.Brewery.getOutput(logic.currentCrafting), new IPoint(1.0f, 6.0f));
this.renderFluid(binnie.extratrees.machines.Brewery.getOutput(logic.currentCrafting), new IPoint(17.0f, 6.0f));
this.renderFluid(binnie.extratrees.machines.Brewery.getOutput(logic.currentCrafting), new IPoint(1.0f, 22.0f));
this.renderFluid(binnie.extratrees.machines.Brewery.getOutput(logic.currentCrafting), new IPoint(17.0f, 22.0f));
this.renderFluid(BreweryRecipes.getOutput(logic.currentCrafting), new IPoint(1.0f, 6.0f));
this.renderFluid(BreweryRecipes.getOutput(logic.currentCrafting), new IPoint(17.0f, 6.0f));
this.renderFluid(BreweryRecipes.getOutput(logic.currentCrafting), new IPoint(1.0f, 22.0f));
this.renderFluid(BreweryRecipes.getOutput(logic.currentCrafting), new IPoint(17.0f, 22.0f));
GL11.glDisable(3089);
final ItemStackSet stacks = new ItemStackSet();
Collections.addAll(stacks, logic.currentCrafting.inputs);
stacks.add(logic.currentCrafting.ingr);
Collections.addAll(stacks, logic.currentCrafting.inputGrains);
stacks.add(logic.currentCrafting.ingredient);
int x = 1;
int y = 6;
for (final ItemStack stack : stacks) {
@@ -11,7 +11,7 @@ import binnie.craftgui.minecraft.control.ControlPlayerInventory;
import binnie.craftgui.minecraft.control.ControlSlot;
import binnie.craftgui.minecraft.control.ControlSlotArray;
import binnie.extratrees.ExtraTrees;
import binnie.extratrees.machines.Brewery;
import binnie.extratrees.machines.brewery.BreweryMachine;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraftforge.fml.relauncher.Side;
@@ -34,14 +34,14 @@ public class WindowBrewery extends Window {
@Override
public void initialiseClient() {
this.setTitle(Machine.getMachine(this.getInventory()).getPackage().getDisplayName());
new ControlSlotArray(this, 42, 32, 1, 3).create(Brewery.slotRecipeGrains);
new ControlSlot(this, 16.0f, 41.0f).assign(Brewery.slotRecipeInput);
new ControlSlot(this, 105.0f, 77.0f).assign(Brewery.slotRecipeYeast);
new ControlLiquidTank(this, 76, 32).setTankID(Brewery.tankInput);
new ControlLiquidTank(this, 162, 32).setTankID(Brewery.tankOutput);
new ControlSlotArray(this, 42, 32, 1, 3).create(BreweryMachine.SLOT_RECIPE_GRAINS);
new ControlSlot(this, 16.0f, 41.0f).assign(BreweryMachine.SLOT_RECIPE_INPUT);
new ControlSlot(this, 105.0f, 77.0f).assign(BreweryMachine.SLOT_YEAST);
new ControlLiquidTank(this, 76, 32).setTankID(BreweryMachine.TANK_INPUT);
new ControlLiquidTank(this, 162, 32).setTankID(BreweryMachine.TANK_OUTPUT);
new ControlEnergyBar(this, 196, 32, 16, 60, Position.Bottom);
new ControlBreweryProgress(this, 110.0f, 32.0f);
new ControlSlotArray(this, (int) (this.getSize().x() / 2.0f - 81.0f), 104, 9, 1).create(Brewery.slotInventory);
new ControlSlotArray(this, (int) (this.getSize().x() / 2.0f - 81.0f), 104, 9, 1).create(BreweryMachine.SLOTS_INVENTORY);
new ControlPlayerInventory(this);
new ControlErrorState(this, 133.0f, 79.0f);
}
@@ -9,8 +9,10 @@ import binnie.extratrees.ExtraTrees;
import binnie.extratrees.alcohol.drink.DrinkLiquid;
import binnie.extratrees.alcohol.drink.DrinkManager;
import binnie.extratrees.alcohol.drink.ItemDrink;
import binnie.extratrees.item.ExtraTreeItems;
import binnie.extratrees.item.Food;
import binnie.extratrees.machines.Brewery;
import binnie.extratrees.machines.brewery.BrewedGrainRecipe;
import binnie.extratrees.machines.brewery.BreweryRecipes;
import binnie.extratrees.machines.Distillery;
import binnie.extratrees.machines.fruitpress.FruitPressRecipes;
import forestry.api.recipes.ISqueezerRecipe;
@@ -69,19 +71,16 @@ public class ModuleAlcohol implements IInitializable {
}
for (final ItemStack stack : ores) {
for (final ISqueezerRecipe entry : RecipeManagers.squeezerManager.recipes()) {
try {
final ItemStack input = entry.getResources()[0];
final FluidStack output = entry.getFluidOutput();
if (!ItemStack.areItemStacksEqual(stack, input) && !OreDictionary.itemMatches(input, stack, true)) {
continue;
}
int amount = output.amount;
if (Objects.equals(output.getFluid().getName(), "seedoil")) {
amount *= 2;
}
FruitPressRecipes.addRecipe(stack, juice.get(amount));
} catch (Exception ex) {
final ItemStack input = entry.getResources()[0];
final FluidStack output = entry.getFluidOutput();
if (!ItemStack.areItemStacksEqual(stack, input) && !OreDictionary.itemMatches(input, stack, true)) {
continue;
}
int amount = output.amount;
if (Objects.equals(output.getFluid().getName(), "seedoil")) {
amount *= 2;
}
FruitPressRecipes.addRecipe(stack, juice.get(amount));
}
}
}
@@ -89,11 +88,25 @@ public class ModuleAlcohol implements IInitializable {
for (final String fermentLiquid : alcohol.fermentationLiquid) {
final FluidStack fluid = Binnie.Liquid.getFluidStack(fermentLiquid, 5);
if (fluid != null) {
Brewery.addRecipe(fluid, alcohol.get(5));
BreweryRecipes.addRecipe(fluid, alcohol.get(5));
}
}
}
Brewery.addBeerAndMashRecipes();
BreweryRecipes.addRecipes(
new BrewedGrainRecipe(Alcohol.Ale, BreweryRecipes.GRAIN_BARLEY, BreweryRecipes.HOPS),
new BrewedGrainRecipe(Alcohol.Lager, BreweryRecipes.GRAIN_BARLEY, BreweryRecipes.HOPS, ExtraTreeItems.LagerYeast.get(1)),
new BrewedGrainRecipe(Alcohol.Stout, BreweryRecipes.GRAIN_ROASTED, BreweryRecipes.HOPS),
new BrewedGrainRecipe(Alcohol.CornBeer, BreweryRecipes.GRAIN_CORN, BreweryRecipes.HOPS),
new BrewedGrainRecipe(Alcohol.RyeBeer, BreweryRecipes.GRAIN_RYE, BreweryRecipes.HOPS),
new BrewedGrainRecipe(Alcohol.WheatBeer, BreweryRecipes.GRAIN_WHEAT, BreweryRecipes.HOPS),
new BrewedGrainRecipe(Alcohol.Barley, BreweryRecipes.GRAIN_BARLEY),
new BrewedGrainRecipe(Alcohol.Corn, BreweryRecipes.GRAIN_CORN),
new BrewedGrainRecipe(Alcohol.Rye, BreweryRecipes.GRAIN_RYE),
new BrewedGrainRecipe(Alcohol.Wheat, BreweryRecipes.GRAIN_WHEAT)
);
this.addDistillery(Alcohol.Apple, Spirit.AppleBrandy, Spirit.AppleLiquor, Spirit.NeutralSpirit);
this.addDistillery(Alcohol.Pear, Spirit.PearBrandy, Spirit.PearLiquor, Spirit.NeutralSpirit);
this.addDistillery(Alcohol.Apricot, Spirit.ApricotBrandy, Spirit.ApricotLiquor, Spirit.NeutralSpirit);
@@ -1,583 +0,0 @@
package binnie.extratrees.machines;
import binnie.Binnie;
import binnie.core.liquid.IFluidType;
import binnie.core.machines.Machine;
import binnie.core.machines.TileEntityMachine;
import binnie.core.machines.inventory.ComponentInventorySlots;
import binnie.core.machines.inventory.ComponentTankContainer;
import binnie.core.machines.inventory.InventorySlot;
import binnie.core.machines.inventory.MachineSide;
import binnie.core.machines.inventory.SlotValidator;
import binnie.core.machines.inventory.TankValidator;
import binnie.core.machines.network.INetwork;
import binnie.core.machines.power.ComponentPowerReceptor;
import binnie.core.machines.power.ComponentProcessSetCost;
import binnie.core.machines.power.ErrorState;
import binnie.core.machines.power.IProcess;
import binnie.craftgui.minecraft.IMachineInformation;
import binnie.extratrees.alcohol.Alcohol;
import binnie.extratrees.core.ExtraTreeTexture;
import binnie.extratrees.core.ExtraTreesGUID;
import binnie.extratrees.item.ExtraTreeItems;
import forestry.api.core.INbtReadable;
import forestry.api.core.INbtWritable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.oredict.OreDictionary;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Brewery {
public static int[] slotRecipeGrains = new int[]{0, 1, 2};
public static int slotRecipeInput = 3;
public static int slotRecipeYeast = 4;
public static int[] slotInventory = new int[]{5, 6, 7, 8, 9, 10, 11, 12, 13};
public static int tankInput = 0;
public static int tankOutput = 1;
private static List<IBreweryRecipe> recipes = new ArrayList<>();
public static boolean isValidGrain(final ItemStack itemstack) {
for (final IBreweryRecipe recipe : Brewery.recipes) {
for (final ItemStack ingredient : recipe.getGrains()) {
if (ingredient.isItemEqual(itemstack)) {
return true;
}
}
}
return false;
}
public static boolean isValidYeast(final ItemStack itemstack) {
for (final IBreweryRecipe recipe : Brewery.recipes) {
for (final ItemStack ingredient : recipe.getYeasts()) {
if (ingredient.isItemEqual(itemstack)) {
return true;
}
}
}
return false;
}
public static FluidStack getOutput(final FluidStack stack) {
final BreweryCrafting crafting = new BreweryCrafting(stack, null, null, null);
for (final IBreweryRecipe recipe : Brewery.recipes) {
if (recipe.getOutput(crafting) != null) {
return recipe.getOutput(crafting);
}
}
return null;
}
@Nullable
public static FluidStack getOutput(final BreweryCrafting crafting) {
if (crafting.currentInput != null && crafting.yeast != null) {
for (final IBreweryRecipe recipe : Brewery.recipes) {
if (recipe.getOutput(crafting) != null) {
return recipe.getOutput(crafting);
}
}
}
return null;
}
public static boolean isValidIngredient(final ItemStack itemstack) {
for (final IBreweryRecipe recipe : Brewery.recipes) {
for (final ItemStack ingr : recipe.getIngredient()) {
if (ingr.isItemEqual(itemstack)) {
return true;
}
}
}
return false;
}
public static boolean isValidInputLiquid(final FluidStack fluid) {
for (final IBreweryRecipe recipe : Brewery.recipes) {
for (final FluidStack ingr : recipe.getInput()) {
if (ingr.isFluidEqual(fluid)) {
return true;
}
}
}
return false;
}
public static boolean isValidOutputLiquid(final FluidStack fluid) {
for (final IBreweryRecipe recipe : Brewery.recipes) {
for (final FluidStack ingr : recipe.getOutput()) {
if (ingr.isFluidEqual(fluid)) {
return true;
}
}
}
return false;
}
public static void addRecipe(final FluidStack input, final FluidStack output) {
Brewery.recipes.add(new BreweryRecipe(input, output));
}
public static void addBeerAndMashRecipes() {
Brewery.recipes.add(new BeerRecipe());
}
public static class PackageBrewery extends ExtraTreeMachine.PackageExtraTreeMachine implements IMachineInformation {
public PackageBrewery() {
super("brewery", ExtraTreeTexture.breweryTexture, true);
}
@Override
public void createMachine(final Machine machine) {
new ExtraTreeMachine.ComponentExtraTreeGUI(machine, ExtraTreesGUID.Brewery);
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
inventory.addSlotArray(Brewery.slotRecipeGrains, "grain");
for (final InventorySlot slot : inventory.getSlots(Brewery.slotRecipeGrains)) {
slot.setValidator(new SlotValidatorBreweryGrain());
slot.setType(InventorySlot.Type.Recipe);
}
inventory.addSlotArray(Brewery.slotInventory, "inventory");
for (final InventorySlot slot : inventory.getSlots(Brewery.slotInventory)) {
slot.forbidExtraction();
}
inventory.addSlot(Brewery.slotRecipeYeast, "yeast");
inventory.getSlot(Brewery.slotRecipeYeast).setValidator(new SlotValidatorYeast());
inventory.getSlot(Brewery.slotRecipeYeast).setType(InventorySlot.Type.Recipe);
inventory.addSlot(Brewery.slotRecipeInput, "ingredient");
inventory.getSlot(Brewery.slotRecipeInput).setValidator(new SlotValidatorBreweryIngredient());
inventory.getSlot(Brewery.slotRecipeInput).setType(InventorySlot.Type.Recipe);
final ComponentTankContainer tanks = new ComponentTankContainer(machine);
tanks.addTank(Brewery.tankInput, "input", 5000);
tanks.getTankSlot(Brewery.tankInput).setValidator(new TankValidatorFermentInput());
tanks.getTankSlot(Brewery.tankInput).setOutputSides(MachineSide.TopAndBottom);
tanks.addTank(Brewery.tankOutput, "output", 5000);
tanks.getTankSlot(Brewery.tankOutput).setValidator(new TankValidatorFermentOutput());
tanks.getTankSlot(Brewery.tankOutput).forbidInsertion();
tanks.getTankSlot(Brewery.tankOutput).setOutputSides(MachineSide.Sides);
new ComponentPowerReceptor(machine);
new ComponentBreweryLogic(machine);
}
@Override
public TileEntity createTileEntity() {
return new TileEntityMachine(this);
}
@Override
public void register() {
}
}
public static class BreweryCrafting implements INbtWritable, INbtReadable {
public FluidStack currentInput;
public ItemStack[] inputs;
public ItemStack ingr;
public ItemStack yeast;
public BreweryCrafting(final FluidStack currentInput, final ItemStack ingr, final ItemStack[] inputs, final ItemStack yeast) {
this.currentInput = currentInput;
this.inputs = ((inputs == null) ? new ItemStack[3] : inputs);
this.ingr = ingr;
this.yeast = yeast;
}
public BreweryCrafting(final NBTTagCompound nbt) {
this.readFromNBT(nbt);
}
@Override
public void readFromNBT(final NBTTagCompound nbt) {
this.currentInput = FluidStack.loadFluidStackFromNBT(nbt.getCompoundTag("fluid"));
this.ingr = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("ingr"));
(this.inputs = new ItemStack[3])[0] = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("in1"));
this.inputs[1] = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("in2"));
this.inputs[2] = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("in3"));
this.yeast = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("yeast"));
}
@Override
public NBTTagCompound writeToNBT(final NBTTagCompound nbt) {
final NBTTagCompound fluidTag = new NBTTagCompound();
this.currentInput.writeToNBT(fluidTag);
nbt.setTag("fluid", fluidTag);
nbt.setTag("ingr", this.getNBT(this.ingr));
nbt.setTag("in1", this.getNBT(this.inputs[0]));
nbt.setTag("in2", this.getNBT(this.inputs[1]));
nbt.setTag("in3", this.getNBT(this.inputs[2]));
nbt.setTag("yeast", this.getNBT(this.yeast));
return nbt;
}
private NBTTagCompound getNBT(final ItemStack ingr) {
if (ingr == null) {
return new NBTTagCompound();
}
final NBTTagCompound nbt = new NBTTagCompound();
ingr.writeToNBT(nbt);
return nbt;
}
}
public static class ComponentBreweryLogic extends ComponentProcessSetCost implements IProcess, INetwork.GuiNBT {
public BreweryCrafting currentCrafting;
public ComponentBreweryLogic(final Machine machine) {
super(machine, 16000, 800);
this.currentCrafting = null;
}
@Override
public ErrorState canWork() {
if (this.getUtil().isTankEmpty(Brewery.tankInput) && this.currentCrafting == null) {
return new ErrorState.InsufficientLiquid("No Input Liquid", Brewery.tankInput);
}
if (Brewery.getOutput(this.getInputCrafting()) == null && this.currentCrafting == null) {
return new ErrorState("No Recipe", "Brewing cannot occur with these ingredients");
}
if (!this.getUtil().hasIngredients(new int[]{0, 1, 2, 3, 4}, Brewery.slotInventory) && this.currentCrafting == null) {
return new ErrorState("Insufficient Ingredients", "Not enough ingredients for Brewing");
}
return super.canWork();
}
private BreweryCrafting getInputCrafting() {
return new BreweryCrafting(this.getUtil().getFluid(Brewery.tankInput), this.getUtil().getStack(Brewery.slotRecipeInput), this.getUtil().getStacks(Brewery.slotRecipeGrains), this.getUtil().getStack(Brewery.slotRecipeYeast));
}
@Override
public ErrorState canProgress() {
if (this.currentCrafting == null) {
return new ErrorState("Brewery Empty", "No liquid in Brewery");
}
if (!this.getUtil().spaceInTank(Brewery.tankOutput, 1000)) {
return new ErrorState.TankSpace("No Space for Fermented Liquid", Brewery.tankOutput);
}
if (this.getUtil().getFluid(Brewery.tankOutput) != null && !this.getUtil().getFluid(Brewery.tankOutput).isFluidEqual(Brewery.getOutput(this.currentCrafting))) {
return new ErrorState.TankSpace("Different fluid in tank", Brewery.tankOutput);
}
return super.canProgress();
}
@Override
protected void onFinishTask() {
FluidStack output = Brewery.getOutput(this.currentCrafting);
if (output != null) {
output = output.copy();
output.amount = 1000;
this.getUtil().fillTank(Brewery.tankOutput, output);
}
}
@Override
public void onUpdate() {
super.onUpdate();
if (this.canWork() == null && this.currentCrafting == null && this.getUtil().getTank(Brewery.tankInput).getFluidAmount() >= 1000) {
final FluidStack stack = this.getUtil().drainTank(Brewery.tankInput, 1000);
this.currentCrafting = this.getInputCrafting();
this.currentCrafting.currentInput = stack;
}
}
@Override
public void sendGuiNBT(final Map<String, NBTTagCompound> data) {
final NBTTagCompound nbt = new NBTTagCompound();
if (this.currentCrafting == null) {
nbt.setBoolean("null", true);
} else {
this.currentCrafting.writeToNBT(nbt);
}
data.put("brewery-recipe", nbt);
}
@Override
public void recieveGuiNBT(final Side side, final EntityPlayer player, final String name, final NBTTagCompound nbt) {
if (name.equals("brewery-recipe")) {
if (nbt.getBoolean("null")) {
this.currentCrafting = null;
} else {
this.currentCrafting = new BreweryCrafting(nbt);
}
}
}
@Override
public String getTooltip() {
if (this.currentCrafting == null) {
return "Empty";
}
FluidStack output = Brewery.getOutput(this.currentCrafting);
if (output == null) {
return "Empty";
}
return "Creating " + output.getFluid().getLocalizedName(output);
}
}
public static class SlotValidatorBreweryGrain extends SlotValidator {
public SlotValidatorBreweryGrain() {
super(SlotValidator.IconBlock);
}
@Override
public boolean isValid(final ItemStack itemStack) {
return Brewery.isValidGrain(itemStack);
}
@Override
public String getTooltip() {
return "Brewing Grains";
}
}
public static class SlotValidatorBreweryIngredient extends SlotValidator {
public SlotValidatorBreweryIngredient() {
super(SlotValidator.IconBlock);
}
@Override
public boolean isValid(final ItemStack itemStack) {
return Brewery.isValidIngredient(itemStack);
}
@Override
public String getTooltip() {
return "Brewing Ingredient";
}
}
public static class SlotValidatorYeast extends SlotValidator {
public SlotValidatorYeast() {
super(SlotValidator.IconBlock);
}
@Override
public boolean isValid(final ItemStack itemStack) {
return Brewery.isValidYeast(itemStack);
}
@Override
public String getTooltip() {
return "Yeast";
}
}
public static class TankValidatorFermentInput extends TankValidator {
@Override
public boolean isValid(final FluidStack itemStack) {
return Brewery.isValidInputLiquid(itemStack);
}
@Override
public String getTooltip() {
return "Fermentable Liquids";
}
}
public static class TankValidatorFermentOutput extends TankValidator {
@Override
public boolean isValid(final FluidStack itemStack) {
return Brewery.isValidOutputLiquid(itemStack);
}
@Override
public String getTooltip() {
return "Fermented Liquids";
}
}
public static class BreweryRecipe implements IBreweryRecipe {
FluidStack input;
ItemStack specificYeast;
FluidStack output;
public BreweryRecipe(final FluidStack input, final FluidStack output) {
this(input, null, output);
}
public BreweryRecipe(final FluidStack input, final ItemStack specificYeast, final FluidStack output) {
this.input = input;
this.specificYeast = specificYeast;
this.output = output;
}
@Override
public FluidStack getOutput(final BreweryCrafting crafting) {
if (this.specificYeast != null && !this.specificYeast.isItemEqual(crafting.yeast)) {
return null;
}
if (this.input.isFluidEqual(crafting.currentInput)) {
return this.output;
}
return null;
}
@Override
public FluidStack[] getInput() {
return new FluidStack[]{this.input};
}
@Override
public FluidStack[] getOutput() {
return new FluidStack[0];
}
@Override
public ItemStack[] getGrains() {
return new ItemStack[0];
}
@Override
public ItemStack[] getIngredient() {
return new ItemStack[0];
}
@Override
public ItemStack[] getYeasts() {
return new ItemStack[]{ExtraTreeItems.Yeast.get(1)};
}
}
public static class BeerRecipe implements IBreweryRecipe {
Map<ItemStack, String> grainCrops;
List<FluidStack> outputs;
static String barley = "seedBarley";
static String wheat = "seedWheat";
static String rye = "seedRye";
static String corn = "seedCorn";
static String roasted = "seedRoasted";
String[] grains;
FluidStack water;
ItemStack hops;
public BeerRecipe() {
this.grainCrops = new HashMap<>();
this.outputs = new ArrayList<>();
this.grains = new String[]{BeerRecipe.barley, BeerRecipe.wheat, BeerRecipe.rye, BeerRecipe.corn, BeerRecipe.roasted};
for (final String grainType : this.grains) {
for (final ItemStack stack : OreDictionary.getOres(grainType)) {
this.grainCrops.put(stack, grainType);
}
}
this.water = Binnie.Liquid.getFluidStack("water", 5);
this.hops = OreDictionary.getOres("cropHops").get(0);
this.add(Alcohol.Ale);
this.add(Alcohol.Lager);
this.add(Alcohol.Stout);
this.add(Alcohol.CornBeer);
this.add(Alcohol.RyeBeer);
this.add(Alcohol.WheatBeer);
this.add(Alcohol.Barley);
this.add(Alcohol.Corn);
this.add(Alcohol.Rye);
this.add(Alcohol.Wheat);
}
private void add(final IFluidType fluid) {
this.outputs.add(fluid.get(1));
}
@Override
public FluidStack getOutput(final BreweryCrafting crafting) {
if (!crafting.currentInput.isFluidEqual(this.water)) {
return null;
}
int roasted = 0;
int barley = 0;
int wheat = 0;
int rye = 0;
int corn = 0;
for (final ItemStack stack : crafting.inputs) {
if (stack == null) {
return null;
}
String name = "";
for (final Map.Entry<ItemStack, String> entry : this.grainCrops.entrySet()) {
if (entry.getKey().isItemEqual(stack)) {
name = entry.getValue();
break;
}
}
if (name.isEmpty()) {
return null;
}
if (name.equals(BeerRecipe.roasted)) {
++roasted;
}
if (name.equals(BeerRecipe.barley)) {
++barley;
}
if (name.equals(BeerRecipe.wheat)) {
++wheat;
}
if (name.equals(BeerRecipe.rye)) {
++rye;
}
if (name.equals(BeerRecipe.corn)) {
++corn;
}
}
final boolean isBeer = crafting.ingr != null;
final boolean isLager = crafting.yeast.isItemEqual(ExtraTreeItems.LagerYeast.get(1));
if (roasted >= 2 && isBeer) {
return Alcohol.Stout.get(5);
}
if (wheat >= 2) {
return isBeer ? Alcohol.WheatBeer.get(5) : Alcohol.Wheat.get(5);
}
if (rye >= 2) {
return isBeer ? Alcohol.RyeBeer.get(5) : Alcohol.Rye.get(5);
}
if (corn >= 2) {
return isBeer ? Alcohol.CornBeer.get(5) : Alcohol.Corn.get(5);
}
return isBeer ? (isLager ? Alcohol.Lager.get(5) : Alcohol.Ale.get(5)) : Alcohol.Barley.get(5);
}
@Override
public FluidStack[] getInput() {
return new FluidStack[]{this.water};
}
@Override
public FluidStack[] getOutput() {
return this.outputs.toArray(new FluidStack[0]);
}
@Override
public ItemStack[] getGrains() {
return this.grainCrops.keySet().toArray(new ItemStack[0]);
}
@Override
public ItemStack[] getIngredient() {
return new ItemStack[]{this.hops};
}
@Override
public ItemStack[] getYeasts() {
return new ItemStack[]{ExtraTreeItems.Yeast.get(1), ExtraTreeItems.LagerYeast.get(1)};
}
}
private interface IBreweryRecipe {
FluidStack getOutput(final BreweryCrafting p0);
FluidStack[] getInput();
FluidStack[] getOutput();
ItemStack[] getGrains();
ItemStack[] getIngredient();
ItemStack[] getYeasts();
}
}
@@ -12,6 +12,7 @@ import binnie.core.resource.BinnieResource;
import binnie.core.resource.ResourceType;
import binnie.extratrees.ExtraTrees;
import binnie.extratrees.core.ExtraTreesGUID;
import binnie.extratrees.machines.brewery.BreweryMachine;
import binnie.extratrees.machines.lumbermill.LumbermillMachine;
import binnie.extratrees.machines.fruitpress.FruitPressMachine;
import net.minecraft.entity.player.EntityPlayer;
@@ -26,7 +27,7 @@ public enum ExtraTreeMachine implements IMachineType {
Panelworker(Designer.PackagePanelworker.class),
Nursery(Nursery.PackageNursery.class),
Press(FruitPressMachine.class),
Brewery(Brewery.PackageBrewery.class),
Brewery(BreweryMachine.class),
Distillery(Distillery.PackageDistillery.class),
Glassworker(Designer.PackageGlassworker.class),
Tileworker(Designer.PackageTileworker.class);
@@ -0,0 +1,113 @@
package binnie.extratrees.machines.brewery;
import binnie.Binnie;
import binnie.core.util.OreDictionaryUtil;
import binnie.extratrees.alcohol.Alcohol;
import binnie.extratrees.item.ExtraTreeItems;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
public class BrewedGrainRecipe implements IBreweryRecipe {
public static final FluidStack WATER = Binnie.Liquid.getFluidStack("water", 5);
private final FluidStack output;
private final int grainOreId;
@Nullable
private final Integer ingredientOreId;
private final ItemStack yeast;
public BrewedGrainRecipe(Alcohol output, int grainOreId) {
this(output, grainOreId, null, null);
}
public BrewedGrainRecipe(Alcohol output, int grainOreId, Integer ingredientOreId) {
this(output, grainOreId, ingredientOreId, null);
}
public BrewedGrainRecipe(Alcohol output, int grainOreId, @Nullable Integer ingredientOreId, @Nullable ItemStack specificYeast) {
this.output = output.get(5);
this.grainOreId = grainOreId;
this.ingredientOreId = ingredientOreId;
if (specificYeast != null) {
this.yeast = specificYeast;
} else {
this.yeast = ExtraTreeItems.Yeast.get(1);
}
}
@Override
public FluidStack getOutput(final BreweryCrafting crafting) {
if (!WATER.isFluidEqual(crafting.inputFluid)) {
return null;
}
if (!isIngredient(crafting.ingredient)) {
return null;
}
if (!yeast.isItemEqual(crafting.yeast)) {
return null;
}
int grainCount = 0;
for (final ItemStack stack : crafting.inputGrains) {
if (stack == null) {
return null;
}
if (isGrain(stack)) {
grainCount++;
}
}
if (grainCount >= 2) {
return output.copy();
} else {
return null;
}
}
@Override
public FluidStack getInput() {
return WATER;
}
@Override
public FluidStack getOutput() {
return this.output;
}
@Override
public boolean isIngredient(@Nullable ItemStack itemstack) {
if (itemstack == null) {
return ingredientOreId == null;
}
return ingredientOreId != null && OreDictionaryUtil.hasOreId(itemstack, ingredientOreId);
}
public List<ItemStack> getIngredients() {
if (ingredientOreId == null) {
return Collections.emptyList();
}
return OreDictionaryUtil.getOres(ingredientOreId);
}
@Override
public boolean isGrain(@Nonnull ItemStack itemStack) {
return OreDictionaryUtil.hasOreId(itemStack, grainOreId);
}
@Override
public List<ItemStack> getGrains() {
return OreDictionaryUtil.getOres(grainOreId);
}
@Override
public ItemStack getYeast() {
return yeast;
}
}
@@ -0,0 +1,66 @@
package binnie.extratrees.machines.brewery;
import forestry.api.core.INbtReadable;
import forestry.api.core.INbtWritable;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nullable;
public class BreweryCrafting implements INbtWritable, INbtReadable {
@Nullable
public FluidStack inputFluid;
public ItemStack[] inputGrains;
@Nullable
public ItemStack ingredient;
@Nullable
public ItemStack yeast;
public BreweryCrafting(@Nullable final FluidStack inputFluid, @Nullable final ItemStack ingredient, @Nullable final ItemStack[] inputGrains, final @Nullable ItemStack yeast) {
this.inputFluid = inputFluid;
this.inputGrains = ((inputGrains == null) ? new ItemStack[3] : inputGrains);
this.ingredient = ingredient;
this.yeast = yeast;
}
public BreweryCrafting(final NBTTagCompound nbt) {
this.readFromNBT(nbt);
}
@Override
public void readFromNBT(final NBTTagCompound nbt) {
this.inputFluid = FluidStack.loadFluidStackFromNBT(nbt.getCompoundTag("fluid"));
this.ingredient = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("ingr"));
this.inputGrains = new ItemStack[] {
ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("in1")),
ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("in2")),
ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("in3"))
};
this.yeast = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("yeast"));
}
@Override
public NBTTagCompound writeToNBT(final NBTTagCompound nbt) {
if (this.inputFluid != null) {
final NBTTagCompound fluidTag = new NBTTagCompound();
this.inputFluid.writeToNBT(fluidTag);
nbt.setTag("fluid", fluidTag);
}
nbt.setTag("ingr", this.getNBT(this.ingredient));
nbt.setTag("in1", this.getNBT(this.inputGrains[0]));
nbt.setTag("in2", this.getNBT(this.inputGrains[1]));
nbt.setTag("in3", this.getNBT(this.inputGrains[2]));
nbt.setTag("yeast", this.getNBT(this.yeast));
return nbt;
}
private NBTTagCompound getNBT(final ItemStack ingr) {
if (ingr == null) {
return new NBTTagCompound();
}
final NBTTagCompound nbt = new NBTTagCompound();
ingr.writeToNBT(nbt);
return nbt;
}
}
@@ -0,0 +1,114 @@
package binnie.extratrees.machines.brewery;
import binnie.core.machines.Machine;
import binnie.core.machines.network.INetwork;
import binnie.core.machines.power.ComponentProcessSetCost;
import binnie.core.machines.power.ErrorState;
import binnie.core.machines.power.IProcess;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.relauncher.Side;
import java.util.Map;
public class BreweryLogic extends ComponentProcessSetCost implements IProcess, INetwork.GuiNBT {
public BreweryCrafting currentCrafting;
public BreweryLogic(final Machine machine) {
super(machine, 16000, 800);
this.currentCrafting = null;
}
@Override
public ErrorState canWork() {
if (this.getUtil().isTankEmpty(BreweryMachine.TANK_INPUT) && this.currentCrafting == null) {
return new ErrorState.InsufficientLiquid("No Input Liquid", BreweryMachine.TANK_INPUT);
}
if (BreweryRecipes.getOutput(this.getInputCrafting()) == null && this.currentCrafting == null) {
return new ErrorState("No Recipe", "Brewing cannot occur with these ingredients");
}
if (!this.getUtil().hasIngredients(new int[]{0, 1, 2, 3, 4}, BreweryMachine.SLOTS_INVENTORY) && this.currentCrafting == null) {
return new ErrorState("Insufficient Ingredients", "Not enough ingredients for Brewing");
}
return super.canWork();
}
private BreweryCrafting getInputCrafting() {
FluidStack inputFluid = this.getUtil().getFluid(BreweryMachine.TANK_INPUT);
ItemStack inputIngredient = this.getUtil().getStack(BreweryMachine.SLOT_RECIPE_INPUT);
ItemStack[] inputGrains = this.getUtil().getStacks(BreweryMachine.SLOT_RECIPE_GRAINS);
ItemStack inputYeast = this.getUtil().getStack(BreweryMachine.SLOT_YEAST);
return new BreweryCrafting(inputFluid, inputIngredient, inputGrains, inputYeast);
}
@Override
public ErrorState canProgress() {
if (this.currentCrafting == null) {
return new ErrorState("Brewery Empty", "No liquid in Brewery");
}
if (!this.getUtil().spaceInTank(BreweryMachine.TANK_OUTPUT, 1000)) {
return new ErrorState.TankSpace("No Space for Fermented Liquid", BreweryMachine.TANK_OUTPUT);
}
FluidStack outputFluid = this.getUtil().getFluid(BreweryMachine.TANK_OUTPUT);
if (outputFluid != null && !outputFluid.isFluidEqual(BreweryRecipes.getOutput(this.currentCrafting))) {
return new ErrorState.TankSpace("Different fluid in tank", BreweryMachine.TANK_OUTPUT);
}
return super.canProgress();
}
@Override
protected void onFinishTask() {
FluidStack output = BreweryRecipes.getOutput(this.currentCrafting);
if (output != null) {
output = output.copy();
output.amount = 1000;
this.getUtil().fillTank(BreweryMachine.TANK_OUTPUT, output);
}
}
@Override
public void onUpdate() {
super.onUpdate();
if (this.canWork() == null && this.currentCrafting == null && this.getUtil().getTank(BreweryMachine.TANK_INPUT).getFluidAmount() >= 1000) {
final FluidStack stack = this.getUtil().drainTank(BreweryMachine.TANK_INPUT, 1000);
this.currentCrafting = this.getInputCrafting();
this.currentCrafting.inputFluid = stack;
}
}
@Override
public void sendGuiNBT(final Map<String, NBTTagCompound> data) {
final NBTTagCompound nbt = new NBTTagCompound();
if (this.currentCrafting == null) {
nbt.setBoolean("null", true);
} else {
this.currentCrafting.writeToNBT(nbt);
}
data.put("brewery-recipe", nbt);
}
@Override
public void recieveGuiNBT(final Side side, final EntityPlayer player, final String name, final NBTTagCompound nbt) {
if (name.equals("brewery-recipe")) {
if (nbt.getBoolean("null")) {
this.currentCrafting = null;
} else {
this.currentCrafting = new BreweryCrafting(nbt);
}
}
}
@Override
public String getTooltip() {
if (this.currentCrafting == null) {
return "Empty";
}
FluidStack output = BreweryRecipes.getOutput(this.currentCrafting);
if (output == null) {
return "Empty";
}
return "Creating " + output.getFluid().getLocalizedName(output);
}
}
@@ -0,0 +1,68 @@
package binnie.extratrees.machines.brewery;
import binnie.core.machines.Machine;
import binnie.core.machines.TileEntityMachine;
import binnie.core.machines.inventory.ComponentInventorySlots;
import binnie.core.machines.inventory.ComponentTankContainer;
import binnie.core.machines.inventory.InventorySlot;
import binnie.core.machines.inventory.MachineSide;
import binnie.core.machines.power.ComponentPowerReceptor;
import binnie.craftgui.minecraft.IMachineInformation;
import binnie.extratrees.core.ExtraTreeTexture;
import binnie.extratrees.core.ExtraTreesGUID;
import binnie.extratrees.machines.ExtraTreeMachine;
import net.minecraft.tileentity.TileEntity;
public class BreweryMachine extends ExtraTreeMachine.PackageExtraTreeMachine implements IMachineInformation {
public static final int TANK_INPUT = 0;
public static final int TANK_OUTPUT = 1;
public static final int[] SLOT_RECIPE_GRAINS = new int[]{0, 1, 2};
public static final int SLOT_RECIPE_INPUT = 3;
public static final int SLOT_YEAST = 4;
public static final int[] SLOTS_INVENTORY = new int[]{5, 6, 7, 8, 9, 10, 11, 12, 13};
public BreweryMachine() {
super("brewery", ExtraTreeTexture.breweryTexture, true);
}
@Override
public void createMachine(final Machine machine) {
new ExtraTreeMachine.ComponentExtraTreeGUI(machine, ExtraTreesGUID.Brewery);
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
inventory.addSlotArray(SLOT_RECIPE_GRAINS, "grain");
for (final InventorySlot slot : inventory.getSlots(SLOT_RECIPE_GRAINS)) {
slot.setValidator(new SlotValidatorBreweryGrain());
slot.setType(InventorySlot.Type.Recipe);
}
inventory.addSlotArray(SLOTS_INVENTORY, "inventory");
for (final InventorySlot slot : inventory.getSlots(SLOTS_INVENTORY)) {
slot.forbidExtraction();
}
inventory.addSlot(SLOT_YEAST, "yeast");
inventory.getSlot(SLOT_YEAST).setValidator(new SlotValidatorBreweryYeast());
inventory.getSlot(SLOT_YEAST).setType(InventorySlot.Type.Recipe);
inventory.addSlot(SLOT_RECIPE_INPUT, "ingredient");
inventory.getSlot(SLOT_RECIPE_INPUT).setValidator(new SlotValidatorBreweryIngredient());
inventory.getSlot(SLOT_RECIPE_INPUT).setType(InventorySlot.Type.Recipe);
final ComponentTankContainer tanks = new ComponentTankContainer(machine);
tanks.addTank(TANK_INPUT, "input", 5000);
tanks.getTankSlot(TANK_INPUT).setValidator(new TankValidatorFermentInput());
tanks.getTankSlot(TANK_INPUT).setOutputSides(MachineSide.TopAndBottom);
tanks.addTank(TANK_OUTPUT, "output", 5000);
tanks.getTankSlot(TANK_OUTPUT).setValidator(new TankValidatorFermentOutput());
tanks.getTankSlot(TANK_OUTPUT).forbidInsertion();
tanks.getTankSlot(TANK_OUTPUT).setOutputSides(MachineSide.Sides);
new ComponentPowerReceptor(machine);
new BreweryLogic(machine);
}
@Override
public TileEntity createTileEntity() {
return new TileEntityMachine(this);
}
@Override
public void register() {
}
}
@@ -0,0 +1,76 @@
package binnie.extratrees.machines.brewery;
import binnie.extratrees.item.ExtraTreeItems;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
public class BreweryRecipe implements IBreweryRecipe {
private final FluidStack input;
private final FluidStack output;
private final ItemStack yeast;
public BreweryRecipe(final FluidStack input, final FluidStack output) {
this(input, output, null);
}
public BreweryRecipe(final FluidStack input, final FluidStack output, @Nullable final ItemStack specificYeast) {
this.input = input;
this.output = output;
if (specificYeast != null) {
this.yeast = specificYeast;
} else {
this.yeast = ExtraTreeItems.Yeast.get(1);
}
}
@Override
public FluidStack getOutput(final BreweryCrafting crafting) {
if (!this.yeast.isItemEqual(crafting.yeast)) {
return null;
}
if (this.input.isFluidEqual(crafting.inputFluid)) {
return this.output;
}
return null;
}
@Override
public FluidStack getInput() {
return this.input;
}
@Override
public FluidStack getOutput() {
return output;
}
@Override
public boolean isGrain(@Nonnull ItemStack itemStack) {
return false;
}
@Override
public List<ItemStack> getGrains() {
return Collections.emptyList();
}
@Override
public boolean isIngredient(@Nonnull ItemStack itemstack) {
return false;
}
@Override
public List<ItemStack> getIngredients() {
return Collections.emptyList();
}
@Override
public ItemStack getYeast() {
return yeast;
}
}
@@ -0,0 +1,103 @@
package binnie.extratrees.machines.brewery;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class BreweryRecipes {
public static final int GRAIN_BARLEY = OreDictionary.getOreID("seedBarley");
public static final int GRAIN_WHEAT = OreDictionary.getOreID("seedWheat");
public static final int GRAIN_RYE = OreDictionary.getOreID("seedRye");
public static final int GRAIN_CORN = OreDictionary.getOreID("seedCorn");
public static final int GRAIN_ROASTED = OreDictionary.getOreID("seedRoasted");
public static final int HOPS = OreDictionary.getOreID("cropHops");
private static List<IBreweryRecipe> recipes = new ArrayList<>();
public static boolean isValidGrain(final ItemStack itemstack) {
for (final IBreweryRecipe recipe : recipes) {
if (recipe.isGrain(itemstack)) {
return true;
}
}
return false;
}
public static boolean isValidYeast(final ItemStack itemstack) {
for (final IBreweryRecipe recipe : recipes) {
ItemStack yeast = recipe.getYeast();
if (yeast.isItemEqual(itemstack)) {
return true;
}
}
return false;
}
public static FluidStack getOutput(final FluidStack stack) {
final BreweryCrafting crafting = new BreweryCrafting(stack, null, null, null);
for (final IBreweryRecipe recipe : recipes) {
if (recipe.getOutput(crafting) != null) {
return recipe.getOutput(crafting);
}
}
return null;
}
@Nullable
public static FluidStack getOutput(final BreweryCrafting crafting) {
if (crafting.inputFluid != null && crafting.yeast != null) {
for (final IBreweryRecipe recipe : recipes) {
if (recipe.getOutput(crafting) != null) {
return recipe.getOutput(crafting);
}
}
}
return null;
}
public static boolean isValidIngredient(final ItemStack itemstack) {
for (final IBreweryRecipe recipe : recipes) {
if (recipe.isIngredient(itemstack)) {
return true;
}
}
return false;
}
public static boolean isValidInputLiquid(final FluidStack fluid) {
for (final IBreweryRecipe recipe : recipes) {
FluidStack input = recipe.getInput();
if (input.isFluidEqual(fluid)) {
return true;
}
}
return false;
}
public static boolean isValidOutputLiquid(final FluidStack fluid) {
for (final IBreweryRecipe recipe : recipes) {
FluidStack output = recipe.getOutput();
if (output.isFluidEqual(fluid)) {
return true;
}
}
return false;
}
public static void addRecipe(final FluidStack input, final FluidStack output) {
recipes.add(new BreweryRecipe(input, output));
}
public static void addRecipe(IBreweryRecipe recipe) {
recipes.add(recipe);
}
public static void addRecipes(IBreweryRecipe... recipes) {
Collections.addAll(BreweryRecipes.recipes, recipes);
}
}
@@ -0,0 +1,25 @@
package binnie.extratrees.machines.brewery;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nonnull;
import java.util.List;
public interface IBreweryRecipe {
FluidStack getOutput(final BreweryCrafting crafting);
FluidStack getInput();
FluidStack getOutput();
boolean isIngredient(@Nonnull ItemStack itemstack);
List<ItemStack> getIngredients();
boolean isGrain(@Nonnull ItemStack itemStack);
List<ItemStack> getGrains();
ItemStack getYeast();
}
@@ -0,0 +1,20 @@
package binnie.extratrees.machines.brewery;
import binnie.core.machines.inventory.SlotValidator;
import net.minecraft.item.ItemStack;
public class SlotValidatorBreweryGrain extends SlotValidator {
public SlotValidatorBreweryGrain() {
super(SlotValidator.IconBlock);
}
@Override
public boolean isValid(final ItemStack itemStack) {
return BreweryRecipes.isValidGrain(itemStack);
}
@Override
public String getTooltip() {
return "Brewing Grains";
}
}
@@ -0,0 +1,20 @@
package binnie.extratrees.machines.brewery;
import binnie.core.machines.inventory.SlotValidator;
import net.minecraft.item.ItemStack;
public class SlotValidatorBreweryIngredient extends SlotValidator {
public SlotValidatorBreweryIngredient() {
super(SlotValidator.IconBlock);
}
@Override
public boolean isValid(final ItemStack itemStack) {
return BreweryRecipes.isValidIngredient(itemStack);
}
@Override
public String getTooltip() {
return "Brewing Ingredient";
}
}
@@ -0,0 +1,20 @@
package binnie.extratrees.machines.brewery;
import binnie.core.machines.inventory.SlotValidator;
import net.minecraft.item.ItemStack;
public class SlotValidatorBreweryYeast extends SlotValidator {
public SlotValidatorBreweryYeast() {
super(SlotValidator.IconBlock);
}
@Override
public boolean isValid(final ItemStack itemStack) {
return BreweryRecipes.isValidYeast(itemStack);
}
@Override
public String getTooltip() {
return "Yeast";
}
}
@@ -0,0 +1,16 @@
package binnie.extratrees.machines.brewery;
import binnie.core.machines.inventory.TankValidator;
import net.minecraftforge.fluids.FluidStack;
public class TankValidatorFermentInput extends TankValidator {
@Override
public boolean isValid(final FluidStack itemStack) {
return BreweryRecipes.isValidInputLiquid(itemStack);
}
@Override
public String getTooltip() {
return "Fermentable Liquids";
}
}
@@ -0,0 +1,16 @@
package binnie.extratrees.machines.brewery;
import binnie.core.machines.inventory.TankValidator;
import net.minecraftforge.fluids.FluidStack;
public class TankValidatorFermentOutput extends TankValidator {
@Override
public boolean isValid(final FluidStack itemStack) {
return BreweryRecipes.isValidOutputLiquid(itemStack);
}
@Override
public String getTooltip() {
return "Fermented Liquids";
}
}
@@ -1,5 +1,6 @@
package binnie.extratrees.machines.lumbermill;
import binnie.core.util.OreDictionaryUtil;
import binnie.core.util.FakeCraftingWorld;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
@@ -66,8 +67,7 @@ public class LumbermillRecipes {
try {
ItemStack recipeOutput = craftingManager.findMatchingRecipe(fakeCraftingInventory, FakeCraftingWorld.getInstance());
if (recipeOutput != null) {
int[] outputOreIds = OreDictionary.getOreIDs(recipeOutput);
if (contains(outputOreIds, plankOreId)) {
if (OreDictionaryUtil.hasOreId(recipeOutput, plankOreId)) {
Item logItem = logCopy.getItem();
ItemStack outputCopy = recipeOutput.copy();
outputCopy.stackSize = (int) Math.ceil(outputCopy.stackSize * 1.5f); // turns stack of 4 up to 6
@@ -80,15 +80,6 @@ public class LumbermillRecipes {
}
}
private static boolean contains(int[] array, int value) {
for (int arrayValue : array) {
if (arrayValue == value) {
return true;
}
}
return false;
}
private static class FakeCraftingHandler extends Container {
@Override
public void onCraftMatrixChanged(IInventory inventoryIn) {
@@ -6,7 +6,7 @@ import binnie.craftgui.controls.ControlTextCentered;
import binnie.craftgui.core.IWidget;
import binnie.craftgui.core.geometry.IArea;
import binnie.craftgui.minecraft.control.ControlItemDisplay;
import binnie.extratrees.machines.Brewery;
import binnie.extratrees.machines.brewery.BreweryRecipes;
import binnie.extratrees.machines.Distillery;
import binnie.extratrees.machines.fruitpress.FruitPressRecipes;
import forestry.api.recipes.ICentrifugeRecipe;
@@ -149,7 +149,7 @@ public abstract class AnalystPageProduce extends ControlAnalystPage {
protected Collection<? extends FluidStack> getAllProducts(final FluidStack stack) {
final Collection<FluidStack> fluids = new UniqueFluidStackSet();
fluids.add(Brewery.getOutput(stack));
fluids.add(BreweryRecipes.getOutput(stack));
fluids.add(Distillery.getOutput(stack, 0));
fluids.add(Distillery.getOutput(stack, 1));
fluids.add(Distillery.getOutput(stack, 2));