Shift clicking in grid crafting
This commit is contained in:
@@ -7,6 +7,7 @@ import net.minecraft.inventory.Container;
|
|||||||
import net.minecraft.inventory.Slot;
|
import net.minecraft.inventory.Slot;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import refinedstorage.container.slot.SlotDisabled;
|
import refinedstorage.container.slot.SlotDisabled;
|
||||||
|
import refinedstorage.container.slot.SlotGridCraftingResult;
|
||||||
import refinedstorage.container.slot.SlotSpecimen;
|
import refinedstorage.container.slot.SlotSpecimen;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -98,6 +99,10 @@ public abstract class ContainerBase extends Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return player.inventory.getItemStack();
|
return player.inventory.getItemStack();
|
||||||
|
} else if (slot instanceof SlotGridCraftingResult && slot.getHasStack() && GuiScreen.isShiftKeyDown()) {
|
||||||
|
((SlotGridCraftingResult) slot).onShiftClick(player);
|
||||||
|
|
||||||
|
return null;
|
||||||
} else if (slot instanceof SlotDisabled) {
|
} else if (slot instanceof SlotDisabled) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,4 +30,8 @@ public class SlotGridCraftingResult extends SlotCrafting {
|
|||||||
|
|
||||||
grid.onCrafted(container);
|
grid.onCrafted(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onShiftClick(EntityPlayer player) {
|
||||||
|
grid.onCraftedShift(container, player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ import refinedstorage.container.ContainerGrid;
|
|||||||
import refinedstorage.inventory.InventorySimple;
|
import refinedstorage.inventory.InventorySimple;
|
||||||
import refinedstorage.util.InventoryUtils;
|
import refinedstorage.util.InventoryUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class TileGrid extends TileMachine {
|
public class TileGrid extends TileMachine {
|
||||||
public static final String NBT_SORTING_DIRECTION = "SortingDirection";
|
public static final String NBT_SORTING_DIRECTION = "SortingDirection";
|
||||||
public static final String NBT_SORTING_TYPE = "SortingType";
|
public static final String NBT_SORTING_TYPE = "SortingType";
|
||||||
@@ -93,6 +96,34 @@ public class TileGrid extends TileMachine {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onCraftedShift(ContainerGrid container, EntityPlayer player) {
|
||||||
|
List<ItemStack> craftedItemsList = new ArrayList<ItemStack>();
|
||||||
|
int craftedItems = 0;
|
||||||
|
ItemStack crafted = craftingResultInventory.getStackInSlot(0);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
onCrafted(container);
|
||||||
|
|
||||||
|
craftedItemsList.add(crafted.copy());
|
||||||
|
|
||||||
|
craftedItems += crafted.stackSize;
|
||||||
|
|
||||||
|
if (!InventoryUtils.compareStack(crafted, craftingResultInventory.getStackInSlot(0)) || craftedItems + crafted.stackSize > 64) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ItemStack craftedItem : craftedItemsList) {
|
||||||
|
if (!player.inventory.addItemStackToInventory(craftedItem.copy())) {
|
||||||
|
if (isConnected() && getController().push(craftedItem.copy())) {
|
||||||
|
// NO OP
|
||||||
|
} else {
|
||||||
|
InventoryUtils.dropStack(player.worldObj, craftedItem, player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int getSortingDirection() {
|
public int getSortingDirection() {
|
||||||
return sortingDirection;
|
return sortingDirection;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user