Skip to content

Commit

Permalink
bypass keybind system for booming to prevent conflicting with vanilla…
Browse files Browse the repository at this point in the history
… hotbar keybinds
  • Loading branch information
gliscowo committed Jan 30, 2023
1 parent 10e9d73 commit e4717fc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main/java/io/wispforest/okboomer/OkBoomer.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ public void onInitializeClient() {
&& InputUtil.isKeyPressed(client.getWindow().getHandle(), KeyBindingHelper.getBoundKeyOf(ROTAT_BINDING).getCode())
&& ((Screen.hasControlDown() && Screen.hasShiftDown()) || currentlyRotatIng);

if (booming != BOOM_BINDING.isPressed()) {
boolean nowBooming = false;
while (BOOM_BINDING.wasPressed()) {
nowBooming = true;
}
boolean nowBooming = KeyBindingHelper.getBoundKeyOf(BOOM_BINDING).getCode() > 0
&& InputUtil.isKeyPressed(client.getWindow().getHandle(), KeyBindingHelper.getBoundKeyOf(BOOM_BINDING).getCode())
&& client.currentScreen == null;

if (booming != nowBooming) {
if (booming) {
boomDivisor = 1;
client.options.smoothCameraEnabled = smoothCameraRestoreValue;
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/io/wispforest/okboomer/mixin/KeyBindingMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.wispforest.okboomer.mixin;

import io.wispforest.okboomer.OkBoomer;
import net.minecraft.client.option.KeyBinding;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(KeyBinding.class)
public class KeyBindingMixin {

@Inject(method = "equals", at = @At("HEAD"), cancellable = true)
private void markCompatible(KeyBinding other, CallbackInfoReturnable<Boolean> cir) {
if (other != OkBoomer.BOOM_BINDING && (Object) this != OkBoomer.BOOM_BINDING) return;
cir.setReturnValue(false);
}

}
1 change: 1 addition & 0 deletions src/main/resources/ok-boomer.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"compatibilityLevel": "JAVA_17",
"client": [
"GameRendererMixin",
"KeyBindingMixin",
"MouseMixin"
],
"injectors": {
Expand Down

0 comments on commit e4717fc

Please sign in to comment.