Fixed JEI recipe transferring in Pattern Grid allowing non-processing recipes in processing mode and vice-versa

This commit is contained in:
raoulvdberge
2018-07-15 13:56:58 +02:00
parent f79388a3db
commit 6fea7b4bc2
2 changed files with 27 additions and 2 deletions

View File

@@ -38,6 +38,7 @@ NOTE: Worlds that used Refined Storage 1.5.x are fully compatible with Refined S
- Fixed crash when moving a wireless item with the number keys (raoulvdberge) - Fixed crash when moving a wireless item with the number keys (raoulvdberge)
- Fixed bug where item storage tracker didn't save sometimes (raoulvdberge) - Fixed bug where item storage tracker didn't save sometimes (raoulvdberge)
- Fixed bug where External Storage doesn't detect new inventory when rotating (raoulvdberge) - Fixed bug where External Storage doesn't detect new inventory when rotating (raoulvdberge)
- Fixed JEI recipe transferring in Pattern Grid allowing non-processing recipes in processing mode and vice-versa (raoulvdberge)
- Prevent accidental Grid scrollbar click after clicking JEI recipe transfer button (raoulvdberge) - Prevent accidental Grid scrollbar click after clicking JEI recipe transfer button (raoulvdberge)
- Added a missing config option for Crafter Manager energy usage (raoulvdberge) - Added a missing config option for Crafter Manager energy usage (raoulvdberge)
- Added support for Disk Drive / Storage Block storage and capacity to OC integration (zangai) - Added support for Disk Drive / Storage Block storage and capacity to OC integration (zangai)

View File

@@ -9,8 +9,10 @@ import com.raoulvdberge.refinedstorage.network.MessageGridProcessingTransfer;
import com.raoulvdberge.refinedstorage.network.MessageGridTransfer; import com.raoulvdberge.refinedstorage.network.MessageGridTransfer;
import mezz.jei.api.gui.IGuiIngredient; import mezz.jei.api.gui.IGuiIngredient;
import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
import mezz.jei.api.recipe.transfer.IRecipeTransferError; import mezz.jei.api.recipe.transfer.IRecipeTransferError;
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler; import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.InventoryCrafting;
@@ -24,6 +26,18 @@ public class RecipeTransferHandlerGrid implements IRecipeTransferHandler {
public static final long TRANSFER_SCROLL_DELAY_MS = 200; public static final long TRANSFER_SCROLL_DELAY_MS = 200;
public static long LAST_TRANSFER; public static long LAST_TRANSFER;
private static final IRecipeTransferError ERROR_CANNOT_TRANSFER = new IRecipeTransferError() {
@Override
public Type getType() {
return Type.INTERNAL;
}
@Override
public void showError(Minecraft minecraft, int mouseX, int mouseY, IRecipeLayout recipeLayout, int recipeX, int recipeY) {
// NO OP
}
};
@Override @Override
public Class<? extends Container> getContainerClass() { public Class<? extends Container> getContainerClass() {
return ContainerGrid.class; return ContainerGrid.class;
@@ -31,11 +45,11 @@ public class RecipeTransferHandlerGrid implements IRecipeTransferHandler {
@Override @Override
public IRecipeTransferError transferRecipe(Container container, IRecipeLayout recipeLayout, EntityPlayer player, boolean maxTransfer, boolean doTransfer) { public IRecipeTransferError transferRecipe(Container container, IRecipeLayout recipeLayout, EntityPlayer player, boolean maxTransfer, boolean doTransfer) {
IGrid grid = ((ContainerGrid) container).getGrid();
if (doTransfer) { if (doTransfer) {
LAST_TRANSFER = System.currentTimeMillis(); LAST_TRANSFER = System.currentTimeMillis();
IGrid grid = ((ContainerGrid) container).getGrid();
if (grid.getType() == GridType.PATTERN && ((NetworkNodeGrid) grid).isProcessingPattern()) { if (grid.getType() == GridType.PATTERN && ((NetworkNodeGrid) grid).isProcessingPattern()) {
List<ItemStack> inputs = new LinkedList<>(); List<ItemStack> inputs = new LinkedList<>();
List<ItemStack> outputs = new LinkedList<>(); List<ItemStack> outputs = new LinkedList<>();
@@ -56,6 +70,16 @@ public class RecipeTransferHandlerGrid implements IRecipeTransferHandler {
} else { } else {
RS.INSTANCE.network.sendToServer(new MessageGridTransfer(recipeLayout.getItemStacks().getGuiIngredients(), container.inventorySlots.stream().filter(s -> s.inventory instanceof InventoryCrafting).collect(Collectors.toList()))); RS.INSTANCE.network.sendToServer(new MessageGridTransfer(recipeLayout.getItemStacks().getGuiIngredients(), container.inventorySlots.stream().filter(s -> s.inventory instanceof InventoryCrafting).collect(Collectors.toList())));
} }
} else {
if (grid.getType() == GridType.PATTERN && ((NetworkNodeGrid) grid).isProcessingPattern()) {
if (recipeLayout.getRecipeCategory().getUid().equals(VanillaRecipeCategoryUid.CRAFTING)) {
return ERROR_CANNOT_TRANSFER;
}
} else {
if (!recipeLayout.getRecipeCategory().getUid().equals(VanillaRecipeCategoryUid.CRAFTING)) {
return ERROR_CANNOT_TRANSFER;
}
}
} }
return null; return null;