mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-21 20:42:35 +00:00
Clean up bottler JEI recipes
This commit is contained in:
1 parent
856e800e0e
commit
3fd07f2a7a
7 files changed
+42
-45
No files matched your search
@@ -25,10 +25,10 @@ public class ContainerBottler extends ContainerLiquidTanks<TileBottler> {
|
||||
super(tile, player, 8, 84);
|
||||
|
||||
this.addSlotToContainer(new SlotLiquidIn(tile, InventoryBottler.SLOT_INPUT_FULL_CONTAINER, 18, 7));
|
||||
this.addSlotToContainer(new SlotOutput(tile, InventoryBottler.SLOT_LEFT_PROCESSING, 18, 35).setPickupWatcher(tile));
|
||||
this.addSlotToContainer(new SlotOutput(tile, InventoryBottler.SLOT_EMPTYING_PROCESSING, 18, 35).setPickupWatcher(tile));
|
||||
this.addSlotToContainer(new SlotOutput(tile, InventoryBottler.SLOT_OUTPUT_EMPTY_CONTAINER, 18, 63));
|
||||
this.addSlotToContainer(new SlotEmptyLiquidContainerIn(tile, InventoryBottler.SLOT_INPUT_EMPTY_CONTAINER, 142, 7));
|
||||
this.addSlotToContainer(new SlotOutput(tile, InventoryBottler.SLOT_RIGHT_PROCESSING, 142, 35).setPickupWatcher(tile));
|
||||
this.addSlotToContainer(new SlotOutput(tile, InventoryBottler.SLOT_FILLING_PROCESSING, 142, 35).setPickupWatcher(tile));
|
||||
this.addSlotToContainer(new SlotOutput(tile, InventoryBottler.SLOT_OUTPUT_FULL_CONTAINER, 142, 63));
|
||||
}
|
||||
}
|
||||
@@ -24,8 +24,8 @@ import forestry.factory.tiles.TileBottler;
|
||||
public class InventoryBottler extends InventoryAdapterTile<TileBottler> {
|
||||
public static final short SLOT_INPUT_FULL_CONTAINER = 0;
|
||||
public static final short SLOT_INPUT_EMPTY_CONTAINER = 1;
|
||||
public static final short SLOT_LEFT_PROCESSING = 2;
|
||||
public static final short SLOT_RIGHT_PROCESSING = 3;
|
||||
public static final short SLOT_EMPTYING_PROCESSING = 2;
|
||||
public static final short SLOT_FILLING_PROCESSING = 3;
|
||||
public static final short SLOT_OUTPUT_EMPTY_CONTAINER = 4;
|
||||
public static final short SLOT_OUTPUT_FULL_CONTAINER = 5;
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public class BottlerRecipeCategory extends ForestryRecipeCategory<BottlerRecipeW
|
||||
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
|
||||
IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks();
|
||||
|
||||
if (recipeWrapper.getRecipe().fillRecipe) {
|
||||
if (recipeWrapper.fillRecipe) {
|
||||
guiItemStacks.init(inputEmpty, true, 44, 0);
|
||||
guiItemStacks.init(outputFull, false, 44, 42);
|
||||
guiFluidStacks.init(tankIndex, true, 23, 1, 16, 58, 10000, false, tankOverlay);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forestry.factory.recipes.jei.bottler;
|
||||
|
||||
import forestry.core.recipes.jei.ForestryRecipeCategoryUid;
|
||||
import forestry.factory.recipes.BottlerRecipe;
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
|
||||
@@ -29,14 +28,7 @@ public class BottlerRecipeHandler implements IRecipeHandler<BottlerRecipeWrapper
|
||||
|
||||
@Override
|
||||
public boolean isRecipeValid(BottlerRecipeWrapper wrapper) {
|
||||
BottlerRecipe recipe = wrapper.getRecipe();
|
||||
if (recipe.fluid == null || recipe.fluid.amount <= 0) {
|
||||
return false;
|
||||
}
|
||||
if (recipe.inputStack == null) {
|
||||
return false;
|
||||
}
|
||||
return recipe.fluid != null;
|
||||
return wrapper.fluid.amount > 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import java.util.List;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.factory.recipes.BottlerRecipe;
|
||||
import mezz.jei.api.ingredients.IIngredientRegistry;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
@@ -35,8 +34,7 @@ public class BottlerRecipeMaker {
|
||||
if (emptyStack.stackSize == 0) {
|
||||
emptyStack = null;
|
||||
}
|
||||
BottlerRecipe recipe = new BottlerRecipe(ingredient, drain, emptyStack, false);
|
||||
recipes.add(new BottlerRecipeWrapper(recipe));
|
||||
recipes.add(new BottlerRecipeWrapper(ingredient, drain, emptyStack, false));
|
||||
addFillRecipe(ingredient, drain.getFluid(), recipes);
|
||||
} else {
|
||||
for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) {
|
||||
@@ -54,8 +52,7 @@ public class BottlerRecipeMaker {
|
||||
int fill = fillCapability.fill(new FluidStack(fluid, Constants.PROCESSOR_TANK_CAPACITY), true);
|
||||
if (fill > 0) {
|
||||
FluidStack filledFluid = new FluidStack(fluid, fill);
|
||||
BottlerRecipe recipe = new BottlerRecipe(ingredient, filledFluid, fillStack, true);
|
||||
recipes.add(new BottlerRecipeWrapper(recipe));
|
||||
recipes.add(new BottlerRecipeWrapper(ingredient, filledFluid, fillStack, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,37 @@
|
||||
package forestry.factory.recipes.jei.bottler;
|
||||
|
||||
import forestry.core.recipes.jei.ForestryRecipeWrapper;
|
||||
import forestry.factory.recipes.BottlerRecipe;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.BlankRecipeWrapper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class BottlerRecipeWrapper extends ForestryRecipeWrapper<BottlerRecipe> {
|
||||
public BottlerRecipeWrapper(BottlerRecipe recipe) {
|
||||
super(recipe);
|
||||
public class BottlerRecipeWrapper extends BlankRecipeWrapper {
|
||||
public final ItemStack inputStack;
|
||||
public final FluidStack fluid;
|
||||
@Nullable
|
||||
public final ItemStack outputStack;
|
||||
public final boolean fillRecipe;
|
||||
|
||||
public BottlerRecipeWrapper(ItemStack inputStack, FluidStack fluid, @Nullable ItemStack outputStack, boolean fillRecipe) {
|
||||
this.inputStack = inputStack;
|
||||
this.fluid = fluid;
|
||||
this.outputStack = outputStack;
|
||||
this.fillRecipe = fillRecipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getIngredients(IIngredients ingredients) {
|
||||
BottlerRecipe recipe = getRecipe();
|
||||
|
||||
ingredients.setInput(ItemStack.class, recipe.inputStack);
|
||||
if (recipe.outputStack != null) {
|
||||
ingredients.setOutput(ItemStack.class, recipe.outputStack);
|
||||
ingredients.setInput(ItemStack.class, inputStack);
|
||||
if (outputStack != null) {
|
||||
ingredients.setOutput(ItemStack.class, outputStack);
|
||||
}
|
||||
|
||||
if (recipe.fillRecipe) {
|
||||
ingredients.setInput(FluidStack.class, recipe.fluid);
|
||||
if (fillRecipe) {
|
||||
ingredients.setInput(FluidStack.class, fluid);
|
||||
} else {
|
||||
ingredients.setOutput(FluidStack.class, recipe.fluid);
|
||||
ingredients.setOutput(FluidStack.class, fluid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -110,14 +110,14 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
|
||||
|
||||
if (updateOnInterval(20)) {
|
||||
boolean movedStack = false;
|
||||
ItemStack leftProcessingStack = getStackInSlot(InventoryBottler.SLOT_LEFT_PROCESSING);
|
||||
ItemStack rightProcessingStack = getStackInSlot(InventoryBottler.SLOT_RIGHT_PROCESSING);
|
||||
ItemStack leftProcessingStack = getStackInSlot(InventoryBottler.SLOT_EMPTYING_PROCESSING);
|
||||
ItemStack rightProcessingStack = getStackInSlot(InventoryBottler.SLOT_FILLING_PROCESSING);
|
||||
if(leftProcessingStack == null){
|
||||
ItemStack inputStack = getStackInSlot(InventoryBottler.SLOT_INPUT_FULL_CONTAINER);
|
||||
if(inputStack != null){
|
||||
leftProcessingStack = inputStack.copy();
|
||||
leftProcessingStack.stackSize = 1;
|
||||
setInventorySlotContents(InventoryBottler.SLOT_LEFT_PROCESSING, leftProcessingStack);
|
||||
setInventorySlotContents(InventoryBottler.SLOT_EMPTYING_PROCESSING, leftProcessingStack);
|
||||
decrStackSize(InventoryBottler.SLOT_INPUT_FULL_CONTAINER, 1);
|
||||
movedStack = true;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
|
||||
if(inputStack != null){
|
||||
rightProcessingStack = inputStack.copy();
|
||||
rightProcessingStack.stackSize = 1;
|
||||
setInventorySlotContents(InventoryBottler.SLOT_RIGHT_PROCESSING, rightProcessingStack);
|
||||
setInventorySlotContents(InventoryBottler.SLOT_FILLING_PROCESSING, rightProcessingStack);
|
||||
decrStackSize(InventoryBottler.SLOT_INPUT_EMPTY_CONTAINER, 1);
|
||||
movedStack = true;
|
||||
}
|
||||
@@ -176,9 +176,9 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
|
||||
public boolean workCycle() {
|
||||
FluidHelper.FillStatus status;
|
||||
if(currentRecipe.fillRecipe){
|
||||
status = FluidHelper.fillContainers(tankManager, this, InventoryBottler.SLOT_RIGHT_PROCESSING, InventoryBottler.SLOT_OUTPUT_FULL_CONTAINER, currentRecipe.fluid.getFluid(), true);
|
||||
status = FluidHelper.fillContainers(tankManager, this, InventoryBottler.SLOT_FILLING_PROCESSING, InventoryBottler.SLOT_OUTPUT_FULL_CONTAINER, currentRecipe.fluid.getFluid(), true);
|
||||
}else{
|
||||
status = FluidHelper.drainContainers(tankManager, this, InventoryBottler.SLOT_LEFT_PROCESSING, InventoryBottler.SLOT_OUTPUT_EMPTY_CONTAINER, true);
|
||||
status = FluidHelper.drainContainers(tankManager, this, InventoryBottler.SLOT_EMPTYING_PROCESSING, InventoryBottler.SLOT_OUTPUT_EMPTY_CONTAINER, true);
|
||||
}
|
||||
if(status == FluidHelper.FillStatus.SUCCESS){
|
||||
currentRecipe = null;
|
||||
@@ -197,7 +197,7 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
|
||||
}
|
||||
|
||||
private void checkFillRecipe(){
|
||||
ItemStack emptyCan = getStackInSlot(InventoryBottler.SLOT_RIGHT_PROCESSING);
|
||||
ItemStack emptyCan = getStackInSlot(InventoryBottler.SLOT_FILLING_PROCESSING);
|
||||
if(emptyCan != null){
|
||||
FluidStack resource = resourceTank.getFluid();
|
||||
if (resource == null) {
|
||||
@@ -222,7 +222,7 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
|
||||
}
|
||||
|
||||
private void checkEmptyRecipe(){
|
||||
ItemStack filledCan = getStackInSlot(InventoryBottler.SLOT_LEFT_PROCESSING);
|
||||
ItemStack filledCan = getStackInSlot(InventoryBottler.SLOT_EMPTYING_PROCESSING);
|
||||
if(filledCan != null){
|
||||
//Empty Container
|
||||
if (currentRecipe == null || !currentRecipe.matchFilled(filledCan) && !currentRecipe.fillRecipe) {
|
||||
@@ -245,12 +245,12 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot(int slotIndex, EntityPlayer player) {
|
||||
if(slotIndex == InventoryBottler.SLOT_LEFT_PROCESSING){
|
||||
if(slotIndex == InventoryBottler.SLOT_EMPTYING_PROCESSING){
|
||||
if(currentRecipe != null && !currentRecipe.fillRecipe){
|
||||
currentRecipe = null;
|
||||
setTicksPerWorkCycle(0);
|
||||
}
|
||||
}else if(slotIndex == InventoryBottler.SLOT_RIGHT_PROCESSING){
|
||||
}else if(slotIndex == InventoryBottler.SLOT_FILLING_PROCESSING){
|
||||
if(currentRecipe != null && currentRecipe.fillRecipe){
|
||||
currentRecipe = null;
|
||||
setTicksPerWorkCycle(0);
|
||||
@@ -277,7 +277,7 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
|
||||
@Override
|
||||
public boolean hasResourcesMin(float percentage) {
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
ItemStack emptyCan = inventory.getStackInSlot(InventoryBottler.SLOT_RIGHT_PROCESSING);
|
||||
ItemStack emptyCan = inventory.getStackInSlot(InventoryBottler.SLOT_FILLING_PROCESSING);
|
||||
if (emptyCan == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -296,7 +296,7 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
|
||||
if (currentRecipe != null) {
|
||||
IFluidTankProperties properties = tankManager.getTankProperties()[0];
|
||||
if(properties != null){
|
||||
emptyStatus = FluidHelper.drainContainers(tankManager, this, InventoryBottler.SLOT_LEFT_PROCESSING, InventoryBottler.SLOT_OUTPUT_EMPTY_CONTAINER, false);
|
||||
emptyStatus = FluidHelper.drainContainers(tankManager, this, InventoryBottler.SLOT_EMPTYING_PROCESSING, InventoryBottler.SLOT_OUTPUT_EMPTY_CONTAINER, false);
|
||||
}else{
|
||||
emptyStatus = FillStatus.SUCCESS;
|
||||
}
|
||||
@@ -308,7 +308,7 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
|
||||
if (currentRecipe == null) {
|
||||
return false;
|
||||
}else{
|
||||
fillStatus = FluidHelper.fillContainers(tankManager, this, InventoryBottler.SLOT_RIGHT_PROCESSING, InventoryBottler.SLOT_OUTPUT_FULL_CONTAINER, currentRecipe.fluid.getFluid(), false);
|
||||
fillStatus = FluidHelper.fillContainers(tankManager, this, InventoryBottler.SLOT_FILLING_PROCESSING, InventoryBottler.SLOT_OUTPUT_FULL_CONTAINER, currentRecipe.fluid.getFluid(), false);
|
||||
}
|
||||
}else{
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user