Skip to content

Commit

Permalink
added targeting margin, not sure if it's working
Browse files Browse the repository at this point in the history
  • Loading branch information
CammiePone committed Apr 19, 2024
1 parent 9c4cefc commit fc7a7c7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,6 @@ public final class IcarusConfig {
public static boolean maxHeightEnabled = true;
@ConfigEntry(id = "max_height_above_world", type = EntryType.INTEGER, translation = "config.icarus.max_height_above_world")
public static int maxHeightAboveWorld = 64;
@ConfigEntry(id = "flying_target_radius", type = EntryType.FLOAT, translation = "config.icarus.flying_target_radius")
public static float flyingTargetRadius = 0.25f;
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package dev.cammiescorner.icarus.mixin;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import dev.cammiescorner.icarus.IcarusConfig;
import dev.cammiescorner.icarus.util.IcarusHelper;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -17,6 +20,14 @@ public abstract class EntityMixin {

@Shadow public float xRotO;

@ModifyReturnValue(method = "getPickRadius", at = @At("RETURN"))
private float icarus$targetRadius(float original) {
if(((Object) this) instanceof Player player && player.isFallFlying())
return Math.max(IcarusConfig.flyingTargetRadius, original * (1 + IcarusConfig.flyingTargetRadius));

return original;
}

@ModifyExpressionValue(method = "turn", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Mth;clamp(FFF)F", ordinal = 0))
private float icarus$updateLookDirection(float original) {
if(((Object) this) instanceof LivingEntity living) {
Expand Down
1 change: 1 addition & 0 deletions Common/src/main/resources/assets/icarus/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"config.icarus.roll_amount": "How much the player can roll while flying. (Requires CameraOverhaul)",
"config.icarus.max_height_enabled": "Whether or not to prevent flight above the maximum height allowed",
"config.icarus.max_height_above_world": "Maximum height above the world build limit that players can fly to",
"config.icarus.flying_target_radius": "How much the targeting hitbox of a flying player is increased by",

"message.icarus.status.no_fly.dimension": "Flying is not allowed in this dimension!"
}

0 comments on commit fc7a7c7

Please sign in to comment.