Create Fabric

Create Fabric

10M Downloads

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

f-raZ0R opened this issue ยท 2 comments

commented

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.

resultingItem = ctx.getItemVariant().toStack((int) ctx.getAmount());
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. DaFuqs/Spectrum#516

Crash Report

https://mclo.gs/fg65w5S

commented

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

commented

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.