Skip to content

Commit

Permalink
Fixed Crash with Hotbar Swap (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
0hwx authored Jan 13, 2025
1 parent 7b170ad commit 96d9729
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main/java/com/cleanroommc/bogosorter/common/HotbarSwap.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ public static boolean isEnabled() {

@SubscribeEvent
public void render(RenderGameOverlayEvent.Post event) {
if (enabled && event.type == RenderGameOverlayEvent.ElementType.ALL && show) {
if (enabled && Minecraft.getMinecraft().thePlayer.inventory.currentItem < 9
&& event.type == RenderGameOverlayEvent.ElementType.ALL
&& show) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

EntityPlayer player = Minecraft.getMinecraft().thePlayer;
Expand Down Expand Up @@ -95,7 +97,9 @@ public void render(RenderGameOverlayEvent.Post event) {

@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {
if (!enabled || Minecraft.getMinecraft().theWorld == null || Minecraft.getMinecraft().thePlayer == null) {
if (!enabled || Minecraft.getMinecraft().theWorld == null
|| Minecraft.getMinecraft().thePlayer == null
|| Minecraft.getMinecraft().thePlayer.inventory.currentItem > 8) {
return;
}
if (show) {
Expand All @@ -120,7 +124,7 @@ public void onKeyInput(InputEvent.KeyInputEvent event) {

@SubscribeEvent
public void onMouseInput(InputEvent.MouseInputEvent event) {
if (!enabled) return;
if (!enabled || Minecraft.getMinecraft().thePlayer.inventory.currentItem > 8) return;
if (show) {
int scroll = Mouse.getEventDWheel();
if (scroll != 0) {
Expand Down

0 comments on commit 96d9729

Please sign in to comment.