Finished casing physics

added initial momentums as a test
This commit is contained in:
Vaern 2025-02-24 23:47:48 -08:00
parent 747d0006b2
commit c5c6beb453
5 changed files with 14 additions and 8 deletions

View File

@ -94,7 +94,7 @@ public class CasingEjector implements Cloneable {
@SideOnly(Side.CLIENT)
public void spawnCasing(TextureManager textureManager, SpentCasing config, World world, double x, double y, double z, float pitch, float yaw, boolean crouched) {
Vec3 rotatedMotionVec = rotateVector(getMotion(), pitch + (float) rand.nextGaussian() * getPitchFactor(), yaw + (float) rand.nextGaussian() * getPitchFactor(), getPitchFactor(), getPitchFactor());
ParticleSpentCasing casing = new ParticleSpentCasing(textureManager, world, x, y, z, rotatedMotionVec.xCoord, rotatedMotionVec.yCoord, rotatedMotionVec.zCoord, (float) (getPitchFactor() * rand.nextGaussian()), (float) (getYawFactor() * rand.nextGaussian()), config, false, 0, 0, 0);
ParticleSpentCasing casing = new ParticleSpentCasing(textureManager, world, x, y, z, rotatedMotionVec.xCoord, rotatedMotionVec.yCoord, rotatedMotionVec.zCoord, (float) (world.rand.nextGaussian() * 5F), (float) (world.rand.nextGaussian() * 10F), config, false, 0, 0, 0);
offsetCasing(casing, getOffset(), pitch, yaw, crouched);

View File

@ -184,7 +184,7 @@ public class ItemAmmoArty extends Item {
return "item." + itemTypes[Math.abs(stack.getItemDamage()) % itemTypes.length].name;
}
protected static SpentCasing SIXTEEN_INCH_CASE = new SpentCasing(CasingType.STRAIGHT).setScale(15F, 15F, 10F).setupSmoke(1F, 1D, 200, 60).setMaxAge(300);
protected static SpentCasing SIXTEEN_INCH_CASE = new SpentCasing(CasingType.STRAIGHT).setScale(15F, 15F, 10F).setupSmoke(1F, 1D, 200, 60).setMaxAge(300).setBounceMotion(1F, 0.5F);
public abstract class ArtilleryShell {

View File

@ -9,6 +9,7 @@ import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import com.hbm.main.ResourceManager;
import com.hbm.util.BobMathUtil;
import com.hbm.util.Tuple.Pair;
import cpw.mods.fml.relauncher.Side;
@ -103,7 +104,7 @@ public class ParticleSpentCasing extends EntityFX {
this.motionX *= 0.7D;
this.motionZ *= 0.7D;
this.rotationPitch = 0;
this.rotationPitch = (float) (Math.floor(this.rotationPitch / 180F + 0.5F)) * 180F;
this.momentumYaw *= 0.7F;
this.onGround = false;
}
@ -201,11 +202,15 @@ public class ParticleSpentCasing extends EntityFX {
if (initMoY != motionY) {
this.motionY *= -0.5D;
if(momentumPitch == 0 && this.motionY > 1e-7) {
momentumPitch = (float) rand.nextGaussian() * 10F * this.config.getBouncePitch();
momentumYaw = (float) rand.nextGaussian() * 10F * this.config.getBounceYaw();
} else if(Math.abs(momentumPitch) > 1e-7)
boolean rotFromSpeed = Math.abs(this.motionY) > 0.04;
if(rotFromSpeed || Math.abs(momentumPitch) > 1e-7) {
momentumPitch *= -0.75F;
if(rotFromSpeed) {
float mult = (float) BobMathUtil.safeClamp(initMoY / 0.2F, -1F, 1F);
momentumPitch += rand.nextGaussian() * 10F * this.config.getBouncePitch() * mult;
momentumYaw += (float) rand.nextGaussian() * 10F * this.config.getBounceYaw() * mult;
}
}
}
if (initMoZ != motionZ) {

View File

@ -86,6 +86,7 @@ public class SpentCasing implements Cloneable {
return casingMap.get(name);
}
/** Multiplier for default standard deviation of 10deg per tick, per bounce w/ full y speed */
public SpentCasing setBounceMotion(float yaw, float pitch) {
this.bounceYaw = yaw;
this.bouncePitch = pitch;

View File

@ -75,7 +75,7 @@ public class CasingCreator implements IParticleCreator {
int smokeLife = data.getInteger("smokeLife");
double smokeLift = data.getDouble("smokeLift");
int nodeLife = data.getInteger("nodeLife");
ParticleSpentCasing casing = new ParticleSpentCasing(texman, world, x, y, z, mX, mY, mZ, 0, 0, casingConfig, smoking, smokeLife, smokeLift, nodeLife);
ParticleSpentCasing casing = new ParticleSpentCasing(texman, world, x, y, z, mX, mY, mZ, (float) (world.rand.nextGaussian() * 10F), (float) (world.rand.nextGaussian() * 5F), casingConfig, smoking, smokeLife, smokeLift, nodeLife);
casing.prevRotationYaw = casing.rotationYaw = yaw;
casing.prevRotationPitch = casing.rotationPitch = pitch;
Minecraft.getMinecraft().effectRenderer.addEffect(casing);