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

Utility Extensions #59

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

solonovamax
Copy link

@solonovamax solonovamax commented Aug 3, 2024

This PR contains a bunch of additional utility extensions, such as:

  • vector operations for Vector3i, Vector3f, Vector3d, Vector2i, Vector2f, and Vector2d
  • conversion functions for Pos{2,3}{i,d,f} (ie. convert from mc Vec*, BlockPos, and joml Vector* classes to the Pos* classes)
  • operator overloads for common number types (Int, Long, Float, and Double. this is to avoid the overhead that comes with boxing & unboxing when using Number. the Number overload is still provided if, for whatever reason, someone has like a Byte or Short or smth and wants to multiply it)
  • infix functions for the cross product and dot product
  • functions for pos*Of, vec*Of, and vector*Of (eg. pos3dOf(x, y, z): Pos3d, vec3Of(x, y, z): Vec3, vector3dOf(x, y, z): Vector3d, etc.)
  • a couple of functions just to make things slightly nicer on yarn (eg. toMcVec3d, which is an alias for toMcVec3, as Vec3 is named Vec3d on yarn)
  • matrix operations for Matrix2f, Matrix2d, Matrix3f, Matrix3d, Matrix3x2f, Matrix3x2d, Matrix4f, Matrix4d, Matrix4x3f, and Matrix4x3d
  • some convenience functions for AABB/Box
  • convenience extensions for World
  • convenience extensions for Registry, allowing for things like
    val MY_ITEM = Registries.ITEM.register("mymod:myid", MyItem())
    I just find this slightly cleaner for registering things.
  • may add some more stuff at some point. I have a bunch of misc. utility functions in many of my projects so I'll prob go through them later and add all the useful ones.

- Add operators for
  - Vector3i
  - Vector3f
  - Vector3d
  - Vector2i
  - Vector2f
  - Vector2d
- Add new operators
  - cross product & dot product
  - overloads to avoid boxing & unboxing
- initialization functions similar to listOf() for vectors
- conversion functions for `Vec*`/`Vector*` -> `Pos*`
- some function aliases for yarn mappings
- Add operators for all JOML matrix types
- Utility extensions for registering so you can do smth like
    val MY_ITEM = Registries.ITEM.register("mymod:myid", MyItem())
- convenience methods for getting entities in an area

Signed-off-by: solonovamax <[email protected]>
@solonovamax
Copy link
Author

oops, hit enter before writing the description lol

@solonovamax solonovamax marked this pull request as draft August 3, 2024 04:00
Also suppress some warnings in the other *Operations files

Signed-off-by: solonovamax <[email protected]>
Soft depends on fabric-permissions-api-v0.
Falls back to vanilla permission checks if it's not present

Signed-off-by: solonovamax <[email protected]>
See: FabricMC/fabric-loom#1153
Using layered mappings with a custom mapping is preferred.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant