Add two variations of a read only item stack handler for input and output
This commit is contained in:
parent
c82c15f48b
commit
a4e3ef44ed
2 changed files with 92 additions and 0 deletions
|
@ -0,0 +1,47 @@
|
||||||
|
package dev.zontreck.libzontreck.items;
|
||||||
|
|
||||||
|
import net.minecraft.core.NonNullList;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
|
|
||||||
|
public class InputItemStackHandler extends ItemStackHandler {
|
||||||
|
private final ItemStackHandler internalSlot;
|
||||||
|
|
||||||
|
public InputItemStackHandler(ItemStackHandler hidden) {
|
||||||
|
super();
|
||||||
|
internalSlot = hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSize(int size) {
|
||||||
|
stacks = NonNullList.<ItemStack>withSize(size, ItemStack.EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStackInSlot(int slot, ItemStack stack) {
|
||||||
|
internalSlot.setStackInSlot(slot, stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSlots() {
|
||||||
|
return internalSlot.getSlots();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getStackInSlot(int slot) {
|
||||||
|
return internalSlot.getStackInSlot(slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
|
||||||
|
setStackInSlot(slot, stack);
|
||||||
|
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack extractItem(int slot, int amount, boolean simulate) {
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
package dev.zontreck.libzontreck.items;
|
||||||
|
|
||||||
|
import net.minecraft.core.NonNullList;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraftforge.items.ItemStackHandler;
|
||||||
|
|
||||||
|
public class OutputItemStackHandler extends ItemStackHandler {
|
||||||
|
private final ItemStackHandler internalSlot;
|
||||||
|
|
||||||
|
public OutputItemStackHandler(ItemStackHandler hidden) {
|
||||||
|
super();
|
||||||
|
internalSlot = hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSize(int size) {
|
||||||
|
stacks = NonNullList.<ItemStack>withSize(size, ItemStack.EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStackInSlot(int slot, ItemStack stack) {
|
||||||
|
internalSlot.setStackInSlot(slot, stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSlots() {
|
||||||
|
return internalSlot.getSlots();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack getStackInSlot(int slot) {
|
||||||
|
return internalSlot.getStackInSlot(slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack extractItem(int slot, int amount, boolean simulate) {
|
||||||
|
return internalSlot.extractItem(slot, amount, simulate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Reference in a new issue