mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-20 04:10:07 +00:00
Add Fruit Press JEI recipes
This commit is contained in:
1 parent
b6f91fe870
commit
31d7d6e76e
16 files changed
+340
-181
No files matched your search
@@ -10,7 +10,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.Press;
|
||||
import binnie.extratrees.machines.fruitpress.FruitPressRecipes;
|
||||
import binnie.extratrees.machines.fruitpress.FruitPressMachine;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -24,16 +25,16 @@ public class ControlFruitPressProgress extends ControlProgressBase {
|
||||
@Override
|
||||
public void onRenderBackground() {
|
||||
CraftGUI.Render.texture(ControlFruitPressProgress.PressSlot, new IPoint(3.0f, 52.0f));
|
||||
Slot slotFromInventory = Window.get(this).getContainer().getSlotFromInventory(Window.get(this).getInventory(), Press.slotCurrent);
|
||||
Slot slotFromInventory = Window.get(this).getContainer().getSlotFromInventory(Window.get(this).getInventory(), FruitPressMachine.SLOT_CURRENT);
|
||||
if (slotFromInventory == null) {
|
||||
return;
|
||||
}
|
||||
final ItemStack input = slotFromInventory.getStack();
|
||||
if (input == null || Press.getOutput(input) == null) {
|
||||
if (input == null || FruitPressRecipes.getOutput(input) == null) {
|
||||
return;
|
||||
}
|
||||
final Fluid fluid = Press.getOutput(input).getFluid();
|
||||
final int hex = fluid.getColor(Press.getOutput(input));
|
||||
final Fluid fluid = FruitPressRecipes.getOutput(input).getFluid();
|
||||
final int hex = fluid.getColor(FruitPressRecipes.getOutput(input));
|
||||
final int r = (hex & 0xFF0000) >> 16;
|
||||
final int g = (hex & 0xFF00) >> 8;
|
||||
final int b = hex & 0xFF;
|
||||
|
||||
@@ -12,7 +12,8 @@ import binnie.craftgui.minecraft.control.ControlLiquidTank;
|
||||
import binnie.craftgui.minecraft.control.ControlPlayerInventory;
|
||||
import binnie.craftgui.minecraft.control.ControlSlot;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.machines.Press;
|
||||
import binnie.extratrees.machines.fruitpress.FruitPressLogic;
|
||||
import binnie.extratrees.machines.fruitpress.FruitPressMachine;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -36,13 +37,13 @@ public class WindowPress extends Window {
|
||||
@Override
|
||||
public void initialiseClient() {
|
||||
this.setTitle(Machine.getMachine(this.getInventory()).getPackage().getDisplayName());
|
||||
new ControlSlot(this, 24.0f, 52.0f).assign(Press.slotFruit);
|
||||
new ControlLiquidTank(this, 99, 32).setTankID(Press.tankWater);
|
||||
new ControlSlot(this, 24.0f, 52.0f).assign(FruitPressMachine.SLOT_FRUIT);
|
||||
new ControlLiquidTank(this, 99, 32).setTankID(FruitPressMachine.TANK_OUTPUT);
|
||||
new ControlEnergyBar(this, 154, 32, 16, 60, Position.Bottom);
|
||||
new ControlPlayerInventory(this);
|
||||
new ControlErrorState(this, 128.0f, 54.0f);
|
||||
new ControlFruitPressProgress(this, 62.0f, 24.0f);
|
||||
((Window) this.getSuperParent()).getContainer().getOrCreateSlot(InventoryType.Machine, Press.slotCurrent);
|
||||
((Window) this.getSuperParent()).getContainer().getOrCreateSlot(InventoryType.Machine, FruitPressMachine.SLOT_CURRENT);
|
||||
}
|
||||
|
||||
public static Window create(final EntityPlayer player, final IInventory inventory, final Side side) {
|
||||
@@ -51,14 +52,14 @@ public class WindowPress extends Window {
|
||||
|
||||
@Override
|
||||
public void recieveGuiNBT(final Side side, final EntityPlayer player, final String name, final NBTTagCompound action) {
|
||||
final Press.ComponentFruitPressLogic logic = Machine.getInterface(Press.ComponentFruitPressLogic.class, this.getInventory());
|
||||
final FruitPressLogic logic = Machine.getInterface(FruitPressLogic.class, this.getInventory());
|
||||
super.recieveGuiNBT(side, player, name, action);
|
||||
if (side == Side.SERVER && name.equals("fruitpress-click")) {
|
||||
if (logic.canWork() == null && (logic.canProgress() == null || logic.canProgress() instanceof ErrorState.InsufficientPower)) {
|
||||
logic.alterProgress(2.0f);
|
||||
} else if (side == Side.SERVER && name.equals("clear-fruit")) {
|
||||
logic.setProgress(0.0f);
|
||||
this.getInventory().setInventorySlotContents(Press.slotCurrent, null);
|
||||
this.getInventory().setInventorySlotContents(FruitPressMachine.SLOT_CURRENT, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import binnie.extratrees.alcohol.drink.ItemDrink;
|
||||
import binnie.extratrees.item.Food;
|
||||
import binnie.extratrees.machines.Brewery;
|
||||
import binnie.extratrees.machines.Distillery;
|
||||
import binnie.extratrees.machines.Press;
|
||||
import binnie.extratrees.machines.fruitpress.FruitPressRecipes;
|
||||
import forestry.api.recipes.ISqueezerRecipe;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -79,7 +79,7 @@ public class ModuleAlcohol implements IInitializable {
|
||||
if (Objects.equals(output.getFluid().getName(), "seedoil")) {
|
||||
amount *= 2;
|
||||
}
|
||||
Press.addRecipe(stack, juice.get(amount));
|
||||
FruitPressRecipes.addRecipe(stack, juice.get(amount));
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@ package binnie.extratrees.integration.jei;
|
||||
|
||||
import binnie.core.integration.jei.Drawables;
|
||||
import binnie.core.integration.jei.SimpleRecipeHandler;
|
||||
import binnie.extratrees.integration.jei.fruitpress.FruitPressRecipeCategory;
|
||||
import binnie.extratrees.integration.jei.fruitpress.FruitPressRecipeMaker;
|
||||
import binnie.extratrees.integration.jei.fruitpress.FruitPressRecipeWrapper;
|
||||
import binnie.extratrees.integration.jei.lumbermill.LumbermillRecipeCategory;
|
||||
import binnie.extratrees.integration.jei.lumbermill.LumbermillRecipeMaker;
|
||||
import binnie.extratrees.integration.jei.lumbermill.LumbermillRecipeWrapper;
|
||||
@@ -31,15 +34,19 @@ public class ExtraTreesJeiPlugin extends BlankModPlugin {
|
||||
ExtraTreesJeiPlugin.drawables = Drawables.getDrawables(guiHelper);
|
||||
|
||||
registry.addRecipeCategories(
|
||||
new LumbermillRecipeCategory()
|
||||
new LumbermillRecipeCategory(),
|
||||
new FruitPressRecipeCategory()
|
||||
);
|
||||
|
||||
registry.addRecipeHandlers(
|
||||
new SimpleRecipeHandler<>(LumbermillRecipeWrapper.class, RecipeUids.LUMBERMILL)
|
||||
new SimpleRecipeHandler<>(LumbermillRecipeWrapper.class, RecipeUids.LUMBERMILL),
|
||||
new SimpleRecipeHandler<>(FruitPressRecipeWrapper.class, RecipeUids.FRUIT_PRESS)
|
||||
);
|
||||
|
||||
registry.addRecipeCategoryCraftingItem(ExtraTreeMachine.Lumbermill.get(1), RecipeUids.LUMBERMILL);
|
||||
registry.addRecipeCategoryCraftingItem(ExtraTreeMachine.Press.get(1), RecipeUids.FRUIT_PRESS);
|
||||
|
||||
registry.addRecipes(LumbermillRecipeMaker.create());
|
||||
registry.addRecipes(FruitPressRecipeMaker.create());
|
||||
}
|
||||
}
|
||||
@@ -2,4 +2,5 @@ package binnie.extratrees.integration.jei;
|
||||
|
||||
public class RecipeUids {
|
||||
public static final String LUMBERMILL = "binnie.extratrees.lumbermill";
|
||||
public static final String FRUIT_PRESS = "binnie.extratrees.fruitpress";
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
package binnie.extratrees.integration.jei.fruitpress;
|
||||
|
||||
import binnie.extratrees.integration.jei.ExtraTreesJeiPlugin;
|
||||
import binnie.extratrees.integration.jei.RecipeUids;
|
||||
import binnie.extratrees.machines.fruitpress.FruitPressMachine;
|
||||
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.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.BlankRecipeCategory;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class FruitPressRecipeCategory extends BlankRecipeCategory {
|
||||
private final IDrawableAnimated arrowAnimated;
|
||||
|
||||
public FruitPressRecipeCategory() {
|
||||
this.arrowAnimated = ExtraTreesJeiPlugin.drawables.createArrowAnimated(56);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUid() {
|
||||
return RecipeUids.FRUIT_PRESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return "Fruit Press";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return ExtraTreesJeiPlugin.guiHelper.createBlankDrawable(74, 60);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(Minecraft minecraft) {
|
||||
IDrawable tank = ExtraTreesJeiPlugin.drawables.getTank();
|
||||
tank.draw(minecraft, 54, 0);
|
||||
|
||||
IDrawable arrow = ExtraTreesJeiPlugin.drawables.getArrow();
|
||||
arrow.draw(minecraft, 27, 26);
|
||||
arrowAnimated.draw(minecraft, 27, 26);
|
||||
|
||||
IDrawable slot = ExtraTreesJeiPlugin.guiHelper.getSlotDrawable();
|
||||
slot.draw(minecraft, 0, 22);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper, IIngredients ingredients) {
|
||||
IDrawable tankOverlay = ExtraTreesJeiPlugin.drawables.getTankOverlay();
|
||||
IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks();
|
||||
fluidStacks.init(FruitPressMachine.TANK_OUTPUT, false, 55, 1, 16, 58, 1000, false, tankOverlay);
|
||||
fluidStacks.set(ingredients);
|
||||
|
||||
IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks();
|
||||
itemStacks.init(0, true, 0, 22);
|
||||
itemStacks.set(ingredients);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package binnie.extratrees.integration.jei.fruitpress;
|
||||
|
||||
import binnie.extratrees.machines.fruitpress.FruitPressRecipes;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class FruitPressRecipeMaker {
|
||||
public static List<FruitPressRecipeWrapper> create() {
|
||||
List<FruitPressRecipeWrapper> recipes = new ArrayList<>();
|
||||
|
||||
Collection<Pair<ItemStack, FluidStack>> recipePairs = FruitPressRecipes.getRecipes();
|
||||
for (Pair<ItemStack, FluidStack> recipePair : recipePairs) {
|
||||
ItemStack fruit = recipePair.getKey();
|
||||
FluidStack juice = recipePair.getValue();
|
||||
recipes.add(new FruitPressRecipeWrapper(fruit, juice));
|
||||
}
|
||||
|
||||
return recipes;
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package binnie.extratrees.integration.jei.fruitpress;
|
||||
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.BlankRecipeWrapper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class FruitPressRecipeWrapper extends BlankRecipeWrapper {
|
||||
private final ItemStack input;
|
||||
private final FluidStack output;
|
||||
|
||||
public FruitPressRecipeWrapper(ItemStack input, FluidStack output) {
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getIngredients(IIngredients ingredients) {
|
||||
ingredients.setInput(ItemStack.class, input);
|
||||
ingredients.setOutput(FluidStack.class, output);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
@ParametersAreNonnullByDefault
|
||||
@FieldsAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
package binnie.extratrees.integration.jei.fruitpress;
|
||||
|
||||
import binnie.core.util.FieldsAreNonnullByDefault;
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@@ -13,6 +13,7 @@ import binnie.core.resource.ResourceType;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.core.ExtraTreesGUID;
|
||||
import binnie.extratrees.machines.lumbermill.LumbermillMachine;
|
||||
import binnie.extratrees.machines.fruitpress.FruitPressMachine;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -24,7 +25,7 @@ public enum ExtraTreeMachine implements IMachineType {
|
||||
Woodworker(Designer.PackageWoodworker.class),
|
||||
Panelworker(Designer.PackagePanelworker.class),
|
||||
Nursery(Nursery.PackageNursery.class),
|
||||
Press(Press.PackagePress.class),
|
||||
Press(FruitPressMachine.class),
|
||||
Brewery(Brewery.PackageBrewery.class),
|
||||
Distillery(Distillery.PackageDistillery.class),
|
||||
Glassworker(Designer.PackageGlassworker.class),
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
package binnie.extratrees.machines;
|
||||
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
import binnie.core.machines.inventory.ComponentTankContainer;
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
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.core.ExtraTreeTexture;
|
||||
import binnie.extratrees.core.ExtraTreesGUID;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Press {
|
||||
public static int slotFruit = 0;
|
||||
public static int slotCurrent = 1;
|
||||
public static int tankWater = 0;
|
||||
private static Map<ItemStack, FluidStack> pressRecipes = new HashMap<>();
|
||||
|
||||
public static boolean isInput(final ItemStack itemstack) {
|
||||
return getOutput(itemstack) != null;
|
||||
}
|
||||
|
||||
public static FluidStack getOutput(final ItemStack itemstack) {
|
||||
if (itemstack == null) {
|
||||
return null;
|
||||
}
|
||||
for (final Map.Entry<ItemStack, FluidStack> entry : Press.pressRecipes.entrySet()) {
|
||||
if (itemstack.isItemEqual(entry.getKey())) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void addRecipe(final ItemStack stack, final FluidStack fluid) {
|
||||
if (getOutput(stack) != null) {
|
||||
return;
|
||||
}
|
||||
Press.pressRecipes.put(stack, fluid);
|
||||
}
|
||||
|
||||
public static class PackagePress extends ExtraTreeMachine.PackageExtraTreeMachine implements IMachineInformation {
|
||||
public PackagePress() {
|
||||
super("press", ExtraTreeTexture.pressTexture, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ExtraTreeMachine.ComponentExtraTreeGUI(machine, ExtraTreesGUID.Press);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(Press.slotFruit, "input");
|
||||
inventory.getSlot(Press.slotFruit).setValidator(new SlotValidatorSqueezable());
|
||||
inventory.getSlot(Press.slotFruit).forbidExtraction();
|
||||
inventory.addSlot(Press.slotCurrent, "process");
|
||||
inventory.getSlot(Press.slotCurrent).setValidator(new SlotValidatorSqueezable());
|
||||
inventory.getSlot(Press.slotCurrent).forbidInteraction();
|
||||
final ComponentTankContainer tanks = new ComponentTankContainer(machine);
|
||||
tanks.addTank(Press.tankWater, "output", 5000);
|
||||
new ComponentPowerReceptor(machine);
|
||||
new ComponentInventoryTransfer(machine).addRestock(new int[]{Press.slotFruit}, Press.slotCurrent, 1);
|
||||
new ComponentFruitPressLogic(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
|
||||
public static class ComponentFruitPressLogic extends ComponentProcessSetCost implements IProcess {
|
||||
int lastProgress;
|
||||
|
||||
public ComponentFruitPressLogic(final Machine machine) {
|
||||
super(machine, 1000, 50);
|
||||
this.lastProgress = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(Press.slotCurrent)) {
|
||||
return new ErrorState.NoItem("No Fruit", Press.slotCurrent);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (!this.getUtil().spaceInTank(Press.tankWater, 5)) {
|
||||
return new ErrorState.TankSpace("No room in tank", Press.tankWater);
|
||||
}
|
||||
if (this.getUtil().getFluid(Press.tankWater) != null && !this.getUtil().getFluid(Press.tankWater).isFluidEqual(Press.getOutput(this.getUtil().getStack(Press.slotCurrent)))) {
|
||||
return new ErrorState.TankSpace("Different fluid in tank", Press.tankWater);
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
this.getUtil().decreaseStack(Press.slotCurrent, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
final FluidStack output = Press.getOutput(this.getUtil().getStack(Press.slotCurrent));
|
||||
if (output == null) {
|
||||
return;
|
||||
}
|
||||
final int newProgress = (int) this.getProgress();
|
||||
while (this.lastProgress + 4 <= newProgress) {
|
||||
final int change = newProgress - this.lastProgress;
|
||||
final int amount = output.amount * change / 100;
|
||||
final FluidStack tank = new FluidStack(output, amount);
|
||||
this.getUtil().fillTank(Press.tankWater, tank);
|
||||
this.lastProgress += 4;
|
||||
}
|
||||
if (this.lastProgress > newProgress) {
|
||||
this.lastProgress = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStartTask() {
|
||||
super.onStartTask();
|
||||
this.lastProgress = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static class SlotValidatorSqueezable extends SlotValidator {
|
||||
public SlotValidatorSqueezable() {
|
||||
super(SlotValidator.IconBlock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
return Press.isInput(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Fruit";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package binnie.extratrees.machines.fruitpress;
|
||||
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.power.ComponentProcessSetCost;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class FruitPressLogic extends ComponentProcessSetCost implements IProcess {
|
||||
public static final int PROCESS_ENERGY = 1000;
|
||||
public static final int PROCESS_LENGTH = 50;
|
||||
|
||||
private int lastProgress;
|
||||
|
||||
public FruitPressLogic(final Machine machine) {
|
||||
super(machine, PROCESS_ENERGY, PROCESS_LENGTH);
|
||||
this.lastProgress = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
if (this.getUtil().isSlotEmpty(FruitPressMachine.SLOT_CURRENT)) {
|
||||
return new ErrorState.NoItem("No Fruit", FruitPressMachine.SLOT_CURRENT);
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorState canProgress() {
|
||||
if (!this.getUtil().spaceInTank(FruitPressMachine.TANK_OUTPUT, 5)) {
|
||||
return new ErrorState.TankSpace("No room in tank", FruitPressMachine.TANK_OUTPUT);
|
||||
}
|
||||
if (this.getUtil().getFluid(FruitPressMachine.TANK_OUTPUT) != null && !this.getUtil().getFluid(FruitPressMachine.TANK_OUTPUT).isFluidEqual(FruitPressRecipes.getOutput(this.getUtil().getStack(FruitPressMachine.SLOT_CURRENT)))) {
|
||||
return new ErrorState.TankSpace("Different fluid in tank", FruitPressMachine.TANK_OUTPUT);
|
||||
}
|
||||
return super.canProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
this.getUtil().decreaseStack(FruitPressMachine.SLOT_CURRENT, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTickTask() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
final FluidStack output = FruitPressRecipes.getOutput(this.getUtil().getStack(FruitPressMachine.SLOT_CURRENT));
|
||||
if (output == null) {
|
||||
return;
|
||||
}
|
||||
final int newProgress = (int) this.getProgress();
|
||||
while (this.lastProgress + 4 <= newProgress) {
|
||||
final int change = newProgress - this.lastProgress;
|
||||
final int amount = output.amount * change / 100;
|
||||
final FluidStack tank = new FluidStack(output, amount);
|
||||
this.getUtil().fillTank(FruitPressMachine.TANK_OUTPUT, tank);
|
||||
this.lastProgress += 4;
|
||||
}
|
||||
if (this.lastProgress > newProgress) {
|
||||
this.lastProgress = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStartTask() {
|
||||
super.onStartTask();
|
||||
this.lastProgress = 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package binnie.extratrees.machines.fruitpress;
|
||||
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.TileEntityMachine;
|
||||
import binnie.core.machines.inventory.ComponentInventorySlots;
|
||||
import binnie.core.machines.inventory.ComponentInventoryTransfer;
|
||||
import binnie.core.machines.inventory.ComponentTankContainer;
|
||||
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 FruitPressMachine extends ExtraTreeMachine.PackageExtraTreeMachine implements IMachineInformation {
|
||||
public static final int SLOT_FRUIT = 0;
|
||||
public static final int SLOT_CURRENT = 1;
|
||||
public static final int TANK_OUTPUT = 0;
|
||||
public static final int TANK_OUTPUT_CAPACITY = 5000;
|
||||
|
||||
public FruitPressMachine() {
|
||||
super("press", ExtraTreeTexture.pressTexture, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createMachine(final Machine machine) {
|
||||
new ExtraTreeMachine.ComponentExtraTreeGUI(machine, ExtraTreesGUID.Press);
|
||||
final ComponentInventorySlots inventory = new ComponentInventorySlots(machine);
|
||||
inventory.addSlot(SLOT_FRUIT, "input");
|
||||
inventory.getSlot(SLOT_FRUIT).setValidator(new SlotValidatorSqueezable());
|
||||
inventory.getSlot(SLOT_FRUIT).forbidExtraction();
|
||||
inventory.addSlot(SLOT_CURRENT, "process");
|
||||
inventory.getSlot(SLOT_CURRENT).setValidator(new SlotValidatorSqueezable());
|
||||
inventory.getSlot(SLOT_CURRENT).forbidInteraction();
|
||||
final ComponentTankContainer tanks = new ComponentTankContainer(machine);
|
||||
tanks.addTank(TANK_OUTPUT, "output", TANK_OUTPUT_CAPACITY);
|
||||
new ComponentPowerReceptor(machine);
|
||||
new ComponentInventoryTransfer(machine).addRestock(new int[]{SLOT_FRUIT}, SLOT_CURRENT, 1);
|
||||
new FruitPressLogic(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity() {
|
||||
return new TileEntityMachine(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package binnie.extratrees.machines.fruitpress;
|
||||
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
public class FruitPressRecipes {
|
||||
// Map<input fruit item, Pair<input fruit, output fluid>>
|
||||
private static Multimap<Item, Pair<ItemStack, FluidStack>> pressRecipes = ArrayListMultimap.create();
|
||||
|
||||
public static boolean isInput(@Nullable final ItemStack itemstack) {
|
||||
return getOutput(itemstack) != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static FluidStack getOutput(@Nullable final ItemStack itemstack) {
|
||||
if (itemstack == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Item item = itemstack.getItem();
|
||||
for (final Map.Entry<ItemStack, FluidStack> entry : FruitPressRecipes.pressRecipes.get(item)) {
|
||||
if (itemstack.isItemEqual(entry.getKey())) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void addRecipe(@Nonnull final ItemStack stack, @Nonnull final FluidStack fluid) {
|
||||
if (getOutput(stack) != null) {
|
||||
return;
|
||||
}
|
||||
Item item = stack.getItem();
|
||||
FruitPressRecipes.pressRecipes.put(item, Pair.of(stack, fluid));
|
||||
}
|
||||
|
||||
public static Collection<Pair<ItemStack, FluidStack>> getRecipes() {
|
||||
return pressRecipes.values();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package binnie.extratrees.machines.fruitpress;
|
||||
|
||||
import binnie.core.machines.inventory.SlotValidator;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SlotValidatorSqueezable extends SlotValidator {
|
||||
public SlotValidatorSqueezable() {
|
||||
super(SlotValidator.IconBlock);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(final ItemStack itemStack) {
|
||||
return FruitPressRecipes.isInput(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return "Fruit";
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import binnie.craftgui.core.geometry.IArea;
|
||||
import binnie.craftgui.minecraft.control.ControlItemDisplay;
|
||||
import binnie.extratrees.machines.Brewery;
|
||||
import binnie.extratrees.machines.Distillery;
|
||||
import binnie.extratrees.machines.Press;
|
||||
import binnie.extratrees.machines.fruitpress.FruitPressRecipes;
|
||||
import forestry.api.recipes.ICentrifugeRecipe;
|
||||
import forestry.api.recipes.ISqueezerRecipe;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
@@ -123,8 +123,8 @@ public abstract class AnalystPageProduce extends ControlAnalystPage {
|
||||
public Collection<FluidStack> getAllFluids(final ItemStack stack) {
|
||||
final List<FluidStack> products = new ArrayList<>();
|
||||
products.addAll(this.getSqueezerFluid(stack));
|
||||
if (Press.getOutput(stack) != null) {
|
||||
products.add(Press.getOutput(stack));
|
||||
if (FruitPressRecipes.getOutput(stack) != null) {
|
||||
products.add(FruitPressRecipes.getOutput(stack));
|
||||
}
|
||||
return products;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user