elveskevtar / SmartMoving

Other
14 stars 0 forks source link

Fun with ArtemisLib #7

Open DoomRater opened 4 years ago

DoomRater commented 4 years ago

So ArtemisLib allows the player to become... differently sized, either bigger or smaller based on a scale. That definitely leads to incompatibilites with what SmartMoving expects to happen to a player.

Making a player smaller doesn't break as much as making a player bigger. When the player is anything larger than 1.0x sized, swimming breaks completely and the player just seizes up. This was tested using Gulliver Reborn 1.8, but I suspect Resizing Potion will do the same thing too as the handling is being done inside ArtemisLib.

elveskevtar commented 4 years ago

Hey, @DoomRater thanks for sharing this. Could you attach a screenshot of this happening? It might take me some time to get to external mod-support as I am still working on some high priority bugs but it will be added to the list.

DoomRater commented 4 years ago

I think a video might be more appropriate. Unlike Better Diving, the swimming absolutely breaks when a player is larger. https://imgur.com/a/o9wkOOu

elveskevtar commented 4 years ago

This is the exact type of thing that really makes me want to completely remake the entire mod from scratch. The implementation is based on a version of MC that was built a long time ago and along the way, some inexperienced coders made hacky changes to port the code to newer versions without understanding how their code would later become unmaintainable. In their defense, I am doing the same thing but I think it's about time it gets the complete rework it deserves with all of the newer Forge features.

The PlayerAPI and RenderPlayerAPI can stay the same as they are just adapters to the vanilla player and render functions (kind of like the original ModLoader but specifically for these classes). However, I always thought that the entire SmartRender mod was unnecessary and not really used by any other mods than SmartMoving. This invalidates its purpose and frankly makes compatibility with other mods such a hassle if they are not using SmartRender themselves...

I guess I will start looking at how difficult it would be to start it from scratch. In my head, not too difficult to set everything up to do custom animations and then I can cherry-pick the original for the specific transforms and rotations on the player.

elveskevtar commented 4 years ago

Just skim through the 3,000 lines of random constants and expressions.

DoomRater commented 4 years ago

I see a fair share of WTFs scrolling through, yeah. A couple places where a math function would have been better than smatterings of if then elseifs...

elveskevtar commented 4 years ago

One thing, I was just thinking about: is that highlighted box in the video supposed to be the collision box? It's supposed to shrink when the player is crawling, swimming, diving, etc. but it's not (well it is but another vanilla thread overwrites SmartMoving 😢)

DoomRater commented 4 years ago

Indeed, that's the F3 + B bounding box overlay. Funny enough, Better Diving does seem to successfully change it, but it also assumes the player is 1.8 meters tall (so when it does, the player becomes 0.9 meters tall every time) and I filed a bug report over on their GitHub.

elveskevtar commented 4 years ago

Oh so if you resized the player it wouldn't change the player size in half? This is why people changing the player/renderer should use scaling instead of constants.

At the end of this updateEntity function the EntityPlayerSP size is successfully changed to 0.65 (this would also be constant) but this seems to not even matter because it is overwritten by the vanilla setSize on another thread sometime before collision checking happens. I'm starting to rewrite this whole mod now 😩. Would you mind telling me what Mod you are using to see the box?

DoomRater commented 4 years ago

F3 + B is a vanilla debug function in 1.12.2 and onward. I'm actually not sure when it was added!

elveskevtar commented 4 years ago

Okay so it's 4 AM and I finally struggled hard enough to start structuring the reboot of the mod and figure out a fix for crawling through 1 block holes. Interestingly enough, I looked at how ArtemisLib accomplished changing size and it worked like a charm. I think I'm going to continue working on a complete redo of the mod but this actually helped solve the major issue of figuring out how to change the entity bounding box in 1.12.x.

Essentially I just had to use the onPlayerTick forge event instead of the ClientPlayerAPI endpoints. This makes a lot of sense but is slowly pushing me in the direction of wondering if we will need the API core mods at all. Either way, I'm really happy with this progress.