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

Pre Renders Bow #4765 #4772

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ public class Trajectories extends Module {
.build()
);

private final Setting<Boolean> preRender = sgGeneral.add(new BoolSetting.Builder() // Render the trajectory
// beforehand
.name("Pre-render")
.description("Calculates and renders trajectories for Bow and Crossbow even before charging them")
.defaultValue(false)
.build()
);

private final Setting<Boolean> otherPlayers = sgGeneral.add(new BoolSetting.Builder()
.name("other-players")
.description("Calculates trajectories for other players.")
Expand Down Expand Up @@ -147,14 +155,15 @@ private void calculatePath(PlayerEntity player, double tickDelta) {
}

// Calculate paths
if (!simulator.set(player, itemStack, 0, accurate.get(), tickDelta)) return;
//Added one more parameter to the set method
if (!simulator.set(player, itemStack, preRender.get(), 0, accurate.get(), tickDelta)) return;
getEmptyPath().calculate();

if (itemStack.getItem() instanceof CrossbowItem && Utils.hasEnchantment(itemStack, Enchantments.MULTISHOT)) {
if (!simulator.set(player, itemStack, MULTISHOT_OFFSET, accurate.get(), tickDelta)) return; // left multishot arrow
if (!simulator.set(player, itemStack, preRender.get(), MULTISHOT_OFFSET, accurate.get(), tickDelta)) return; // left multishot arrow
getEmptyPath().calculate();

if (!simulator.set(player, itemStack, -MULTISHOT_OFFSET, accurate.get(), tickDelta)) return; // right multishot arrow
if (!simulator.set(player, itemStack, preRender.get(), -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 @@ -40,12 +40,15 @@ public class ProjectileEntitySimulator {

// held items

public boolean set(Entity user, ItemStack itemStack, double simulated, boolean accurate, double tickDelta) {
public boolean set(Entity user, ItemStack itemStack, boolean prerender, double simulated, boolean accurate, double tickDelta) {
Item item = itemStack.getItem();

if (item instanceof BowItem) {
double charge = BowItem.getPullProgress(mc.player.getItemUseTime());
if (charge <= 0) return false;
if (charge <= 0 && !prerender)
return false;
else if (charge == 0 && prerender)
charge = 1; // render fully charged bow

set(user, 0, charge * 3, simulated, 0.05000000074505806, 0.6, accurate, tickDelta);
}
Expand Down
Loading