mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-19 06:09:05 +00:00
Fix Sizing Changes Mid Firing
This commit is contained in:
1 parent
3859bb70cb
commit
a7d780565f
4 files changed
+80
-51
No files matched your search
@@ -30,11 +30,15 @@ public class EntityAbilityDisc extends EntityEnergyProjectile {
|
||||
private boolean returning = false;
|
||||
private int ticksSinceMiss = 0;
|
||||
|
||||
// Disc shape properties
|
||||
// Disc shape properties (target values)
|
||||
private float discRadius = 1.0f; // Width of disc
|
||||
private float discThickness = 0.2f; // Height of disc
|
||||
private float prevDiscRadius = 1.0f;
|
||||
private float prevDiscThickness = 0.2f;
|
||||
|
||||
// Lerp-smoothed render values
|
||||
private float renderDiscRadius = 1.0f;
|
||||
private float renderDiscThickness = 0.2f;
|
||||
private float prevRenderDiscRadius = 1.0f;
|
||||
private float prevRenderDiscThickness = 0.2f;
|
||||
|
||||
// Boomerang owner-gone tracking
|
||||
private int returnOwnerNullTicks = 0;
|
||||
@@ -136,16 +140,23 @@ public class EntityAbilityDisc extends EntityEnergyProjectile {
|
||||
|
||||
@Override
|
||||
protected void updateProjectile() {
|
||||
// Store previous values for interpolation
|
||||
prevDiscRadius = discRadius;
|
||||
prevDiscThickness = discThickness;
|
||||
// Save previous render values for sub-tick interpolation
|
||||
prevRenderDiscRadius = renderDiscRadius;
|
||||
prevRenderDiscThickness = renderDiscThickness;
|
||||
|
||||
// Handle charging state (windup phase)
|
||||
if (isCharging()) {
|
||||
// During charging, snap render values to target (size grows smoothly already)
|
||||
renderDiscRadius = discRadius;
|
||||
renderDiscThickness = discThickness;
|
||||
updateCharging();
|
||||
return;
|
||||
}
|
||||
|
||||
// Lerp render values toward target (smooth out sync packet jumps)
|
||||
renderDiscRadius += (discRadius - renderDiscRadius) * 0.15f;
|
||||
renderDiscThickness += (discThickness - renderDiscThickness) * 0.15f;
|
||||
|
||||
// In preview mode, run movement on client (no server)
|
||||
if (previewMode) {
|
||||
updatePreviewMovement();
|
||||
@@ -354,11 +365,10 @@ public class EntityAbilityDisc extends EntityEnergyProjectile {
|
||||
}
|
||||
|
||||
public float getInterpolatedDiscRadius(float partialTicks) {
|
||||
return prevDiscRadius + (discRadius - prevDiscRadius) * partialTicks;
|
||||
return prevRenderDiscRadius + (renderDiscRadius - prevRenderDiscRadius) * partialTicks;
|
||||
}
|
||||
|
||||
public void setDiscRadius(float radius) {
|
||||
this.prevDiscRadius = this.discRadius;
|
||||
this.discRadius = radius;
|
||||
}
|
||||
|
||||
@@ -367,11 +377,10 @@ public class EntityAbilityDisc extends EntityEnergyProjectile {
|
||||
}
|
||||
|
||||
public float getInterpolatedDiscThickness(float partialTicks) {
|
||||
return prevDiscThickness + (discThickness - prevDiscThickness) * partialTicks;
|
||||
return prevRenderDiscThickness + (renderDiscThickness - prevRenderDiscThickness) * partialTicks;
|
||||
}
|
||||
|
||||
public void setDiscThickness(float thickness) {
|
||||
this.prevDiscThickness = this.discThickness;
|
||||
this.discThickness = thickness;
|
||||
}
|
||||
|
||||
@@ -459,8 +468,6 @@ public class EntityAbilityDisc extends EntityEnergyProjectile {
|
||||
|
||||
@Override
|
||||
protected void applyProjectileClientSyncData(NBTTagCompound nbt) {
|
||||
prevDiscRadius = discRadius;
|
||||
prevDiscThickness = discThickness;
|
||||
discRadius = nbt.getFloat("DiscRadius");
|
||||
discThickness = nbt.getFloat("DiscThickness");
|
||||
vertical = nbt.getBoolean("Vertical");
|
||||
@@ -474,8 +481,10 @@ public class EntityAbilityDisc extends EntityEnergyProjectile {
|
||||
this.boomerangDelay = nbt.hasKey("BoomerangDelay") ? nbt.getInteger("BoomerangDelay") : 40;
|
||||
this.discRadius = sanitize(nbt.hasKey("DiscRadius") ? nbt.getFloat("DiscRadius") : 1.0f, 1.0f, MAX_ENTITY_SIZE);
|
||||
this.discThickness = sanitize(nbt.hasKey("DiscThickness") ? nbt.getFloat("DiscThickness") : 0.2f, 0.2f, MAX_ENTITY_SIZE);
|
||||
this.prevDiscRadius = this.discRadius;
|
||||
this.prevDiscThickness = this.discThickness;
|
||||
this.renderDiscRadius = this.discRadius;
|
||||
this.renderDiscThickness = this.discThickness;
|
||||
this.prevRenderDiscRadius = this.discRadius;
|
||||
this.prevRenderDiscThickness = this.discThickness;
|
||||
this.vertical = nbt.hasKey("Vertical") ? nbt.getBoolean("Vertical") : false;
|
||||
this.returning = nbt.hasKey("Returning") && nbt.getBoolean("Returning");
|
||||
// Charging state (common fields handled by base)
|
||||
|
||||
Reference in new issue
Block a user