Improved drawer validity check
This commit is contained in:
parent
e96b9207e6
commit
105f45d67b
|
@ -38,7 +38,7 @@ public abstract class ArmoryCabinetInventoryHandler implements IItemHandler, INB
|
|||
@NotNull
|
||||
@Override
|
||||
public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) {
|
||||
if (isItemValid(slot, stack)) {
|
||||
if (isValid(slot, stack)) {
|
||||
if (!simulate){
|
||||
this.stackList.set(slot, stack);
|
||||
onChange();
|
||||
|
@ -68,6 +68,10 @@ public abstract class ArmoryCabinetInventoryHandler implements IItemHandler, INB
|
|||
|
||||
@Override
|
||||
public boolean isItemValid(int slot, @NotNull ItemStack stack) {
|
||||
return isCertifiedStack(stack);
|
||||
}
|
||||
|
||||
private boolean isValid(int slot, @NotNull ItemStack stack) {
|
||||
return !stack.isEmpty() && this.stackList.get(slot).isEmpty() && isCertifiedStack(stack);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public abstract class BigInventoryHandler implements IItemHandler, INBTSerializa
|
|||
@Nonnull
|
||||
@Override
|
||||
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
|
||||
if (isItemValid(slot, stack)) {
|
||||
if (isValid(slot, stack)) {
|
||||
BigStack bigStack = this.storedStacks.get(slot);
|
||||
int inserted = Math.min(getSlotLimit(slot) - bigStack.getAmount(), stack.getCount());
|
||||
if (!simulate){
|
||||
|
@ -96,6 +96,10 @@ public abstract class BigInventoryHandler implements IItemHandler, INBTSerializa
|
|||
|
||||
@Override
|
||||
public boolean isItemValid(int slot, @Nonnull ItemStack stack) {
|
||||
return !stack.isEmpty();
|
||||
}
|
||||
|
||||
private boolean isValid(int slot, @Nonnull ItemStack stack){
|
||||
if (slot < type.getSlots()){
|
||||
BigStack bigStack = this.storedStacks.get(slot);
|
||||
ItemStack fl = bigStack.getStack();
|
||||
|
|
|
@ -49,7 +49,7 @@ public abstract class CompactingInventoryHandler implements IItemHandler, INBTSe
|
|||
@Nonnull
|
||||
@Override
|
||||
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
|
||||
if (isItemValid(slot, stack)) {
|
||||
if (isValid(slot, stack)) {
|
||||
CompactingUtil.Result result = this.resultList.get(slot);
|
||||
int inserted = Math.min(getSlotLimit(slot) * result.getNeeded() - amount, stack.getCount() * result.getNeeded());
|
||||
inserted = (int) (Math.floor(inserted / result.getNeeded()) * result.getNeeded());
|
||||
|
@ -125,6 +125,10 @@ public abstract class CompactingInventoryHandler implements IItemHandler, INBTSe
|
|||
|
||||
@Override
|
||||
public boolean isItemValid(int slot, @Nonnull ItemStack stack) {
|
||||
return isSetup() && slot < 3 && stack.isEmpty();
|
||||
}
|
||||
|
||||
private boolean isValid(int slot, @Nonnull ItemStack stack){
|
||||
if (slot < 3){
|
||||
CompactingUtil.Result bigStack = this.resultList.get(slot);
|
||||
ItemStack fl = bigStack.getResult();
|
||||
|
|
Loading…
Reference in New Issue
Block a user