Fix server crash in Magical Scrubber

This commit is contained in:
zontreck 2023-12-27 13:16:46 -07:00
parent 950c5cad65
commit 8a395bd9d6

View file

@ -238,18 +238,23 @@ public class MagicalScrubberBlockEntity extends BlockEntity implements MenuProvi
if(enchantments.size()>0)
{
Iterator<Map.Entry<Enchantment,Integer>> iEntries = enchantments.entrySet().iterator();
Map.Entry<Enchantment,Integer> entry = iEntries.next();
EnchantmentInstance eInst = new EnchantmentInstance(entry.getKey(), entry.getValue());
existing = EnchantedBookItem.createForEnchantment(eInst);
enchantments.remove(entry.getKey());
//iEntries.remove();
main = makeOutputItem(main.copy());
while(iEntries.hasNext())
try{
Map.Entry<Enchantment,Integer> entry = iEntries.next();
EnchantmentInstance eInst = new EnchantmentInstance(entry.getKey(), entry.getValue());
existing = EnchantedBookItem.createForEnchantment(eInst);
iEntries.remove();
main = makeOutputItem(main.copy());
while(iEntries.hasNext())
{
entry = iEntries.next();
main.enchant(entry.getKey(), entry.getValue());
}
}catch(Exception E)
{
entry = iEntries.next();
main.enchant(entry.getKey(), entry.getValue());
entity.outputItems.setStackInSlot(0, main);
entity.itemsHandler.extractItem(0, 1, false);
entity.resetProgress();
return;
}
if(enchantments.size()==0){