Fabricators-of-Create / Create

[Fabric Mod] Building Tools and Aesthetic Technology
MIT License
887 stars 200 forks source link

Item Drains crash the game when fluid containing items that do not leave remainders get inserted into them #1622

Closed f-raZ0R closed 3 days ago

f-raZ0R commented 3 days ago

Context

I am not sure whether this is a case of "I am doing something that is bad practice, and there is a better way to implement such an item", or a case of "create shouldn't be doing it like this", but I can see exactly the part of code that causes this crash.

https://github.com/Fabricators-of-Create/Create/blob/4617718a381d455546ed8bed014b5cdd220f1bdb/src/main/java/com/simibubi/create/content/fluids/transfer/GenericItemEmptying.java#L68 right here, you unconditionally call getAmount() on the item remainder, without checking whether said item remainder... exists.

getAmount, does... default long getAmount() { if (getItemVariant().isBlank()) { throw new IllegalStateException("Amount may not be queried when the current item variant is blank."); } not like being given a nonexistent item

"wait a minute Athebyne what are you doing how did you implement a fluid containing item without a remainder. can you even do that" here is my pr with said implementation. https://github.com/DaFuqs/Spectrum/pull/516

Crash Report

https://mclo.gs/fg65w5S

TropheusJ commented 3 days ago

of course it doesn't just return 0, that would be absurd... needs to be fixed in create.

f-raZ0R commented 3 days ago

if it's relevant, it also ups the severity of this crash that the block entity remains processing the item. So this winds up being a ticking entity crash, and it crashes the game again as soon as it is loaded.