Skip to content

Commit

Permalink
Fix Spell Randomizer crashing if empty
Browse files Browse the repository at this point in the history
  • Loading branch information
iron431 committed Aug 14, 2023
1 parent 11a96be commit f9f259b
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ protected RandomizeSpellFunction(LootItemCondition[] lootConditions, NumberProvi
protected ItemStack run(ItemStack itemStack, LootContext lootContext) {
//irons_spellbooks.LOGGER.debug("RandomizeScrollFunction.run {}", itemStack.hashCode());
if (itemStack.getItem() instanceof Scroll || Utils.canImbue(itemStack)) {

var spellList = getWeightedSpellList(applicableSpells.getApplicableSpells());
var applicableSpells = this.applicableSpells.getApplicableSpells();
if (applicableSpells.isEmpty()) {
//Return empty item stack
itemStack.setCount(0);
return itemStack;
}
var spellList = getWeightedSpellList(applicableSpells);
int total = spellList.floorKey(Integer.MAX_VALUE);
SpellType spellType = SpellType.NONE_SPELL;
if (!spellList.isEmpty()) {
Expand Down

0 comments on commit f9f259b

Please sign in to comment.