Skip to content

Commit 3e644a2

Browse files
committed
Fix crash from assert items entity
1 parent 452fbea commit 3e644a2

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ minecraft_version=1.21.11-rc2
88
loader_version=0.18.1
99

1010
# Mod Properties
11-
mod_version=2.4.0-beta1
11+
mod_version=2.4.0-beta2
1212
maven_group=io.github.misode
1313
archives_base_name=packtest
1414

src/main/java/io/github/misode/packtest/commands/AssertCommand.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import net.minecraft.server.level.ServerPlayer;
3535
import net.minecraft.world.Container;
3636
import net.minecraft.world.entity.Entity;
37+
import net.minecraft.world.entity.SlotAccess;
3738
import net.minecraft.world.inventory.SlotRange;
3839
import net.minecraft.world.item.ItemStack;
3940
import net.minecraft.world.level.block.entity.BlockEntity;
@@ -200,9 +201,9 @@ private static AssertResult assertItemsEntity(CommandContext<CommandSourceStack>
200201
for(Entity entity : entities) {
201202
IntList slots = slotRange.slots();
202203
for(int i = 0; i < slots.size(); ++i) {
203-
ItemStack itemStack = Objects.requireNonNull(entity.getSlot(slots.getInt(i))).get();
204-
if (itemPredicate.test(itemStack)) {
205-
count += itemStack.getCount();
204+
SlotAccess slot = entity.getSlot(slots.getInt(i));
205+
if (slot != null && itemPredicate.test(slot.get())) {
206+
count += slot.get().getCount();
206207
}
207208
}
208209
}

0 commit comments

Comments
 (0)