Implement modular baby entity scaling (For feature request #1058)#1216
Implement modular baby entity scaling (For feature request #1058)#1216mfishma wants to merge 4 commits intoViaVersion:masterfrom
Conversation
🤦 It was right there in the Issue, baby dolphin: 0.6×0.9 → 0.39×0.585, scale by 0.65
|
(I renamed the branch, trying to keep the old PR, but couldn't) |
|
Personal Opinion: This PR looks quite AI vibecoded (e.g: lots of comments everywhere and body of PR is oddly professionalish) and may not qualify for merge. |
|
Fair enough, I'm also not a fan of over-confident "AI vibecoding" being dumped into repositories. To be fully transparent: yeah, I used AI to help draft this PR. As a neuro-spicy developer myself, I used it to help organize my thoughts, summarize the changes for any reviewers, and save myself time. But I can see that it resulted in the code being way over-commented in an attempt to explain the changes. And the PR body came out feeling a bit weirdly corporate. My goal was just to get this scaling logic out there for the Happy Ghast, learn more about how ViaBackwards works, and let the team assess its impact. It seemed more relevant given the recent focus on baby mobs, so there's a chance of more mobs with babies introduced soon. I totally understand that this touches some core Rewriter logic and will take time to review. Once it's reviewed, lemme know which parts feel too noisy or over-explained, and I can take one more pass to strip out the excess comments and clean it up to better match the rest of the project's style. |
Scaling mob entities down to baby size
For feature request #1058
Overview
This PR introduces a new EntityScaleHelper API to provide a modular, instantiable way to physically scale baby mobs when backported to older clients. This should also future-proof baby mob scaling when backporting to clients that don't have native support for any new adult mob or its variants (e.g., 1.21.6 Happy Ghast (ghast) → 1.21.5, or 1.21.2 Squids → 1.20).
Changes made
scaleHelper.addBabyScale(EntityType, factor).trackAndInjectin EntityScaleHelper.java abstracts the logic of parsing theisBabymetadata index (16), calculating the scale, diffing it against EntityScaleData (stored in StoredEntityData), and forcefully injecting theUPDATE_ATTRIBUTESpacket into the pipeline.AttributeRewriterthat intercepts server-sent attribute updates. This injectsminecraft:scalechanges and overrides them with our entity's tracked scale modifier. This cleans up manual interceptor blocks in 1.21.6 and protects squids/dolphins in 1.21.2 from server scale overrides.minecraft:generic.scale/minecraft:scale: The helper constructor takes the correct attribute key string so the injection logic natively handles the 1.21.2 attribute rename without hard-coding IDs.Decisions
UPDATE_ATTRIBUTESpacket when a baby mob spawns if the scale isn't modified on the server side. So we had to forcefully spoof the packet when the metadata dictates a scale drop.Verification
Manual testing