Added an extra slot when the drawer is void for mods that do checks stuff too much and it doesn't send stuff when it's full closes #27
This commit is contained in:
parent
b6b2422837
commit
5626fca71e
|
@ -30,12 +30,14 @@ public abstract class BigInventoryHandler implements IItemHandler, INBTSerializa
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSlots() {
|
public int getSlots() {
|
||||||
|
if (isVoid()) return type.getSlots() + 1;
|
||||||
return type.getSlots();
|
return type.getSlots();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getStackInSlot(int slot) {
|
public ItemStack getStackInSlot(int slot) {
|
||||||
|
if (type.getSlots() == slot) return ItemStack.EMPTY;
|
||||||
BigStack bigStack = this.storedStacks.get(slot);
|
BigStack bigStack = this.storedStacks.get(slot);
|
||||||
ItemStack copied = bigStack.getStack().copy();
|
ItemStack copied = bigStack.getStack().copy();
|
||||||
copied.setCount(bigStack.getAmount());
|
copied.setCount(bigStack.getAmount());
|
||||||
|
@ -45,6 +47,7 @@ public abstract class BigInventoryHandler implements IItemHandler, INBTSerializa
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
|
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
|
||||||
|
if (isVoid() && type.getSlots() == slot && isVoidValid(stack)) return ItemStack.EMPTY;
|
||||||
if (isValid(slot, stack)) {
|
if (isValid(slot, stack)) {
|
||||||
BigStack bigStack = this.storedStacks.get(slot);
|
BigStack bigStack = this.storedStacks.get(slot);
|
||||||
int inserted = Math.min(getSlotLimit(slot) - bigStack.getAmount(), stack.getCount());
|
int inserted = Math.min(getSlotLimit(slot) - bigStack.getAmount(), stack.getCount());
|
||||||
|
@ -62,7 +65,7 @@ public abstract class BigInventoryHandler implements IItemHandler, INBTSerializa
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ItemStack extractItem(int slot, int amount, boolean simulate) {
|
public ItemStack extractItem(int slot, int amount, boolean simulate) {
|
||||||
if (amount == 0) return ItemStack.EMPTY;
|
if (amount == 0 || type.getSlots() == slot) return ItemStack.EMPTY;
|
||||||
if (slot < type.getSlots()){
|
if (slot < type.getSlots()){
|
||||||
BigStack bigStack = this.storedStacks.get(slot);
|
BigStack bigStack = this.storedStacks.get(slot);
|
||||||
if (bigStack.getStack().isEmpty()) return ItemStack.EMPTY;
|
if (bigStack.getStack().isEmpty()) return ItemStack.EMPTY;
|
||||||
|
@ -89,6 +92,7 @@ public abstract class BigInventoryHandler implements IItemHandler, INBTSerializa
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSlotLimit(int slot) {
|
public int getSlotLimit(int slot) {
|
||||||
|
if (type.getSlots() == slot) return Integer.MAX_VALUE;
|
||||||
double stackSize = 1;
|
double stackSize = 1;
|
||||||
if (!getStoredStacks().get(slot).getStack().isEmpty()) {
|
if (!getStoredStacks().get(slot).getStack().isEmpty()) {
|
||||||
stackSize = getStoredStacks().get(slot).getStack().getMaxStackSize() / 64D;
|
stackSize = getStoredStacks().get(slot).getStack().getMaxStackSize() / 64D;
|
||||||
|
@ -112,6 +116,13 @@ public abstract class BigInventoryHandler implements IItemHandler, INBTSerializa
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isVoidValid(ItemStack stack){
|
||||||
|
for (BigStack storedStack : this.storedStacks) {
|
||||||
|
if (storedStack.getStack().sameItem(stack) && ItemStack.tagMatches(storedStack.getStack(), stack)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag serializeNBT() {
|
public CompoundTag serializeNBT() {
|
||||||
CompoundTag compoundTag = new CompoundTag();
|
CompoundTag compoundTag = new CompoundTag();
|
||||||
|
|
|
@ -34,12 +34,14 @@ public abstract class CompactingInventoryHandler implements IItemHandler, INBTSe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSlots() {
|
public int getSlots() {
|
||||||
|
if (isVoid()) return 4;
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getStackInSlot(int slot) {
|
public ItemStack getStackInSlot(int slot) {
|
||||||
|
if (slot == 3) return ItemStack.EMPTY;
|
||||||
CompactingUtil.Result bigStack = this.resultList.get(slot);
|
CompactingUtil.Result bigStack = this.resultList.get(slot);
|
||||||
ItemStack copied = bigStack.getResult().copy();
|
ItemStack copied = bigStack.getResult().copy();
|
||||||
copied.setCount(this.amount / bigStack.getNeeded());
|
copied.setCount(this.amount / bigStack.getNeeded());
|
||||||
|
@ -49,6 +51,7 @@ public abstract class CompactingInventoryHandler implements IItemHandler, INBTSe
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
|
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
|
||||||
|
if (isVoid() && slot == 3 && isVoidValid(stack)) return ItemStack.EMPTY;
|
||||||
if (isValid(slot, stack)) {
|
if (isValid(slot, stack)) {
|
||||||
CompactingUtil.Result result = this.resultList.get(slot);
|
CompactingUtil.Result result = this.resultList.get(slot);
|
||||||
int inserted = Math.min(getSlotLimit(slot) * result.getNeeded() - amount, stack.getCount() * result.getNeeded());
|
int inserted = Math.min(getSlotLimit(slot) * result.getNeeded() - amount, stack.getCount() * result.getNeeded());
|
||||||
|
@ -64,6 +67,13 @@ public abstract class CompactingInventoryHandler implements IItemHandler, INBTSe
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isVoidValid(ItemStack stack) {
|
||||||
|
for (CompactingUtil.Result result : this.resultList) {
|
||||||
|
if (result.getResult().sameItem(stack) && ItemStack.tagMatches(result.getResult(), stack)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isSetup(){
|
public boolean isSetup(){
|
||||||
return !this.resultList.get(this.resultList.size() -1).getResult().isEmpty();
|
return !this.resultList.get(this.resultList.size() -1).getResult().isEmpty();
|
||||||
|
@ -96,7 +106,7 @@ public abstract class CompactingInventoryHandler implements IItemHandler, INBTSe
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ItemStack extractItem(int slot, int amount, boolean simulate) {
|
public ItemStack extractItem(int slot, int amount, boolean simulate) {
|
||||||
if (amount == 0) return ItemStack.EMPTY;
|
if (amount == 0 || slot == 3) return ItemStack.EMPTY;
|
||||||
if (slot < 3){
|
if (slot < 3){
|
||||||
CompactingUtil.Result bigStack = this.resultList.get(slot);
|
CompactingUtil.Result bigStack = this.resultList.get(slot);
|
||||||
if (bigStack.getResult().isEmpty()) return ItemStack.EMPTY;
|
if (bigStack.getResult().isEmpty()) return ItemStack.EMPTY;
|
||||||
|
@ -126,6 +136,7 @@ public abstract class CompactingInventoryHandler implements IItemHandler, INBTSe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSlotLimit(int slot) {
|
public int getSlotLimit(int slot) {
|
||||||
|
if (slot == 3) return Integer.MAX_VALUE;
|
||||||
return (int) Math.min(Integer.MAX_VALUE, Math.floor((TOTAL_AMOUNT * getMultiplier()) / this.resultList.get(slot).getNeeded()));
|
return (int) Math.min(Integer.MAX_VALUE, Math.floor((TOTAL_AMOUNT * getMultiplier()) / this.resultList.get(slot).getNeeded()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ public class EnderInventoryHandler extends BigInventoryHandler implements ILocka
|
||||||
this.voidItems = nbt.getBoolean(NBT_VOID);
|
this.voidItems = nbt.getBoolean(NBT_VOID);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO Implement all of these methods
|
|
||||||
@Override
|
@Override
|
||||||
public void onChange() {
|
public void onChange() {
|
||||||
manager.setDirty();
|
manager.setDirty();
|
||||||
|
@ -43,6 +42,7 @@ public class EnderInventoryHandler extends BigInventoryHandler implements ILocka
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSlotLimit(int slot) {
|
public int getSlotLimit(int slot) {
|
||||||
|
if (slot == 1) return Integer.MAX_VALUE;
|
||||||
double stackSize = 1;
|
double stackSize = 1;
|
||||||
if (!getStoredStacks().get(slot).getStack().isEmpty()) {
|
if (!getStoredStacks().get(slot).getStack().isEmpty()) {
|
||||||
stackSize = getStoredStacks().get(slot).getStack().getMaxStackSize() / 64D;
|
stackSize = getStoredStacks().get(slot).getStack().getMaxStackSize() / 64D;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user