DragonsPlusMinecraft / CreateEnchantmentIndustry

An add-on for Create, providing enchanting & experience related automation.
https://modrinth.com/mod/create-enchantment-industry
MIT License
45 stars 41 forks source link

Inserting a non-printable item into a printer crashes the game. #170

Closed VoidLeech closed 6 months ago

VoidLeech commented 6 months ago

Minecraft Version

1.20.1

Describe the Bug

Reported in the Create discord: https://discord.com/channels/620934202875183104/689866656914210897/1235653717240578110

Attempting to insert a non-printable item, using automatic item transport, into a printer crashes the game. Crashes with:

Reproduction Steps

  1. Place printer
  2. Place chute on top of printer
  3. Insert a non-printable item into the chute (say, an experience nugget, or a stripped oak log)
  4. Crash

Expected Result

No crash

Screenshots and Videos

No response

Crash Report or Log

https://mclo.gs/zW6NihO

Other Mods

Reproducible with just Create and CEI.

Mod Version

1.2.9.c

Forge Version

47.2.0

MarbleGateKeeper commented 6 months ago

I believe it's a bug of Create itself. The Chute does not check inserting avaliability before insertion. I'll do a temporary fix.

VoidLeech commented 6 months ago

Neither does the hopper (as mentioned before), here's a log: https://mclo.gs/RRbnydj

I think this solution will just work, but the real issue is probably in https://github.com/DragonsPlusMinecraft/CreateEnchantmentIndustry/blob/8ffc3c90434b42947760ab62f1584059aa67b157/src/main/java/plus/dragons/createenchantmentindustry/content/contraptions/enchanting/printer/PrinterBlockEntity.java#L105-L120 There is a null check for entry, but no early return, so you set printEntry to null regardless, which is then directly used in tooExpensive = Printing.isTooExpensive(...) matchPrintEntry should probably return a bool, or Printing.isTooExpensive should check for null

MarbleGateKeeper commented 6 months ago

Well, the code that uses the method does a check to make sure the entry won't be null already. So if the entry will be null after insertion, the insertion will be prohibited.