Skip to content

Commit 492f001

Browse files
committed
fix sortInventory crashes the client due to null tag from data components
1 parent 9bc5e62 commit 492f001

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/main/java/com/plusls/ommc/impl/feature/sortInventory/SortInventoryHelper.java

+15-2
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,21 @@ public int compare(ItemStack a, ItemStack b) {
431431
//#else
432432
//$$ CustomData dataA = a.get(DataComponents.CUSTOM_DATA);
433433
//$$ CustomData dataB = b.get(DataComponents.CUSTOM_DATA);
434-
//$$ CompoundTag tagA = dataA.copyTag();
435-
//$$ CompoundTag tagB = dataB.copyTag();
434+
//$$ CustomData dataA = a.get(DataComponents.CUSTOM_DATA);
435+
//$$ CustomData dataB = b.get(DataComponents.CUSTOM_DATA);
436+
//$$ CompoundTag tagA, tagB;
437+
//$$ if (dataA != null) {
438+
//$$ tagA = dataA.copyTag();
439+
//$$ }
440+
//$$ else{
441+
//$$ tagA = null;
442+
//$$ }
443+
//$$ if (dataB != null) {
444+
//$$ tagB = dataB.copyTag();
445+
//$$ }
446+
//$$ else{
447+
//$$ tagB = null;
448+
//$$ }
436449
//#endif
437450

438451
if (ShulkerBoxItemHelper.isShulkerBoxBlockItem(a) && ShulkerBoxItemHelper.isShulkerBoxBlockItem(b) &&

0 commit comments

Comments
 (0)