mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-28 05:35:38 +00:00
Ability Effects
This commit is contained in:
1 parent
d6d29613e8
commit
563b6f7a26
26 files changed
+799
-324
No files matched your search
@@ -78,6 +78,9 @@ public abstract class Ability implements IAbility {
|
||||
// Custom data for external mods
|
||||
protected NBTTagCompound customData = new NBTTagCompound();
|
||||
|
||||
// Configurable potion effects
|
||||
protected List<AbilityEffect> effects = new ArrayList<>();
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// EXECUTION STATE (not saved, reset each combat)
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
@@ -224,6 +227,21 @@ public abstract class Ability implements IAbility {
|
||||
hitEntity.velocityChanged = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies all configured effects to the given entity.
|
||||
* Call this after damage is applied to the target.
|
||||
*
|
||||
* @param entity The entity to apply effects to
|
||||
*/
|
||||
protected void applyEffects(EntityLivingBase entity) {
|
||||
if (entity == null || effects.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (AbilityEffect effect : effects) {
|
||||
effect.apply(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public float getTelegraphRadius() {
|
||||
return 5.0f;
|
||||
}
|
||||
@@ -662,6 +680,13 @@ public abstract class Ability implements IAbility {
|
||||
for (Condition c : conditions) condList.appendTag(c.writeNBT());
|
||||
nbt.setTag("conditions", condList);
|
||||
|
||||
// Effects
|
||||
NBTTagList effectList = new NBTTagList();
|
||||
for (AbilityEffect effect : effects) {
|
||||
effectList.appendTag(effect.writeNBT());
|
||||
}
|
||||
nbt.setTag("effects", effectList);
|
||||
|
||||
// Type-specific
|
||||
NBTTagCompound typeNBT = new NBTTagCompound();
|
||||
writeTypeNBT(typeNBT);
|
||||
@@ -735,6 +760,18 @@ public abstract class Ability implements IAbility {
|
||||
if (c != null) conditions.add(c);
|
||||
}
|
||||
|
||||
// Effects
|
||||
effects.clear();
|
||||
if (nbt.hasKey("effects")) {
|
||||
NBTTagList effectList = nbt.getTagList("effects", 10);
|
||||
for (int i = 0; i < effectList.tagCount(); i++) {
|
||||
AbilityEffect effect = AbilityEffect.fromNBT(effectList.getCompoundTagAt(i));
|
||||
if (effect != null && effect.isValid()) {
|
||||
effects.add(effect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
readTypeNBT(nbt.getCompoundTag("typeData"));
|
||||
}
|
||||
|
||||
@@ -807,7 +844,7 @@ public abstract class Ability implements IAbility {
|
||||
}
|
||||
|
||||
public void setCooldownTicks(int cooldownTicks) {
|
||||
this.cooldownTicks = cooldownTicks;
|
||||
this.cooldownTicks = Math.max(0, cooldownTicks);
|
||||
}
|
||||
|
||||
public int getWindUpTicks() {
|
||||
@@ -815,7 +852,7 @@ public abstract class Ability implements IAbility {
|
||||
}
|
||||
|
||||
public void setWindUpTicks(int windUpTicks) {
|
||||
this.windUpTicks = windUpTicks;
|
||||
this.windUpTicks = Math.max(0, windUpTicks);
|
||||
}
|
||||
|
||||
public int getActiveTicks() {
|
||||
@@ -823,7 +860,7 @@ public abstract class Ability implements IAbility {
|
||||
}
|
||||
|
||||
public void setActiveTicks(int activeTicks) {
|
||||
this.activeTicks = activeTicks;
|
||||
this.activeTicks = Math.max(1, activeTicks);
|
||||
}
|
||||
|
||||
public int getRecoveryTicks() {
|
||||
@@ -831,7 +868,7 @@ public abstract class Ability implements IAbility {
|
||||
}
|
||||
|
||||
public void setRecoveryTicks(int recoveryTicks) {
|
||||
this.recoveryTicks = recoveryTicks;
|
||||
this.recoveryTicks = Math.max(0, recoveryTicks);
|
||||
}
|
||||
|
||||
public boolean isInterruptible() {
|
||||
@@ -963,6 +1000,24 @@ public abstract class Ability implements IAbility {
|
||||
conditions.add(c);
|
||||
}
|
||||
|
||||
public List<AbilityEffect> getEffects() {
|
||||
return effects;
|
||||
}
|
||||
|
||||
public void setEffects(List<AbilityEffect> effects) {
|
||||
this.effects = effects != null ? effects : new ArrayList<>();
|
||||
}
|
||||
|
||||
public void addEffect(AbilityEffect effect) {
|
||||
if (effect != null && effect.isValid()) {
|
||||
effects.add(effect);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearEffects() {
|
||||
effects.clear();
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// IAbility API METHODS
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
package kamkeel.npcs.controllers.data.ability;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
|
||||
/**
|
||||
* Represents a configurable potion effect that can be applied by abilities.
|
||||
* Provides a unified system for managing debuffs like slowness, weakness, poison, etc.
|
||||
*/
|
||||
public class AbilityEffect {
|
||||
|
||||
public enum EffectType {
|
||||
NONE("gui.none", -1),
|
||||
SLOWNESS("potion.moveSlowdown", Potion.moveSlowdown.id),
|
||||
WEAKNESS("potion.weakness", Potion.weakness.id),
|
||||
POISON("potion.poison", Potion.poison.id),
|
||||
WITHER("potion.wither", Potion.wither.id),
|
||||
BLINDNESS("potion.blindness", Potion.blindness.id),
|
||||
NAUSEA("potion.confusion", Potion.confusion.id),
|
||||
HUNGER("potion.hunger", Potion.hunger.id),
|
||||
MINING_FATIGUE("potion.digSlowDown", Potion.digSlowdown.id);
|
||||
|
||||
private final String langKey;
|
||||
private final int potionId;
|
||||
|
||||
EffectType(String langKey, int potionId) {
|
||||
this.langKey = langKey;
|
||||
this.potionId = potionId;
|
||||
}
|
||||
|
||||
public String getLangKey() {
|
||||
return langKey;
|
||||
}
|
||||
|
||||
public int getPotionId() {
|
||||
return potionId;
|
||||
}
|
||||
|
||||
public static EffectType fromOrdinal(int ordinal) {
|
||||
EffectType[] values = values();
|
||||
if (ordinal >= 0 && ordinal < values.length) {
|
||||
return values[ordinal];
|
||||
}
|
||||
return NONE;
|
||||
}
|
||||
}
|
||||
|
||||
private EffectType type = EffectType.NONE;
|
||||
private int durationTicks = 60;
|
||||
private int amplifier = 0; // 0-10
|
||||
|
||||
public AbilityEffect() {
|
||||
}
|
||||
|
||||
public AbilityEffect(EffectType type, int durationTicks, int amplifier) {
|
||||
this.type = type;
|
||||
this.durationTicks = Math.max(1, durationTicks);
|
||||
this.amplifier = Math.max(0, Math.min(10, amplifier));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of this effect.
|
||||
*/
|
||||
public AbilityEffect copy() {
|
||||
return new AbilityEffect(type, durationTicks, amplifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies this effect to the given entity.
|
||||
* Does nothing if type is NONE.
|
||||
*/
|
||||
public void apply(EntityLivingBase entity) {
|
||||
if (entity == null || type == EffectType.NONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
int potionId = type.getPotionId();
|
||||
if (potionId >= 0) {
|
||||
entity.addPotionEffect(new PotionEffect(potionId, durationTicks, amplifier));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes this effect to NBT.
|
||||
*/
|
||||
public NBTTagCompound writeNBT() {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setInteger("type", type.ordinal());
|
||||
nbt.setInteger("duration", durationTicks);
|
||||
nbt.setInteger("amplifier", amplifier);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads this effect from NBT.
|
||||
*/
|
||||
public void readNBT(NBTTagCompound nbt) {
|
||||
this.type = EffectType.fromOrdinal(nbt.getInteger("type"));
|
||||
this.durationTicks = nbt.hasKey("duration") ? nbt.getInteger("duration") : 60;
|
||||
this.amplifier = nbt.hasKey("amplifier") ? nbt.getInteger("amplifier") : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an AbilityEffect from NBT.
|
||||
*/
|
||||
public static AbilityEffect fromNBT(NBTTagCompound nbt) {
|
||||
AbilityEffect effect = new AbilityEffect();
|
||||
effect.readNBT(nbt);
|
||||
return effect;
|
||||
}
|
||||
|
||||
// Getters & Setters
|
||||
|
||||
public EffectType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(EffectType type) {
|
||||
this.type = type != null ? type : EffectType.NONE;
|
||||
}
|
||||
|
||||
public int getDurationTicks() {
|
||||
return durationTicks;
|
||||
}
|
||||
|
||||
public void setDurationTicks(int durationTicks) {
|
||||
this.durationTicks = Math.max(1, durationTicks);
|
||||
}
|
||||
|
||||
public int getAmplifier() {
|
||||
return amplifier;
|
||||
}
|
||||
|
||||
public void setAmplifier(int amplifier) {
|
||||
this.amplifier = Math.max(0, Math.min(10, amplifier));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this effect is configured (not NONE).
|
||||
*/
|
||||
public boolean isValid() {
|
||||
return type != EffectType.NONE;
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,6 @@ import kamkeel.npcs.controllers.data.ability.TargetingMode;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
@@ -41,9 +39,6 @@ public class AbilityCutter extends Ability {
|
||||
private SweepMode sweepMode = SweepMode.SWIPE;
|
||||
private float sweepSpeed = 6.0f;
|
||||
|
||||
private int stunDuration = 0;
|
||||
private int poisonDurationSeconds = 0;
|
||||
private int poisonLevel = 0;
|
||||
private boolean piercing = true;
|
||||
private float innerRadius = 0.0f;
|
||||
|
||||
@@ -161,15 +156,9 @@ public class AbilityCutter extends Ability {
|
||||
// Apply damage with scripted event support
|
||||
boolean wasHit = applyAbilityDamage(npc, entity, actualDamage, knockback);
|
||||
|
||||
// Only apply effects if hit wasn't cancelled
|
||||
// Apply effects if hit wasn't cancelled
|
||||
if (wasHit) {
|
||||
if (stunDuration > 0) {
|
||||
entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, stunDuration, 10));
|
||||
entity.addPotionEffect(new PotionEffect(Potion.weakness.id, stunDuration, 2));
|
||||
}
|
||||
if (poisonDurationSeconds > 0) {
|
||||
entity.addPotionEffect(new PotionEffect(Potion.poison.id, poisonDurationSeconds * 20, poisonLevel));
|
||||
}
|
||||
applyEffects(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,9 +195,6 @@ public class AbilityCutter extends Ability {
|
||||
nbt.setFloat("knockback", knockback);
|
||||
nbt.setString("sweepMode", sweepMode.name());
|
||||
nbt.setFloat("sweepSpeed", sweepSpeed);
|
||||
nbt.setInteger("stunDuration", stunDuration);
|
||||
nbt.setInteger("poisonDurationSeconds", poisonDurationSeconds);
|
||||
nbt.setInteger("poisonLevel", poisonLevel);
|
||||
nbt.setBoolean("piercing", piercing);
|
||||
nbt.setFloat("innerRadius", innerRadius);
|
||||
}
|
||||
@@ -225,9 +211,6 @@ public class AbilityCutter extends Ability {
|
||||
this.sweepMode = SweepMode.SWIPE;
|
||||
}
|
||||
this.sweepSpeed = nbt.hasKey("sweepSpeed") ? nbt.getFloat("sweepSpeed") : 6.0f;
|
||||
this.stunDuration = nbt.hasKey("stunDuration") ? nbt.getInteger("stunDuration") : 0;
|
||||
this.poisonDurationSeconds = nbt.hasKey("poisonDurationSeconds") ? nbt.getInteger("poisonDurationSeconds") : 0;
|
||||
this.poisonLevel = nbt.hasKey("poisonLevel") ? nbt.getInteger("poisonLevel") : 0;
|
||||
this.piercing = !nbt.hasKey("piercing") || nbt.getBoolean("piercing");
|
||||
this.innerRadius = nbt.hasKey("innerRadius") ? nbt.getFloat("innerRadius") : 0.0f;
|
||||
}
|
||||
@@ -281,30 +264,6 @@ public class AbilityCutter extends Ability {
|
||||
this.sweepSpeed = sweepSpeed;
|
||||
}
|
||||
|
||||
public int getStunDuration() {
|
||||
return stunDuration;
|
||||
}
|
||||
|
||||
public void setStunDuration(int stunDuration) {
|
||||
this.stunDuration = stunDuration;
|
||||
}
|
||||
|
||||
public int getPoisonDurationSeconds() {
|
||||
return poisonDurationSeconds;
|
||||
}
|
||||
|
||||
public void setPoisonDurationSeconds(int poisonDurationSeconds) {
|
||||
this.poisonDurationSeconds = poisonDurationSeconds;
|
||||
}
|
||||
|
||||
public int getPoisonLevel() {
|
||||
return poisonLevel;
|
||||
}
|
||||
|
||||
public void setPoisonLevel(int poisonLevel) {
|
||||
this.poisonLevel = poisonLevel;
|
||||
}
|
||||
|
||||
public boolean isPiercing() {
|
||||
return piercing;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import kamkeel.npcs.controllers.data.ability.TargetingMode;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
|
||||
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityHeavyHit;
|
||||
@@ -23,9 +21,6 @@ public class AbilityHeavyHit extends Ability {
|
||||
|
||||
private float damage = 8.0f;
|
||||
private float knockback = 2.0f;
|
||||
private int slownessLevel = 1;
|
||||
private int weaknessLevel = 0;
|
||||
private int potionDurationSeconds = 2;
|
||||
|
||||
public AbilityHeavyHit() {
|
||||
this.typeId = "ability.cnpc.heavy_hit";
|
||||
@@ -73,14 +68,9 @@ public class AbilityHeavyHit extends Ability {
|
||||
// Apply damage with scripted event support
|
||||
boolean wasHit = applyAbilityDamage(npc, target, damage, knockback);
|
||||
|
||||
if (wasHit && potionDurationSeconds > 0) {
|
||||
int durationTicks = potionDurationSeconds * 20;
|
||||
if (slownessLevel >= 0) {
|
||||
target.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, durationTicks, slownessLevel));
|
||||
}
|
||||
if (weaknessLevel >= 0) {
|
||||
target.addPotionEffect(new PotionEffect(Potion.weakness.id, durationTicks, weaknessLevel));
|
||||
}
|
||||
// Apply effects if hit wasn't cancelled
|
||||
if (wasHit) {
|
||||
applyEffects(target);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,18 +83,12 @@ public class AbilityHeavyHit extends Ability {
|
||||
public void writeTypeNBT(NBTTagCompound nbt) {
|
||||
nbt.setFloat("damage", damage);
|
||||
nbt.setFloat("knockback", knockback);
|
||||
nbt.setInteger("slownessLevel", slownessLevel);
|
||||
nbt.setInteger("weaknessLevel", weaknessLevel);
|
||||
nbt.setInteger("potionDurationSeconds", potionDurationSeconds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readTypeNBT(NBTTagCompound nbt) {
|
||||
this.damage = nbt.hasKey("damage") ? nbt.getFloat("damage") : 8.0f;
|
||||
this.knockback = nbt.hasKey("knockback") ? nbt.getFloat("knockback") : 2.0f;
|
||||
this.slownessLevel = nbt.hasKey("slownessLevel") ? nbt.getInteger("slownessLevel") : 1;
|
||||
this.weaknessLevel = nbt.hasKey("weaknessLevel") ? nbt.getInteger("weaknessLevel") : 0;
|
||||
this.potionDurationSeconds = nbt.hasKey("potionDurationSeconds") ? nbt.getInteger("potionDurationSeconds") : 2;
|
||||
}
|
||||
|
||||
// Getters & Setters
|
||||
@@ -123,28 +107,4 @@ public class AbilityHeavyHit extends Ability {
|
||||
public void setKnockback(float knockback) {
|
||||
this.knockback = knockback;
|
||||
}
|
||||
|
||||
public int getSlownessLevel() {
|
||||
return slownessLevel;
|
||||
}
|
||||
|
||||
public void setSlownessLevel(int slownessLevel) {
|
||||
this.slownessLevel = slownessLevel;
|
||||
}
|
||||
|
||||
public int getWeaknessLevel() {
|
||||
return weaknessLevel;
|
||||
}
|
||||
|
||||
public void setWeaknessLevel(int weaknessLevel) {
|
||||
this.weaknessLevel = weaknessLevel;
|
||||
}
|
||||
|
||||
public int getPotionDurationSeconds() {
|
||||
return potionDurationSeconds;
|
||||
}
|
||||
|
||||
public void setPotionDurationSeconds(int potionDurationSeconds) {
|
||||
this.potionDurationSeconds = potionDurationSeconds;
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,6 @@ import kamkeel.npcs.controllers.data.ability.TargetingMode;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
@@ -28,7 +26,6 @@ public class AbilityShockwave extends Ability {
|
||||
private float pushRadius = 8.0f;
|
||||
private float pushStrength = 1.5f;
|
||||
private float damage = 8.0f;
|
||||
private int stunDuration = 0;
|
||||
private int maxTargets = 10;
|
||||
|
||||
// Runtime state
|
||||
@@ -122,10 +119,9 @@ public class AbilityShockwave extends Ability {
|
||||
// Apply damage with custom knockback direction
|
||||
boolean wasHit = applyAbilityDamageWithDirection(npc, entity, damage * distFactor, finalPush, dx, dz);
|
||||
|
||||
// Apply stun if hit connected
|
||||
if (wasHit && stunDuration > 0) {
|
||||
entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, stunDuration, 10));
|
||||
entity.addPotionEffect(new PotionEffect(Potion.weakness.id, stunDuration, 2));
|
||||
// Apply effects if hit connected
|
||||
if (wasHit) {
|
||||
applyEffects(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -145,7 +141,6 @@ public class AbilityShockwave extends Ability {
|
||||
nbt.setFloat("pushRadius", pushRadius);
|
||||
nbt.setFloat("pushStrength", pushStrength);
|
||||
nbt.setFloat("damage", damage);
|
||||
nbt.setInteger("stunDuration", stunDuration);
|
||||
nbt.setInteger("maxTargets", maxTargets);
|
||||
}
|
||||
|
||||
@@ -154,7 +149,6 @@ public class AbilityShockwave extends Ability {
|
||||
this.pushRadius = nbt.hasKey("pushRadius") ? nbt.getFloat("pushRadius") : 8.0f;
|
||||
this.pushStrength = nbt.hasKey("pushStrength") ? nbt.getFloat("pushStrength") : 1.5f;
|
||||
this.damage = nbt.hasKey("damage") ? nbt.getFloat("damage") : 8.0f;
|
||||
this.stunDuration = nbt.hasKey("stunDuration") ? nbt.getInteger("stunDuration") : 0;
|
||||
this.maxTargets = nbt.hasKey("maxTargets") ? nbt.getInteger("maxTargets") : 10;
|
||||
}
|
||||
|
||||
@@ -183,14 +177,6 @@ public class AbilityShockwave extends Ability {
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
public int getStunDuration() {
|
||||
return stunDuration;
|
||||
}
|
||||
|
||||
public void setStunDuration(int stunDuration) {
|
||||
this.stunDuration = stunDuration;
|
||||
}
|
||||
|
||||
public int getMaxTargets() {
|
||||
return maxTargets;
|
||||
}
|
||||
|
||||
@@ -261,8 +261,13 @@ public class AbilityTeleport extends Ability {
|
||||
int blockY = MathHelper.floor_double(checkY);
|
||||
int blockZ = MathHelper.floor_double(checkZ);
|
||||
|
||||
// Skip out-of-world coordinates
|
||||
if (blockY < 0 || blockY >= 256) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Block block = world.getBlock(blockX, blockY, blockZ);
|
||||
if (block.getMaterial().isSolid() && block.isOpaqueCube()) {
|
||||
if (block != null && block.getMaterial().isSolid() && block.isOpaqueCube()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -327,10 +332,20 @@ public class AbilityTeleport extends Ability {
|
||||
}
|
||||
|
||||
private boolean isSafeLocation(World world, int x, int y, int z) {
|
||||
// Bounds check - ensure we're within valid world coordinates
|
||||
if (y < 1 || y >= 255) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Block groundBlock = world.getBlock(x, y - 1, z);
|
||||
Block feetBlock = world.getBlock(x, y, z);
|
||||
Block headBlock = world.getBlock(x, y + 1, z);
|
||||
|
||||
// Defensive null checks (shouldn't happen in MC 1.7.10, but safe)
|
||||
if (groundBlock == null || feetBlock == null || headBlock == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return groundBlock.getMaterial().isSolid() &&
|
||||
!feetBlock.getMaterial().isSolid() &&
|
||||
!headBlock.getMaterial().isSolid();
|
||||
|
||||
@@ -8,8 +8,6 @@ import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
@@ -45,12 +43,6 @@ public class AbilityTrap extends Ability {
|
||||
private float damage = 6.0f;
|
||||
private float damageRadius = 0.0f;
|
||||
private float knockback = 0.5f;
|
||||
private int stunDuration = 0;
|
||||
private int rootDuration = 40;
|
||||
private int slowDuration = 0;
|
||||
private int slowLevel = 1;
|
||||
private int poisonDuration = 0;
|
||||
private int poisonLevel = 0;
|
||||
private boolean visible = true;
|
||||
|
||||
// Offset parameters - trap spawns near target, not exactly on them
|
||||
@@ -262,24 +254,9 @@ public class AbilityTrap extends Ability {
|
||||
// Apply damage with scripted event support
|
||||
boolean wasHit = applyAbilityDamage(npc, entity, damage, knockback);
|
||||
|
||||
// Only apply effects if the hit wasn't cancelled
|
||||
// Apply effects if the hit wasn't cancelled
|
||||
if (wasHit) {
|
||||
if (stunDuration > 0) {
|
||||
entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, stunDuration, 10));
|
||||
entity.addPotionEffect(new PotionEffect(Potion.weakness.id, stunDuration, 2));
|
||||
}
|
||||
|
||||
if (rootDuration > 0) {
|
||||
entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, rootDuration, 127));
|
||||
}
|
||||
|
||||
if (slowDuration > 0) {
|
||||
entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, slowDuration, slowLevel));
|
||||
}
|
||||
|
||||
if (poisonDuration > 0 && poisonLevel >= 0) {
|
||||
entity.addPotionEffect(new PotionEffect(Potion.poison.id, poisonDuration, poisonLevel));
|
||||
}
|
||||
applyEffects(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -309,12 +286,6 @@ public class AbilityTrap extends Ability {
|
||||
nbt.setFloat("damage", damage);
|
||||
nbt.setFloat("damageRadius", damageRadius);
|
||||
nbt.setFloat("knockback", knockback);
|
||||
nbt.setInteger("stunDuration", stunDuration);
|
||||
nbt.setInteger("rootDuration", rootDuration);
|
||||
nbt.setInteger("slowDuration", slowDuration);
|
||||
nbt.setInteger("slowLevel", slowLevel);
|
||||
nbt.setInteger("poisonDuration", poisonDuration);
|
||||
nbt.setInteger("poisonLevel", poisonLevel);
|
||||
nbt.setBoolean("visible", visible);
|
||||
nbt.setFloat("minOffset", minOffset);
|
||||
nbt.setFloat("maxOffset", maxOffset);
|
||||
@@ -336,12 +307,6 @@ public class AbilityTrap extends Ability {
|
||||
this.damage = nbt.hasKey("damage") ? nbt.getFloat("damage") : 6.0f;
|
||||
this.damageRadius = nbt.hasKey("damageRadius") ? nbt.getFloat("damageRadius") : 0.0f;
|
||||
this.knockback = nbt.hasKey("knockback") ? nbt.getFloat("knockback") : 0.5f;
|
||||
this.stunDuration = nbt.hasKey("stunDuration") ? nbt.getInteger("stunDuration") : 0;
|
||||
this.rootDuration = nbt.hasKey("rootDuration") ? nbt.getInteger("rootDuration") : 40;
|
||||
this.slowDuration = nbt.hasKey("slowDuration") ? nbt.getInteger("slowDuration") : 0;
|
||||
this.slowLevel = nbt.hasKey("slowLevel") ? nbt.getInteger("slowLevel") : 1;
|
||||
this.poisonDuration = nbt.hasKey("poisonDuration") ? nbt.getInteger("poisonDuration") : 0;
|
||||
this.poisonLevel = nbt.hasKey("poisonLevel") ? nbt.getInteger("poisonLevel") : 0;
|
||||
this.visible = !nbt.hasKey("visible") || nbt.getBoolean("visible");
|
||||
this.minOffset = nbt.hasKey("minOffset") ? nbt.getFloat("minOffset") : 0.0f;
|
||||
this.maxOffset = nbt.hasKey("maxOffset") ? nbt.getFloat("maxOffset") : 1.5f;
|
||||
@@ -421,54 +386,6 @@ public class AbilityTrap extends Ability {
|
||||
this.knockback = knockback;
|
||||
}
|
||||
|
||||
public int getStunDuration() {
|
||||
return stunDuration;
|
||||
}
|
||||
|
||||
public void setStunDuration(int stunDuration) {
|
||||
this.stunDuration = stunDuration;
|
||||
}
|
||||
|
||||
public int getRootDuration() {
|
||||
return rootDuration;
|
||||
}
|
||||
|
||||
public void setRootDuration(int rootDuration) {
|
||||
this.rootDuration = rootDuration;
|
||||
}
|
||||
|
||||
public int getSlowDuration() {
|
||||
return slowDuration;
|
||||
}
|
||||
|
||||
public void setSlowDuration(int slowDuration) {
|
||||
this.slowDuration = slowDuration;
|
||||
}
|
||||
|
||||
public int getSlowLevel() {
|
||||
return slowLevel;
|
||||
}
|
||||
|
||||
public void setSlowLevel(int slowLevel) {
|
||||
this.slowLevel = slowLevel;
|
||||
}
|
||||
|
||||
public int getPoisonDuration() {
|
||||
return poisonDuration;
|
||||
}
|
||||
|
||||
public void setPoisonDuration(int poisonDuration) {
|
||||
this.poisonDuration = poisonDuration;
|
||||
}
|
||||
|
||||
public int getPoisonLevel() {
|
||||
return poisonLevel;
|
||||
}
|
||||
|
||||
public void setPoisonLevel(int poisonLevel) {
|
||||
this.poisonLevel = poisonLevel;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return visible;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import kamkeel.npcs.controllers.data.ability.TargetingMode;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
@@ -32,8 +30,6 @@ public class AbilityVortex extends Ability {
|
||||
private float pullStrength = 0.8f;
|
||||
private float damage = 0.0f;
|
||||
private float knockback = 0.0f;
|
||||
private int stunDuration = 0;
|
||||
private int rootDuration = 0;
|
||||
private boolean aoe = false;
|
||||
private int maxTargets = 5;
|
||||
private boolean damageOnPull = false;
|
||||
@@ -134,7 +130,7 @@ public class AbilityVortex extends Ability {
|
||||
ticksSincePullDamage++;
|
||||
|
||||
for (UUID uuid : new HashSet<>(pulledEntities)) {
|
||||
EntityLivingBase entity = findEntity(world, uuid);
|
||||
EntityLivingBase entity = findEntity(npc, world, uuid);
|
||||
if (entity == null || entity.isDead) {
|
||||
pulledEntities.remove(uuid);
|
||||
continue;
|
||||
@@ -187,25 +183,23 @@ public class AbilityVortex extends Ability {
|
||||
|
||||
// Only apply effects if hit wasn't cancelled
|
||||
if (wasHit) {
|
||||
if (stunDuration > 0) {
|
||||
entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, stunDuration, 10));
|
||||
entity.addPotionEffect(new PotionEffect(Potion.weakness.id, stunDuration, 2));
|
||||
}
|
||||
|
||||
if (rootDuration > 0) {
|
||||
entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, rootDuration, 127));
|
||||
}
|
||||
applyEffects(entity);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an entity by UUID within the vortex pull area.
|
||||
* Uses AABB search instead of iterating all loaded entities.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private EntityLivingBase findEntity(World world, UUID uuid) {
|
||||
for (Object obj : world.loadedEntityList) {
|
||||
if (obj instanceof EntityLivingBase) {
|
||||
EntityLivingBase entity = (EntityLivingBase) obj;
|
||||
if (entity.getUniqueID().equals(uuid)) {
|
||||
return entity;
|
||||
}
|
||||
private EntityLivingBase findEntity(EntityNPCInterface npc, World world, UUID uuid) {
|
||||
// Search within pull radius (entities being pulled should be within this area)
|
||||
AxisAlignedBB searchBox = npc.boundingBox.expand(pullRadius, pullRadius / 2, pullRadius);
|
||||
List<EntityLivingBase> nearbyEntities = world.getEntitiesWithinAABB(EntityLivingBase.class, searchBox);
|
||||
|
||||
for (EntityLivingBase entity : nearbyEntities) {
|
||||
if (entity.getUniqueID().equals(uuid)) {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -231,8 +225,6 @@ public class AbilityVortex extends Ability {
|
||||
nbt.setFloat("pullStrength", pullStrength);
|
||||
nbt.setFloat("damage", damage);
|
||||
nbt.setFloat("knockback", knockback);
|
||||
nbt.setInteger("stunDuration", stunDuration);
|
||||
nbt.setInteger("rootDuration", rootDuration);
|
||||
nbt.setBoolean("aoe", aoe);
|
||||
nbt.setInteger("maxTargets", maxTargets);
|
||||
nbt.setBoolean("damageOnPull", damageOnPull);
|
||||
@@ -245,8 +237,6 @@ public class AbilityVortex extends Ability {
|
||||
this.pullStrength = nbt.hasKey("pullStrength") ? nbt.getFloat("pullStrength") : 0.8f;
|
||||
this.damage = nbt.hasKey("damage") ? nbt.getFloat("damage") : 0.0f;
|
||||
this.knockback = nbt.hasKey("knockback") ? nbt.getFloat("knockback") : 0.0f;
|
||||
this.stunDuration = nbt.hasKey("stunDuration") ? nbt.getInteger("stunDuration") : 0;
|
||||
this.rootDuration = nbt.hasKey("rootDuration") ? nbt.getInteger("rootDuration") : 0;
|
||||
this.aoe = nbt.hasKey("aoe") && nbt.getBoolean("aoe");
|
||||
this.maxTargets = nbt.hasKey("maxTargets") ? nbt.getInteger("maxTargets") : 5;
|
||||
this.damageOnPull = nbt.hasKey("damageOnPull") && nbt.getBoolean("damageOnPull");
|
||||
@@ -286,22 +276,6 @@ public class AbilityVortex extends Ability {
|
||||
this.knockback = knockback;
|
||||
}
|
||||
|
||||
public int getStunDuration() {
|
||||
return stunDuration;
|
||||
}
|
||||
|
||||
public void setStunDuration(int stunDuration) {
|
||||
this.stunDuration = stunDuration;
|
||||
}
|
||||
|
||||
public int getRootDuration() {
|
||||
return rootDuration;
|
||||
}
|
||||
|
||||
public void setRootDuration(int rootDuration) {
|
||||
this.rootDuration = rootDuration;
|
||||
}
|
||||
|
||||
public boolean isAoe() {
|
||||
return aoe;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user