FirstPersonModel
FirstPersonModel copied to clipboard
Update MinecraftWrapper.java
fixes #77
PR Summary
- Simplification of code
This PR includes an update where a line of code that used to set the value of
realYawhas been removed. This ultimately simplifies the code, making it more readable and easier to maintain over time.
Huh, will have to test that.
Quality Gate passed
Kudos, no new issues were introduced!
0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication
Hm, at least with paladin's furniture mod, the behavior seems to be exactly the same(broken):
Which mod did you try this with, where this fixed the issue?
I tested it with Create Fabric and Sit on 1.20.1 Quilt as well as Sit on 1.20.2 Fabric
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
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.
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);
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.
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.
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.
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.