mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 03:47:27 +00:00
Added Dual Orb Ability
This commit is contained in:
1 parent
245e8f8162
commit
e9f22dab2a
4 files changed
+810
No files matched your search
@@ -363,6 +363,7 @@ public class AbilityController implements IAbilityHandler {
|
||||
registerType("cnpc:sweeper", AbilitySweeper::new);
|
||||
registerType("cnpc:projectile", AbilityProjectile::new);
|
||||
registerType("cnpc:orb", AbilityOrb::new);
|
||||
registerType("cnpc:dual_orb", AbilityDualOrb::new);
|
||||
registerType("cnpc:disc", AbilityDisc::new);
|
||||
registerType("cnpc:laser_shot", AbilityLaserShot::new);
|
||||
registerType("cnpc:beam", AbilityEnergyBeam::new);
|
||||
|
||||
@@ -0,0 +1,481 @@
|
||||
package kamkeel.npcs.controllers.data.ability.type;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
import kamkeel.npcs.controllers.data.ability.AnchorPoint;
|
||||
import kamkeel.npcs.controllers.data.ability.LockMovementType;
|
||||
import kamkeel.npcs.controllers.data.ability.TargetingMode;
|
||||
import kamkeel.npcs.controllers.data.ability.data.*;
|
||||
import kamkeel.npcs.controllers.data.telegraph.Telegraph;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
|
||||
import kamkeel.npcs.entity.EntityAbilityOrb;
|
||||
import kamkeel.npcs.util.AnchorPointHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
|
||||
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityDualOrb;
|
||||
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.util.ValueUtil;
|
||||
|
||||
public class AbilityDualOrb extends Ability {
|
||||
// Ability-specific properties
|
||||
private float orbSize = 1.0f;
|
||||
private boolean dualFire= true;
|
||||
private int dualFireDelay = 20;
|
||||
|
||||
// Data classes for energy properties
|
||||
public final EnergyColorData[] colorData = new EnergyColorData[]{
|
||||
new EnergyColorData(), new EnergyColorData()
|
||||
};
|
||||
public final EnergyCombatData combatData = new EnergyCombatData();
|
||||
public final EnergyHomingData homingData = new EnergyHomingData();
|
||||
public final EnergyLightningData[] lightningData = new EnergyLightningData[]{
|
||||
new EnergyLightningData(), new EnergyLightningData()
|
||||
};
|
||||
public final EnergyLifespanData lifespanData = new EnergyLifespanData();
|
||||
private EnergyAnchorData[] anchorData = new EnergyAnchorData[]{
|
||||
new EnergyAnchorData(AnchorPoint.RIGHT_HAND), new EnergyAnchorData(AnchorPoint.LEFT_HAND)
|
||||
};
|
||||
|
||||
// Transient state for orb entity (used during windup charging)
|
||||
private transient EntityAbilityOrb orbEntity = null;
|
||||
private transient EntityAbilityOrb orbEntity2 = null;
|
||||
|
||||
public AbilityDualOrb() {
|
||||
this.typeId = "ability.cnpc.dual_orb";
|
||||
this.name = "Dual Orb";
|
||||
this.targetingMode = TargetingMode.AGGRO_TARGET;
|
||||
this.maxRange = 25.0f;
|
||||
this.minRange = 5.0f;
|
||||
this.cooldownTicks = 0;
|
||||
this.windUpTicks = 30;
|
||||
this.lockMovement = LockMovementType.WINDUP;
|
||||
this.telegraphType = TelegraphType.CIRCLE;
|
||||
this.showTelegraph = true;
|
||||
// Default built-in animation
|
||||
this.windUpAnimationName = "Ability_DualBeam_Windup";
|
||||
this.activeAnimationName = "Ability_DualBeam_Active";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTypeSettings() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public SubGuiAbilityConfig createConfigGui(IAbilityConfigCallback callback) {
|
||||
return new SubGuiAbilityDualOrb(this, callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTargetingModeLocked() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetingMode[] getAllowedTargetingModes() {
|
||||
return new TargetingMode[]{TargetingMode.AGGRO_TARGET};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecute(EntityLivingBase caster, EntityLivingBase target, World world) {
|
||||
if (world.isRemote) {
|
||||
signalCompletion();
|
||||
return;
|
||||
}
|
||||
|
||||
// Start moving the orb that was spawned during windup
|
||||
if (orbEntity != null && !orbEntity.isDead) {
|
||||
orbEntity.startMoving(target);
|
||||
}
|
||||
|
||||
if (dualFire) {
|
||||
if (orbEntity2 != null && !orbEntity2.isDead && dualFireDelay <= 0) {
|
||||
orbEntity2.startMoving(target);
|
||||
}
|
||||
} else {
|
||||
orbEntity2.setDead();
|
||||
}
|
||||
|
||||
// Ability stays active until entity dies (prevents firing another while projectile is alive)
|
||||
// Movement locking is handled separately by the base class
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindUpTick(EntityLivingBase caster, EntityLivingBase target, World world, int tick) {
|
||||
if (world.isRemote) return;
|
||||
|
||||
// Spawn orb in charging mode on first tick of windup
|
||||
if (tick == 1) {
|
||||
// Create orb in charging mode - follows caster based on anchor point during windup
|
||||
Vec3 spawnPos1 = AnchorPointHelper.calculateAnchorPosition(caster, anchorData[0]);
|
||||
orbEntity = new EntityAbilityOrb(
|
||||
world, caster, target,
|
||||
spawnPos1.xCoord, spawnPos1.yCoord, spawnPos1.zCoord, orbSize,
|
||||
colorData[0], combatData, homingData, lightningData[0], lifespanData);
|
||||
|
||||
Vec3 spawnPos2 = AnchorPointHelper.calculateAnchorPosition(caster, anchorData[1]);
|
||||
orbEntity2 = new EntityAbilityOrb(
|
||||
world, caster, target,
|
||||
spawnPos2.xCoord, spawnPos2.yCoord, spawnPos2.zCoord, orbSize,
|
||||
colorData[1], combatData, homingData, lightningData[1], lifespanData);
|
||||
|
||||
orbEntity.setSiblingUUID(orbEntity2.getPersistentID());
|
||||
orbEntity2.setSiblingUUID(orbEntity.getPersistentID());
|
||||
|
||||
orbEntity.setupCharging(anchorData[0], windUpTicks);
|
||||
orbEntity2.setupCharging(anchorData[1], windUpTicks);
|
||||
|
||||
orbEntity.setEffects(this.effects);
|
||||
|
||||
if (dualFire) {
|
||||
orbEntity2.setEffects(this.effects);
|
||||
}
|
||||
|
||||
world.spawnEntityInWorld(orbEntity);
|
||||
world.spawnEntityInWorld(orbEntity2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActiveTick(EntityLivingBase caster, EntityLivingBase target, World world, int tick) {
|
||||
// Signal completion when entity dies
|
||||
if (dualFire) {
|
||||
if ((orbEntity == null || orbEntity.isDead) && (orbEntity2 == null || orbEntity2.isDead)) {
|
||||
orbEntity = null;
|
||||
orbEntity2 = null;
|
||||
signalCompletion();
|
||||
}
|
||||
|
||||
if (tick == dualFireDelay && orbEntity2 != null && !orbEntity2.isDead) {
|
||||
orbEntity2.startMoving(target);
|
||||
}
|
||||
} else {
|
||||
if (orbEntity == null || orbEntity.isDead) {
|
||||
orbEntity = null;
|
||||
signalCompletion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete(EntityLivingBase caster, EntityLivingBase target) {
|
||||
// Nothing to clean up - entity manages itself
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanup() {
|
||||
// Despawn orb entity if still alive
|
||||
if (orbEntity != null && !orbEntity.isDead) {
|
||||
orbEntity.setDead();
|
||||
}
|
||||
|
||||
if (orbEntity2 != null && !orbEntity2.isDead) {
|
||||
orbEntity2.setDead();
|
||||
}
|
||||
|
||||
orbEntity = null;
|
||||
orbEntity2 = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TelegraphInstance createTelegraph(EntityLivingBase caster, EntityLivingBase target) {
|
||||
if (!showTelegraph || telegraphType == TelegraphType.NONE || target == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Create small circle telegraph at target position
|
||||
Telegraph telegraph = Telegraph.circle(orbSize * 1.5f);
|
||||
telegraph.setDurationTicks(windUpTicks);
|
||||
telegraph.setColor(windUpColor);
|
||||
telegraph.setWarningColor(activeColor);
|
||||
telegraph.setWarningStartTick(Math.max(5, windUpTicks / 4));
|
||||
telegraph.setHeightOffset(telegraphHeightOffset);
|
||||
|
||||
// Position at target and follow target during windup
|
||||
TelegraphInstance instance = new TelegraphInstance(telegraph, target.posX, target.posY, target.posZ, caster.rotationYaw);
|
||||
instance.setCasterEntityId(caster.getEntityId());
|
||||
instance.setEntityIdToFollow(target.getEntityId());
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTelegraphRadius() {
|
||||
return orbSize * 1.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTypeNBT(NBTTagCompound nbt) {
|
||||
nbt.setFloat("orbSize", orbSize);
|
||||
nbt.setBoolean("dualFire", dualFire);
|
||||
nbt.setInteger("dualFireDelay", dualFireDelay);
|
||||
combatData.writeNBT(nbt);
|
||||
homingData.writeNBT(nbt);
|
||||
lifespanData.writeNBT(nbt);
|
||||
// Backward compat: old key was "orbSpeed"
|
||||
nbt.setFloat("orbSpeed", homingData.speed);
|
||||
|
||||
NBTTagCompound orb1 = new NBTTagCompound();
|
||||
NBTTagCompound orb2 = new NBTTagCompound();
|
||||
|
||||
anchorData[0].writeNBT(orb1);
|
||||
anchorData[1].writeNBT(orb2);
|
||||
colorData[0].writeNBT(orb1);
|
||||
colorData[1].writeNBT(orb2);
|
||||
lightningData[0].writeNBT(orb1);
|
||||
lightningData[1].writeNBT(orb2);
|
||||
|
||||
nbt.setTag("Orb_1", orb1);
|
||||
nbt.setTag("Orb_2", orb2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readTypeNBT(NBTTagCompound nbt) {
|
||||
NBTTagCompound orb1 = nbt.hasKey("Orb_1") ? nbt.getCompoundTag("Orb_1") : new NBTTagCompound();
|
||||
NBTTagCompound orb2 = nbt.hasKey("Orb_2") ? nbt.getCompoundTag("Orb_2") : new NBTTagCompound();
|
||||
|
||||
this.orbSize = nbt.hasKey("orbSize") ? nbt.getFloat("orbSize") : 1.0f;
|
||||
this.dualFire = !nbt.hasKey("dualFire") || nbt.getBoolean("dualFire");
|
||||
this.dualFireDelay = nbt.hasKey("dualFireDelay") ? nbt.getInteger("dualFireDelay") : 0;
|
||||
combatData.readNBT(nbt);
|
||||
homingData.readNBT(nbt);
|
||||
lifespanData.readNBT(nbt);
|
||||
// Backward compat: old key was "orbSpeed"
|
||||
if (nbt.hasKey("orbSpeed")) {
|
||||
homingData.speed = nbt.getFloat("orbSpeed");
|
||||
}
|
||||
|
||||
anchorData[0].readNBT(orb1);
|
||||
anchorData[1].readNBT(orb2);
|
||||
colorData[0].readNBT(orb1);
|
||||
colorData[1].readNBT(orb2);
|
||||
lightningData[0].readNBT(orb1);
|
||||
lightningData[1].readNBT(orb2);
|
||||
}
|
||||
|
||||
// Getters & Setters
|
||||
private EnergyColorData getColorData(int orb) {
|
||||
orb = ValueUtil.clamp(orb, 0, 1);
|
||||
return colorData[orb];
|
||||
}
|
||||
private EnergyLightningData getLightningData(int orb) {
|
||||
orb = ValueUtil.clamp(orb, 0, 1);
|
||||
return lightningData[orb];
|
||||
}
|
||||
private EnergyAnchorData getAnchorData(int orb) {
|
||||
orb = ValueUtil.clamp(orb, 0, 1);
|
||||
return anchorData[orb];
|
||||
}
|
||||
|
||||
public float getOrbSpeed() {
|
||||
return homingData.speed;
|
||||
}
|
||||
|
||||
public void setOrbSpeed(float orbSpeed) {
|
||||
homingData.speed = orbSpeed;
|
||||
}
|
||||
|
||||
public float getOrbSize() {
|
||||
return orbSize;
|
||||
}
|
||||
|
||||
public void setOrbSize(float orbSize) {
|
||||
this.orbSize = orbSize;
|
||||
}
|
||||
|
||||
public boolean isDualFire() {
|
||||
return dualFire;
|
||||
}
|
||||
|
||||
public void setDualFire(boolean dualFire) {
|
||||
this.dualFire = dualFire;
|
||||
}
|
||||
|
||||
public int getDualFireDelay() {
|
||||
return dualFireDelay;
|
||||
}
|
||||
|
||||
public void setDualFireDelay(int dualFireDelay) {
|
||||
this.dualFireDelay = dualFireDelay;
|
||||
}
|
||||
|
||||
public float getMaxDistance() {
|
||||
return lifespanData.maxDistance;
|
||||
}
|
||||
|
||||
public void setMaxDistance(float maxDistance) {
|
||||
lifespanData.maxDistance = maxDistance;
|
||||
}
|
||||
|
||||
public int getMaxLifetime() {
|
||||
return lifespanData.maxLifetime;
|
||||
}
|
||||
|
||||
public void setMaxLifetime(int maxLifetime) {
|
||||
lifespanData.maxLifetime = maxLifetime;
|
||||
}
|
||||
|
||||
public float getDamage() {
|
||||
return combatData.damage;
|
||||
}
|
||||
|
||||
public void setDamage(float damage) {
|
||||
combatData.damage = damage;
|
||||
}
|
||||
|
||||
public float getKnockback() {
|
||||
return combatData.knockback;
|
||||
}
|
||||
|
||||
public void setKnockback(float knockback) {
|
||||
combatData.knockback = knockback;
|
||||
}
|
||||
|
||||
public float getKnockbackUp() {
|
||||
return combatData.knockbackUp;
|
||||
}
|
||||
|
||||
public void setKnockbackUp(float knockbackUp) {
|
||||
combatData.knockbackUp = knockbackUp;
|
||||
}
|
||||
|
||||
public boolean isHoming() {
|
||||
return homingData.homing;
|
||||
}
|
||||
|
||||
public void setHoming(boolean homing) {
|
||||
homingData.homing = homing;
|
||||
}
|
||||
|
||||
public float getHomingStrength() {
|
||||
return homingData.homingStrength;
|
||||
}
|
||||
|
||||
public void setHomingStrength(float homingStrength) {
|
||||
homingData.homingStrength = homingStrength;
|
||||
}
|
||||
|
||||
public float getHomingRange() {
|
||||
return homingData.homingRange;
|
||||
}
|
||||
|
||||
public void setHomingRange(float homingRange) {
|
||||
homingData.homingRange = homingRange;
|
||||
}
|
||||
|
||||
public boolean isExplosive() {
|
||||
return combatData.explosive;
|
||||
}
|
||||
|
||||
public void setExplosive(boolean explosive) {
|
||||
combatData.explosive = explosive;
|
||||
}
|
||||
|
||||
public float getExplosionRadius() {
|
||||
return combatData.explosionRadius;
|
||||
}
|
||||
|
||||
public void setExplosionRadius(float explosionRadius) {
|
||||
combatData.explosionRadius = explosionRadius;
|
||||
}
|
||||
|
||||
public float getExplosionDamageFalloff() {
|
||||
return combatData.explosionDamageFalloff;
|
||||
}
|
||||
|
||||
public void setExplosionDamageFalloff(float explosionDamageFalloff) {
|
||||
combatData.explosionDamageFalloff = explosionDamageFalloff;
|
||||
}
|
||||
|
||||
|
||||
public int getInnerColor(int orb) { return getColorData(orb).innerColor; }
|
||||
public void setInnerColor(int orb, int innerColor) { getColorData(orb).innerColor = innerColor; }
|
||||
public int getOuterColor(int orb) { return getColorData(orb).outerColor; }
|
||||
public void setOuterColor(int orb, int outerColor) { getColorData(orb).outerColor = outerColor; }
|
||||
public boolean isOuterColorEnabled(int orb) { return getColorData(orb).outerColorEnabled; }
|
||||
public void setOuterColorEnabled(int orb, boolean enabled) { getColorData(orb).outerColorEnabled = enabled; }
|
||||
public float getOuterColorWidth(int orb) { return getColorData(orb).outerColorWidth; }
|
||||
public void setOuterColorWidth(int orb, float width) { getColorData(orb).outerColorWidth = width; }
|
||||
public float getOuterColorAlpha(int orb) { return getColorData(orb).outerColorAlpha; }
|
||||
public void setOuterColorAlpha(int orb, float alpha) { getColorData(orb).outerColorAlpha = alpha; }
|
||||
public float getRotationSpeed(int orb) { return getColorData(orb).rotationSpeed; }
|
||||
public void setRotationSpeed(int orb, float speed) { getColorData(orb).rotationSpeed = speed; }
|
||||
|
||||
public int getInnerColor() { return getInnerColor(0); }
|
||||
public void setInnerColor(int innerColor) { setInnerColor(0, innerColor); }
|
||||
public int getOuterColor() { return getOuterColor(0); }
|
||||
public void setOuterColor(int outerColor) { setOuterColor(0, outerColor); }
|
||||
public boolean isOuterColorEnabled() { return isOuterColorEnabled(0); }
|
||||
public void setOuterColorEnabled(boolean enabled) { setOuterColorEnabled(0, enabled); }
|
||||
public float getOuterColorWidth() { return getOuterColorWidth(0); }
|
||||
public void setOuterColorWidth(float width) { setOuterColorWidth(0, width); }
|
||||
public float getOuterColorAlpha() { return getOuterColorAlpha(0); }
|
||||
public void setOuterColorAlpha(float alpha) { setOuterColorAlpha(0, alpha); }
|
||||
public float getRotationSpeed() { return getRotationSpeed(0); }
|
||||
public void setRotationSpeed(float speed) { setRotationSpeed(0, speed); }
|
||||
|
||||
|
||||
public boolean hasLightningEffect(int orb) { return getLightningData(orb).lightningEffect; }
|
||||
public void setLightningEffect(int orb, boolean lightningEffect) { getLightningData(orb).lightningEffect = lightningEffect; }
|
||||
public float getLightningDensity(int orb) { return getLightningData(orb).lightningDensity; }
|
||||
public void setLightningDensity(int orb, float lightningDensity) { getLightningData(orb).lightningDensity = lightningDensity; }
|
||||
public float getLightningRadius(int orb) { return getLightningData(orb).lightningRadius; }
|
||||
public void setLightningRadius(int orb, float lightningRadius) { getLightningData(orb).lightningRadius = lightningRadius; }
|
||||
|
||||
public boolean hasLightningEffect() { return hasLightningEffect(0); }
|
||||
public void setLightningEffect(boolean lightningEffect) { setLightningEffect(0, lightningEffect); }
|
||||
public float getLightningDensity() { return getLightningDensity(0); }
|
||||
public void setLightningDensity(float lightningDensity) { setLightningDensity(0, lightningDensity); }
|
||||
public float getLightningRadius() { return getLightningRadius(0); }
|
||||
public void setLightningRadius(float lightningRadius) { setLightningRadius(0, lightningRadius); }
|
||||
|
||||
|
||||
public AnchorPoint getAnchorPointEnum(int orb) { return getAnchorData(orb).anchorPoint; }
|
||||
public void setAnchorPointEnum(int orb, AnchorPoint anchorPoint) { getAnchorData(orb).anchorPoint = anchorPoint; }
|
||||
public float getAnchorOffsetX(int orb) { return getAnchorData(orb).anchorOffsetX; }
|
||||
public void setAnchorOffsetX(int orb, float x) { getAnchorData(orb).anchorOffsetX = x; }
|
||||
public float getAnchorOffsetY(int orb) { return getAnchorData(orb).anchorOffsetY; }
|
||||
public void setAnchorOffsetY(int orb, float y) { getAnchorData(orb).anchorOffsetY = y; }
|
||||
public float getAnchorOffsetZ(int orb) { return getAnchorData(orb).anchorOffsetZ; }
|
||||
public void setAnchorOffsetZ(int orb, float z) { getAnchorData(orb).anchorOffsetZ = z; }
|
||||
|
||||
public AnchorPoint getAnchorPointEnum() { return getAnchorPointEnum(0); }
|
||||
public void setAnchorPointEnum(AnchorPoint anchorPoint) { setAnchorPointEnum(0, anchorPoint); }
|
||||
public float getAnchorOffsetX() { return getAnchorOffsetX(0); }
|
||||
public void setAnchorOffsetX(float x) { setAnchorOffsetX(0, x); }
|
||||
public float getAnchorOffsetY() { return getAnchorOffsetY(0); }
|
||||
public void setAnchorOffsetY(float y) { setAnchorOffsetY(0, y); }
|
||||
public float getAnchorOffsetZ() { return getAnchorOffsetZ(0); }
|
||||
public void setAnchorOffsetZ(float z) { setAnchorOffsetZ(0, z); }
|
||||
|
||||
//@Override
|
||||
public int getAnchorPoint(int orb) { return getAnchorData(orb).anchorPoint.ordinal(); }
|
||||
public int getAnchorPoint() { return getAnchorData(0).anchorPoint.ordinal(); }
|
||||
|
||||
//@Override
|
||||
public void setAnchorPoint(int orb, int point) { getAnchorData(orb).anchorPoint = AnchorPoint.fromOrdinal(point); }
|
||||
public void setAnchorPoint(int point) { getAnchorData(0).anchorPoint = AnchorPoint.fromOrdinal(point); }
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Entity createPreviewEntity(EntityNPCInterface npc) {
|
||||
if (npc == null || npc.worldObj == null) return null;
|
||||
|
||||
EntityAbilityOrb orb = new EntityAbilityOrb(npc.worldObj);
|
||||
orb.setupPreview(npc, orbSize, colorData[0], lightningData[0], anchorData[0], windUpTicks);
|
||||
return orb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreviewActiveDuration() {
|
||||
return lifespanData.maxLifetime > 0 ? Math.min(lifespanData.maxLifetime, 100) : 100;
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Orb projectile - spherical homing energy ball.
|
||||
@@ -37,6 +38,8 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
|
||||
// Data watcher index for charging state (synced to clients)
|
||||
private static final int DW_CHARGING = 20;
|
||||
|
||||
private UUID siblingUUID = null;
|
||||
|
||||
public EntityAbilityOrb(World world) {
|
||||
super(world);
|
||||
}
|
||||
@@ -441,6 +444,18 @@ public class EntityAbilityOrb extends EntityAbilityProjectile {
|
||||
return size;
|
||||
}
|
||||
|
||||
public UUID getSiblingUUID() {
|
||||
return siblingUUID;
|
||||
}
|
||||
|
||||
public void setSiblingUUID(UUID siblingUUID) {
|
||||
if (siblingUUID == null)
|
||||
return;
|
||||
|
||||
if (this.siblingUUID == null)
|
||||
this.siblingUUID = siblingUUID;
|
||||
}
|
||||
|
||||
// ==================== NBT ====================
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,313 @@
|
||||
package noppes.npcs.client.gui.advanced.ability;
|
||||
|
||||
import kamkeel.npcs.controllers.data.ability.AbilityEffect;
|
||||
import kamkeel.npcs.controllers.data.ability.AnchorPoint;
|
||||
import kamkeel.npcs.controllers.data.ability.type.AbilityDualOrb;
|
||||
import kamkeel.npcs.controllers.data.ability.type.AbilityOrb;
|
||||
import noppes.npcs.client.gui.SubGuiColorSelector;
|
||||
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
|
||||
import noppes.npcs.client.gui.util.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SubGuiAbilityDualOrb extends SubGuiAbilityConfig {
|
||||
private final AbilityDualOrb orb;
|
||||
private int editingVisualColorId = 0;
|
||||
private int editingOrb = 0;
|
||||
|
||||
public SubGuiAbilityDualOrb(AbilityDualOrb ability, IAbilityConfigCallback callback) {
|
||||
super(ability, callback);
|
||||
this.orb = ability;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasVisualSettings() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initTypeTab(int startY) {
|
||||
int y = startY;
|
||||
int labelX = guiLeft + 8;
|
||||
int fieldX = guiLeft + 85;
|
||||
int col2LabelX = guiLeft + 145;
|
||||
int col2FieldX = guiLeft + 205;
|
||||
|
||||
// Row 1: Damage + Speed
|
||||
addLabel(new GuiNpcLabel(100, "enchantment.damage", labelX, y + 5));
|
||||
addTextField(createFloatField(100, fieldX, y, 50, orb.getDamage()));
|
||||
|
||||
addLabel(new GuiNpcLabel(101, "stats.speed", col2LabelX, y + 5));
|
||||
addTextField(createFloatField(101, col2FieldX, y, 50, orb.getOrbSpeed()));
|
||||
|
||||
y += 24;
|
||||
|
||||
// Row 2: Orb Size + Max Distance
|
||||
addLabel(new GuiNpcLabel(102, "stats.size", labelX, y + 5));
|
||||
addTextField(createFloatField(102, fieldX, y, 50, orb.getOrbSize()));
|
||||
|
||||
addLabel(new GuiNpcLabel(103, "ability.maxDist", col2LabelX, y + 5));
|
||||
addTextField(createFloatField(103, col2FieldX, y, 50, orb.getMaxDistance()));
|
||||
|
||||
y += 24;
|
||||
|
||||
// Row 3: Homing + Homing Strength (only show strength if homing)
|
||||
addLabel(new GuiNpcLabel(104, "ability.homing", labelX, y + 5));
|
||||
GuiNpcButton homingBtn = new GuiNpcButton(104, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, orb.isHoming() ? 1 : 0);
|
||||
homingBtn.setHoverText("ability.hover.homing");
|
||||
addButton(homingBtn);
|
||||
|
||||
if (orb.isHoming()) {
|
||||
addLabel(new GuiNpcLabel(105, "ability.homingStr", col2LabelX, y + 5));
|
||||
addTextField(createFloatField(105, col2FieldX, y, 50, orb.getHomingStrength()));
|
||||
}
|
||||
|
||||
y += 24;
|
||||
|
||||
// Row 4: Explosive + Explosion Radius (only show radius if explosive)
|
||||
addLabel(new GuiNpcLabel(106, "ability.explosive", labelX, y + 5));
|
||||
GuiNpcButton explosiveBtn = new GuiNpcButton(106, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, orb.isExplosive() ? 1 : 0);
|
||||
explosiveBtn.setHoverText("ability.hover.explosive");
|
||||
addButton(explosiveBtn);
|
||||
|
||||
if (orb.isExplosive()) {
|
||||
addLabel(new GuiNpcLabel(107, "ability.explosionRad", col2LabelX, y + 5));
|
||||
addTextField(createFloatField(107, col2FieldX, y, 50, orb.getExplosionRadius()));
|
||||
}
|
||||
|
||||
y += 24;
|
||||
|
||||
// Row 5: Knockback + Max Lifetime
|
||||
addLabel(new GuiNpcLabel(108, "ability.knockback", labelX, y + 5));
|
||||
addTextField(createFloatField(108, fieldX, y, 50, orb.getKnockback()));
|
||||
|
||||
addLabel(new GuiNpcLabel(109, "ability.lifetime", col2LabelX, y + 5));
|
||||
addTextField(createIntField(109, col2FieldX, y, 50, orb.getMaxLifetime()));
|
||||
|
||||
y += 24;
|
||||
|
||||
addLabel(new GuiNpcLabel(110, "ability.dualFire", labelX, y + 5));
|
||||
addButton(new GuiNpcButtonYesNo(110, fieldX, y, orb.isDualFire()));
|
||||
|
||||
if (orb.isDualFire()) {
|
||||
addLabel(new GuiNpcLabel(111, "ability.dualFireDelay", col2LabelX, y + 5));
|
||||
addTextField(createIntField(111, col2FieldX, y, 50, orb.getDualFireDelay()));
|
||||
}
|
||||
|
||||
y += 24;
|
||||
|
||||
// Row 7: Effects button
|
||||
addButton(new GuiNpcButton(150, labelX, y, 80, 20, "ability.effects"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initVisualTab(int startY) {
|
||||
int y = startY;
|
||||
int labelX = guiLeft + 8;
|
||||
int fieldX = guiLeft + 85;
|
||||
int col2LabelX = guiLeft + 180;
|
||||
int col2FieldX = guiLeft + 260;
|
||||
|
||||
// Row 1: Anchor Point
|
||||
addLabel(new GuiNpcLabel(210, "ability.anchorPoint", labelX, y + 5));
|
||||
GuiNpcButton anchorBtn = new GuiNpcButton(210, fieldX, y, 80, 20, AnchorPoint.getDisplayNames(), orb.getAnchorPointEnum(editingOrb).ordinal());
|
||||
anchorBtn.setHoverText("ability.hover.anchorPoint");
|
||||
addButton(anchorBtn);
|
||||
|
||||
y += 24;
|
||||
|
||||
// Row 2: Inner Color + Rotation Speed
|
||||
addLabel(new GuiNpcLabel(200, "ability.innerColor", labelX, y + 5));
|
||||
String innerHex = String.format("%06X", orb.getInnerColor(editingOrb) & 0xFFFFFF);
|
||||
GuiNpcButton innerColorBtn = new GuiNpcButton(200, fieldX, y, 55, 20, innerHex);
|
||||
innerColorBtn.setTextColor(orb.getInnerColor(editingOrb) & 0xFFFFFF);
|
||||
addButton(innerColorBtn);
|
||||
|
||||
addLabel(new GuiNpcLabel(205, "ability.rotationSpeed", col2LabelX, y + 5));
|
||||
addTextField(createFloatField(205, col2FieldX, y, 55, orb.getRotationSpeed(editingOrb)));
|
||||
|
||||
y += 24;
|
||||
|
||||
// Row 3: Outer Glow Enabled
|
||||
addLabel(new GuiNpcLabel(202, "ability.outerEnabled", labelX, y + 5));
|
||||
addButton(new GuiNpcButton(202, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, orb.isOuterColorEnabled(editingOrb) ? 1 : 0));
|
||||
|
||||
// Only show Outer Color and Width if Outer Glow is enabled
|
||||
if (orb.isOuterColorEnabled()) {
|
||||
addLabel(new GuiNpcLabel(204, "ability.outerAlpha", col2LabelX, y + 5));
|
||||
GuiNpcTextField alphaField = createFloatField(204, col2FieldX, y, 55, orb.getOuterColorAlpha(editingOrb));
|
||||
alphaField.setEnabled(orb.isOuterColorEnabled(editingOrb));
|
||||
alphaField.setMinMaxDefaultFloat(0, 1, 0.5f);
|
||||
addTextField(alphaField);
|
||||
|
||||
y += 24;
|
||||
|
||||
// Row 4: Outer Color + Outer Width
|
||||
addLabel(new GuiNpcLabel(201, "ability.outerColor", labelX, y + 5));
|
||||
String outerHex = String.format("%06X", orb.getOuterColor(editingOrb) & 0xFFFFFF);
|
||||
GuiNpcButton outerColorBtn = new GuiNpcButton(201, fieldX, y, 55, 20, outerHex);
|
||||
outerColorBtn.setTextColor(orb.getOuterColor(editingOrb) & 0xFFFFFF);
|
||||
addButton(outerColorBtn);
|
||||
|
||||
addLabel(new GuiNpcLabel(203, "ability.outerWidth", col2LabelX, y + 5));
|
||||
addTextField(createFloatField(203, col2FieldX, y, 55, orb.getOuterColorWidth(editingOrb)));
|
||||
}
|
||||
|
||||
y += 24;
|
||||
|
||||
// Row 5: Lightning Effect Enabled
|
||||
addLabel(new GuiNpcLabel(206, "ability.lightning", labelX, y + 5));
|
||||
GuiNpcButton lightningBtn = new GuiNpcButton(206, fieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, orb.hasLightningEffect(editingOrb) ? 1 : 0);
|
||||
lightningBtn.setHoverText("ability.hover.lightning");
|
||||
addButton(lightningBtn);
|
||||
|
||||
// Only show Lightning settings if Lightning is enabled
|
||||
if (orb.hasLightningEffect(editingOrb)) {
|
||||
y += 24;
|
||||
|
||||
// Row 61: Density + Radius
|
||||
addLabel(new GuiNpcLabel(207, "ability.lightningDensity", labelX, y + 5));
|
||||
GuiNpcTextField densityField = new GuiNpcTextField(207, this, fontRendererObj, fieldX, y, 55, 18, "" + orb.getLightningDensity(editingOrb));
|
||||
densityField.setMinMaxDefaultFloat(0.01f, 5.0f, 0.15f);
|
||||
addTextField(densityField);
|
||||
|
||||
addLabel(new GuiNpcLabel(208, "ability.lightningRadius", col2LabelX, y + 5));
|
||||
GuiNpcTextField radiusField = new GuiNpcTextField(208, this, fontRendererObj, col2FieldX, y, 55, 18, "" + orb.getLightningRadius(editingOrb));
|
||||
radiusField.setMinMaxDefaultFloat(0.1f, 10.0f, 0.5f);
|
||||
addTextField(radiusField);
|
||||
}
|
||||
|
||||
y += 24;
|
||||
|
||||
addButton(new GuiNpcButton(400, col2FieldX, y, 55, 20, new String[]{"Orb 1", "Orb 2"}, editingOrb));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleTypeButton(int id, GuiNpcButton button) {
|
||||
int value = button.getValue();
|
||||
switch (id) {
|
||||
case 104:
|
||||
orb.setHoming(value == 1);
|
||||
initGui();
|
||||
break;
|
||||
case 106:
|
||||
orb.setExplosive(value == 1);
|
||||
initGui();
|
||||
break;
|
||||
case 110:
|
||||
orb.setDualFire(value == 1);
|
||||
initGui();
|
||||
break;
|
||||
case 150:
|
||||
setSubGui(new SubGuiAbilityEffects(orb.getEffects()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleVisualButton(int id, GuiNpcButton button) {
|
||||
int value = button.getValue();
|
||||
switch (id) {
|
||||
case 200:
|
||||
editingVisualColorId = 200;
|
||||
setSubGui(new SubGuiColorSelector(orb.getInnerColor(editingOrb)));
|
||||
break;
|
||||
case 201:
|
||||
editingVisualColorId = 201;
|
||||
setSubGui(new SubGuiColorSelector(orb.getOuterColor(editingOrb)));
|
||||
break;
|
||||
case 202:
|
||||
orb.setOuterColorEnabled(editingOrb, value == 1);
|
||||
initGui();
|
||||
break;
|
||||
case 206:
|
||||
orb.setLightningEffect(editingOrb, value == 1);
|
||||
initGui();
|
||||
break;
|
||||
case 210:
|
||||
orb.setAnchorPointEnum(editingOrb, AnchorPoint.fromOrdinal(value));
|
||||
break;
|
||||
case 400:
|
||||
editingOrb = (editingOrb + 1) % 2;
|
||||
initGui();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subGuiClosed(SubGuiInterface subgui) {
|
||||
if (subgui instanceof SubGuiColorSelector && editingVisualColorId != 0) {
|
||||
SubGuiColorSelector colorSelector = (SubGuiColorSelector) subgui;
|
||||
int rgb = colorSelector.color & 0x00FFFFFF;
|
||||
if (editingVisualColorId == 200) {
|
||||
orb.setInnerColor(rgb);
|
||||
} else if (editingVisualColorId == 201) {
|
||||
orb.setOuterColor(rgb);
|
||||
}
|
||||
editingVisualColorId = 0;
|
||||
initGui();
|
||||
} else if (subgui instanceof SubGuiAbilityEffects) {
|
||||
SubGuiAbilityEffects effectsGui = (SubGuiAbilityEffects) subgui;
|
||||
List<AbilityEffect> result = effectsGui.getResult();
|
||||
if (result != null) {
|
||||
orb.setEffects(result);
|
||||
}
|
||||
} else {
|
||||
super.subGuiClosed(subgui);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleTypeTextField(int id, GuiNpcTextField field) {
|
||||
switch (id) {
|
||||
case 100:
|
||||
orb.setDamage(parseFloat(field, orb.getDamage()));
|
||||
break;
|
||||
case 101:
|
||||
orb.setOrbSpeed(parseFloat(field, orb.getOrbSpeed()));
|
||||
break;
|
||||
case 102:
|
||||
orb.setOrbSize(parseFloat(field, orb.getOrbSize()));
|
||||
break;
|
||||
case 103:
|
||||
orb.setMaxDistance(parseFloat(field, orb.getMaxDistance()));
|
||||
break;
|
||||
case 105:
|
||||
orb.setHomingStrength(parseFloat(field, orb.getHomingStrength()));
|
||||
break;
|
||||
case 107:
|
||||
orb.setExplosionRadius(parseFloat(field, orb.getExplosionRadius()));
|
||||
break;
|
||||
case 108:
|
||||
orb.setKnockback(parseFloat(field, orb.getKnockback()));
|
||||
break;
|
||||
case 109:
|
||||
orb.setMaxLifetime(field.getInteger());
|
||||
break;
|
||||
case 111:
|
||||
orb.setDualFireDelay(field.getInteger());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleVisualTextField(int id, GuiNpcTextField field) {
|
||||
switch (id) {
|
||||
case 203:
|
||||
orb.setOuterColorWidth(editingOrb, parseFloat(field, orb.getOuterColorWidth(editingOrb)));
|
||||
break;
|
||||
case 204:
|
||||
orb.setOuterColorAlpha(editingOrb, parseFloat(field, orb.getOuterColorAlpha(editingOrb)));
|
||||
break;
|
||||
case 205:
|
||||
orb.setRotationSpeed(editingOrb, parseFloat(field, orb.getRotationSpeed(editingOrb)));
|
||||
break;
|
||||
case 207:
|
||||
orb.setLightningDensity(editingOrb, parseFloat(field, orb.getLightningDensity(editingOrb)));
|
||||
break;
|
||||
case 208:
|
||||
orb.setLightningRadius(editingOrb, parseFloat(field, orb.getLightningRadius(editingOrb)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user