Fix Sizing Changes Mid Firing

This commit is contained in:
Kam committed 2026-03-10 23:01:54 -04:00
1 parent 3859bb70cb
commit a7d780565f
4 files changed
+80 -51

No files matched your search

@@ -31,9 +31,12 @@ import java.util.List;
*/
public class EntityAbilityLaser extends EntityEnergyProjectile {
// Laser-specific properties
// Laser-specific properties (target value)
private float laserWidth = 0.2f;
private float prevLaserWidth = 0.2f;
// Lerp-smoothed render values
private float renderLaserWidth = 0.2f;
private float prevRenderLaserWidth = 0.2f;
private float expansionSpeed = 2.0f; // Blocks per tick
private float maxLength = 32.0f; // Maximum beam reach in blocks
@@ -145,14 +148,19 @@ public class EntityAbilityLaser extends EntityEnergyProjectile {
@Override
protected void updateProjectile() {
// Store previous values for interpolation
prevLaserWidth = laserWidth;
// Save previous render value for sub-tick interpolation
prevRenderLaserWidth = renderLaserWidth;
if (isCharging()) {
// During charging, snap render value to target
renderLaserWidth = laserWidth;
updateCharging();
return;
}
// Lerp render value toward target (smooth out sync packet jumps)
renderLaserWidth += (laserWidth - renderLaserWidth) * 0.15f;
// Save previous positions for partial tick interpolation
prevStartX = startX;
prevStartY = startY;
@@ -708,11 +716,10 @@ public class EntityAbilityLaser extends EntityEnergyProjectile {
}
public float getInterpolatedLaserWidth(float partialTicks) {
return prevLaserWidth + (laserWidth - prevLaserWidth) * partialTicks;
return prevRenderLaserWidth + (renderLaserWidth - prevRenderLaserWidth) * partialTicks;
}
public void setLaserWidth(float width) {
this.prevLaserWidth = this.laserWidth;
this.laserWidth = width;
}
@@ -888,7 +895,6 @@ public class EntityAbilityLaser extends EntityEnergyProjectile {
@Override
protected void applyProjectileClientSyncData(NBTTagCompound nbt) {
prevLaserWidth = laserWidth;
laserWidth = nbt.getFloat("LaserWidth");
expansionSpeed = nbt.getFloat("ExpansionSpeed");
maxLength = nbt.getFloat("MaxLength");
@@ -902,7 +908,8 @@ public class EntityAbilityLaser extends EntityEnergyProjectile {
@Override
protected void readProjectileNBT(NBTTagCompound nbt) {
this.laserWidth = sanitize(nbt.hasKey("LaserWidth") ? nbt.getFloat("LaserWidth") : 0.2f, 0.2f, MAX_ENTITY_SIZE);
this.prevLaserWidth = this.laserWidth;
this.renderLaserWidth = this.laserWidth;
this.prevRenderLaserWidth = this.laserWidth;
this.expansionSpeed = sanitize(nbt.hasKey("ExpansionSpeed") ? nbt.getFloat("ExpansionSpeed") : 2.0f, 0.1f, MAX_ENTITY_SIZE);
this.maxLength = sanitize(nbt.hasKey("MaxLength") ? nbt.getFloat("MaxLength") : 32.0f, 1.0f, MAX_ENTITY_SIZE);
this.dirX = nbt.getDouble("DirX");