mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-14 04:59:57 +00:00
Better Barrier Tracking
This commit is contained in:
1 parent
077fc3cb1d
commit
747918c4dc
3 files changed
+23
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package kamkeel.npcs.entity;
|
||||
|
||||
import kamkeel.npcs.controllers.data.ability.AbilityTargetHelper;
|
||||
import kamkeel.npcs.controllers.data.ability.data.EnergyBarrierData;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -236,6 +237,16 @@ public abstract class EntityEnergyBarrier extends EntityEnergyAbility {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an entity is an ally of this barrier's owner.
|
||||
* Allies should not be knocked back by barriers.
|
||||
*/
|
||||
protected boolean isAllyOfOwner(EntityLivingBase entity) {
|
||||
Entity owner = getOwnerEntity();
|
||||
if (owner == null || !(owner instanceof EntityLivingBase)) return false;
|
||||
return AbilityTargetHelper.isAlly((EntityLivingBase) owner, entity);
|
||||
}
|
||||
|
||||
// ==================== GETTERS ====================
|
||||
|
||||
public EnergyBarrierData getBarrierData() {
|
||||
|
||||
@@ -58,6 +58,10 @@ public class EntityEnergyDome extends EntityEnergyBarrier {
|
||||
Entity owner = ownerEntityId >= 0 ? worldObj.getEntityByID(ownerEntityId) : null;
|
||||
if (owner != null) {
|
||||
this.setPosition(owner.posX, owner.posY, owner.posZ);
|
||||
// Sync prevPos with owner's prevPos for smooth interpolation
|
||||
this.prevPosX = owner.prevPosX;
|
||||
this.prevPosY = owner.prevPosY;
|
||||
this.prevPosZ = owner.prevPosZ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,6 +166,7 @@ public class EntityEnergyDome extends EntityEnergyBarrier {
|
||||
for (EntityLivingBase ent : entities) {
|
||||
if (ent.getEntityId() == ownerEntityId) continue;
|
||||
if (!isKnockbackTarget(ent)) continue;
|
||||
if (isAllyOfOwner(ent)) continue;
|
||||
|
||||
double dx = ent.posX - posX;
|
||||
double dy = (ent.posY + ent.height * 0.5) - posY;
|
||||
|
||||
@@ -130,6 +130,12 @@ public class EntityEnergyPanel extends EntityEnergyBarrier {
|
||||
double newZ = owner.posZ + (Math.cos(yawRad) * frontDist);
|
||||
|
||||
this.setPosition(newX, newY, newZ);
|
||||
|
||||
// Sync prevPos with owner's prevPos for smooth interpolation
|
||||
float prevYawRad = (float) Math.toRadians(owner.prevRotationYaw);
|
||||
this.prevPosX = owner.prevPosX + (-Math.sin(prevYawRad) * frontDist);
|
||||
this.prevPosY = owner.prevPosY + panelData.heightOffset + (owner.height * 0.5f);
|
||||
this.prevPosZ = owner.prevPosZ + (Math.cos(prevYawRad) * frontDist);
|
||||
}
|
||||
|
||||
private void updateLaunched() {
|
||||
@@ -296,6 +302,7 @@ public class EntityEnergyPanel extends EntityEnergyBarrier {
|
||||
for (EntityLivingBase ent : entities) {
|
||||
if (ent.getEntityId() == ownerEntityId) continue;
|
||||
if (!isKnockbackTarget(ent)) continue;
|
||||
if (isAllyOfOwner(ent)) continue;
|
||||
|
||||
// Transform entity position to panel-local space
|
||||
double dx = ent.posX - posX;
|
||||
|
||||
Reference in new issue
Block a user