FirstPersonModel icon indicating copy to clipboard operation
FirstPersonModel copied to clipboard

Update MinecraftWrapper.java

Open R-Horizon2375 opened this issue 1 year ago • 9 comments

fixes #77

R-Horizon2375 avatar Jan 01 '24 12:01 R-Horizon2375

PR Summary

  • Simplification of code This PR includes an update where a line of code that used to set the value of realYaw has been removed. This ultimately simplifies the code, making it more readable and easier to maintain over time.

what-the-diff[bot] avatar Jan 01 '24 12:01 what-the-diff[bot]

Huh, will have to test that.

tr7zw avatar Jan 01 '24 12:01 tr7zw

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

sonarqubecloud[bot] avatar Jan 01 '24 12:01 sonarqubecloud[bot]

Hm, at least with paladin's furniture mod, the behavior seems to be exactly the same(broken): 2024-01-03_17 56 32 Which mod did you try this with, where this fixed the issue?

tr7zw avatar Jan 03 '24 17:01 tr7zw

I tested it with Create Fabric and Sit on 1.20.1 Quilt as well as Sit on 1.20.2 Fabric 2024-01-06_17 08 04 2024-01-06_17 07 48

R-Horizon2375 avatar Jan 06 '24 06:01 R-Horizon2375

Hm, then it might be just a partial fix. Will have to investigate this more. I'll now first look into reworking the entire mod to my new buildscript format which unites 1.20.4-1.16.5 in the same code base. Then look into how this stuff works/should work with other modded chairs

tr7zw avatar Jan 06 '24 18:01 tr7zw

I tested a few other mods and they worked fine, looks like it might just be paladin's furniture mod. It also suffers the issue differently to what's in the bug report, with paladin's furniture looking correct when facing the same way as the seat, rather than south.

R-Horizon2375 avatar Jan 07 '24 11:01 R-Horizon2375

This has to do with the fact that the code, as of currently, uses the offset based on the rotation of the riden entity, instead of the player.

An easy fix to this would be to remove any code checking for a ridens entity bodyYaw, and just using the players bodyYaw for the used rotation of the first person model.

A solution would be changing this:

if(abstractClientPlayerEntity_1.getVehicle() instanceof Boat || abstractClientPlayerEntity_1.getVehicle() instanceof Minecart) {
    realYaw = Mth.rotLerp(client.getFrameTime(), abstractClientPlayerEntity_1.yBodyRotO, abstractClientPlayerEntity_1.yBodyRot);
} else if(abstractClientPlayerEntity_1.getVehicle() instanceof LivingEntity){
    realYaw = Mth.rotLerp(client.getFrameTime(), ((LivingEntity)abstractClientPlayerEntity_1.getVehicle()).yBodyRotO, ((LivingEntity)abstractClientPlayerEntity_1.getVehicle()).yBodyRot);
} else {
    realYaw = Mth.rotLerp(client.getFrameTime(), abstractClientPlayerEntity_1.getVehicle().yRotO, abstractClientPlayerEntity_1.getVehicle().getYRot());
}
bodyOffset = FirstPersonModelCore.inVehicleBodyOffset + (FirstPersonModelCore.config.sitXOffset / 100f);

at line 57 in MinecraftWrapper.java to:

if(abstractClientPlayerEntity_1.getVehicle() instanceof Boat || abstractClientPlayerEntity_1.getVehicle() instanceof Minecart) {
    realYaw = Mth.rotLerp(client.getFrameTime(), abstractClientPlayerEntity_1.yBodyRotO, abstractClientPlayerEntity_1.yBodyRot);
}
bodyOffset = FirstPersonModelCore.inVehicleBodyOffset + (FirstPersonModelCore.config.sitXOffset / 100f);

mashedram avatar Jan 13 '24 13:01 mashedram

I'll do a deeper dive and tests into this later. First want to get out this version which fixes already lots of other issues.

tr7zw avatar Jan 18 '24 19:01 tr7zw

Ok, currently doing this deeper dive into whats going on. @basbakker1912 's solution still has issues with these chairs(and actually all other living? entities except boats/minecarts)

https://github.com/tr7zw/FirstPersonModel/assets/5133936/33e0e073-1006-4016-a6d2-3f85654a0672

Also figured out that the paladins chairs are "MobEntities", so they are living entities.

So the actual issue is 2 fold:

  • non living entities(like end crystals or some modded chairs) shouldn't use any rotation, so this pr is in fact correct and will get merged
  • the offset on any living entity (horse/pig/players/chicken/armorstand/Paladins chairs/whatever) has been wrong this entire time.

I'll merge this pr and then try to fix the offset calculation for living entities. That should fix all sitting issues with vanilla and modded entities except ones that do custom sitting logic like boats have, but at normal modded chairs shouldn't be affected by this.

tr7zw avatar Jun 08 '24 21:06 tr7zw

Welp, this branch is so out of sync with main, I can't merge it directly. Going to credit @R-Horizon2375 in the commit for the find and close the pr.

tr7zw avatar Jun 08 '24 21:06 tr7zw

https://github.com/tr7zw/FirstPersonModel/commit/68b99252b7a5c4d3bbd50d3f7e0b59a656f7000a turned out to be a bit more logic than just changing which values get used/removing a line of code. Apparently the body rotation isn't correctly setup at the point in time the offsets get updated, which further added to the confusion. Now the body rotation just gets calculated from the vehicle and head rotations.

tr7zw avatar Jun 08 '24 22:06 tr7zw