Skip to content

Commit 7a26cec

Browse files
committed
fix: 🐛 Fixed Sojourner's Staff crash when a selected light source ran out
1 parent 7ead7db commit 7a26cec

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
@@ -13,7 +13,7 @@ loader_version_range=[4,)
1313
mod_id=reliquary
1414
mod_name=Reliquary Reincarnations
1515
mod_license=All Rights Reserved
16-
mod_version=2.0.87
16+
mod_version=2.0.88
1717
mod_group_id=net.p3pp3rf1y
1818
mod_authors=P3pp3rF1y
1919
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
@@ -208,7 +208,7 @@ public InteractionResult use(Level level, Player player, InteractionHand hand) {
208208
if (inserted > 0) {
209209
int currentTorchIndex = getCurrentTorchIndex(staff);
210210
extractStoredCharge(staff, currentTorchIndex, inserted);
211-
if (currentTorchIndex != TORCH_SLOT && getTorchCount(staff) == 0) {
211+
if (currentTorchIndex != TORCH_SLOT && isSlotEmpty(staff, currentTorchIndex)) {
212212
removeSlot(staff, currentTorchIndex);
213213
}
214214
}
@@ -229,6 +229,10 @@ protected void extractStoredCharge(ItemStack containerStack, int slot, int charg
229229
getFromHandler(containerStack, handler -> handler.extractItem(slot, chargeToExtract));
230230
}
231231

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

0 commit comments

Comments
 (0)