Skip to content

Commit

Permalink
no gravity entities with correct trajectory and accurate multishot cr…
Browse files Browse the repository at this point in the history
…ossbow trajectories (MeteorDevelopment#3818)
  • Loading branch information
xNasuni authored Jul 12, 2023
1 parent c6e2764 commit 9a36f0a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
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;
}

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

return true;
}

Expand Down

0 comments on commit 9a36f0a

Please sign in to comment.