Fixed External Storage not calculating max stack size in the calculation of it's capacity display in the GUI, fixes #1409

This commit is contained in:
raoulvdberge
2017-08-09 11:10:14 +02:00
parent 8f00b4cc73
commit 43940741e8
3 changed files with 15 additions and 5 deletions

View File

@@ -9,6 +9,7 @@
- Fixed Grid crash with search history (raoulvdberge) - Fixed Grid crash with search history (raoulvdberge)
- Fixed Grid crash with search field (raoulvdberge) - Fixed Grid crash with search field (raoulvdberge)
- Fixed External Storage not working without Storage Drawers (raoulvdberge) - Fixed External Storage not working without Storage Drawers (raoulvdberge)
- Fixed External Storage not calculating max stack size in the calculation of it's capacity display in the GUI (raoulvdberge)
### 1.5.14 ### 1.5.14
- Updated Forge to 2426 (raoulvdberge) - Updated Forge to 2426 (raoulvdberge)

View File

@@ -43,7 +43,17 @@ public class StorageItemItemHandler extends StorageItemExternal {
public int getCapacity() { public int getCapacity() {
IItemHandler handler = handlerSupplier.get(); IItemHandler handler = handlerSupplier.get();
return handler != null ? handler.getSlots() * 64 : 0; if (handler == null) {
return 0;
}
int capacity = 0;
for (int i = 0; i < handler.getSlots(); ++i) {
capacity += Math.min(handler.getSlotLimit(i), handler.getStackInSlot(i).getMaxStackSize());
}
return capacity;
} }
@Override @Override
@@ -122,10 +132,8 @@ public class StorageItemItemHandler extends StorageItemExternal {
int size = 0; int size = 0;
for (int i = 0; i < handler.getSlots(); ++i) { for (int i = 0; i < handler.getSlots(); ++i) {
if (!handler.getStackInSlot(i).isEmpty()) {
size += handler.getStackInSlot(i).getCount(); size += handler.getStackInSlot(i).getCount();
} }
}
return size; return size;
} }

View File

@@ -6,6 +6,7 @@ import com.raoulvdberge.refinedstorage.container.ContainerBase;
import com.raoulvdberge.refinedstorage.gui.sidebutton.*; import com.raoulvdberge.refinedstorage.gui.sidebutton.*;
import com.raoulvdberge.refinedstorage.util.RenderUtils; import com.raoulvdberge.refinedstorage.util.RenderUtils;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.FMLCommonHandler;
import java.io.IOException; import java.io.IOException;
@@ -104,7 +105,7 @@ public class GuiStorage extends GuiBase {
drawTooltip(mouseX, mouseY, (gui.getCapacity() == -1 ? drawTooltip(mouseX, mouseY, (gui.getCapacity() == -1 ?
t("misc.refinedstorage:storage.stored_minimal", gui.getStored()) : t("misc.refinedstorage:storage.stored_minimal", gui.getStored()) :
t("misc.refinedstorage:storage.stored_capacity_minimal", gui.getStored(), gui.getCapacity()) t("misc.refinedstorage:storage.stored_capacity_minimal", gui.getStored(), gui.getCapacity())
) + "\n" + t("misc.refinedstorage:storage.full", full)); ) + "\n" + TextFormatting.GRAY + t("misc.refinedstorage:storage.full", full));
} }
} }