Skip to content

Commit ea409d7

Browse files
committed
fix: 🐛 Fixed Sojourner's Staff crash when a selected light source ran out
1 parent 8c237b8 commit ea409d7

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.79
18+
mod_version=2.0.80
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
@@ -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)