Skip to content

Commit b1b3972

Browse files
committed
fix: 🐛 Fixed Sojourner's Staff crash when a selected light source ran out
1 parent 94050c2 commit b1b3972

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.78
18+
mod_version=2.0.79
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
@@ -209,7 +209,7 @@ public InteractionResult use(Level level, Player player, InteractionHand hand) {
209209
if (inserted > 0) {
210210
int currentTorchIndex = getCurrentTorchIndex(staff);
211211
extractStoredCharge(staff, currentTorchIndex, inserted);
212-
if (currentTorchIndex != TORCH_SLOT && getTorchCount(staff) == 0) {
212+
if (currentTorchIndex != TORCH_SLOT && isSlotEmpty(staff, currentTorchIndex)) {
213213
removeSlot(staff, currentTorchIndex);
214214
}
215215
}
@@ -230,6 +230,10 @@ protected void extractStoredCharge(ItemStack containerStack, int slot, int charg
230230
getFromHandler(containerStack, handler -> handler.extractItem(slot, chargeToExtract));
231231
}
232232

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

0 commit comments

Comments
 (0)