mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 13:10:04 +00:00
Lot's of Weird Ability Interaction Fixes
This commit is contained in:
1 parent
25320f8de1
commit
b5534b4a39
9 files changed
+212
-132
No files matched your search
@@ -64,7 +64,8 @@ public class AbilitySlam extends Ability implements IAbilitySlam {
|
||||
private transient int airTicks = 0;
|
||||
private transient int maxAirTicks = 60; // Timeout to prevent stuck in air
|
||||
private transient boolean airSlam = false; // True when slam initiated while already in the air
|
||||
private transient double groundY = 0; // Cached ground level for air slams
|
||||
private transient double airSlamStartY = 0; // Start height for air-slam damage scaling
|
||||
private transient boolean wasFlying = false; // Restore player flight after air slam
|
||||
|
||||
public AbilitySlam() {
|
||||
this.typeId = "ability.cnpc.slam";
|
||||
@@ -179,30 +180,46 @@ public class AbilitySlam extends Ability implements IAbilitySlam {
|
||||
if (!caster.onGround) {
|
||||
// Air slam: player is already airborne (flying, falling, jumping)
|
||||
airSlam = true;
|
||||
airSlamStartY = caster.posY;
|
||||
targetX = caster.posX;
|
||||
targetY = caster.posY;
|
||||
targetZ = caster.posZ;
|
||||
|
||||
// Find ground level below player (scan to world bottom)
|
||||
int bx = (int) Math.floor(caster.posX);
|
||||
int bz = (int) Math.floor(caster.posZ);
|
||||
groundY = 0;
|
||||
for (int by = (int) Math.floor(caster.posY) - 1; by >= 0; by--) {
|
||||
if (caster.worldObj.getBlock(bx, by, bz).getMaterial().isSolid()) {
|
||||
groundY = by + 1;
|
||||
break;
|
||||
// If the player is flying, temporarily disable it so gravity/velocity apply normally.
|
||||
if (caster instanceof EntityPlayerMP) {
|
||||
EntityPlayerMP mp = (EntityPlayerMP) caster;
|
||||
wasFlying = mp.capabilities.isFlying;
|
||||
if (wasFlying) {
|
||||
mp.capabilities.isFlying = false;
|
||||
mp.sendPlayerAbilities();
|
||||
}
|
||||
}
|
||||
|
||||
hasLaunched = true;
|
||||
hasRisen = true; // Skip rise detection — we're already above ground
|
||||
|
||||
// Start descent smoothly; physics/collision handles exact landing surface.
|
||||
// Only damp horizontal drift when movement is locked during ACTIVE.
|
||||
if (isMovementLockedDuringActive()) {
|
||||
caster.motionX *= 0.25;
|
||||
caster.motionZ *= 0.25;
|
||||
}
|
||||
caster.motionY = Math.min(caster.motionY, -0.2);
|
||||
|
||||
if (!isPreview()) {
|
||||
if (caster instanceof EntityPlayerMP) {
|
||||
((EntityPlayerMP) caster).playerNetServerHandler.sendPacket(
|
||||
new S12PacketEntityVelocity(caster));
|
||||
} else {
|
||||
caster.velocityChanged = true;
|
||||
}
|
||||
caster.worldObj.playSoundAtEntity(caster, "mob.irongolem.throw", 0.8f, 0.8f);
|
||||
}
|
||||
} else {
|
||||
// Ground slam: normal ballistic arc
|
||||
airSlam = false;
|
||||
airSlamStartY = 0;
|
||||
wasFlying = false;
|
||||
|
||||
// Calculate target position along player's look direction (horizontal only)
|
||||
float yawRad = (float) Math.toRadians(caster.rotationYaw);
|
||||
@@ -354,6 +371,10 @@ public class AbilitySlam extends Ability implements IAbilitySlam {
|
||||
if (!hasLaunched) return;
|
||||
if (hasLanded) return;
|
||||
|
||||
boolean playerCaster = isPlayerCaster(caster);
|
||||
boolean activeMovementLocked = isMovementLockedDuringActive();
|
||||
boolean forceHorizontalControl = !playerCaster || activeMovementLocked;
|
||||
|
||||
airTicks++;
|
||||
|
||||
// Continuously reset fall distance during slam to prevent fall damage
|
||||
@@ -361,31 +382,22 @@ public class AbilitySlam extends Ability implements IAbilitySlam {
|
||||
caster.fallDistance = 0;
|
||||
}
|
||||
|
||||
// Air slam: force descent via position update (works regardless of flight state)
|
||||
// Air slam: accelerate descent smoothly via velocity; landing uses normal collision.
|
||||
if (airSlam && !isPreview() && !hasLanded) {
|
||||
double descentSpeed = Math.min(1.5, 0.3 + airTicks * 0.12);
|
||||
double nextY = caster.posY - descentSpeed;
|
||||
|
||||
if (nextY <= groundY) {
|
||||
// Reached ground — land
|
||||
if (caster instanceof EntityPlayerMP) {
|
||||
((EntityPlayerMP) caster).setPositionAndUpdate(caster.posX, groundY, caster.posZ);
|
||||
} else {
|
||||
caster.setPosition(caster.posX, groundY, caster.posZ);
|
||||
}
|
||||
caster.onGround = true;
|
||||
onLanding(caster, caster.worldObj);
|
||||
return;
|
||||
if (forceHorizontalControl) {
|
||||
caster.motionX *= 0.2;
|
||||
caster.motionZ *= 0.2;
|
||||
}
|
||||
|
||||
// Continue descent
|
||||
caster.motionX = 0;
|
||||
caster.motionZ = 0;
|
||||
caster.motionY = -descentSpeed;
|
||||
double nextMotionY = caster.motionY - 0.18;
|
||||
caster.motionY = Math.max(-1.6, nextMotionY);
|
||||
if (caster instanceof EntityPlayerMP) {
|
||||
((EntityPlayerMP) caster).setPositionAndUpdate(caster.posX, nextY, caster.posZ);
|
||||
// Only push authoritative velocity every tick when ACTIVE movement is locked.
|
||||
if (forceHorizontalControl) {
|
||||
((EntityPlayerMP) caster).playerNetServerHandler.sendPacket(
|
||||
new S12PacketEntityVelocity(caster));
|
||||
}
|
||||
} else {
|
||||
caster.setPosition(caster.posX, nextY, caster.posZ);
|
||||
caster.velocityChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -427,16 +439,19 @@ public class AbilitySlam extends Ability implements IAbilitySlam {
|
||||
return;
|
||||
}
|
||||
|
||||
// Face toward target destination while in air (both NPC and Player)
|
||||
// Face toward destination while in air unless player ACTIVE movement is unlocked.
|
||||
// Unlocked players keep free horizontal drift/look control.
|
||||
if (!isPreview()) {
|
||||
double dx = targetX - caster.posX;
|
||||
double dz = targetZ - caster.posZ;
|
||||
if (dx * dx + dz * dz > 0.25) {
|
||||
float targetYaw = (float) (Math.atan2(-dx, dz) * 180.0D / Math.PI);
|
||||
caster.rotationYaw = targetYaw;
|
||||
caster.rotationYawHead = targetYaw;
|
||||
if (isPlayerCaster(caster)) {
|
||||
caster.velocityChanged = true;
|
||||
if (forceHorizontalControl) {
|
||||
double dx = targetX - caster.posX;
|
||||
double dz = targetZ - caster.posZ;
|
||||
if (dx * dx + dz * dz > 0.25) {
|
||||
float targetYaw = (float) (Math.atan2(-dx, dz) * 180.0D / Math.PI);
|
||||
caster.rotationYaw = targetYaw;
|
||||
caster.rotationYawHead = targetYaw;
|
||||
if (playerCaster) {
|
||||
caster.velocityChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -450,13 +465,16 @@ public class AbilitySlam extends Ability implements IAbilitySlam {
|
||||
if (!isPreview() && caster instanceof EntityNPCInterface) {
|
||||
((EntityNPCInterface) caster).setNpcJumpingState(false);
|
||||
}
|
||||
restoreFlightIfNeeded(caster);
|
||||
|
||||
// Signal that the ability has completed its active phase
|
||||
signalCompletion();
|
||||
|
||||
// Stop horizontal momentum
|
||||
caster.motionX = 0;
|
||||
caster.motionZ = 0;
|
||||
// Stop horizontal momentum only when movement is controlled by the ability.
|
||||
if (!isPlayerCaster(caster) || isMovementLockedDuringActive()) {
|
||||
caster.motionX = 0;
|
||||
caster.motionZ = 0;
|
||||
}
|
||||
|
||||
if (!isPreview()) {
|
||||
// Reset fall distance to prevent fall damage on landing
|
||||
@@ -473,7 +491,8 @@ public class AbilitySlam extends Ability implements IAbilitySlam {
|
||||
// Scale damage based on fall distance for air slams
|
||||
float effectiveDamage = damage;
|
||||
if (airSlam) {
|
||||
double fallDistance = startY - caster.posY;
|
||||
double fallStartY = airSlamStartY > 0 ? airSlamStartY : startY;
|
||||
double fallDistance = fallStartY - caster.posY;
|
||||
if (fallDistance < 0) fallDistance = 0;
|
||||
// Scale linearly: full damage at leapHeight distance, minimum 25% for tiny falls
|
||||
float heightFactor = (float) Math.min(1.0, fallDistance / Math.max(1.0, leapHeight));
|
||||
@@ -548,11 +567,14 @@ public class AbilitySlam extends Ability implements IAbilitySlam {
|
||||
if (!isPreview() && caster instanceof EntityNPCInterface) {
|
||||
((EntityNPCInterface) caster).setNpcJumpingState(false);
|
||||
}
|
||||
restoreFlightIfNeeded(caster);
|
||||
hasLaunched = false;
|
||||
hasLanded = false;
|
||||
hasRisen = false;
|
||||
airTicks = 0;
|
||||
airSlam = false;
|
||||
airSlamStartY = 0;
|
||||
wasFlying = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -560,20 +582,26 @@ public class AbilitySlam extends Ability implements IAbilitySlam {
|
||||
if (!isPreview() && caster instanceof EntityNPCInterface) {
|
||||
((EntityNPCInterface) caster).setNpcJumpingState(false);
|
||||
}
|
||||
restoreFlightIfNeeded(caster);
|
||||
hasLaunched = false;
|
||||
hasLanded = false;
|
||||
hasRisen = false;
|
||||
airTicks = 0;
|
||||
airSlam = false;
|
||||
airSlamStartY = 0;
|
||||
wasFlying = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup() {
|
||||
// Caster may be unavailable here; flight restoration is handled in onComplete/onInterrupt.
|
||||
hasLaunched = false;
|
||||
hasLanded = false;
|
||||
hasRisen = false;
|
||||
airTicks = 0;
|
||||
airSlam = false;
|
||||
airSlamStartY = 0;
|
||||
wasFlying = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -584,6 +612,21 @@ public class AbilitySlam extends Ability implements IAbilitySlam {
|
||||
hasRisen = false;
|
||||
airTicks = 0;
|
||||
airSlam = false;
|
||||
airSlamStartY = 0;
|
||||
wasFlying = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore player flight if it was disabled for an air slam.
|
||||
*/
|
||||
private void restoreFlightIfNeeded(EntityLivingBase caster) {
|
||||
if (airSlam && wasFlying && caster instanceof EntityPlayerMP) {
|
||||
EntityPlayerMP mp = (EntityPlayerMP) caster;
|
||||
if (!mp.capabilities.isFlying) {
|
||||
mp.capabilities.isFlying = true;
|
||||
mp.sendPlayerAbilities();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -36,8 +36,8 @@ public class AbilityBeam extends AbilityEnergyProjectile<EntityAbilityBeam> impl
|
||||
|
||||
public AbilityBeam() {
|
||||
super(
|
||||
new EnergyDisplayData(0xFFFFFF, 0x00AAFF, true, 0.4f, 0.5f, 6.0f),
|
||||
new EnergyCombatData(10.0f, 1.5f, 0.2f, false, 4.0f, 0.5f, HitType.MULTI, 5),
|
||||
new EnergyDisplayData(0xFFFFFF, 0x00AAFF, true, 0.4f, 0.5f, 10.0f),
|
||||
new EnergyCombatData(10.0f, 1.5f, 0.2f, false, 4.0f, 0.5f, HitType.SINGLE, 5),
|
||||
new EnergyHomingData(0.4f, true, 0.1f, 15.0f),
|
||||
new EnergyLifespanData(150.0f, 200)
|
||||
);
|
||||
|
||||
@@ -38,7 +38,7 @@ public class AbilityDisc extends AbilityEnergyProjectile<EntityAbilityDisc> impl
|
||||
|
||||
public AbilityDisc() {
|
||||
super(
|
||||
new EnergyDisplayData(0xFFFFFF, 0xFF8800, true, 0.4f, 0.5f, 5.0f),
|
||||
new EnergyDisplayData(0xFFFFFF, 0xFF8800, true, 0.4f, 0.5f, 10.0f),
|
||||
new EnergyCombatData(8.0f, 1.2f, 0.15f, false, 3.0f, 0.5f, HitType.PIERCE, 5),
|
||||
new EnergyHomingData(0.6f, true, 0.12f, 18.0f),
|
||||
new EnergyLifespanData(150.0f, 200)
|
||||
|
||||
+3
-2
@@ -254,10 +254,11 @@ public abstract class AbilityEnergyProjectile<E extends EntityEnergyProjectile>
|
||||
|
||||
/**
|
||||
* Hook for launch target selection.
|
||||
* Default returns null so projectiles launch along owner look vector.
|
||||
* Players launch along their look vector (crosshair-aligned), so target is ignored.
|
||||
* NPCs use their resolved target so launch math can track the target immediately.
|
||||
*/
|
||||
protected EntityLivingBase getLaunchTarget(EntityLivingBase caster, EntityLivingBase target) {
|
||||
return null;
|
||||
return isPlayerCaster(caster) ? null : target;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,7 +32,7 @@ public class AbilityOrb extends AbilityEnergyProjectile<EntityAbilityOrb> implem
|
||||
|
||||
public AbilityOrb() {
|
||||
super(
|
||||
new EnergyDisplayData(0xFFFFFF, 0xFF0000, true, 0.4f, 0.5f, 0.0f),
|
||||
new EnergyDisplayData(0xFFFFFF, 0xFF0000, true, 0.4f, 0.5f, 10.0f),
|
||||
new EnergyCombatData(),
|
||||
new EnergyHomingData(),
|
||||
new EnergyLifespanData()
|
||||
|
||||
@@ -81,12 +81,19 @@ public class EntityAbilityLaser extends EntityEnergyProjectile {
|
||||
this.dirZ = dz / len;
|
||||
}
|
||||
} else {
|
||||
// Fire in NPC's facing direction
|
||||
float yaw = (float) Math.toRadians(owner.rotationYaw);
|
||||
float pitch = (float) Math.toRadians(owner.rotationPitch);
|
||||
this.dirX = -Math.sin(yaw) * Math.cos(pitch);
|
||||
this.dirY = -Math.sin(pitch);
|
||||
this.dirZ = Math.cos(yaw) * Math.cos(pitch);
|
||||
// Fall back to owner look direction so launch matches visual aim.
|
||||
Vec3 look = owner == null ? null : owner.getLookVec();
|
||||
if (look != null) {
|
||||
this.dirX = look.xCoord;
|
||||
this.dirY = look.yCoord;
|
||||
this.dirZ = look.zCoord;
|
||||
} else {
|
||||
float yaw = (float) Math.toRadians(owner.rotationYaw);
|
||||
float pitch = (float) Math.toRadians(owner.rotationPitch);
|
||||
this.dirX = -Math.sin(yaw) * Math.cos(pitch);
|
||||
this.dirY = -Math.sin(pitch);
|
||||
this.dirZ = Math.cos(yaw) * Math.cos(pitch);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize end point
|
||||
@@ -134,6 +141,12 @@ public class EntityAbilityLaser extends EntityEnergyProjectile {
|
||||
// Check for block collision along the new segment
|
||||
if (!worldObj.isRemote) {
|
||||
checkBlockCollision();
|
||||
// Re-evaluate barriers against the current beam segment before entity hits.
|
||||
// This prevents first-tick pass-through where the pre-update barrier check
|
||||
// still sees a zero-length beam.
|
||||
if (checkBarrierCollisionForCurrentSegment()) {
|
||||
return;
|
||||
}
|
||||
checkEntityCollisionAlongLine();
|
||||
}
|
||||
} else {
|
||||
@@ -163,19 +176,33 @@ public class EntityAbilityLaser extends EntityEnergyProjectile {
|
||||
if (owner == null || !(owner instanceof EntityLivingBase)) return;
|
||||
EntityLivingBase livingOwner = (EntityLivingBase) owner;
|
||||
|
||||
// Update direction from owner's current rotation
|
||||
float yaw = (float) Math.toRadians(owner.rotationYaw);
|
||||
if (lockVerticalDirection) {
|
||||
// Only update horizontal direction (yaw), keep vertical (pitch) fixed
|
||||
double horizontalLen = Math.sqrt(dirX * dirX + dirZ * dirZ);
|
||||
if (horizontalLen < 0.001) horizontalLen = 1.0;
|
||||
dirX = -Math.sin(yaw) * horizontalLen;
|
||||
dirZ = Math.cos(yaw) * horizontalLen;
|
||||
} else {
|
||||
// Use owner look vector (head/eye aim) for direction updates so hit logic matches visuals.
|
||||
Vec3 look = livingOwner.getLookVec();
|
||||
if (look == null) {
|
||||
float yaw = (float) Math.toRadians(owner.rotationYaw);
|
||||
float pitch = (float) Math.toRadians(owner.rotationPitch);
|
||||
dirX = -Math.sin(yaw) * Math.cos(pitch);
|
||||
dirY = -Math.sin(pitch);
|
||||
dirZ = Math.cos(yaw) * Math.cos(pitch);
|
||||
look = Vec3.createVectorHelper(
|
||||
-Math.sin(yaw) * Math.cos(pitch),
|
||||
-Math.sin(pitch),
|
||||
Math.cos(yaw) * Math.cos(pitch)
|
||||
);
|
||||
}
|
||||
|
||||
if (lockVerticalDirection) {
|
||||
// Keep current vertical component, but align horizontal direction to current look.
|
||||
double lookHorizontalLen = Math.sqrt(look.xCoord * look.xCoord + look.zCoord * look.zCoord);
|
||||
if (lookHorizontalLen > 0.0001) {
|
||||
double currentHorizontalLen = Math.sqrt(dirX * dirX + dirZ * dirZ);
|
||||
if (currentHorizontalLen < 0.0001) {
|
||||
currentHorizontalLen = Math.sqrt(Math.max(0.0001, 1.0 - dirY * dirY));
|
||||
}
|
||||
dirX = (look.xCoord / lookHorizontalLen) * currentHorizontalLen;
|
||||
dirZ = (look.zCoord / lookHorizontalLen) * currentHorizontalLen;
|
||||
}
|
||||
} else {
|
||||
dirX = look.xCoord;
|
||||
dirY = look.yCoord;
|
||||
dirZ = look.zCoord;
|
||||
}
|
||||
|
||||
// Keep direction normalized for consistent expansion and collision math.
|
||||
@@ -188,10 +215,7 @@ public class EntityAbilityLaser extends EntityEnergyProjectile {
|
||||
direction.zCoord / dirLen
|
||||
);
|
||||
} else {
|
||||
Vec3 look = livingOwner.getLookVec();
|
||||
if (look != null) {
|
||||
direction = look;
|
||||
}
|
||||
direction = look != null ? look : Vec3.createVectorHelper(1.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
dirX = direction.xCoord;
|
||||
@@ -320,49 +344,24 @@ public class EntityAbilityLaser extends EntityEnergyProjectile {
|
||||
|
||||
/**
|
||||
* Check if an entity's bounding box intersects with the laser line.
|
||||
* Uses separate XZ (horizontal) and Y (vertical) checks against
|
||||
* the entity's full bounding box rather than just its center point.
|
||||
* Uses a swept segment vs expanded AABB intercept test for reliable hits.
|
||||
*/
|
||||
private boolean isEntityOnLine(EntityLivingBase entity) {
|
||||
double ex = entity.posX;
|
||||
double ez = entity.posZ;
|
||||
AxisAlignedBB bb = entity.boundingBox;
|
||||
if (bb == null) return false;
|
||||
|
||||
// Project entity XZ position onto the laser line direction
|
||||
double vx = ex - startX;
|
||||
double vz = ez - startZ;
|
||||
// Project using horizontal direction components only
|
||||
double dirLenXZ = Math.sqrt(dirX * dirX + dirZ * dirZ);
|
||||
double dot;
|
||||
if (dirLenXZ > 0.001) {
|
||||
dot = (vx * dirX + vz * dirZ + (entity.posY + entity.height * 0.5 - startY) * dirY);
|
||||
} else {
|
||||
// Laser fires nearly straight up/down - use full 3D projection
|
||||
dot = vx * dirX + (entity.posY + entity.height * 0.5 - startY) * dirY + vz * dirZ;
|
||||
}
|
||||
dot = Math.max(0, Math.min(dot, currentLength));
|
||||
// Minimum effective width keeps thin lasers from visually clipping targets without hitting.
|
||||
double effectiveWidth = Math.max(laserWidth, 0.65);
|
||||
double expand = effectiveWidth * 0.5;
|
||||
AxisAlignedBB expanded = bb.expand(expand, expand, expand);
|
||||
|
||||
// Closest point on laser line at this parameter
|
||||
double closestX = startX + dirX * dot;
|
||||
double closestY = startY + dirY * dot;
|
||||
double closestZ = startZ + dirZ * dot;
|
||||
Vec3 segmentStart = Vec3.createVectorHelper(startX, startY, startZ);
|
||||
Vec3 segmentEnd = Vec3.createVectorHelper(endX, endY, endZ);
|
||||
MovingObjectPosition intercept = expanded.calculateIntercept(segmentStart, segmentEnd);
|
||||
if (intercept != null) return true;
|
||||
|
||||
// XZ distance check: entity center vs laser line point
|
||||
// Use minimum collision width so visually thin lasers still hit reliably
|
||||
double xzDistSq = (ex - closestX) * (ex - closestX) + (ez - closestZ) * (ez - closestZ);
|
||||
double effectiveWidth = Math.max(laserWidth, 0.5);
|
||||
double hitRadiusXZ = effectiveWidth * 0.5 + entity.width * 0.5;
|
||||
if (xzDistSq > hitRadiusXZ * hitRadiusXZ) return false;
|
||||
|
||||
// Y overlap check: laser point vs entity's full height range
|
||||
double entityMinY = entity.boundingBox.minY;
|
||||
double entityMaxY = entity.boundingBox.maxY;
|
||||
double laserHalfWidth = effectiveWidth * 0.5;
|
||||
|
||||
// Check if laser Y is within entity's height range (expanded by laser half-width)
|
||||
if (closestY < entityMinY - laserHalfWidth) return false;
|
||||
if (closestY > entityMaxY + laserHalfWidth) return false;
|
||||
|
||||
return true;
|
||||
// Handle edge case where the segment starts or ends already inside the target volume.
|
||||
return expanded.isVecInside(segmentStart) || expanded.isVecInside(segmentEnd);
|
||||
}
|
||||
|
||||
// ==================== BARRIER COLLISION ====================
|
||||
@@ -375,7 +374,17 @@ public class EntityAbilityLaser extends EntityEnergyProjectile {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected boolean checkBarrierCollision() {
|
||||
if (currentLength <= 0 || fullyExtended) return false;
|
||||
return checkBarrierCollisionInternal(false);
|
||||
}
|
||||
|
||||
private boolean checkBarrierCollisionForCurrentSegment() {
|
||||
return checkBarrierCollisionInternal(true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private boolean checkBarrierCollisionInternal(boolean allowWhenFullyExtended) {
|
||||
if (currentLength <= 0) return false;
|
||||
if (fullyExtended && !allowWhenFullyExtended) return false;
|
||||
|
||||
List<EntityAbilityBarrier> barriers = EntityAbilityBarrier.getActiveBarriers(worldObj);
|
||||
for (EntityAbilityBarrier barrier : barriers) {
|
||||
@@ -404,11 +413,25 @@ public class EntityAbilityLaser extends EntityEnergyProjectile {
|
||||
|
||||
float damage = getModifiedDamage();
|
||||
dome.onProjectileHit(this, damage);
|
||||
return false; // Don't kill laser — it's truncated and will linger
|
||||
// Block this tick so entity collision doesn't continue through the dome.
|
||||
// Laser remains alive and lingers at truncated length.
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// Non-dome barriers: fall through to standard check
|
||||
if (barrier.isIncomingProjectile(this)) {
|
||||
// For line-based lasers, use a swept segment against generic barrier checks.
|
||||
// Panel/Dome logic expects previous+current positions and motion; map those
|
||||
// to [start -> end] each tick.
|
||||
double segMotionX = endX - startX;
|
||||
double segMotionY = endY - startY;
|
||||
double segMotionZ = endZ - startZ;
|
||||
boolean incoming = barrier.isIncomingGenericProjectile(
|
||||
endX, endY, endZ,
|
||||
segMotionX, segMotionY, segMotionZ,
|
||||
startX, startY, startZ,
|
||||
this.ownerEntityId
|
||||
);
|
||||
|
||||
if (incoming) {
|
||||
float damage = getModifiedDamage();
|
||||
if (barrier.onProjectileHit(this, damage)) {
|
||||
hasHit = true;
|
||||
|
||||
@@ -72,7 +72,7 @@ public class EntityAbilityOrb extends EntityEnergyProjectile {
|
||||
* Called by ability when windup ends.
|
||||
*/
|
||||
public void startMoving(EntityLivingBase target) {
|
||||
startMovingAlongLookVectorDefault();
|
||||
startMovingTowardTargetDefault(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -837,7 +837,11 @@ public abstract class EntityEnergyProjectile extends EntityEnergyAbility {
|
||||
*/
|
||||
protected boolean beginLookVectorLaunch(boolean resetInterpolationState) {
|
||||
setCharging(false);
|
||||
boolean positioned = setLookVectorLaunchPosition(true);
|
||||
Entity owner = getOwnerEntity();
|
||||
boolean positioned = false;
|
||||
if (owner instanceof EntityLivingBase && shouldSnapLaunchToLookVector((EntityLivingBase) owner)) {
|
||||
positioned = setLookVectorLaunchPosition((EntityLivingBase) owner, getOwnerLookVector(), true);
|
||||
}
|
||||
syncStartPositionToCurrent();
|
||||
if (resetInterpolationState) {
|
||||
syncPositionStateToCurrent(true);
|
||||
@@ -850,7 +854,7 @@ public abstract class EntityEnergyProjectile extends EntityEnergyAbility {
|
||||
*/
|
||||
protected boolean beginLookVectorLaunch(EntityLivingBase owner, Vec3 look, boolean resetInterpolationState) {
|
||||
setCharging(false);
|
||||
boolean positioned = setLookVectorLaunchPosition(owner, look, true);
|
||||
boolean positioned = shouldSnapLaunchToLookVector(owner) && setLookVectorLaunchPosition(owner, look, true);
|
||||
syncStartPositionToCurrent();
|
||||
if (resetInterpolationState) {
|
||||
syncPositionStateToCurrent(true);
|
||||
@@ -858,6 +862,14 @@ public abstract class EntityEnergyProjectile extends EntityEnergyAbility {
|
||||
return positioned;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only player-cast projectiles should be recentered to look-vector launch origin.
|
||||
* NPC projectiles keep their anchor charge origin so casts originate from the configured anchor.
|
||||
*/
|
||||
protected boolean shouldSnapLaunchToLookVector(EntityLivingBase owner) {
|
||||
return owner instanceof EntityPlayer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default preview launch: snap to look-vector origin and fire along look.
|
||||
*/
|
||||
|
||||
@@ -31,6 +31,7 @@ public class AbilityHotbarComponent extends HudComponent {
|
||||
|
||||
private static final int BASE_SLOT_SIZE = 24;
|
||||
private static final int BASE_SPACING = 28;
|
||||
private static final int EDIT_HANDLE_SIZE = 10;
|
||||
|
||||
private AbilityHotbarSlotRenderer[] slots = new AbilityHotbarSlotRenderer[TOTAL_SLOTS];
|
||||
|
||||
@@ -430,25 +431,18 @@ public class AbilityHotbarComponent extends HudComponent {
|
||||
int modeLabelW = fr.getStringWidth(modeLabel);
|
||||
fr.drawStringWithShadow(modeLabel, overlayWidth / 2 - modeLabelW / 2, overlayHeight + 2, 0xAA888888);
|
||||
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glColor4f(0.2f, 0.8f, 0.2f, 0.8f);
|
||||
GL11.glLineWidth(1.0f);
|
||||
GL11.glBegin(GL11.GL_LINE_LOOP);
|
||||
GL11.glVertex2f(0, 0);
|
||||
GL11.glVertex2f(overlayWidth, 0);
|
||||
GL11.glVertex2f(overlayWidth, overlayHeight);
|
||||
GL11.glVertex2f(0, overlayHeight);
|
||||
GL11.glEnd();
|
||||
net.minecraft.client.gui.Gui.drawRect(0, 0, overlayWidth, overlayHeight, 0x22000000);
|
||||
drawRectOutline(0, 0, overlayWidth, overlayHeight, 0xCC66CC66);
|
||||
|
||||
GL11.glColor4f(0.8f, 0.8f, 0.8f, 0.9f);
|
||||
GL11.glBegin(GL11.GL_QUADS);
|
||||
GL11.glVertex2f(overlayWidth - 10, overlayHeight - 10);
|
||||
GL11.glVertex2f(overlayWidth, overlayHeight - 10);
|
||||
GL11.glVertex2f(overlayWidth, overlayHeight);
|
||||
GL11.glVertex2f(overlayWidth - 10, overlayHeight);
|
||||
GL11.glEnd();
|
||||
int handleLeft = overlayWidth - EDIT_HANDLE_SIZE;
|
||||
int handleTop = overlayHeight - EDIT_HANDLE_SIZE;
|
||||
net.minecraft.client.gui.Gui.drawRect(handleLeft, handleTop, overlayWidth, overlayHeight, 0xFFE0E0E0);
|
||||
drawRectOutline(handleLeft, handleTop, overlayWidth, overlayHeight, 0xFF5A5A5A);
|
||||
net.minecraft.client.gui.Gui.drawRect(handleLeft + 2, handleTop + 7, handleLeft + 8, handleTop + 8, 0xAA666666);
|
||||
net.minecraft.client.gui.Gui.drawRect(handleLeft + 4, handleTop + 5, handleLeft + 8, handleTop + 6, 0xAA666666);
|
||||
net.minecraft.client.gui.Gui.drawRect(handleLeft + 6, handleTop + 3, handleLeft + 8, handleTop + 4, 0xAA666666);
|
||||
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
@@ -694,4 +688,11 @@ public class AbilityHotbarComponent extends HudComponent {
|
||||
updateAbilities();
|
||||
lastUpdateTime = Minecraft.getSystemTime();
|
||||
}
|
||||
|
||||
private void drawRectOutline(int left, int top, int right, int bottom, int color) {
|
||||
net.minecraft.client.gui.Gui.drawRect(left, top, right, top + 1, color);
|
||||
net.minecraft.client.gui.Gui.drawRect(left, bottom - 1, right, bottom, color);
|
||||
net.minecraft.client.gui.Gui.drawRect(left, top, left + 1, bottom, color);
|
||||
net.minecraft.client.gui.Gui.drawRect(right - 1, top, right, bottom, color);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user