Skip to content

Commit 0e31af1

Browse files
committed
aimassist pls :3
1 parent bc4257e commit 0e31af1

4 files changed

Lines changed: 313 additions & 9 deletions

File tree

src/main/java/io/github/moulberry/notenoughupdates/coffeeclient/CoffeeClient.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import io.github.moulberry.notenoughupdates.coffeeclient.module.modules.InvWalkModule;
3838
import io.github.moulberry.notenoughupdates.coffeeclient.module.modules.AimAssistModule;
3939
import io.github.moulberry.notenoughupdates.coffeeclient.module.modules.VelocityModule;
40+
import io.github.moulberry.notenoughupdates.coffeeclient.module.modules.TrajectoriesModule;
4041
import io.github.moulberry.notenoughupdates.coffeeclient.property.Property;
4142
import io.github.moulberry.notenoughupdates.coffeeclient.property.PropertyManager;
4243
import net.minecraftforge.common.MinecraftForge;
@@ -48,7 +49,7 @@
4849

4950
public class CoffeeClient {
5051

51-
public static final String CLIENT_NAME = "&7[&bCoffeeClient&7]&r ";
52+
public static final String CLIENT_NAME = "&7[&bSchrodinger's Client&7]&r ";
5253
public static final Logger LOGGER = LogManager.getLogger("CoffeeClient");
5354

5455
public static ModuleManager moduleManager;
@@ -107,6 +108,7 @@ private static void registerModules() {
107108
moduleManager.registerModule(InvWalkModule.class, new InvWalkModule());
108109
moduleManager.registerModule(AimAssistModule.class, new AimAssistModule());
109110
moduleManager.registerModule(VelocityModule.class, new VelocityModule());
111+
moduleManager.registerModule(TrajectoriesModule.class, new TrajectoriesModule());
110112
}
111113

112114
private static void registerCommands() {

src/main/java/io/github/moulberry/notenoughupdates/coffeeclient/module/ModuleManager.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
/*
2-
* Copyright (C) 2025 CoffeeClient contributors
3-
*
4-
* This file is part of CoffeeClient addon for NotEnoughUpdates.
5-
*/
6-
71
package io.github.moulberry.notenoughupdates.coffeeclient.module;
82

93
import net.minecraftforge.common.MinecraftForge;

src/main/java/io/github/moulberry/notenoughupdates/coffeeclient/module/modules/AimAssistModule.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import io.github.moulberry.notenoughupdates.coffeeclient.property.properties.IntProperty;
1313
import io.github.moulberry.notenoughupdates.coffeeclient.util.RandomUtil;
1414
import io.github.moulberry.notenoughupdates.coffeeclient.util.RotationUtil;
15+
import io.github.moulberry.notenoughupdates.coffeeclient.util.TeamUtil;
16+
import io.github.moulberry.notenoughupdates.coffeeclient.util.ItemUtil;
1517

1618
import net.minecraft.client.Minecraft;
1719
import net.minecraft.entity.Entity;
@@ -35,6 +37,9 @@ public class AimAssistModule extends Module {
3537
public final BooleanProperty playersOnly = new BooleanProperty("players-only", true);
3638
public final BooleanProperty targetInvisible = new BooleanProperty("target-invisible", false);
3739
public final BooleanProperty ignoreTeammates = new BooleanProperty("ignore-teammates", true);
40+
public final BooleanProperty weaponsOnly = new BooleanProperty("weapons-only", true);
41+
public final BooleanProperty allowTools = new BooleanProperty("allow-tools", false);
42+
public final BooleanProperty team = new BooleanProperty("teams", true);
3843

3944
public AimAssistModule() {
4045
super("AimAssist", false);
@@ -46,6 +51,13 @@ public void onClientTick(TickEvent.ClientTickEvent event) {
4651
return;
4752
}
4853

54+
// Check weapons-only restriction
55+
if (weaponsOnly.getValue() && !ItemUtil.hasRawUnbreakingEnchant()) {
56+
if (!allowTools.getValue() || !ItemUtil.isHoldingTool()) {
57+
return;
58+
}
59+
}
60+
4961
if (event.phase == TickEvent.Phase.END) {
5062
if (!onClick.getValue() || mc.gameSettings.keyBindAttack.isKeyDown()) {
5163
EntityLivingBase target = findTarget();
@@ -100,9 +112,21 @@ private EntityLivingBase findTarget() {
100112
continue;
101113
}
102114

103-
if (ignoreTeammates.getValue() && living instanceof EntityPlayer) {
115+
if (living instanceof EntityPlayer) {
104116
EntityPlayer player = (EntityPlayer) living;
105-
if (mc.thePlayer.isOnSameTeam(player)) {
117+
118+
// Check teams setting
119+
if (team.getValue() && TeamUtil.isSameTeam(player)) {
120+
continue;
121+
}
122+
123+
// Legacy ignore teammates check
124+
if (ignoreTeammates.getValue() && mc.thePlayer.isOnSameTeam(player)) {
125+
continue;
126+
}
127+
128+
// Check for bots
129+
if (TeamUtil.isBot(player)) {
106130
continue;
107131
}
108132
}
Lines changed: 284 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,284 @@
1+
/*
2+
* Copyright (C) 2025 CoffeeClient contributors
3+
*
4+
* This file is part of CoffeeClient addon for NotEnoughUpdates.
5+
*/
6+
7+
package io.github.moulberry.notenoughupdates.coffeeclient.module.modules;
8+
9+
import io.github.moulberry.notenoughupdates.coffeeclient.module.Module;
10+
import io.github.moulberry.notenoughupdates.coffeeclient.property.properties.BooleanProperty;
11+
import io.github.moulberry.notenoughupdates.coffeeclient.property.properties.IntProperty;
12+
import io.github.moulberry.notenoughupdates.mixins.AccessorRenderManager;
13+
import net.minecraft.block.material.Material;
14+
import net.minecraft.client.Minecraft;
15+
import net.minecraft.client.renderer.GlStateManager;
16+
import net.minecraft.client.renderer.Tessellator;
17+
import net.minecraft.client.renderer.WorldRenderer;
18+
import net.minecraft.client.renderer.entity.RenderManager;
19+
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
20+
import net.minecraft.entity.Entity;
21+
import net.minecraft.item.*;
22+
import net.minecraft.util.*;
23+
import net.minecraftforge.client.event.RenderWorldLastEvent;
24+
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
25+
import org.lwjgl.opengl.GL11;
26+
27+
import java.awt.*;
28+
import java.util.ArrayList;
29+
30+
public class TrajectoriesModule extends Module {
31+
private static final Minecraft mc = Minecraft.getMinecraft();
32+
33+
public final IntProperty opacity = new IntProperty("opacity", 100, 0, 100);
34+
public final BooleanProperty bow = new BooleanProperty("bow", true);
35+
public final BooleanProperty projectiles = new BooleanProperty("projectiles", false);
36+
public final BooleanProperty pearls = new BooleanProperty("pearls", true);
37+
38+
public TrajectoriesModule() {
39+
super("Trajectories", false, true);
40+
}
41+
42+
@SubscribeEvent
43+
public void onRenderWorld(RenderWorldLastEvent event) {
44+
if (!isEnabled() || mc.thePlayer == null || mc.thePlayer.getHeldItem() == null
45+
|| mc.gameSettings.thirdPersonView != 0) {
46+
return;
47+
}
48+
49+
Item item = mc.thePlayer.getHeldItem().getItem();
50+
RenderManager renderManager = mc.getRenderManager();
51+
boolean isBow = false;
52+
float velocityMultiplier = 1.5F;
53+
float drag = 0.99F;
54+
float gravity;
55+
float hitboxExpand;
56+
57+
if (item instanceof ItemBow && bow.getValue()) {
58+
if (!mc.thePlayer.isUsingItem()) {
59+
return;
60+
}
61+
isBow = true;
62+
gravity = 0.05F;
63+
hitboxExpand = 0.3F;
64+
float charge = (float) mc.thePlayer.getItemInUseDuration() / 20.0F;
65+
charge = (charge * charge + charge * 2.0F) / 3.0F;
66+
if (charge < 0.1F) {
67+
return;
68+
}
69+
if (charge > 1.0F) {
70+
charge = 1.0F;
71+
}
72+
velocityMultiplier = charge * 3.0F;
73+
} else if (item instanceof ItemFishingRod && projectiles.getValue()) {
74+
gravity = 0.04F;
75+
hitboxExpand = 0.25F;
76+
drag = 0.92F;
77+
} else if ((item instanceof ItemSnowball || item instanceof ItemEgg) && projectiles.getValue()) {
78+
gravity = 0.03F;
79+
hitboxExpand = 0.25F;
80+
} else {
81+
if (!(item instanceof ItemEnderPearl) || !pearls.getValue()) {
82+
return;
83+
}
84+
gravity = 0.03F;
85+
hitboxExpand = 0.25F;
86+
}
87+
88+
float yaw = mc.thePlayer.rotationYaw;
89+
float pitch = mc.thePlayer.rotationPitch;
90+
double x = ((AccessorRenderManager) renderManager).getRenderPosX() -
91+
(double) MathHelper.cos(yaw / 180.0F * (float) Math.PI) * 0.16;
92+
double y = ((AccessorRenderManager) renderManager).getRenderPosY() +
93+
(double) mc.thePlayer.getEyeHeight() - 0.1F;
94+
double z = ((AccessorRenderManager) renderManager).getRenderPosZ() -
95+
(double) MathHelper.sin(yaw / 180.0F * (float) Math.PI) * 0.16;
96+
97+
double mx = (double) (MathHelper.sin(yaw / 180.0F * (float) Math.PI) *
98+
MathHelper.cos(pitch / 180.0F * (float) Math.PI)) * (isBow ? 1.0 : 0.4) * -1.0;
99+
double my = (double) MathHelper.sin(pitch / 180.0F * (float) Math.PI) *
100+
(isBow ? 1.0 : 0.4) * -1.0;
101+
double mz = (double) (MathHelper.cos(yaw / 180.0F * (float) Math.PI) *
102+
MathHelper.cos(pitch / 180.0F * (float) Math.PI)) * (isBow ? 1.0 : 0.4);
103+
104+
float mag = MathHelper.sqrt_double(mx * mx + my * my + mz * mz);
105+
mx /= mag;
106+
my /= mag;
107+
mz /= mag;
108+
mx *= velocityMultiplier;
109+
my *= velocityMultiplier;
110+
mz *= velocityMultiplier;
111+
112+
MovingObjectPosition mop = null;
113+
boolean hasHitBlock = false;
114+
boolean hasHitEntity = false;
115+
WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer();
116+
ArrayList<Vec3> trajectoryPoints = new ArrayList<>();
117+
118+
while (!hasHitBlock && y > 0.0) {
119+
Vec3 start = new Vec3(x, y, z);
120+
Vec3 end = new Vec3(x + mx, y + my, z + mz);
121+
mop = mc.theWorld.rayTraceBlocks(start, end, false, true, false);
122+
start = new Vec3(x, y, z);
123+
end = new Vec3(x + mx, y + my, z + mz);
124+
125+
if (mop != null) {
126+
hasHitBlock = true;
127+
end = new Vec3(mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord);
128+
}
129+
130+
AxisAlignedBB aabb = new AxisAlignedBB(
131+
x - (double) hitboxExpand,
132+
y - (double) hitboxExpand,
133+
z - (double) hitboxExpand,
134+
x + (double) hitboxExpand,
135+
y + (double) hitboxExpand,
136+
z + (double) hitboxExpand).addCoord(mx, my, mz).expand(1.0, 1.0, 1.0);
137+
138+
int minChunkX = MathHelper.floor_double((aabb.minX - 2.0) / 16.0);
139+
int maxChunkX = MathHelper.floor_double((aabb.maxX + 2.0) / 16.0);
140+
int minChunkZ = MathHelper.floor_double((aabb.minZ - 2.0) / 16.0);
141+
int maxChunkZ = MathHelper.floor_double((aabb.maxZ + 2.0) / 16.0);
142+
ArrayList<Entity> possibleEntities = new ArrayList<>();
143+
144+
for (int x1 = minChunkX; x1 <= maxChunkX; ++x1) {
145+
for (int z1 = minChunkZ; z1 <= maxChunkZ; ++z1) {
146+
mc.theWorld.getChunkFromChunkCoords(x1, z1).getEntitiesWithinAABBForEntity(
147+
mc.thePlayer,
148+
aabb,
149+
possibleEntities,
150+
null);
151+
}
152+
}
153+
154+
for (Entity entity : possibleEntities) {
155+
if (entity.canBeCollidedWith() && entity != mc.thePlayer) {
156+
AxisAlignedBB entityBox = entity.getEntityBoundingBox().expand(
157+
hitboxExpand,
158+
hitboxExpand,
159+
hitboxExpand);
160+
MovingObjectPosition intercept = entityBox.calculateIntercept(start, end);
161+
if (intercept != null) {
162+
hasHitEntity = true;
163+
hasHitBlock = true;
164+
mop = intercept;
165+
}
166+
}
167+
}
168+
169+
x += mx;
170+
y += my;
171+
z += mz;
172+
173+
if (mc.theWorld.getBlockState(new BlockPos(x, y, z)).getBlock().getMaterial() == Material.water) {
174+
mx *= 0.6;
175+
my *= 0.6;
176+
mz *= 0.6;
177+
} else {
178+
mx *= drag;
179+
my *= drag;
180+
mz *= drag;
181+
}
182+
my -= gravity;
183+
184+
trajectoryPoints.add(
185+
new Vec3(
186+
x - ((AccessorRenderManager) renderManager).getRenderPosX(),
187+
y - ((AccessorRenderManager) renderManager).getRenderPosY(),
188+
z - ((AccessorRenderManager) renderManager).getRenderPosZ()));
189+
}
190+
191+
if (trajectoryPoints.size() > 1) {
192+
enableRenderState();
193+
setColor(new Color(
194+
hasHitEntity ? 85 : 255,
195+
255,
196+
hasHitEntity ? 85 : 255,
197+
(int) (opacity.getValue().floatValue() / 100.0F * 255.0F)).getRGB());
198+
GL11.glLineWidth(1.5F);
199+
GL11.glEnable(GL11.GL_LINE_SMOOTH);
200+
GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);
201+
202+
worldRenderer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION);
203+
trajectoryPoints.forEach(vec3 -> worldRenderer.pos(vec3.xCoord, vec3.yCoord, vec3.zCoord).endVertex());
204+
Tessellator.getInstance().draw();
205+
206+
GlStateManager.pushMatrix();
207+
GlStateManager.translate(
208+
x - ((AccessorRenderManager) renderManager).getRenderPosX(),
209+
y - ((AccessorRenderManager) renderManager).getRenderPosY(),
210+
z - ((AccessorRenderManager) renderManager).getRenderPosZ());
211+
212+
if (mop != null) {
213+
switch (mop.sideHit.getAxis().ordinal()) {
214+
case 0:
215+
GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
216+
break;
217+
case 1:
218+
GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
219+
}
220+
drawLine(
221+
-0.25F,
222+
-0.25F,
223+
0.25F,
224+
0.25F,
225+
1.5F,
226+
new Color(
227+
hasHitEntity ? 85 : 255,
228+
255,
229+
hasHitEntity ? 85 : 255,
230+
(int) (opacity.getValue().floatValue() / 100.0F * 255.0F)).getRGB());
231+
drawLine(
232+
-0.25F,
233+
0.25F,
234+
0.25F,
235+
-0.25F,
236+
1.5F,
237+
new Color(
238+
hasHitEntity ? 85 : 255,
239+
255,
240+
hasHitEntity ? 85 : 255,
241+
(int) (opacity.getValue().floatValue() / 100.0F * 255.0F)).getRGB());
242+
}
243+
244+
GlStateManager.popMatrix();
245+
GL11.glDisable(GL11.GL_LINE_SMOOTH);
246+
GL11.glLineWidth(2.0F);
247+
GlStateManager.resetColor();
248+
disableRenderState();
249+
}
250+
}
251+
252+
private void enableRenderState() {
253+
GL11.glDepthMask(false);
254+
GL11.glEnable(GL11.GL_BLEND);
255+
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
256+
GL11.glDisable(GL11.GL_TEXTURE_2D);
257+
GL11.glDisable(GL11.GL_CULL_FACE);
258+
}
259+
260+
private void disableRenderState() {
261+
GL11.glEnable(GL11.GL_TEXTURE_2D);
262+
GL11.glEnable(GL11.GL_CULL_FACE);
263+
GL11.glDisable(GL11.GL_BLEND);
264+
GL11.glDepthMask(true);
265+
}
266+
267+
private void setColor(int rgb) {
268+
float alpha = (float) (rgb >> 24 & 0xFF) / 255.0F;
269+
float red = (float) (rgb >> 16 & 0xFF) / 255.0F;
270+
float green = (float) (rgb >> 8 & 0xFF) / 255.0F;
271+
float blue = (float) (rgb & 0xFF) / 255.0F;
272+
GL11.glColor4f(red, green, blue, alpha);
273+
}
274+
275+
private void drawLine(float x1, float y1, float x2, float y2, float width, int color) {
276+
GL11.glLineWidth(width);
277+
setColor(color);
278+
WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer();
279+
worldRenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION);
280+
worldRenderer.pos(x1, y1, 0.0).endVertex();
281+
worldRenderer.pos(x2, y2, 0.0).endVertex();
282+
Tessellator.getInstance().draw();
283+
}
284+
}

0 commit comments

Comments
 (0)