mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 01:32:19 +00:00
Ability Preview GUI
This commit is contained in:
1 parent
216a3dbbf8
commit
55658a7956
37 files changed
+2396
-162
No files matched your search
@@ -50,8 +50,12 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
@@ -188,6 +192,95 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
|
||||
return orb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an orb in preview mode for GUI display.
|
||||
* Follows anchor point and animations like in the real game.
|
||||
* Can be fired when transitioning to active phase.
|
||||
*/
|
||||
public static EntityAbilityOrb createPreview(World world, EntityNPCInterface owner,
|
||||
float orbSize, int innerColor, int outerColor,
|
||||
boolean outerColorEnabled, float outerColorWidth, float rotationSpeed,
|
||||
boolean lightningEffect, float lightningDensity, float lightningRadius, int lightningFadeTime,
|
||||
AnchorPoint anchorPoint, int chargeDuration) {
|
||||
EntityAbilityOrb orb = new EntityAbilityOrb(world);
|
||||
orb.setPreviewMode(true);
|
||||
orb.setPreviewOwner(owner);
|
||||
|
||||
// Set visual properties
|
||||
orb.innerColor = innerColor;
|
||||
orb.outerColor = outerColor;
|
||||
orb.outerColorEnabled = outerColorEnabled;
|
||||
orb.outerColorWidth = outerColorWidth;
|
||||
orb.rotationSpeed = rotationSpeed;
|
||||
orb.lightningEffect = lightningEffect;
|
||||
orb.lightningDensity = lightningDensity;
|
||||
orb.lightningRadius = lightningRadius;
|
||||
orb.lightningFadeTime = lightningFadeTime;
|
||||
|
||||
// Set charging state (like createCharging does)
|
||||
orb.setCharging(true);
|
||||
orb.chargeDuration = chargeDuration;
|
||||
orb.chargeTick = 0;
|
||||
orb.anchorPoint = anchorPoint;
|
||||
|
||||
// Store target size and start at 0 for grow effect
|
||||
orb.targetSize = orbSize;
|
||||
orb.size = 0.01f;
|
||||
orb.renderCurrentSize = 0.01f;
|
||||
orb.prevRenderSize = 0.01f;
|
||||
|
||||
// Initial position at anchor point
|
||||
Vec3 pos = AnchorPointHelper.calculateAnchorPosition(owner, anchorPoint);
|
||||
orb.setPosition(pos.xCoord, pos.yCoord, pos.zCoord);
|
||||
orb.prevPosX = pos.xCoord;
|
||||
orb.prevPosY = pos.yCoord;
|
||||
orb.prevPosZ = pos.zCoord;
|
||||
orb.startX = pos.xCoord;
|
||||
orb.startY = pos.yCoord;
|
||||
orb.startZ = pos.zCoord;
|
||||
|
||||
// Clear motion while charging
|
||||
orb.motionX = 0;
|
||||
orb.motionY = 0;
|
||||
orb.motionZ = 0;
|
||||
|
||||
return orb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start preview firing (simulates firing toward a point in front of NPC).
|
||||
*/
|
||||
public void startPreviewFiring() {
|
||||
if (!isCharging()) return;
|
||||
|
||||
setCharging(false);
|
||||
|
||||
// Update start position to current position
|
||||
startX = posX;
|
||||
startY = posY;
|
||||
startZ = posZ;
|
||||
|
||||
// Sync prev position to prevent visual jump on first frame
|
||||
prevPosX = posX;
|
||||
prevPosY = posY;
|
||||
prevPosZ = posZ;
|
||||
|
||||
// Fire forward based on owner facing direction
|
||||
Entity owner = getOwner();
|
||||
if (owner != null) {
|
||||
float yaw = (float) Math.toRadians(owner.rotationYaw);
|
||||
float pitch = (float) Math.toRadians(0); // Fire horizontally
|
||||
motionX = -Math.sin(yaw) * Math.cos(pitch) * speed;
|
||||
motionY = -Math.sin(pitch) * speed;
|
||||
motionZ = Math.cos(yaw) * Math.cos(pitch) * speed;
|
||||
} else {
|
||||
// Default: fire forward (positive X in model space)
|
||||
motionX = speed;
|
||||
motionY = 0;
|
||||
motionZ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the orb moving (exit charging mode).
|
||||
* Called by ability when windup ends.
|
||||
@@ -232,6 +325,12 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
|
||||
return;
|
||||
}
|
||||
|
||||
// In preview mode, run movement on client (no server)
|
||||
if (previewMode) {
|
||||
updatePreviewMovement();
|
||||
return;
|
||||
}
|
||||
|
||||
if (worldObj.isRemote) {
|
||||
handleClientInterpolation();
|
||||
} else {
|
||||
@@ -254,6 +353,16 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update movement in preview mode (client-side only, no damage).
|
||||
*/
|
||||
private void updatePreviewMovement() {
|
||||
// Simple movement - just apply motion
|
||||
this.posX += motionX;
|
||||
this.posY += motionY;
|
||||
this.posZ += motionZ;
|
||||
}
|
||||
|
||||
private void updateHoming() {
|
||||
if (!homing) return;
|
||||
|
||||
|
||||
Reference in new issue
Block a user