Skip to content

Commit 70d1b0c

Browse files
committed
fix: 🐛 Fixed Sojourner's Staff crash when a selected light source ran out
1 parent a5617f3 commit 70d1b0c

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ loader_version_range=[4,)
1515
mod_id=reliquary
1616
mod_name=Reliquary Reincarnations
1717
mod_license=All Rights Reserved
18-
mod_version=2.0.73
18+
mod_version=2.0.74
1919
mod_group_id=net.p3pp3rf1y
2020
mod_authors=P3pp3rF1y
2121
mod_description=Two words: magical swag. Oh, and a gun.

src/main/java/reliquary/item/SojournerStaffItem.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public InteractionResult use(Level level, Player player, InteractionHand hand) {
207207
if (inserted > 0) {
208208
int currentTorchIndex = getCurrentTorchIndex(staff);
209209
extractStoredCharge(staff, currentTorchIndex, inserted);
210-
if (currentTorchIndex != TORCH_SLOT && getTorchCount(staff) == 0) {
210+
if (currentTorchIndex != TORCH_SLOT && isSlotEmpty(staff, currentTorchIndex)) {
211211
removeSlot(staff, currentTorchIndex);
212212
}
213213
}
@@ -228,6 +228,10 @@ protected void extractStoredCharge(ItemStack containerStack, int slot, int charg
228228
getFromHandler(containerStack, handler -> handler.extractItem(slot, chargeToExtract, false));
229229
}
230230

231+
private boolean isSlotEmpty(ItemStack stack, int slot) {
232+
return getFromHandler(stack, handler -> slot < handler.getSlots() && handler.getStackInSlot(slot).isEmpty());
233+
}
234+
231235
@Override
232236
protected boolean removeSlotWhenEmpty(int slot) {
233237
return slot != TORCH_SLOT;

0 commit comments

Comments
 (0)