Skip to content
This repository was archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Minor inventory crafting bug fixes?
Browse files Browse the repository at this point in the history
  • Loading branch information
TacoTechnica committed Jan 19, 2022
1 parent a4df09c commit 06fbbd6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
16 changes: 6 additions & 10 deletions src/main/java/adris/altoclef/tasks/CraftGenericTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import adris.altoclef.util.slots.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.screen.CraftingScreenHandler;
import net.minecraft.screen.PlayerScreenHandler;
import net.minecraft.screen.slot.SlotActionType;

import java.util.Optional;
Expand All @@ -42,15 +40,13 @@ protected void onStart(AltoClef mod) {
@Override
protected Task onTick(AltoClef mod) {

boolean bigCrafting = (mod.getPlayer().currentScreenHandler instanceof CraftingScreenHandler);
boolean bigCrafting = StorageHelper.isBigCraftingOpen();

if (!bigCrafting) {
if (!(mod.getPlayer().currentScreenHandler instanceof PlayerScreenHandler)) {
// Make sure we're not in another screen before we craft,
// otherwise crafting won't work
StorageHelper.closeScreen();
// Just to be safe
}
if (!bigCrafting && !StorageHelper.isPlayerInventoryOpen()) {
// Make sure we're not in another screen before we craft,
// otherwise crafting won't work
StorageHelper.closeScreen();
// Just to be safe
}

// For each slot in table
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/adris/altoclef/tasks/CraftInInventoryTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,16 @@ protected boolean shouldAvoidPickingUp(AltoClef mod) {
@Override
protected void onResourceStart(AltoClef mod) {
_fullCheckFailed = false;
StorageHelper.closeScreen(); // Just to be safe I guess
}

@Override
protected Task onResourceTick(AltoClef mod) {
// Grab from output FIRST
if (StorageHelper.getItemStackInCursorSlot().isEmpty() && Arrays.stream(_itemTargets).anyMatch(target -> target.matches(StorageHelper.getItemStackInSlot(PlayerSlot.CRAFT_OUTPUT_SLOT).getItem()))) {
return new ClickSlotTask(PlayerSlot.CRAFT_OUTPUT_SLOT, 0, SlotActionType.PICKUP);
if (StorageHelper.isPlayerInventoryOpen()) {
if (StorageHelper.getItemStackInCursorSlot().isEmpty() && Arrays.stream(_itemTargets).anyMatch(target -> target.matches(StorageHelper.getItemStackInSlot(PlayerSlot.CRAFT_OUTPUT_SLOT).getItem()))) {
return new ClickSlotTask(PlayerSlot.CRAFT_OUTPUT_SLOT, 0, SlotActionType.PICKUP);
}
}

ItemTarget toGet = _itemTargets[0];
Expand Down

0 comments on commit 06fbbd6

Please sign in to comment.