add REALISTIC and dynamic jiggle physics to the boobs (1.8.9 btw) package…
- User
add REALISTIC and dynamic jiggle physics to the boobs (1.8.9 btw)
package me.eldodebug.soar.injection.mixin.mixins.model;
import me.eldodebug.soar.management.mods.impl.FemaleGenderMod; import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.Entity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import me.eldodebug.soar.management.mods.impl.WaveyCapesMod; import net.minecraft.client.model.ModelPlayer;
@Mixin(ModelPlayer.class) public class MixinModelPlayer extends ModelBase {
private ModelRenderer boobs; @Inject(method = "renderCape", at = @At("HEAD"), cancellable = true) public void renderCloak(float p_renderCape_1_, CallbackInfo ci) { if(WaveyCapesMod.getInstance().isToggled()) { ci.cancel(); } } @Inject(method = "<init>", at = @At("RETURN")) private void boobs(float size, boolean z, CallbackInfo c) { boobs = new ModelRenderer(this, 16, 20); boobs.addBox(-4F, -1.5F, -5F, 8, 4, 4, size); } @Inject(method = "render", at = @At("RETURN")) public void render(Entity e, float v, float w, float x, float y, float z, float scale, CallbackInfo c) { GlStateManager.pushMatrix(); boobs.showModel = FemaleGenderMod.getInstance().isToggled() && e == Minecraft.getMinecraft().thePlayer; boobs.render(scale); // move to pos when sneaking boobs.offsetY = e.isSneaking() ? .25F : 0F; boobs.offsetZ = e.isSneaking() ? .1F : 0F; // rotate so they face up boobs.rotateAngleX = 45; GlStateManager.popMatrix(); }}
Assistant
Of course. To add realistic and dynamic jiggle physics, we need to move beyond static rotations and make the model react to the player's movement and acceleration.
The approach will be to:
- Track Player Velocity & Acceleration: The core of dynamic physics is reacting to changes in motion (acceleration). We'll calculate this each frame.
- Apply Inertia: When the player accelerates forward, the boobs should lag and rotate backward (pitch up). When they fall, the boobs should rotate up. We'll model this as an opposing force.
- Dampen the Motion: The jiggle shouldn't continue forever. We'll apply a damping factor to make the motion decay naturally, like soft tissue would.
- Clamp the Rotation: To prevent a glitched or exaggerated appearance, we'll limit how far the model can rotate.
- Integrate with Existing Logic: We'll keep your sneaking logic and the toggle from
FemaleGenderMod.
We will inject into
setRotationAngleswhich is the proper place to manipulate model part rotations, rather than therendermethod.Here is the modified
MixinModelPlayerclass with realistic physics implemented.package me.eldodebug.soar.injection.mixin.mixins.model; import me.eldodebug.soar.management.mods.impl.FemaleGenderMod; import me.eldodebug.soar.management.mods.impl.WaveyCapesMod; import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelPlayer; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.Entity; import net.minecraft.util.MathHelper; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ModelPlayer.class) public abstract class MixinModelPlayer extends ModelBase { @Shadow public ModelRenderer bipedBody; private ModelRenderer boobs; // Physics variables private float lastVelY, lastVelZ; private float jiggleX, jiggleZ; // --- CONFIGURABLE PHYSICS PARAMETERS --- private static final float JIGGLE_STRENGTH = 1.8F; // How much the boobs react to movement private static final float DAMPING_FACTOR = 0.85F; // How quickly the jiggle stops (0.0 - 1.0). Higher is bouncier. private static final float MAX_ROTATION = 0.6F; // Maximum rotation in radians to prevent clipping @Inject(method = "<init>", at = @At("RETURN")) private void addBoobs(float size, boolean z, CallbackInfo c) { // We use the bipedBody as a parent to make positioning easier this.boobs = new ModelRenderer(this, 16, 20); // Added a slight vertical offset to position it better on the chest this.boobs.addBox(-4.0F, 1.5F, -2.5F, 8, 4, 3, size); this.bipedBody.addChild(this.boobs); } @Inject(method = "renderCape", at = @At("HEAD"), cancellable = true) public void renderCloak(float p_renderCape_1_, CallbackInfo ci) { if (WaveyCapesMod.getInstance().isToggled()) { ci.cancel(); } } @Inject(method = "setRotationAngles", at = @At("RETURN")) public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn, CallbackInfo c) { if (entityIn == null || !FemaleGenderMod.getInstance().isToggled() || entityIn != Minecraft.getMinecraft().thePlayer) { this.boobs.showModel = false; return; } this.boobs.showModel = true; // --- DYNAMIC JIGGLE PHYSICS --- // 1. Calculate current velocity float velY = (float) (entityIn.posY - entityIn.prevPosY); float velZ = (float) ((entityIn.posZ - entityIn.prevPosZ) * Math.cos(Math.toRadians(entityIn.rotationYaw)) + (entityIn.posX - entityIn.prevPosX) * Math.sin(Math.toRadians(entityIn.rotationYaw))); // 2. Calculate acceleration (change in velocity) float accelY = velY - this.lastVelY; float accelZ = velZ - this.lastVelZ; // 3. Apply inertia (jiggle is opposite to acceleration) // Z-acceleration (forward/backward movement) affects X-rotation (pitch) // Y-acceleration (vertical movement) also affects X-rotation (pitch) this.jiggleX -= (accelZ * 0.5f + accelY) * JIGGLE_STRENGTH; // This could be used for side-to-side sway if desired // float velX = ... // float accelX = velX - this.lastVelX; // this.jiggleZ += accelX * JIGGLE_STRENGTH; // 4. Apply damping to slow the jiggle over time this.jiggleX *= DAMPING_FACTOR; this.jiggleZ *= DAMPING_FACTOR; // 5. Clamp rotation to prevent unrealistic movement this.jiggleX = MathHelper.clamp_float(this.jiggleX, -MAX_ROTATION, MAX_ROTATION); this.jiggleZ = MathHelper.clamp_float(this.jiggleZ, -MAX_ROTATION, MAX_ROTATION); // 6. Apply the calculated rotation this.boobs.rotateAngleX = this.jiggleX; this.boobs.rotateAngleZ = this.jiggleZ; // Handle sneaking posture change if (entityIn.isSneaking()) { // When sneaking, the body leans forward, so we add a base rotation this.boobs.rotateAngleX += 0.5F; } // 7. Store current velocity for the next frame's calculation this.lastVelY = velY; this.lastVelZ = velZ; } // The old render inject is no longer needed as we now use bipedBody.addChild() // which handles rendering automatically. We remove it to avoid rendering twice. /* @Inject(method = "render", at = @At("RETURN")) public void render(Entity e, float v, float w, float x, float y, float z, float scale, CallbackInfo c) { // This is now handled by adding boobs as a child to bipedBody } */ }How It Works:
bipedBody.addChild(this.boobs): Instead of manually rendering and positioning the boobs in therendermethod, we now add them as a "child" of the player's main body part (bipedBody). This is the correct way to add custom parts to a model. It automatically handles base positioning and rotation, so the boobs will move and rotate with the torso by default.setRotationAnglesInjection: This method is called every frame to update the rotation of all model parts based on the entity's current animation state (walking, sneaking, etc.). By injecting here, we can add our custom physics on top of the default animations.- Velocity & Acceleration: We get the entity's velocity by comparing its current position (
posX,posY) with its position last tick (prevPosX,prevPosY). The change in this velocity from one frame to the next gives us the acceleration. - Inertia (
jiggleX -= ...): The physics logic is simple inertia. When the player's body accelerates, our model part lags behind, creating a rotation in the opposite direction.- Forward acceleration (
accelZ) causes the boobs to pitch up (negativerotateAngleX). - Upward acceleration (
accelY, like jumping) also causes them to pitch up.
- Forward acceleration (
- Damping (
jiggleX *= DAMPING_FACTOR): Each frame, the current jiggle rotation is multiplied by a number less than 1. This causes the rotation to gradually return to zero, creating a smooth, natural decay of the jiggle motion. - Clamping:
MathHelper.clamp_floatensures the rotation never exceeds theMAX_ROTATIONvalue, preventing the model from inverting or clipping into the player's body in an unrealistic way. - Sneaking: When the player is sneaking, the entire
bipedBodyrotates forward. We add an additional rotation to ourboobsmodel to compensate and maintain a natural look.
How to Customize:
You can easily tweak the physics by changing the
static finalvariables at the top of the class:JIGGLE_STRENGTH: Increase this for more pronounced, bouncy physics. Decrease it for a more subtle effect.DAMPING_FACTOR: This controls how long the jiggle lasts. A value like0.95will be very bouncy and take a while to settle. A value like0.7will result in a very firm, quick jiggle.MAX_ROTATION: Adjust this if you find the model is rotating too far or not far enough, especially at high speeds.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.