Added ability to shift click items into Importer, Exporter, Constructor, Destructor and Detector to set up whitelist / blacklist configurations easier, fixes #202

This commit is contained in:
Raoul Van den Berge
2016-07-19 02:10:51 +02:00
parent 8c11c617dd
commit 55cd5c2c47
7 changed files with 39 additions and 4 deletions

View File

@@ -12,6 +12,7 @@
**Features** **Features**
- Added X button to Processing Pattern Encoder to clear configuration of inputs and outputs - Added X button to Processing Pattern Encoder to clear configuration of inputs and outputs
- Added Grid view toggle buttons (regular, craftable items only, no craftable items) - Added Grid view toggle buttons (regular, craftable items only, no craftable items)
- Added ability to shift click items into Importer, Exporter, Constructor, Destructor and Detector to set up whitelist / blacklist configurations easier
- Re-added opposite facing on shift click functionality - Re-added opposite facing on shift click functionality
- Updated to Forge 2014 - Updated to Forge 2014

View File

@@ -6,6 +6,8 @@ import net.minecraft.inventory.ClickType;
import net.minecraft.inventory.Container; 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 net.minecraftforge.items.ItemHandlerHelper;
import refinedstorage.RefinedStorageUtils;
import refinedstorage.container.slot.SlotDisabled; import refinedstorage.container.slot.SlotDisabled;
import refinedstorage.container.slot.SlotSpecimen; import refinedstorage.container.slot.SlotSpecimen;
import refinedstorage.container.slot.SlotSpecimenLegacy; import refinedstorage.container.slot.SlotSpecimenLegacy;
@@ -106,6 +108,25 @@ public abstract class ContainerBase extends Container {
return null; return null;
} }
public ItemStack mergeItemStackToSpecimen(ItemStack stack, int begin, int end) {
for (int i = begin; i < end; ++i) {
if (RefinedStorageUtils.compareStackNoQuantity(getSlot(i).getStack(), stack)) {
return null;
}
}
for (int i = begin; i < end; ++i) {
if (!getSlot(i).getHasStack()) {
getSlot(i).putStack(ItemHandlerHelper.copyStackWithSize(stack, 1));
getSlot(i).onSlotChanged();
return null;
}
}
return null;
}
@Override @Override
public boolean canInteractWith(EntityPlayer player) { public boolean canInteractWith(EntityPlayer player) {
return true; return true;

View File

@@ -34,7 +34,7 @@ public class ContainerConstructor extends ContainerBase {
return null; return null;
} }
} else if (!mergeItemStack(stack, 0, 4, false)) { } else if (!mergeItemStack(stack, 0, 4, false)) {
return null; return mergeItemStackToSpecimen(stack, 4, 4 + 1);
} }
if (stack.stackSize == 0) { if (stack.stackSize == 0) {

View File

@@ -36,7 +36,7 @@ public class ContainerDestructor extends ContainerBase {
return null; return null;
} }
} else if (!mergeItemStack(stack, 0, 4, false)) { } else if (!mergeItemStack(stack, 0, 4, false)) {
return null; return mergeItemStackToSpecimen(stack, 4, 4 + 9);
} }
if (stack.stackSize == 0) { if (stack.stackSize == 0) {

View File

@@ -1,6 +1,8 @@
package refinedstorage.container; package refinedstorage.container;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import refinedstorage.container.slot.SlotSpecimen; import refinedstorage.container.slot.SlotSpecimen;
import refinedstorage.tile.TileDetector; import refinedstorage.tile.TileDetector;
@@ -12,4 +14,15 @@ public class ContainerDetector extends ContainerBase {
addPlayerInventory(8, 55); addPlayerInventory(8, 55);
} }
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
Slot slot = getSlot(index);
if (slot != null && slot.getHasStack() && index > 0) {
return mergeItemStackToSpecimen(slot.getStack(), 0, 1);
}
return null;
}
} }

View File

@@ -36,7 +36,7 @@ public class ContainerExporter extends ContainerBase {
return null; return null;
} }
} else if (!mergeItemStack(stack, 0, 4, false)) { } else if (!mergeItemStack(stack, 0, 4, false)) {
return null; return mergeItemStackToSpecimen(stack, 4, 4 + 9);
} }
if (stack.stackSize == 0) { if (stack.stackSize == 0) {

View File

@@ -36,7 +36,7 @@ public class ContainerImporter extends ContainerBase {
return null; return null;
} }
} else if (!mergeItemStack(stack, 0, 4, false)) { } else if (!mergeItemStack(stack, 0, 4, false)) {
return null; return mergeItemStackToSpecimen(stack, 4, 4 + 9);
} }
if (stack.stackSize == 0) { if (stack.stackSize == 0) {