Skip to content

Commit

Permalink
Adjust player speed tweak hooks, closes #247
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed Aug 27, 2023
1 parent ccb7def commit 1892cf1
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@
import mod.acgaming.universaltweaks.config.UTConfig;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(PlayerCapabilities.class)
public class UTPlayerSpeedMixin
{
@Redirect(method = "getFlySpeed", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/PlayerCapabilities;flySpeed:F"))
public float utModifyFlySpeed(PlayerCapabilities instance)
@Inject(method = "getFlySpeed", at = @At(value = "RETURN"), cancellable = true)
public void utModifyFlySpeed(CallbackInfoReturnable<Float> cir)
{
return (float) UTConfig.TWEAKS_ENTITIES.PLAYER_SPEED.utPlayerFlySpeed;
if (UTConfig.TWEAKS_ENTITIES.PLAYER_SPEED.utPlayerSpeedToggle) cir.setReturnValue((float) UTConfig.TWEAKS_ENTITIES.PLAYER_SPEED.utPlayerFlySpeed);
}

@Redirect(method = "getWalkSpeed", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/player/PlayerCapabilities;walkSpeed:F"))
public float utModifyWalkSpeed(PlayerCapabilities instance)
@Inject(method = "getWalkSpeed", at = @At(value = "RETURN"), cancellable = true)
public void utModifyWalkSpeed(CallbackInfoReturnable<Float> cir)
{
return (float) UTConfig.TWEAKS_ENTITIES.PLAYER_SPEED.utPlayerWalkSpeed;
if (UTConfig.TWEAKS_ENTITIES.PLAYER_SPEED.utPlayerSpeedToggle) cir.setReturnValue((float) UTConfig.TWEAKS_ENTITIES.PLAYER_SPEED.utPlayerWalkSpeed);
}
}

0 comments on commit 1892cf1

Please sign in to comment.