Skip to content

Commit

Permalink
RocketMan - Tweaked defaults since duration boost was patched. Added …
Browse files Browse the repository at this point in the history
…acceleration backoff threshold setting.
  • Loading branch information
0xTas committed Aug 6, 2024
1 parent 335a647 commit 1d215d4
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 26 deletions.
40 changes: 26 additions & 14 deletions src/main/java/dev/stardust/mixin/FireworkRocketEntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.util.math.MathHelper;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import net.minecraft.entity.FlyingItemEntity;
import com.llamalad7.mixinextras.sugar.Local;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -30,13 +31,20 @@ public abstract class FireworkRocketEntityMixin implements FlyingItemEntity {
@Shadow
private @Nullable LivingEntity shooter;

@Unique
private @Nullable RocketMan rm;

// See RocketMan.java
@Inject(method = "tick", at = @At("HEAD"))
private void createTrackedRocketEntity(CallbackInfo ci) {
if (this.shooter == null) return;
Modules modules = Modules.get();
if (modules == null) return;
RocketMan rm = modules.get(RocketMan.class);

if (this.rm == null) {
Modules modules = Modules.get();
if (modules == null) return;
rm = modules.get(RocketMan.class);
}

if (!rm.getClientInstance().player.isFallFlying()) return;
if (!this.shooter.getUuid().equals(rm.getClientInstance().player.getUuid())) return;
if (!rm.isActive() || rm.currentRocket == (Object)this) return;
Expand All @@ -60,21 +68,23 @@ private void createTrackedRocketEntity(CallbackInfo ci) {

@ModifyConstant(method = "tick", constant = @Constant(doubleValue = 1.5))
private double boostFireworkRocketSpeed(double multiplier) {
Modules modules = Modules.get();
if (modules == null) return multiplier;

RocketMan rm = modules.get(RocketMan.class);
if (this.rm == null) {
Modules modules = Modules.get();
if (modules == null) return multiplier;
rm = modules.get(RocketMan.class);
}
if (!rm.isActive() || !rm.boostSpeed.get()) return multiplier;

return rm.getRocketBoostAcceleration();
}

@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getVelocity()Lnet/minecraft/util/math/Vec3d;"))
private void spoofRotationVector(CallbackInfo ci, @Local(ordinal = 0) LocalRef<Vec3d> rotationVec) {
Modules modules = Modules.get();
if (modules == null) return;

RocketMan rm = modules.get(RocketMan.class);
if (this.rm == null) {
Modules modules = Modules.get();
if (modules == null) return;
rm = modules.get(RocketMan.class);
}
if (!rm.isActive() || !rm.shouldLockYLevel()) return;
if (!rm.getClientInstance().player.isFallFlying() || !rm.hasActiveRocket) return;

Expand All @@ -87,9 +97,11 @@ private void spoofRotationVector(CallbackInfo ci, @Local(ordinal = 0) LocalRef<V

@Inject(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/projectile/FireworkRocketEntity;explodeAndRemove()V", shift = At.Shift.BEFORE), cancellable = true)
private void extendFireworkDuration(CallbackInfo ci) {
Modules modules = Modules.get();
if (modules == null) return;
RocketMan rm = modules.get(RocketMan.class);
if (this.rm == null) {
Modules modules = Modules.get();
if (modules == null) return;
rm = modules.get(RocketMan.class);
}
if (rm.currentRocket == null) return;
if (!rm.isActive() || !rm.extendRockets.get()) return;
if (rm.currentRocket.getId() != ((FireworkRocketEntity)(Object)this).getId()) return;
Expand Down
14 changes: 11 additions & 3 deletions src/main/java/dev/stardust/mixin/LivingEntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Unique;
import com.llamalad7.mixinextras.sugar.Local;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -23,12 +25,18 @@ public LivingEntityMixin(EntityType<?> type, World world) {
super(type, world);
}

@Unique
@Nullable private RocketMan rm;

// See RocketMan.java
@Inject(method = "travel", at = @At(value = "INVOKE", target = "Ljava/lang/Math;sqrt(D)D"))
private void spoofPitchForSpeedCalcs(CallbackInfo ci, @Local(ordinal = 0) LocalFloatRef f, @Local(ordinal = 1)LocalRef<Vec3d> rotationVec) {
Modules modules = Modules.get();
if (modules == null) return;
RocketMan rm = modules.get(RocketMan.class);
if (this.rm == null) {
Modules modules = Modules.get();
if (modules == null) return;
rm = modules.get(RocketMan.class);
}

if (!rm.isActive() || !rm.shouldLockYLevel()) return;
if (!this.getUuid().equals(rm.getClientInstance().player.getUuid())) return;
if (!rm.getClientInstance().player.isFallFlying() || !rm.hasActiveRocket) return;
Expand Down
27 changes: 18 additions & 9 deletions src/main/java/dev/stardust/modules/RocketMan.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,19 @@ public enum RocketMode { OnForwardKey, Static, Dynamic }
.build()
);

private final Setting<Double> rocketSpeedThreshold = sgBoosts.add(
new DoubleSetting.Builder()
.name("Acceleration Backoff Threshold")
.description("Backs down on acceleration when you've slowed down enough since using your last rocket (to prevent rubberbanding.)")
.min(0).max(2).defaultValue(.69)
.build()
);

public final Setting<Boolean> extendRockets = sgBoosts.add(
new BoolSetting.Builder()
.name("Boost Rocket Duration")
.description("Extend the duration of your rocket's boost effect.")
.defaultValue(true)
.defaultValue(false)
.build()
);

Expand Down Expand Up @@ -214,6 +222,14 @@ public enum RocketMode { OnForwardKey, Static, Dynamic }
.build()
);

public final Setting<Boolean> forceRocketUsage = sgHover.add(
new BoolSetting.Builder()
.name("Force Rocket Usage")
.description("Force rocket usage when hovering.")
.defaultValue(true)
.build()
);

public final Setting<Boolean> yLevelLock = sgControl.add(
new BoolSetting.Builder()
.name("Y Level Lock")
Expand Down Expand Up @@ -422,13 +438,6 @@ public enum RocketMode { OnForwardKey, Static, Dynamic }
.build()
);

private final Setting<Double> rocketSpeedThreshold = sgScroll.add(
new DoubleSetting.Builder()
.name("Rocket Accel Threshold (Debug)")
.min(0).max(2).defaultValue(.85)
.build()
);

private int timer = 0;
private int ticksBusy = 0;
private int hoverTimer = 0;
Expand Down Expand Up @@ -852,7 +861,7 @@ private void onTick(TickEvent.Pre event) {
++durabilityCheckTicks;
if (hoverTimer == 2 && (!hasActiveRocket || durationBoosted)) {
useFireworkRocket("hover initiate");
} else if (!hasActiveRocket) useFireworkRocket("hover maintain");
} else if (!hasActiveRocket && forceRocketUsage.get()) useFireworkRocket("hover maintain");
return;
} else hoverTimer = 0;

Expand Down

0 comments on commit 1d215d4

Please sign in to comment.