Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no gravity entities with correct trajectory and accurate multishot crossbow trajectories #3818

Merged
merged 7 commits into from
Jul 12, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public class Trajectories extends Module {
private final Pool<Vector3d> vec3s = new Pool<>(Vector3d::new);
private final List<Path> paths = new ArrayList<>();

private static final double MULTISHOT_OFFSET = Math.toRadians(10); // accurate-ish offset of crossbow multishot in radians (10° degrees)

public Trajectories() {
super(Categories.Render, "trajectories", "Predicts the trajectory of throwable items.");
}
Expand Down Expand Up @@ -146,10 +148,10 @@ private void calculatePath(PlayerEntity player, double tickDelta) {
getEmptyPath().calculate();

if (itemStack.getItem() instanceof CrossbowItem && EnchantmentHelper.getLevel(Enchantments.MULTISHOT, itemStack) > 0) {
if (!simulator.set(player, itemStack, -10, accurate.get(), tickDelta)) return;
if (!simulator.set(player, itemStack, MULTISHOT_OFFSET, accurate.get(), tickDelta)) return; // left multishot arrow
getEmptyPath().calculate();

if (!simulator.set(player, itemStack, 10, accurate.get(), tickDelta)) return;
if (!simulator.set(player, itemStack, -MULTISHOT_OFFSET, accurate.get(), tickDelta)) return; // right multishot arrow
getEmptyPath().calculate();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,14 @@ public boolean set(Entity entity, boolean accurate, double tickDelta) {
set(entity, 0.5, 0.05, 0.8, accurate, tickDelta);
} else if (entity instanceof WitherSkullEntity || entity instanceof FireballEntity || entity instanceof DragonFireballEntity) {
set(entity, 0.95, 0, 0.8, accurate, tickDelta);
}
else {
} else {
return false;
xNasuni marked this conversation as resolved.
Show resolved Hide resolved
}

if (entity.hasNoGravity()) {
this.gravity = 0;
}

return true;
}

Expand Down