Create Enchantment Industry

Create Enchantment Industry

17M Downloads

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

VoidLeech opened this issue ยท 3 comments

commented

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:

  • chutes
  • funnels
  • hoppers
  • (that seems to be it for vanilla+create, but I imagine that other mods that add item-transport features break as well)

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

commented

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

commented

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

this.copyTarget = copyTarget;
matchPrintEntry(copyTarget);
tooExpensive = Printing.isTooExpensive(printEntry, copyTarget, CeiConfigs.SERVER.copierTankCapacity.get());
}
processingTicks = -1;
notifyUpdate();
}
private void matchPrintEntry(ItemStack copyTarget){
var entry = Printing.match(copyTarget);
if(entry==null){
// Happen when mod that contains a PrintEntry is removed.
this.copyTarget = null;
tooExpensive = false;
}
printEntry = entry;

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

commented

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.