Made drawers respect stack sizes
This commit is contained in:
parent
6b73994dfa
commit
e4ee831933
|
@ -276,7 +276,7 @@ public abstract class ControllableDrawerTile<T extends ControllableDrawerTile<T>
|
|||
BlockHitResult blockResult = (BlockHitResult) rayTraceResult;
|
||||
Direction facing = blockResult.getDirection();
|
||||
if (facing.equals(this.getFacingDirection())){
|
||||
ItemHandlerHelper.giveItemToPlayer(playerIn, getStorage().extractItem(slot, playerIn.isShiftKeyDown() ? 64 : 1, false));
|
||||
ItemHandlerHelper.giveItemToPlayer(playerIn, getStorage().extractItem(slot, playerIn.isShiftKeyDown() ? getStorage().getStackInSlot(slot).getMaxStackSize() : 1, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,8 +89,12 @@ public abstract class BigInventoryHandler implements IItemHandler, INBTSerializa
|
|||
|
||||
@Override
|
||||
public int getSlotLimit(int slot) {
|
||||
if (hasDowngrade()) return 64;
|
||||
return (int) Math.min(Integer.MAX_VALUE, type.getSlotAmount() * (long) getMultiplier());
|
||||
double stackSize = 1;
|
||||
if (!getStoredStacks().get(slot).getStack().isEmpty()) {
|
||||
stackSize = getStoredStacks().get(slot).getStack().getMaxStackSize() / 64D;
|
||||
}
|
||||
if (hasDowngrade()) return (int) Math.floor(64 * stackSize);
|
||||
return (int) Math.floor(Math.min(Integer.MAX_VALUE, type.getSlotAmount() * (long) getMultiplier()) * stackSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
package com.buuz135.functionalstorage.inventory;
|
||||
|
||||
import com.buuz135.functionalstorage.FunctionalStorage;
|
||||
import com.buuz135.functionalstorage.network.EnderDrawerSyncMessage;
|
||||
import com.buuz135.functionalstorage.world.EnderSavedData;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.network.NetworkDirection;
|
||||
|
||||
public class EnderInventoryHandler extends BigInventoryHandler{
|
||||
|
||||
|
@ -47,7 +43,11 @@ public class EnderInventoryHandler extends BigInventoryHandler{
|
|||
|
||||
@Override
|
||||
public int getSlotLimit(int slot) {
|
||||
return (int) Math.min(Integer.MAX_VALUE, FunctionalStorage.DrawerType.X_1.getSlotAmount() * 4);
|
||||
double stackSize = 1;
|
||||
if (!getStoredStacks().get(slot).getStack().isEmpty()) {
|
||||
stackSize = getStoredStacks().get(slot).getStack().getMaxStackSize() / 64D;
|
||||
}
|
||||
return (int) Math.floor(Math.min(Integer.MAX_VALUE, FunctionalStorage.DrawerType.X_1.getSlotAmount() * 4) * stackSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue
Block a user