-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated user accessibility with keybinding entries and lockable mouse…
… scrolling (config) #7
- Loading branch information
Showing
5 changed files
with
63 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
package net.shirojr.boatism.event; | ||
|
||
import net.shirojr.boatism.event.custom.CommandRegistrationEvents; | ||
import net.shirojr.boatism.event.custom.KeyBindEvents; | ||
|
||
public class BoatismEvents { | ||
public static void registerEvents() { | ||
CommandRegistrationEvents.register(); | ||
} | ||
|
||
public static void registerClientEvents() { | ||
|
||
KeyBindEvents.register(); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/net/shirojr/boatism/event/custom/KeyBindEvents.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package net.shirojr.boatism.event.custom; | ||
|
||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; | ||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; | ||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; | ||
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; | ||
import net.minecraft.client.option.KeyBinding; | ||
import net.minecraft.client.util.InputUtil; | ||
import net.minecraft.network.PacketByteBuf; | ||
import net.shirojr.boatism.Boatism; | ||
import net.shirojr.boatism.network.BoatismNetworkIdentifiers; | ||
|
||
public class KeyBindEvents { | ||
private static KeyBinding POWER_LEVEL_UP; | ||
private static KeyBinding POWER_LEVEL_DOWN; | ||
|
||
private static final String BOATISM_KEYBINDINGS_GROUP = "key.%s.group".formatted(Boatism.MODID); | ||
public static void register() { | ||
POWER_LEVEL_UP = KeyBindingHelper.registerKeyBinding( | ||
new KeyBinding("key.%s.power_level_up".formatted(Boatism.MODID), | ||
InputUtil.Type.KEYSYM, InputUtil.UNKNOWN_KEY.getCode(), BOATISM_KEYBINDINGS_GROUP) | ||
); | ||
POWER_LEVEL_DOWN = KeyBindingHelper.registerKeyBinding( | ||
new KeyBinding("key.%s.power_level_down".formatted(Boatism.MODID), | ||
InputUtil.Type.KEYSYM, InputUtil.UNKNOWN_KEY.getCode(), BOATISM_KEYBINDINGS_GROUP) | ||
); | ||
|
||
ClientTickEvents.END_CLIENT_TICK.register(client -> { | ||
if (client.player == null) return; | ||
while (POWER_LEVEL_UP.wasPressed()) { | ||
sendPowerLevelChangePacket(1); | ||
} | ||
while (POWER_LEVEL_DOWN.wasPressed()) { | ||
sendPowerLevelChangePacket(-1); | ||
} | ||
}); | ||
} | ||
|
||
private static void sendPowerLevelChangePacket(int delta) { | ||
PacketByteBuf buf = PacketByteBufs.create(); | ||
buf.writeDouble(delta); | ||
ClientPlayNetworking.send(BoatismNetworkIdentifiers.SCROLLED.getIdentifier(), buf); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters