Skip to content

Commit

Permalink
RocketMan - Changed OnForwardKey mode to OnKey mode and made the keyb…
Browse files Browse the repository at this point in the history
…ind configurable.
  • Loading branch information
0xTas committed Nov 7, 2024
1 parent 401b8b7 commit 28135a1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/main/java/dev/stardust/mixin/MinecraftClientMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private void mixinRender(CallbackInfo ci) {
RocketMan.RocketMode mode = rocketMan.usageMode.get();

switch (mode) {
case OnForwardKey -> {
case OnKey -> {
if (mc.player.input.sneaking) {
mc.player.changeLookDirection(0.0f, rocketMan.getPitchSpeed() * deltaTime);
} else if (mc.player.input.jumping) {
Expand Down
22 changes: 16 additions & 6 deletions src/main/java/dev/stardust/modules/RocketMan.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public RocketMan() {

public enum KeyModifiers { Alt, Ctrl, Shift, None }
public enum HoverMode { Off, Hold, Toggle, Creative }
public enum RocketMode { OnForwardKey, Static, Dynamic, Speed }
public enum RocketMode {OnKey, Static, Dynamic, Speed }

private final SettingGroup sgRockets = settings.createGroup("Rocket Usage");
private final SettingGroup sgBoosts = settings.createGroup("Rocket Boosts");
Expand All @@ -61,7 +61,15 @@ public enum RocketMode { OnForwardKey, Static, Dynamic, Speed }
new EnumSetting.Builder<RocketMode>()
.name("Usage Mode")
.description("Which mode to operate in.")
.defaultValue(RocketMode.OnForwardKey)
.defaultValue(RocketMode.OnKey)
.build()
);

public final Setting<Keybind> usageKey = sgRockets.add(
new KeybindSetting.Builder()
.name("Rocket Key")
.description("The key you want to press to use a rocket.")
.defaultValue(Keybind.fromKey(GLFW.GLFW_KEY_W))
.build()
);

Expand All @@ -70,7 +78,7 @@ public enum RocketMode { OnForwardKey, Static, Dynamic, Speed }
.name("Rocket Usage Cooldown")
.description("How often (in ticks) to allow using firework rockets.")
.range(1, 10000).sliderRange(2, 100).defaultValue(40)
.visible(() -> usageMode.get().equals(RocketMode.OnForwardKey) || usageMode.get().equals(RocketMode.Speed))
.visible(() -> usageMode.get().equals(RocketMode.OnKey) || usageMode.get().equals(RocketMode.Speed))
.build()
);

Expand Down Expand Up @@ -196,7 +204,7 @@ public enum RocketMode { OnForwardKey, Static, Dynamic, Speed }
.name("Invert Pitch")
.description("Invert pitch control for W & S keys.")
.defaultValue(false)
.visible(() -> keyboardControl.get() && !usageMode.get().equals(RocketMode.OnForwardKey))
.visible(() -> keyboardControl.get() && !usageMode.get().equals(RocketMode.OnKey))
.build()
);

Expand Down Expand Up @@ -685,6 +693,7 @@ public boolean shouldMuteElytra() {

// See FireworkRocketEntityMixin.java
public double getRocketBoostAcceleration() {
if (isHovering) return 0.0;
double maxSpeed = speedSetting.get();
double currentBps = Math.round(Utils.getPlayerSpeed().length() * 100) * .01;
double increment = shouldLockYLevel() ? accelerationSetting.get() * 2 : accelerationSetting.get();
Expand Down Expand Up @@ -868,6 +877,7 @@ private void onTick(TickEvent.Pre event) {
++timer;
++hoverTimer;
++ticksFlying;
firstRocket = true;
++rocketStockTicks;
++durabilityCheckTicks;
if (hoverTimer == 2 && (!hasActiveRocket || durationBoosted)) {
Expand Down Expand Up @@ -898,8 +908,8 @@ private void onTick(TickEvent.Pre event) {
case Dynamic -> {
if (!hasActiveRocket) useFireworkRocket("dynamic usage");
}
case OnForwardKey -> {
if (mc.player.input.pressingForward && !justUsed) {
case OnKey -> {
if (usageKey.get().isPressed() && !justUsed) {
justUsed = true;
useFireworkRocket("forward key usage");
}
Expand Down

0 comments on commit 28135a1

Please sign in to comment.