Skip to content

Commit df1f758

Browse files
authored
feat(module): implement option to disable middle click extra in creative mode (#5795)
1 parent 31717aa commit df1f758

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/main/java/meteordevelopment/meteorclient/systems/modules/player/MiddleClickExtra.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import net.minecraft.item.Items;
3030
import net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket;
3131
import net.minecraft.util.Hand;
32+
import net.minecraft.world.GameMode;
3233

3334
import static org.lwjgl.glfw.GLFW.GLFW_MOUSE_BUTTON_MIDDLE;
3435

@@ -66,6 +67,13 @@ public class MiddleClickExtra extends Module {
6667
.build()
6768
);
6869

70+
private final Setting<Boolean> disableInCreative = sgGeneral.add(new BoolSetting.Builder()
71+
.name("disable-in-creative")
72+
.description("Middle click action is disabled in Creative mode.")
73+
.defaultValue(true)
74+
.build()
75+
);
76+
6977
private final Setting<Boolean> notify = sgGeneral.add(new BoolSetting.Builder()
7078
.name("notify")
7179
.description("Notifies you when you do not have the specified item in your hotbar.")
@@ -92,6 +100,8 @@ public void onDeactivate() {
92100
private void onMouseClick(MouseClickEvent event) {
93101
if (event.action != KeyAction.Press || event.button() != GLFW_MOUSE_BUTTON_MIDDLE || mc.currentScreen != null) return;
94102

103+
if (disabledByCreative()) return;
104+
95105
if (mode.get() == Mode.AddFriend) {
96106
if (mc.targetedEntity == null) return;
97107
if (!(mc.targetedEntity instanceof PlayerEntity player)) return;
@@ -180,6 +190,12 @@ void swapBack(boolean wasCancelled) {
180190
}
181191
}
182192

193+
private boolean disabledByCreative() {
194+
if (mc.player == null) return false;
195+
196+
return disableInCreative.get() && mc.player.getGameMode() == GameMode.CREATIVE;
197+
}
198+
183199
public enum Mode {
184200
Pearl(Items.ENDER_PEARL, true),
185201
XP(Items.EXPERIENCE_BOTTLE, true),

0 commit comments

Comments
 (0)