ImmersiveMC

ImmersiveMC

2M Downloads

Refactor All Hitboxes

hammy275 opened this issue ยท 1 comments

commented

Right now, there are three separate arrays for hitboxes:

  • inputHitboxes: Stores all hitboxes concerned with input
  • hitboxes: Scattered across different classes and has all "main" hitboxes
  • triggerHitboxes: Stores hitboxes that should be interacted with with a trigger press in VR

And as a bonus, the regular hitboxes are used as triggerHitboxes for the backpack.

This is insane, and keeping track of all of the different ways these interact is too much, and makes code confusing and hard to read. Plus, triggerHitboxes become limited in what they can do.

Instead, hitboxes should be more than just an AxisAlignedBB. They should be a class (Hitbox), which contains:

hitbox: The actual AABB of the hitbox.
isTrigger: true if this is a trigger hitbox.
isInput: true if this is an input hitbox.
slotNum: An integer ID that maps to the item slot number of this Hitbox.

They can all be public since they'll all also be final and all types in them are immutable anyways.

The following helper methods can exist on something that extends AbstractImmersiveInfo that relates to hitboxes:

getHitboxes(): Returns the Info's array of all hitboxes.
getTriggerHitboxes(): Gets an array of all the trigger-based hitboxes.
getInputHitboxes(): Gets an array of all the input hitboxes.

Hitboxes should continue to only be used for items, so the hitboxes for opening/closing chests and for handling buttons/levers should remain OUTSIDE of this system.

commented

Will actually close this for now, but may re-open if I decide to go through with this refactor.