Skip to content

Commit

Permalink
fix: #152 for 1.21 don't sort in spectator
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHillcox committed Dec 10, 2024
1 parent 26a659a commit f8b7976
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/java/cpw/mods/inventorysorter/KeyHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@

package cpw.mods.inventorysorter;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen;
import net.minecraft.client.KeyMapping;
import com.mojang.blaze3d.platform.InputConstants;
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.level.GameType;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.EventPriority;
import net.neoforged.bus.api.IEventBus;
Expand Down Expand Up @@ -105,6 +108,12 @@ private boolean mouseScrollEvaluate(final KeyMapping kb, final ScreenEvent.Mouse
}

private <T extends ScreenEvent> void onInputEvent(T evt, BiPredicate<KeyMapping, T> kbTest) {
// Don't sort on spectator
MultiPlayerGameMode gameMode = Minecraft.getInstance().gameMode;
if (gameMode != null && gameMode.getPlayerMode() == GameType.SPECTATOR) {
return;
}

final Screen gui = evt.getScreen();
if (!(gui instanceof AbstractContainerScreen && !(gui instanceof CreativeModeInventoryScreen))) {
return;
Expand All @@ -130,4 +139,4 @@ private <T extends ScreenEvent> void onInputEvent(T evt, BiPredicate<KeyMapping,
}

}
}
}

0 comments on commit f8b7976

Please sign in to comment.