Refactoring for Code Cleanup and Projectile Abstract Class Handling

This commit is contained in:
Kam committed 2026-02-14 15:21:56 -05:00
1 parent a1f3f5184b
commit a23b199e7e
30 files changed
+1226 -2395

No files matched your search

@@ -44,47 +44,10 @@ public class EntityAbilityLaser extends EntityAbilityProjectile {
// End point for rendering
private double endX, endY, endZ;
// Charging state (during windup)
private boolean charging = false;
private int chargeDuration = 40;
private int chargeTick = 0;
private float targetSize = 1.0f; // Full size to grow to during charging
// Data watcher index for charging state (synced to clients)
private static final int DW_CHARGING = 20;
public EntityAbilityLaser(World world) {
super(world);
}
@Override
protected void entityInit() {
super.entityInit();
// Register data watcher for charging state
this.dataWatcher.addObject(DW_CHARGING, (byte) 0);
}
/**
* Check if orb is in charging state (synced via data watcher).
* In preview mode, uses local field since data watcher isn't synced.
*/
public boolean isCharging() {
if (previewMode) {
return this.charging;
}
return this.dataWatcher.getWatchableObjectByte(DW_CHARGING) == 1;
}
/**
* Set charging state (server only, synced to clients via data watcher).
*/
private void setCharging(boolean value) {
this.charging = value;
if (!worldObj.isRemote) {
this.dataWatcher.updateObject(DW_CHARGING, (byte) (value ? 1 : 0));
}
}
/**
* Full constructor with all parameters using data classes.
*/
@@ -131,25 +94,6 @@ public class EntityAbilityLaser extends EntityAbilityProjectile {
this.endZ = z;
}
/**
* Setup this orb in charging mode (for windup phase).
* The orb will grow from 0 to orbSize over chargeDuration ticks.
* Position follows the owner based on anchor point.
*/
public void setupCharging(EnergyAnchorData anchor, int chargeDuration) {
setCharging(true);
this.chargeDuration = chargeDuration;
this.chargeTick = 0;
this.anchorData = anchor;
this.targetSize = this.size;
this.size = 0.01f;
this.renderCurrentSize = 0.01f;
this.prevRenderSize = 0.01f;
this.motionX = 0;
this.motionY = 0;
this.motionZ = 0;
}
@Override
protected void updateRotation() {
// Laser doesn't rotate
@@ -252,8 +196,6 @@ public class EntityAbilityLaser extends EntityAbilityProjectile {
}
public void startMoving(EntityLivingBase target) {
if (!isCharging()) return;
setCharging(false);
// Initialize from current anchor position
@@ -322,44 +264,6 @@ public class EntityAbilityLaser extends EntityAbilityProjectile {
}
}
/**
* Update during charging state - follow owner based on anchor point.
*/
private void updateCharging() {
chargeTick++;
Entity owner = getOwnerEntity();
if (owner == null || owner.isDead) {
setDead();
return;
}
// Grow size based on charge progress
float progress = getChargeProgress();
this.size = targetSize * progress;
// Calculate position based on anchor point, offset downward by half size to center
if (owner instanceof EntityLivingBase) {
Vec3 pos = AnchorPointHelper.calculateAnchorPosition((EntityLivingBase) owner, anchorData);
setPosition(pos.xCoord, pos.yCoord, pos.zCoord);
}
}
/**
* Get the charge progress (0-1).
*/
public float getChargeProgress() {
if (chargeDuration <= 0) return 1.0f;
return Math.min(1.0f, (float) chargeTick / chargeDuration);
}
public float getInterpolatedChargeProgress(float partialTicks) {
if (chargeDuration <= 0) return 1.0f;
float prevProgress = Math.max(0, (float) (chargeTick - 1) / chargeDuration);
float currProgress = Math.min(1.0f, (float) chargeTick / chargeDuration);
return prevProgress + (currProgress - prevProgress) * partialTicks;
}
private void checkEntityCollisionAlongLine() {
// Expand search AABB by entity sizes to ensure we find all potential targets
double expand = Math.max(laserWidth, 1.0);
@@ -520,13 +424,7 @@ public class EntityAbilityLaser extends EntityAbilityProjectile {
this.endY = nbt.getDouble("EndY");
this.endZ = nbt.getDouble("EndZ");
// Charging state
boolean isCharging = nbt.hasKey("Charging") && nbt.getBoolean("Charging");
this.charging = isCharging;
this.dataWatcher.updateObject(DW_CHARGING, (byte) (isCharging ? 1 : 0));
this.chargeDuration = nbt.hasKey("ChargeDuration") ? nbt.getInteger("ChargeDuration") : 40;
this.chargeTick = nbt.hasKey("ChargeTick") ? nbt.getInteger("ChargeTick") : 0;
this.targetSize = nbt.hasKey("TargetSize") ? nbt.getFloat("TargetSize") : this.size;
readChargingNBT(nbt);
}
@Override
@@ -543,11 +441,7 @@ public class EntityAbilityLaser extends EntityAbilityProjectile {
nbt.setDouble("EndY", endY);
nbt.setDouble("EndZ", endZ);
// Charging state
nbt.setBoolean("Charging", isCharging());
nbt.setInteger("ChargeDuration", chargeDuration);
nbt.setInteger("ChargeTick", chargeTick);
nbt.setFloat("TargetSize", targetSize);
writeChargingNBT(nbt);
}
/**