Mojang / minecraft-scripting-libraries

Sets of typescript scripting libraries for use with the minecraft scripting modules.
MIT License
14 stars 1 forks source link

Add `ImmutableVector3Builder` #27

Open ink0rr opened 2 months ago

ink0rr commented 2 months ago

It's mentioned in a comment, but the implementation doesn't exists.

https://github.com/Mojang/minecraft-scripting-libraries/blob/8cf3f6aa9c7d1826f2e8abc74fa583d17b1b8795/libraries/math/src/vector3/vectorWrapper.ts#L13

rlandav commented 1 month ago

A build of a stale comment leftover when I was first implementing this I guess. I was a bit torn on how valuable people would find the immutable version vs. just using the functions instead. Is this something you would find valuable?

ink0rr commented 1 month ago

Not really, I've settled with just cloning the vector when I need to avoid mutating the original object.

const a = new Vector3Builder(0, 0, 0);
const b = new Vector3Builder(a).add({ x: 1, y: 2, z: 3 });

Though it looks kinda awkward, I think it would be nice to have something like a .clone() method if possible.

const a = new Vector3Builder(0, 0, 0);
const b = a.clone().add({ x: 1, y: 2, z: 3 });