diff --git a/code/datums/material_container.dm b/code/datums/material_container.dm
index 6870c3d303b01..d8e100575222d 100644
--- a/code/datums/material_container.dm
+++ b/code/datums/material_container.dm
@@ -60,9 +60,15 @@
return 0
/datum/material_container/proc/insert_stack(obj/item/stack/S, amt = 0)
- if(!amt)
+ if(amt <= 0)
+ return 0
+ if(amt > S.amount)
amt = S.amount
+
var/material_amt = get_item_material_amount(S)
+ if(!material_amt)
+ return 0
+
amt = min(amt, round(((max_amount - total_amount) / material_amt)))
if(!amt)
return 0
diff --git a/code/modules/clothing/shoes/bananashoes.dm b/code/modules/clothing/shoes/bananashoes.dm
index 795490b381f9e..a51af2db1b429 100644
--- a/code/modules/clothing/shoes/bananashoes.dm
+++ b/code/modules/clothing/shoes/bananashoes.dm
@@ -37,13 +37,17 @@
user << "You cannot retrieve any bananium from the prototype shoes."
/obj/item/clothing/shoes/clown_shoes/banana_shoes/attackby(obj/item/O, mob/user, params)
+ if(!istype(O,/obj/item/stack/sheet))
+ return
if(!bananium.get_item_material_amount(O))
user << "This item has no bananium!"
return
if(!user.unEquip(O))
user << "You can't drop [O]!"
return
- var/sheet_amount = bananium.insert_stack(O)
+
+ var/obj/item/stack/sheet/S = O
+ var/sheet_amount = bananium.insert_stack(O,S.amount)
if(sheet_amount)
user << "You insert [sheet_amount] bananium sheets into the prototype shoes."
else
diff --git a/code/modules/research/protolathe.dm b/code/modules/research/protolathe.dm
index 5b2ddee54a0cc..197ac1d725346 100644
--- a/code/modules/research/protolathe.dm
+++ b/code/modules/research/protolathe.dm
@@ -104,10 +104,12 @@ Note: Must be placed west/left of and R&D console to function.
return
if (stat)
return 1
- if(istype(O,/obj/item/stack/sheet))
- if(!materials.has_space( materials.get_item_material_amount(O) ))
- user << "The [src.name]'s material bin is full! Please remove material before adding more."
- return 1
+ if(!istype(O,/obj/item/stack/sheet))
+ return 1
+
+ if(!materials.has_space( materials.get_item_material_amount(O) ))
+ user << "The [src.name]'s material bin is full! Please remove material before adding more."
+ return 1
var/obj/item/stack/sheet/stack = O
var/amount = round(input("How many sheets do you want to add?") as num)//No decimals
@@ -115,7 +117,6 @@ Note: Must be placed west/left of and R&D console to function.
return
var/amount_inserted = materials.insert_stack(O,amount)
if(!amount_inserted)
- user << "You could not insert [O], it has no usable materials."
return 1
else
busy = 1