diff --git a/Common/src/main/java/dev/cammiescorner/icarus/IcarusConfig.java b/Common/src/main/java/dev/cammiescorner/icarus/IcarusConfig.java index 3ef4635..7c2f046 100644 --- a/Common/src/main/java/dev/cammiescorner/icarus/IcarusConfig.java +++ b/Common/src/main/java/dev/cammiescorner/icarus/IcarusConfig.java @@ -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; } diff --git a/Common/src/main/java/dev/cammiescorner/icarus/mixin/EntityMixin.java b/Common/src/main/java/dev/cammiescorner/icarus/mixin/EntityMixin.java index 9e77516..5348489 100644 --- a/Common/src/main/java/dev/cammiescorner/icarus/mixin/EntityMixin.java +++ b/Common/src/main/java/dev/cammiescorner/icarus/mixin/EntityMixin.java @@ -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; @@ -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) { diff --git a/Common/src/main/resources/assets/icarus/lang/en_us.json b/Common/src/main/resources/assets/icarus/lang/en_us.json index e7b62e1..9f86c9e 100644 --- a/Common/src/main/resources/assets/icarus/lang/en_us.json +++ b/Common/src/main/resources/assets/icarus/lang/en_us.json @@ -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!" }