Better slotspecimen
This commit is contained in:
@@ -57,7 +57,7 @@ public abstract class ContainerBase extends Container {
|
||||
Slot slot = id >= 0 ? getSlot(id) : null;
|
||||
|
||||
if (slot instanceof SlotSpecimen) {
|
||||
if (((SlotSpecimen) slot).isSizeAllowed()) {
|
||||
if (((SlotSpecimen) slot).isWithSize()) {
|
||||
if (slot.getStack() != null) {
|
||||
if (GuiScreen.isShiftKeyDown()) {
|
||||
slot.putStack(null);
|
||||
|
||||
@@ -2,7 +2,7 @@ package refinedstorage.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
import refinedstorage.container.slot.SlotSpecimenItemBlock;
|
||||
import refinedstorage.container.slot.SlotSpecimen;
|
||||
import refinedstorage.tile.TileConstructor;
|
||||
|
||||
public class ContainerConstructor extends ContainerBase {
|
||||
@@ -10,7 +10,7 @@ public class ContainerConstructor extends ContainerBase {
|
||||
public ContainerConstructor(EntityPlayer player, TileConstructor constructor) {
|
||||
super(player);
|
||||
|
||||
addSlotToContainer(new SlotSpecimenItemBlock(constructor.getFilter(), 0, 80, 20));
|
||||
addSlotToContainer(new SlotSpecimen(constructor.getFilter(), 0, 80, 20, SlotSpecimen.SPECIMEN_BLOCK));
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
addSlotToContainer(new SlotItemHandler(constructor.getUpgrades(), i, 187, 6 + (i * 18)));
|
||||
|
||||
@@ -2,7 +2,7 @@ package refinedstorage.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
import refinedstorage.container.slot.SlotSpecimenItemBlock;
|
||||
import refinedstorage.container.slot.SlotSpecimen;
|
||||
import refinedstorage.tile.TileDestructor;
|
||||
|
||||
public class ContainerDestructor extends ContainerBase {
|
||||
@@ -10,7 +10,7 @@ public class ContainerDestructor extends ContainerBase {
|
||||
super(player);
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
addSlotToContainer(new SlotSpecimenItemBlock(destructor.getInventory(), i, 8 + (18 * i), 20));
|
||||
addSlotToContainer(new SlotSpecimen(destructor.getInventory(), i, 8 + (18 * i), 20, SlotSpecimen.SPECIMEN_BLOCK));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
|
||||
@@ -8,7 +8,7 @@ public class ContainerDetector extends ContainerBase {
|
||||
public ContainerDetector(EntityPlayer player, TileDetector detector) {
|
||||
super(player);
|
||||
|
||||
addSlotToContainer(new SlotSpecimen(detector.getInventory(), 0, 107, 20, false));
|
||||
addSlotToContainer(new SlotSpecimen(detector.getInventory(), 0, 107, 20));
|
||||
|
||||
addPlayerInventory(8, 55);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ public class ContainerExporter extends ContainerBase {
|
||||
super(player);
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
addSlotToContainer(new SlotSpecimen(exporter.getFilters(), i, 8 + (18 * i), 20, false));
|
||||
addSlotToContainer(new SlotSpecimen(exporter.getFilters(), i, 8 + (18 * i), 20));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
|
||||
@@ -10,7 +10,7 @@ public class ContainerImporter extends ContainerBase {
|
||||
super(player);
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
addSlotToContainer(new SlotSpecimen(importer.getFilters(), i, 8 + (18 * i), 20, false));
|
||||
addSlotToContainer(new SlotSpecimen(importer.getFilters(), i, 8 + (18 * i), 20));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
|
||||
@@ -17,7 +17,7 @@ public class ContainerInterface extends ContainerBase {
|
||||
}
|
||||
|
||||
for (int i = 9; i < 18; ++i) {
|
||||
addSlotToContainer(new SlotSpecimen(tile.getItems(), i, 8 + (18 * (i - 9)), 54, true));
|
||||
addSlotToContainer(new SlotSpecimen(tile.getItems(), i, 8 + (18 * (i - 9)), 54, SlotSpecimen.SPECIMEN_SIZE));
|
||||
}
|
||||
|
||||
for (int i = 18; i < 27; ++i) {
|
||||
|
||||
@@ -15,7 +15,7 @@ public class ContainerProcessingPatternEncoder extends ContainerBase {
|
||||
int y = 20;
|
||||
|
||||
for (int i = 0; i < 9 * 2; ++i) {
|
||||
addSlotToContainer(new SlotSpecimen(processingPatternEncoder.getConfiguration(), i, x, y, false));
|
||||
addSlotToContainer(new SlotSpecimen(processingPatternEncoder.getConfiguration(), i, x, y));
|
||||
|
||||
x += 18;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class ContainerStorage extends ContainerBase {
|
||||
|
||||
protected void addSpecimenAndPlayerInventorySlots(IItemHandler filters) {
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
addSlotToContainer(new SlotSpecimen(filters, i, 8 + (18 * i), 20, false));
|
||||
addSlotToContainer(new SlotSpecimen(filters, i, 8 + (18 * i), 20));
|
||||
}
|
||||
|
||||
addPlayerInventory(8, 129);
|
||||
|
||||
@@ -1,17 +1,25 @@
|
||||
package refinedstorage.container.slot;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
|
||||
public class SlotSpecimen extends SlotItemHandler {
|
||||
private boolean sizeAllowed;
|
||||
public static final int SPECIMEN_SIZE = 1;
|
||||
public static final int SPECIMEN_BLOCK = 2;
|
||||
|
||||
public SlotSpecimen(IItemHandler handler, int id, int x, int y, boolean allowSize) {
|
||||
private int flags = 0;
|
||||
|
||||
public SlotSpecimen(IItemHandler handler, int id, int x, int y, int flags) {
|
||||
super(handler, id, x, y);
|
||||
|
||||
this.sizeAllowed = allowSize;
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
public SlotSpecimen(IItemHandler handler, int id, int x, int y) {
|
||||
this(handler, id, x, y, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -21,19 +29,23 @@ public class SlotSpecimen extends SlotItemHandler {
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return true;
|
||||
return isBlockOnly() ? (stack.getItem() instanceof ItemBlock) : true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putStack(ItemStack stack) {
|
||||
if (stack != null && !sizeAllowed) {
|
||||
if (stack != null && !isWithSize()) {
|
||||
stack.stackSize = 1;
|
||||
}
|
||||
|
||||
super.putStack(stack);
|
||||
}
|
||||
|
||||
public boolean isSizeAllowed() {
|
||||
return sizeAllowed;
|
||||
public boolean isWithSize() {
|
||||
return (flags & SPECIMEN_SIZE) == SPECIMEN_SIZE;
|
||||
}
|
||||
|
||||
public boolean isBlockOnly() {
|
||||
return (flags & SPECIMEN_BLOCK) == SPECIMEN_BLOCK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package refinedstorage.container.slot;
|
||||
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
// @TODO: This can probably be removed?
|
||||
public class SlotSpecimenItemBlock extends SlotSpecimen {
|
||||
public SlotSpecimenItemBlock(IItemHandler handler, int id, int x, int y) {
|
||||
super(handler, id, x, y, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return stack.getItem() instanceof ItemBlock;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user