|
30 | 30 | import net.minecraft.client.multiplayer.ProfileKeyPairManager; |
31 | 31 | import net.minecraft.client.player.LocalPlayer; |
32 | 32 | import net.minecraft.util.thread.ReentrantBlockableEventLoop; |
| 33 | +import net.minecraft.world.entity.player.Player; |
| 34 | +import net.minecraft.world.entity.projectile.ProjectileUtil; |
| 35 | +import net.minecraft.world.phys.AABB; |
33 | 36 | import net.minecraft.world.phys.EntityHitResult; |
34 | | -import net.minecraft.world.phys.HitResult; |
| 37 | +import net.minecraft.world.phys.Vec3; |
35 | 38 | import net.wurstclient.WurstClient; |
36 | 39 | import net.wurstclient.event.EventManager; |
37 | 40 | import net.wurstclient.events.HandleBlockBreakingListener.HandleBlockBreakingEvent; |
@@ -131,12 +134,30 @@ private void onDoItemPick(CallbackInfo ci) |
131 | 134 | { |
132 | 135 | if(!WurstClient.INSTANCE.isEnabled()) |
133 | 136 | return; |
| 137 | + |
| 138 | + // Do a custom long-range entity raycast to find players |
| 139 | + // at greater distances than the vanilla reach limit |
| 140 | + LocalPlayer localPlayer = WurstClient.MC.player; |
| 141 | + if(localPlayer == null) |
| 142 | + return; |
| 143 | + |
| 144 | + double reach = 64.0; |
| 145 | + Vec3 eyePos = localPlayer.getEyePosition(1.0F); |
| 146 | + Vec3 lookVec = localPlayer.getViewVector(1.0F); |
| 147 | + Vec3 endPos = |
| 148 | + eyePos.add(lookVec.x * reach, lookVec.y * reach, lookVec.z * reach); |
| 149 | + |
| 150 | + AABB searchBox = localPlayer.getBoundingBox() |
| 151 | + .expandTowards(lookVec.scale(reach)).inflate(1.0); |
| 152 | + |
| 153 | + EntityHitResult hit = ProjectileUtil.getEntityHitResult(localPlayer, |
| 154 | + eyePos, endPos, searchBox, |
| 155 | + e -> e instanceof Player && !e.isSpectator(), reach * reach); |
134 | 156 |
|
135 | | - HitResult hitResult = WurstClient.MC.hitResult; |
136 | | - if(!(hitResult instanceof EntityHitResult eHitResult)) |
| 157 | + if(hit == null) |
137 | 158 | return; |
138 | 159 |
|
139 | | - WurstClient.INSTANCE.getFriends().middleClick(eHitResult.getEntity()); |
| 160 | + WurstClient.INSTANCE.getFriends().middleClick(hit.getEntity()); |
140 | 161 | } |
141 | 162 |
|
142 | 163 | /** |
|
0 commit comments