Skip to content

Commit f3a8af5

Browse files
committed
🐛 Fix using item not being released on gui open
1 parent f631b23 commit f3a8af5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

common/src/main/java/com/mrcrayfish/controllable/client/ControllerEvents.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package com.mrcrayfish.controllable.client;
22

3+
import com.mrcrayfish.controllable.Controllable;
34
import com.mrcrayfish.controllable.client.binding.ButtonBinding;
45
import com.mrcrayfish.controllable.client.gui.screens.SettingsScreen;
56
import com.mrcrayfish.controllable.client.gui.widget.ControllerButton;
7+
import com.mrcrayfish.controllable.client.input.Controller;
68
import com.mrcrayfish.framework.api.event.ScreenEvents;
79
import net.minecraft.client.Minecraft;
810
import net.minecraft.client.gui.components.AbstractWidget;
@@ -26,6 +28,17 @@ public static void init()
2628
private static void onScreenInit(Screen screen)
2729
{
2830
ButtonBinding.resetButtonStates();
31+
32+
// Fixes an issue where using item is not stopped after opening a screen
33+
Controller controller = Controllable.getController();
34+
if(controller != null && Controllable.getInput().isControllerInUse())
35+
{
36+
Minecraft mc = Minecraft.getInstance();
37+
if(mc.gameMode != null && mc.player != null && mc.player.isUsingItem())
38+
{
39+
mc.gameMode.releaseUsingItem(mc.player);
40+
}
41+
}
2942
}
3043

3144
private static void onModifyScreenWidgets(Screen screen, List<AbstractWidget> widgets, Consumer<AbstractWidget> add, Consumer<AbstractWidget> remove)

0 commit comments

Comments
 (0)