Skip to content

Commit

Permalink
more support
Browse files Browse the repository at this point in the history
  • Loading branch information
GenerelSchwerz committed Aug 20, 2024
1 parent db59773 commit 9708249
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 24 deletions.
9 changes: 3 additions & 6 deletions examples/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,26 @@ const emptyVec = new Vec3(0, 0, 0);




bot.on("entityMoved", async (ent) => {
if (checkedEntities[ent.id]) return;
if (ent.velocity.equals(emptyVec)) return;

checkedEntities[ent.id] = [];

// console.log(ent)
if (["arrow", "firework_rocket", "ender_pearl", "egg", "potion", "trident", "fishing_bobber"].includes(ent.name!)) {
if (["arrow", "firework_rocket", "ender_pearl", "egg", "potion", "trident", "fishing_bobber", "snowball", "llama_spit"].includes(ent.name!)) {
console.log(vectorMagnitude(ent.velocity));

const initShot = StaticShot.calculateShotForPoints(ent, true, intercepter);

(async () => {

for (let i = 0; i < 3; i++) {
for (let i = 0; i < 1; i++) {
for (const idx in initShot.positions) {
const pos = initShot.positions[idx];
const vel = initShot.velocities[idx];
const { x, y, z } = pos;
const { x: vx, y: vy, z: vz } = vel;
bot.chat(`/particle flame ${x} ${y} ${z} 0 0 0 0 1 force`);
console.log(`pos: ${x.toFixed(3)} ${y.toFixed(3)} ${z.toFixed(3)} vel: ${vx.toFixed(3)} ${vy.toFixed(3)} ${vz.toFixed(3)}`);
// console.log(`pos: ${x.toFixed(3)} ${y.toFixed(3)} ${z.toFixed(3)} vel: ${vx.toFixed(3)} ${vy.toFixed(3)} ${vz.toFixed(3)}`);
}

await bot.waitForTicks(20);
Expand Down
27 changes: 13 additions & 14 deletions src/calc/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,26 @@ import { ProjectileEnvInfo } from "../types";

type ProjectileInfos = { [name: string]: ProjectileEnvInfo };


export const projectileGravity: Record<string, number> = {
arrow: 0.05,
trident: 0.05,
egg: 0.04,
snowball: 0.04,
ender_pearl: 0.0375,
splash_potion: 0.03,
egg: 0.03,
snowball: 0.03,
ender_pearl: 0.03,
potion: 0.05,
firework_rocket: 0.0,
fishing_bobber: 0.03,
};

export const projectileAirResistance: Record<string, number> = {
arrow: 0.99,
trident: 0.99,
egg: 0.99,
snowball: 0.99,
ender_pearl: 0.99,
splash_potion: 0.99,
firework_rocket: 0.99,
fishing_bobber: 0.92,
arrow: 1 - 0.99,
trident: 1 - 0.99,
egg: 1 - 0.99,
snowball: 1 - 0.99,
ender_pearl: 1 - 0.99,
potion: 1 - 0.99,
firework_rocket: 1 - 0.99,
fishing_bobber: 1 - 0.92,
};

export const trajectoryInfo: ProjectileInfos = {
Expand All @@ -33,7 +32,7 @@ export const trajectoryInfo: ProjectileInfos = {
snowball: { v0: 1.5, g: projectileGravity["snowball"], ph: 1.52, a: projectileAirResistance["snowball"] },
egg: { v0: 1.5, g: projectileGravity["egg"], ph: 1.52, a: projectileAirResistance["egg"] },
ender_pearl: { v0: 1.5, g: projectileGravity["ender_pearl"], ph: 1.52, a: projectileAirResistance["ender_pearl"] },
splash_potion: { v0: 0.4, g: projectileGravity["potion"], ph: 1.52, a: projectileAirResistance["potion"] },
potion: { v0: 0.4, g: projectileGravity["potion"], ph: 1.52, a: projectileAirResistance["potion"] },
fishing_rod: { v0: 1.5, g: projectileGravity["fishing_bobber"], ph: 1.62, a: projectileAirResistance["fishing_bobber"] }, // TODO: nake v0 variable dependent on yaw and pitch.
};

Expand Down
1 change: 0 additions & 1 deletion src/shot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ export class Shot {

public calcToEntity(target: AABBComponents | AABB, blockChecking: boolean = false): BasicShotInfo {
if (!(target instanceof AABB)) target = getEntityAABBRaw(target);
console.log(target)
// height = height = 1.62 ? height + 0.18 : 0;
const entityAABB = target;
let currentPosition = this.initialPos.clone();
Expand Down
3 changes: 0 additions & 3 deletions src/staticShot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export class StaticShot {

if (tickVelocity.y < 0 && currentPosition.y < 0) break;

console.log(currentPosition);
currentPosition.add(tickVelocity);
tickVelocity.translate(offsetX, offsetY, offsetZ);
nextPosition.add(tickVelocity);
Expand All @@ -102,8 +101,6 @@ export class StaticShot {
): { positions: Vec3[]; velocities: Vec3[]; blockHit: Block | null } {
if (!projectileGravity[name!]) throw "invalid projectile: " + name;
const gravity = projectileGravity[name!];
console.log(gravity);


let points: Vec3[] = [];
let pointVelocities: Vec3[] = [];
Expand Down

0 comments on commit 9708249

Please sign in to comment.