mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-19 11:59:26 +00:00
Potion Effect System + Manual and Remove Bulk
This commit is contained in:
1 parent
85db3df355
commit
2a1a5643d3
38 files changed
+427
-415
No files matched your search
@@ -1181,61 +1181,37 @@ public abstract class Ability implements IAbility {
|
||||
maxRange = nbt.getFloat("maxRange");
|
||||
cooldownTicks = nbt.getInteger("cooldown");
|
||||
windUpTicks = nbt.getInteger("windUp");
|
||||
syncWindupWithAnimation = !nbt.hasKey("syncWindup") || nbt.getBoolean("syncWindup");
|
||||
syncWindupWithAnimation = nbt.getBoolean("syncWindup");
|
||||
dazedTicks = nbt.getInteger("recovery");
|
||||
interruptible = nbt.getBoolean("interruptible");
|
||||
lockMovement = LockMovementType.fromOrdinal(nbt.getInteger("lockMovement"));
|
||||
if (nbt.hasKey("rotationMode")) {
|
||||
// Current format
|
||||
rotationMode = RotationMode.fromOrdinal(nbt.getInteger("rotationMode"));
|
||||
rotationPhase = LockMovementType.fromOrdinal(nbt.getInteger("rotationPhase"));
|
||||
} else if (nbt.hasKey("lockType")) {
|
||||
// Legacy format migration: lockType was LockType enum (0=MOVEMENT, 1=ROTATION, 2=BOTH)
|
||||
int oldLockType = nbt.getInteger("lockType");
|
||||
if (oldLockType == 0) {
|
||||
// MOVEMENT only: movement locked, rotation was free
|
||||
rotationMode = RotationMode.FREE;
|
||||
} else if (oldLockType == 1) {
|
||||
// ROTATION only: rotation locked same timing as old lockMovement, movement was free
|
||||
rotationMode = RotationMode.LOCKED;
|
||||
rotationPhase = lockMovement;
|
||||
lockMovement = LockMovementType.NO;
|
||||
} else {
|
||||
// BOTH: both locked same timing
|
||||
rotationMode = RotationMode.LOCKED;
|
||||
rotationPhase = lockMovement;
|
||||
}
|
||||
} else {
|
||||
rotationMode = RotationMode.FREE;
|
||||
rotationPhase = LockMovementType.WINDUP_AND_ACTIVE;
|
||||
}
|
||||
rotationMode = RotationMode.fromOrdinal(nbt.getInteger("rotationMode"));
|
||||
rotationPhase = LockMovementType.fromOrdinal(nbt.getInteger("rotationPhase"));
|
||||
windUpColor = nbt.getInteger("windUpColor");
|
||||
activeColor = nbt.getInteger("activeColor");
|
||||
windUpSound = nbt.getString("windUpSound");
|
||||
activeSound = nbt.getString("activeSound");
|
||||
windUpAnimationId = nbt.hasKey("windUpAnimationId") ? nbt.getInteger("windUpAnimationId") : -1;
|
||||
activeAnimationId = nbt.hasKey("activeAnimationId") ? nbt.getInteger("activeAnimationId") : -1;
|
||||
windUpAnimationId = nbt.getInteger("windUpAnimationId");
|
||||
activeAnimationId = nbt.getInteger("activeAnimationId");
|
||||
windUpAnimationName = nbt.getString("windUpAnimationName");
|
||||
activeAnimationName = nbt.getString("activeAnimationName");
|
||||
showTelegraph = !nbt.hasKey("showTelegraph") || nbt.getBoolean("showTelegraph");
|
||||
if (nbt.hasKey("telegraphType")) {
|
||||
try {
|
||||
telegraphType = TelegraphType.valueOf(nbt.getString("telegraphType"));
|
||||
} catch (Exception e) {
|
||||
telegraphType = TelegraphType.CIRCLE;
|
||||
}
|
||||
showTelegraph = nbt.getBoolean("showTelegraph");
|
||||
try {
|
||||
telegraphType = TelegraphType.valueOf(nbt.getString("telegraphType"));
|
||||
} catch (Exception e) {
|
||||
telegraphType = TelegraphType.CIRCLE;
|
||||
}
|
||||
telegraphHeightOffset = nbt.hasKey("telegraphHeightOffset") ? nbt.getFloat("telegraphHeightOffset") : 0.1f;
|
||||
telegraphHeightOffset = nbt.getFloat("telegraphHeightOffset");
|
||||
customData = nbt.getCompoundTag("customData");
|
||||
allowedBy = nbt.hasKey("allowedBy") ? UserType.fromOrdinal(nbt.getInteger("allowedBy")) : UserType.BOTH;
|
||||
ignoreCooldown = nbt.hasKey("ignoreCooldown") && nbt.getBoolean("ignoreCooldown");
|
||||
allowedBy = UserType.fromOrdinal(nbt.getInteger("allowedBy"));
|
||||
ignoreCooldown = nbt.getBoolean("ignoreCooldown");
|
||||
|
||||
// Burst
|
||||
burstEnabled = nbt.hasKey("burstEnabled") && nbt.getBoolean("burstEnabled");
|
||||
burstAmount = nbt.hasKey("burstAmount") ? nbt.getInteger("burstAmount") : 0;
|
||||
burstDelay = nbt.hasKey("burstDelay") ? nbt.getInteger("burstDelay") : 0;
|
||||
burstReplayAnimations = !nbt.hasKey("burstReplayAnimations") || nbt.getBoolean("burstReplayAnimations");
|
||||
burstOverlap = nbt.hasKey("burstOverlap") && nbt.getBoolean("burstOverlap");
|
||||
burstEnabled = nbt.getBoolean("burstEnabled");
|
||||
burstAmount = nbt.getInteger("burstAmount");
|
||||
burstDelay = nbt.getInteger("burstDelay");
|
||||
burstReplayAnimations = nbt.getBoolean("burstReplayAnimations");
|
||||
burstOverlap = nbt.getBoolean("burstOverlap");
|
||||
|
||||
// Conditions
|
||||
conditions.clear();
|
||||
|
||||
@@ -2,67 +2,24 @@ 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;
|
||||
import noppes.npcs.constants.EnumPotionType;
|
||||
|
||||
/**
|
||||
* Represents a configurable potion effect that can be applied by abilities.
|
||||
* Provides a unified system for managing debuffs like slowness, weakness, poison, etc.
|
||||
* Uses the unified EnumPotionType enum shared across melee, ranged, and ability systems.
|
||||
*/
|
||||
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),
|
||||
BURN("ability.effect.burn", -1);
|
||||
|
||||
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 String[] getLangKeys() {
|
||||
EffectType[] types = values();
|
||||
String[] keys = new String[types.length];
|
||||
for (int i = 0; i < types.length; i++) keys[i] = types[i].langKey;
|
||||
return keys;
|
||||
}
|
||||
|
||||
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 EnumPotionType type = EnumPotionType.None;
|
||||
private int manualPotionId = 0;
|
||||
private int durationTicks = 60;
|
||||
private int amplifier = 0; // 0-10
|
||||
|
||||
public AbilityEffect() {
|
||||
}
|
||||
|
||||
public AbilityEffect(EffectType type, int durationTicks, int amplifier) {
|
||||
public AbilityEffect(EnumPotionType type, int durationTicks, int amplifier) {
|
||||
this.type = type;
|
||||
this.durationTicks = Math.max(1, durationTicks);
|
||||
this.amplifier = Math.max(0, Math.min(10, amplifier));
|
||||
@@ -72,25 +29,27 @@ public class AbilityEffect {
|
||||
* Creates a copy of this effect.
|
||||
*/
|
||||
public AbilityEffect copy() {
|
||||
return new AbilityEffect(type, durationTicks, amplifier);
|
||||
AbilityEffect copy = new AbilityEffect(type, durationTicks, amplifier);
|
||||
copy.manualPotionId = this.manualPotionId;
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies this effect to the given entity.
|
||||
* Does nothing if type is NONE.
|
||||
* Does nothing if type is None. Validates potion IDs before applying.
|
||||
*/
|
||||
public void apply(EntityLivingBase entity) {
|
||||
if (entity == null || type == EffectType.NONE) {
|
||||
if (entity == null || type == EnumPotionType.None) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == EffectType.BURN) {
|
||||
if (type == EnumPotionType.Fire) {
|
||||
entity.setFire(Math.max(1, durationTicks / 20));
|
||||
return;
|
||||
}
|
||||
|
||||
int potionId = type.getPotionId();
|
||||
if (potionId >= 0) {
|
||||
int potionId = type.getResolvedPotionId(manualPotionId);
|
||||
if (EnumPotionType.isValidPotionId(potionId)) {
|
||||
entity.addPotionEffect(new PotionEffect(potionId, durationTicks, amplifier));
|
||||
}
|
||||
}
|
||||
@@ -100,9 +59,12 @@ public class AbilityEffect {
|
||||
*/
|
||||
public NBTTagCompound writeNBT() {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setInteger("type", type.ordinal());
|
||||
nbt.setInteger("potionType", type.ordinal());
|
||||
nbt.setInteger("duration", durationTicks);
|
||||
nbt.setInteger("amplifier", amplifier);
|
||||
if (type == EnumPotionType.Manual) {
|
||||
nbt.setInteger("manualPotionId", manualPotionId);
|
||||
}
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@@ -110,9 +72,12 @@ public class AbilityEffect {
|
||||
* 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;
|
||||
this.type = EnumPotionType.fromOrdinal(nbt.getInteger("potionType"));
|
||||
this.durationTicks = nbt.getInteger("duration");
|
||||
this.amplifier = nbt.getInteger("amplifier");
|
||||
if (type == EnumPotionType.Manual) {
|
||||
this.manualPotionId = nbt.getInteger("manualPotionId");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,12 +91,20 @@ public class AbilityEffect {
|
||||
|
||||
// Getters & Setters
|
||||
|
||||
public EffectType getType() {
|
||||
public EnumPotionType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(EffectType type) {
|
||||
this.type = type != null ? type : EffectType.NONE;
|
||||
public void setType(EnumPotionType type) {
|
||||
this.type = type != null ? type : EnumPotionType.None;
|
||||
}
|
||||
|
||||
public int getManualPotionId() {
|
||||
return manualPotionId;
|
||||
}
|
||||
|
||||
public void setManualPotionId(int manualPotionId) {
|
||||
this.manualPotionId = Math.max(0, manualPotionId);
|
||||
}
|
||||
|
||||
public int getDurationTicks() {
|
||||
@@ -151,9 +124,9 @@ public class AbilityEffect {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this effect is configured (not NONE).
|
||||
* Returns true if this effect is configured (not None).
|
||||
*/
|
||||
public boolean isValid() {
|
||||
return type != EffectType.NONE;
|
||||
return type != EnumPotionType.None;
|
||||
}
|
||||
}
|
||||
@@ -91,10 +91,10 @@ public class EnergyAnchorData implements IEnergyAnchorData {
|
||||
}
|
||||
|
||||
public void readNBT(NBTTagCompound nbt) {
|
||||
this.anchorPoint = nbt.hasKey("anchorPoint") ? AnchorPoint.fromOrdinal(nbt.getInteger("anchorPoint")) : AnchorPoint.FRONT;
|
||||
this.anchorOffsetX = nbt.hasKey("anchorOffsetX") ? nbt.getFloat("anchorOffsetX") : 0;
|
||||
this.anchorOffsetY = nbt.hasKey("anchorOffsetY") ? nbt.getFloat("anchorOffsetY") : 0;
|
||||
this.anchorOffsetZ = nbt.hasKey("anchorOffsetZ") ? nbt.getFloat("anchorOffsetZ") : 0;
|
||||
this.anchorPoint = AnchorPoint.fromOrdinal(nbt.getInteger("anchorPoint"));
|
||||
this.anchorOffsetX = nbt.getFloat("anchorOffsetX");
|
||||
this.anchorOffsetY = nbt.getFloat("anchorOffsetY");
|
||||
this.anchorOffsetZ = nbt.getFloat("anchorOffsetZ");
|
||||
}
|
||||
|
||||
public EnergyAnchorData copy() {
|
||||
|
||||
@@ -97,12 +97,12 @@ public class EnergyCombatData implements IEnergyCombatData {
|
||||
}
|
||||
|
||||
public void readNBT(NBTTagCompound nbt) {
|
||||
damage = nbt.hasKey("damage") ? nbt.getFloat("damage") : 7.0f;
|
||||
knockback = nbt.hasKey("knockback") ? nbt.getFloat("knockback") : 1.0f;
|
||||
knockbackUp = nbt.hasKey("knockbackUp") ? nbt.getFloat("knockbackUp") : 0.1f;
|
||||
explosive = nbt.hasKey("explosive") && nbt.getBoolean("explosive");
|
||||
explosionRadius = nbt.hasKey("explosionRadius") ? nbt.getFloat("explosionRadius") : 3.0f;
|
||||
explosionDamageFalloff = nbt.hasKey("explosionDamageFalloff") ? nbt.getFloat("explosionDamageFalloff") : 0.5f;
|
||||
damage = nbt.getFloat("damage");
|
||||
knockback = nbt.getFloat("knockback");
|
||||
knockbackUp = nbt.getFloat("knockbackUp");
|
||||
explosive = nbt.getBoolean("explosive");
|
||||
explosionRadius = nbt.getFloat("explosionRadius");
|
||||
explosionDamageFalloff = nbt.getFloat("explosionDamageFalloff");
|
||||
}
|
||||
|
||||
public EnergyCombatData copy() {
|
||||
|
||||
@@ -102,12 +102,12 @@ public class EnergyDisplayData implements IEnergyDisplayData {
|
||||
}
|
||||
|
||||
public void readNBT(NBTTagCompound nbt) {
|
||||
innerColor = nbt.hasKey("innerColor") ? nbt.getInteger("innerColor") : 0xFFFFFF;
|
||||
outerColor = nbt.hasKey("outerColor") ? nbt.getInteger("outerColor") : 0x8888FF;
|
||||
outerColorEnabled = !nbt.hasKey("outerColorEnabled") || nbt.getBoolean("outerColorEnabled");
|
||||
outerColorWidth = nbt.hasKey("outerColorWidth") ? nbt.getFloat("outerColorWidth") : 0.4f;
|
||||
outerColorAlpha = nbt.hasKey("outerColorAlpha") ? nbt.getFloat("outerColorAlpha") : 0.5f;
|
||||
rotationSpeed = nbt.hasKey("rotationSpeed") ? nbt.getFloat("rotationSpeed") : 4.0f;
|
||||
innerColor = nbt.getInteger("innerColor");
|
||||
outerColor = nbt.getInteger("outerColor");
|
||||
outerColorEnabled = nbt.getBoolean("outerColorEnabled");
|
||||
outerColorWidth = nbt.getFloat("outerColorWidth");
|
||||
outerColorAlpha = nbt.getFloat("outerColorAlpha");
|
||||
rotationSpeed = nbt.getFloat("rotationSpeed");
|
||||
}
|
||||
|
||||
public EnergyDisplayData copy() {
|
||||
|
||||
@@ -71,10 +71,10 @@ public class EnergyHomingData implements IEnergyHomingData {
|
||||
}
|
||||
|
||||
public void readNBT(NBTTagCompound nbt) {
|
||||
speed = nbt.hasKey("speed") ? nbt.getFloat("speed") : 0.5f;
|
||||
homing = !nbt.hasKey("homing") || nbt.getBoolean("homing");
|
||||
homingStrength = nbt.hasKey("homingStrength") ? nbt.getFloat("homingStrength") : 0.15f;
|
||||
homingRange = nbt.hasKey("homingRange") ? nbt.getFloat("homingRange") : 20.0f;
|
||||
speed = nbt.getFloat("speed");
|
||||
homing = nbt.getBoolean("homing");
|
||||
homingStrength = nbt.getFloat("homingStrength");
|
||||
homingRange = nbt.getFloat("homingRange");
|
||||
}
|
||||
|
||||
public EnergyHomingData copy() {
|
||||
|
||||
@@ -44,8 +44,8 @@ public class EnergyLifespanData implements IEnergyLifespanData {
|
||||
}
|
||||
|
||||
public void readNBT(NBTTagCompound nbt) {
|
||||
maxDistance = nbt.hasKey("maxDistance") ? nbt.getFloat("maxDistance") : 30.0f;
|
||||
maxLifetime = nbt.hasKey("maxLifetime") ? nbt.getInteger("maxLifetime") : 200;
|
||||
maxDistance = nbt.getFloat("maxDistance");
|
||||
maxLifetime = nbt.getInteger("maxLifetime");
|
||||
}
|
||||
|
||||
public EnergyLifespanData copy() {
|
||||
|
||||
@@ -71,10 +71,10 @@ public class EnergyLightningData implements IEnergyLightningData {
|
||||
}
|
||||
|
||||
public void readNBT(NBTTagCompound nbt) {
|
||||
lightningEffect = nbt.hasKey("lightningEffect") && nbt.getBoolean("lightningEffect");
|
||||
lightningDensity = nbt.hasKey("lightningDensity") ? nbt.getFloat("lightningDensity") : 0.15f;
|
||||
lightningRadius = nbt.hasKey("lightningRadius") ? nbt.getFloat("lightningRadius") : 0.5f;
|
||||
lightningFadeTime = nbt.hasKey("lightningFadeTime") ? nbt.getInteger("lightningFadeTime") : 6;
|
||||
lightningEffect = nbt.getBoolean("lightningEffect");
|
||||
lightningDensity = nbt.getFloat("lightningDensity");
|
||||
lightningRadius = nbt.getFloat("lightningRadius");
|
||||
lightningFadeTime = nbt.getInteger("lightningFadeTime");
|
||||
}
|
||||
|
||||
public EnergyLightningData copy() {
|
||||
|
||||
@@ -184,7 +184,7 @@ public class EnergyTrajectoryData implements IEnergyTrajectoryData {
|
||||
}
|
||||
|
||||
public void readNBT(NBTTagCompound nbt) {
|
||||
this.currentPath = nbt.hasKey("currentPath") ? nbt.getInteger("currentPath") : 0;
|
||||
this.currentPath = nbt.getInteger("currentPath");
|
||||
|
||||
int i = 0;
|
||||
while (nbt.hasKey("Path_" + i, Constants.NBT.TAG_COMPOUND)) {
|
||||
@@ -275,8 +275,8 @@ public class EnergyTrajectoryData implements IEnergyTrajectoryData {
|
||||
}
|
||||
|
||||
public void readNBT(NBTTagCompound nbt) {
|
||||
this.delayTicks = nbt.hasKey("delay") ? nbt.getInteger("delay") : 0;
|
||||
this.concluded = nbt.hasKey("concluded") && nbt.getBoolean("concluded");
|
||||
this.delayTicks = nbt.getInteger("delay");
|
||||
this.concluded = nbt.getBoolean("concluded");
|
||||
|
||||
double x = nbt.getDouble("X");
|
||||
double y = nbt.getDouble("Y");
|
||||
|
||||
@@ -44,8 +44,8 @@ public class ProjectileData {
|
||||
anchor.readNBT(nbt);
|
||||
colorOverride = nbt.getBoolean("colorOverride");
|
||||
if (colorOverride) {
|
||||
innerColor = nbt.hasKey("overrideInnerColor") ? nbt.getInteger("overrideInnerColor") : 0xFFFFFF;
|
||||
outerColor = nbt.hasKey("overrideOuterColor") ? nbt.getInteger("overrideOuterColor") : 0x8888FF;
|
||||
innerColor = nbt.getInteger("overrideInnerColor");
|
||||
outerColor = nbt.getInteger("overrideOuterColor");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import noppes.npcs.client.gui.util.GuiNPCInterface;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
||||
import noppes.npcs.client.gui.util.GuiNpcTextField;
|
||||
import noppes.npcs.constants.EnumPotionType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -26,7 +27,7 @@ import java.util.Map;
|
||||
public class AbilityFieldBuilder extends GuiFieldBuilder {
|
||||
|
||||
// Effects list metadata: widgetId -> [effectIndex, action]
|
||||
// action: 0=type, 1=duration(text), 2=amp, 3=delete, 4=add
|
||||
// action: 0=type, 1=duration(text), 2=amp, 3=delete, 4=add, 5=manualId(text)
|
||||
private final Map<Integer, int[]> effectWidgetMeta = new HashMap<>();
|
||||
|
||||
public AbilityFieldBuilder(GuiNPCInterface parent, FontRenderer fontRenderer) {
|
||||
@@ -57,15 +58,15 @@ public class AbilityFieldBuilder extends GuiFieldBuilder {
|
||||
List<AbilityEffect> effects = (List<AbilityEffect>) def.getValue();
|
||||
if (effects == null) effects = new ArrayList<>();
|
||||
|
||||
String[] typeNames = AbilityEffect.EffectType.getLangKeys();
|
||||
String[] typeNames = EnumPotionType.getLangKeysNoNone();
|
||||
String[] ampValues = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
|
||||
|
||||
for (int e = 0; e < effects.size() && e < 5; e++) {
|
||||
AbilityEffect effect = effects.get(e);
|
||||
|
||||
// Type selector button
|
||||
int typeIdx = effect.getType().ordinal();
|
||||
GuiNpcButton typeBtn = new GuiNpcButton(widgetId, colLLabel, y, 100, 20, typeNames, typeIdx);
|
||||
// Type selector button (index offset by -1 since None is excluded)
|
||||
int typeIdx = effect.getType().ordinal() - 1;
|
||||
GuiNpcButton typeBtn = new GuiNpcButton(widgetId, colLLabel, y, 100, 20, typeNames, Math.max(0, typeIdx));
|
||||
sw.addButton(typeBtn);
|
||||
buttonFieldMap.put(widgetId, def);
|
||||
effectWidgetMeta.put(widgetId, new int[]{e, 0});
|
||||
@@ -81,12 +82,16 @@ public class AbilityFieldBuilder extends GuiFieldBuilder {
|
||||
effectWidgetMeta.put(widgetId, new int[]{e, 1});
|
||||
widgetId++;
|
||||
|
||||
// Amplifier selector (0-10)
|
||||
GuiNpcButton ampBtn = new GuiNpcButton(widgetId, colLLabel + 158, y, 40, 20, ampValues, effect.getAmplifier());
|
||||
sw.addButton(ampBtn);
|
||||
buttonFieldMap.put(widgetId, def);
|
||||
effectWidgetMeta.put(widgetId, new int[]{e, 2});
|
||||
widgetId++;
|
||||
if (effect.getType() != EnumPotionType.Fire) {
|
||||
// Amplifier selector (0-10) — not applicable to Fire
|
||||
GuiNpcButton ampBtn = new GuiNpcButton(widgetId, colLLabel + 158, y, 40, 20, ampValues, effect.getAmplifier());
|
||||
sw.addButton(ampBtn);
|
||||
buttonFieldMap.put(widgetId, def);
|
||||
effectWidgetMeta.put(widgetId, new int[]{e, 2});
|
||||
widgetId++;
|
||||
} else {
|
||||
widgetId++; // keep widgetId in sync
|
||||
}
|
||||
|
||||
// Delete button
|
||||
GuiNpcButton delBtn = new GuiNpcButton(clearId, colLLabel + 202, y, 20, 20, "X");
|
||||
@@ -96,6 +101,20 @@ public class AbilityFieldBuilder extends GuiFieldBuilder {
|
||||
clearId++;
|
||||
|
||||
y += rowHeight;
|
||||
|
||||
// Manual potion ID field (shown on next row when type is Manual)
|
||||
if (effect.getType() == EnumPotionType.Manual) {
|
||||
sw.addLabel(new GuiNpcLabel(labelId++, "effect.potionid", colLLabel, y + 5, 0xFFFFFF));
|
||||
GuiNpcTextField idField = new GuiNpcTextField(widgetId, parent, fontRenderer,
|
||||
colLLabel + 80, y, 50, 20, String.valueOf(effect.getManualPotionId()));
|
||||
idField.setIntegersOnly();
|
||||
idField.setMinMaxDefault(0, Integer.MAX_VALUE, 0);
|
||||
sw.addTextField(idField);
|
||||
textFieldMap.put(widgetId, def);
|
||||
effectWidgetMeta.put(widgetId, new int[]{e, 5});
|
||||
widgetId++;
|
||||
y += rowHeight;
|
||||
}
|
||||
}
|
||||
|
||||
// Add button (if < 5 effects)
|
||||
@@ -133,7 +152,7 @@ public class AbilityFieldBuilder extends GuiFieldBuilder {
|
||||
switch (action) {
|
||||
case 0: // Type changed
|
||||
if (effectIdx < effects.size()) {
|
||||
effects.get(effectIdx).setType(AbilityEffect.EffectType.fromOrdinal(((GuiNpcButton) button).getValue()));
|
||||
effects.get(effectIdx).setType(EnumPotionType.fromIndexNoNone(((GuiNpcButton) button).getValue()));
|
||||
}
|
||||
return true;
|
||||
case 2: // Amp changed
|
||||
@@ -148,7 +167,7 @@ public class AbilityFieldBuilder extends GuiFieldBuilder {
|
||||
return true;
|
||||
case 4: // Add
|
||||
if (effects.size() < 5) {
|
||||
effects.add(new AbilityEffect(AbilityEffect.EffectType.SLOWNESS, 60, 0));
|
||||
effects.add(new AbilityEffect(EnumPotionType.Slowness, 60, 0));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -162,12 +181,16 @@ public class AbilityFieldBuilder extends GuiFieldBuilder {
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean handleTextFieldEvent(int textFieldId, GuiNpcTextField field) {
|
||||
int[] meta = effectWidgetMeta.get(textFieldId);
|
||||
if (meta != null && meta[1] == 1) { // duration field
|
||||
if (meta != null) {
|
||||
FieldDef def = textFieldMap.get(textFieldId);
|
||||
if (def != null && def.getType() == FieldType.EFFECTS_LIST) {
|
||||
List<AbilityEffect> effects = (List<AbilityEffect>) def.getValue();
|
||||
if (effects != null && meta[0] < effects.size()) {
|
||||
effects.get(meta[0]).setDurationTicks(field.getInteger());
|
||||
if (meta[1] == 1) { // duration field
|
||||
effects.get(meta[0]).setDurationTicks(field.getInteger());
|
||||
} else if (meta[1] == 5) { // manual potion ID field
|
||||
effects.get(meta[0]).setManualPotionId(field.getInteger());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -356,13 +356,13 @@ public class AbilityBeam extends Ability implements IAbilityEnergyBeam {
|
||||
|
||||
@Override
|
||||
public void readTypeNBT(NBTTagCompound nbt) {
|
||||
this.beamWidth = nbt.hasKey("beamWidth") ? nbt.getFloat("beamWidth") : 0.4f;
|
||||
this.headSize = nbt.hasKey("headSize") ? nbt.getFloat("headSize") : 0.6f;
|
||||
this.beamWidth = nbt.getFloat("beamWidth");
|
||||
this.headSize = nbt.getFloat("headSize");
|
||||
|
||||
int count = nbt.hasKey("projectileCount") ? nbt.getInteger("projectileCount") : 1;
|
||||
int count = nbt.getInteger("projectileCount");
|
||||
initProjectiles(count);
|
||||
|
||||
this.fireDelay = nbt.hasKey("fireDelay") ? nbt.getInteger("fireDelay") : 0;
|
||||
this.fireDelay = nbt.getInteger("fireDelay");
|
||||
|
||||
combatData.readNBT(nbt);
|
||||
homingData.readNBT(nbt);
|
||||
|
||||
@@ -359,16 +359,10 @@ public class AbilityCharge extends Ability implements IAbilityCharge {
|
||||
|
||||
@Override
|
||||
public void readTypeNBT(NBTTagCompound nbt) {
|
||||
this.chargeSpeed = nbt.hasKey("chargeSpeed") ? nbt.getFloat("chargeSpeed") : 0.8f;
|
||||
this.damage = nbt.hasKey("damage") ? nbt.getFloat("damage") : 8.0f;
|
||||
this.knockback = nbt.hasKey("knockback") ? nbt.getFloat("knockback") : 3.0f;
|
||||
if (nbt.hasKey("hitWidth")) {
|
||||
this.hitWidth = nbt.getFloat("hitWidth");
|
||||
} else if (nbt.hasKey("hitRadius")) {
|
||||
this.hitWidth = nbt.getFloat("hitRadius");
|
||||
} else {
|
||||
this.hitWidth = 1.5f;
|
||||
}
|
||||
this.chargeSpeed = nbt.getFloat("chargeSpeed");
|
||||
this.damage = nbt.getFloat("damage");
|
||||
this.knockback = nbt.getFloat("knockback");
|
||||
this.hitWidth = nbt.getFloat("hitWidth");
|
||||
}
|
||||
|
||||
// Getters & Setters
|
||||
|
||||
@@ -326,19 +326,19 @@ public class AbilityCutter extends Ability implements IAbilityCutter {
|
||||
|
||||
@Override
|
||||
public void readTypeNBT(NBTTagCompound nbt) {
|
||||
this.arcAngle = nbt.hasKey("arcAngle") ? nbt.getFloat("arcAngle") : 90.0f;
|
||||
this.range = nbt.hasKey("range") ? nbt.getFloat("range") : 6.0f;
|
||||
this.damage = nbt.hasKey("damage") ? nbt.getFloat("damage") : 7.0f;
|
||||
this.knockback = nbt.hasKey("knockback") ? nbt.getFloat("knockback") : 1.5f;
|
||||
this.arcAngle = nbt.getFloat("arcAngle");
|
||||
this.range = nbt.getFloat("range");
|
||||
this.damage = nbt.getFloat("damage");
|
||||
this.knockback = nbt.getFloat("knockback");
|
||||
try {
|
||||
this.sweepMode = SweepMode.valueOf(nbt.getString("sweepMode"));
|
||||
} catch (Exception e) {
|
||||
this.sweepMode = SweepMode.SWIPE;
|
||||
}
|
||||
this.sweepSpeed = nbt.hasKey("sweepSpeed") ? nbt.getFloat("sweepSpeed") : 6.0f;
|
||||
this.spinDurationTicks = nbt.hasKey("spinDurationTicks") ? nbt.getInteger("spinDurationTicks") : 60;
|
||||
this.piercing = !nbt.hasKey("piercing") || nbt.getBoolean("piercing");
|
||||
this.innerRadius = nbt.hasKey("innerRadius") ? nbt.getFloat("innerRadius") : 0.0f;
|
||||
this.sweepSpeed = nbt.getFloat("sweepSpeed");
|
||||
this.spinDurationTicks = nbt.getInteger("spinDurationTicks");
|
||||
this.piercing = nbt.getBoolean("piercing");
|
||||
this.innerRadius = nbt.getFloat("innerRadius");
|
||||
}
|
||||
|
||||
// Getters & Setters
|
||||
|
||||
@@ -310,8 +310,8 @@ public class AbilityDash extends Ability implements IAbilityDash {
|
||||
} catch (Exception e) {
|
||||
this.dashMode = DashMode.DEFENSIVE;
|
||||
}
|
||||
this.dashDistance = nbt.hasKey("dashDistance") ? nbt.getFloat("dashDistance") : 4.0f;
|
||||
this.dashSpeed = nbt.hasKey("dashSpeed") ? nbt.getFloat("dashSpeed") : 0.5f;
|
||||
this.dashDistance = nbt.getFloat("dashDistance");
|
||||
this.dashSpeed = nbt.getFloat("dashSpeed");
|
||||
}
|
||||
|
||||
// Getters & Setters
|
||||
|
||||
@@ -368,16 +368,16 @@ public class AbilityDisc extends Ability implements IAbilityDisc {
|
||||
|
||||
@Override
|
||||
public void readTypeNBT(NBTTagCompound nbt) {
|
||||
this.discRadius = nbt.hasKey("discRadius") ? nbt.getFloat("discRadius") : 1.0f;
|
||||
this.discThickness = nbt.hasKey("discThickness") ? nbt.getFloat("discThickness") : 0.2f;
|
||||
this.vertical = nbt.hasKey("vertical") && nbt.getBoolean("vertical");
|
||||
this.boomerang = nbt.hasKey("boomerang") && nbt.getBoolean("boomerang");
|
||||
this.boomerangDelay = nbt.hasKey("boomerangDelay") ? nbt.getInteger("boomerangDelay") : 40;
|
||||
this.discRadius = nbt.getFloat("discRadius");
|
||||
this.discThickness = nbt.getFloat("discThickness");
|
||||
this.vertical = nbt.getBoolean("vertical");
|
||||
this.boomerang = nbt.getBoolean("boomerang");
|
||||
this.boomerangDelay = nbt.getInteger("boomerangDelay");
|
||||
|
||||
int count = nbt.hasKey("projectileCount") ? nbt.getInteger("projectileCount") : 1;
|
||||
int count = nbt.getInteger("projectileCount");
|
||||
initProjectiles(count);
|
||||
|
||||
this.fireDelay = nbt.hasKey("fireDelay") ? nbt.getInteger("fireDelay") : 0;
|
||||
this.fireDelay = nbt.getInteger("fireDelay");
|
||||
|
||||
// Shared combat/movement data
|
||||
combatData.readNBT(nbt);
|
||||
|
||||
@@ -238,27 +238,19 @@ public class AbilityGuard extends Ability implements IAbilityGuard {
|
||||
|
||||
@Override
|
||||
public void readTypeNBT(NBTTagCompound nbt) {
|
||||
this.durationTicks = nbt.hasKey("durationTicks") ? nbt.getInteger("durationTicks") : 60;
|
||||
this.damageReduction = nbt.hasKey("damageReduction") ? nbt.getFloat("damageReduction") : 0.5f;
|
||||
this.canCounter = nbt.hasKey("canCounter") && nbt.getBoolean("canCounter");
|
||||
this.counterWindow = nbt.hasKey("counterWindow") ? nbt.getInteger("counterWindow") : 10;
|
||||
this.durationTicks = nbt.getInteger("durationTicks");
|
||||
this.damageReduction = nbt.getFloat("damageReduction");
|
||||
this.canCounter = nbt.getBoolean("canCounter");
|
||||
this.counterWindow = nbt.getInteger("counterWindow");
|
||||
try {
|
||||
this.counterType = CounterType.valueOf(nbt.getString("counterType"));
|
||||
} catch (Exception e) {
|
||||
this.counterType = CounterType.FLAT;
|
||||
}
|
||||
if (nbt.hasKey("counterValue")) {
|
||||
this.counterValue = nbt.getFloat("counterValue");
|
||||
} else if (nbt.hasKey("counterDamage")) {
|
||||
this.counterValue = nbt.getFloat("counterDamage");
|
||||
} else {
|
||||
this.counterValue = 6.0f;
|
||||
}
|
||||
this.counterSound = nbt.hasKey("counterSound") ? nbt.getString("counterSound") : "random.wood_click";
|
||||
this.counterAnimationId = nbt.hasKey("counterAnimationId") ? nbt.getInteger("counterAnimationId") : -1;
|
||||
this.counterAnimationName = nbt.hasKey("counterAnimationName") ?
|
||||
nbt.getString("counterAnimationName") :
|
||||
"Ability_Guard_Counter";
|
||||
this.counterValue = nbt.getFloat("counterValue");
|
||||
this.counterSound = nbt.getString("counterSound");
|
||||
this.counterAnimationId = nbt.getInteger("counterAnimationId");
|
||||
this.counterAnimationName = nbt.getString("counterAnimationName");
|
||||
}
|
||||
|
||||
// Getters & Setters
|
||||
|
||||
@@ -115,11 +115,11 @@ public class AbilityHazard extends AbilityZone implements IAbilityHazard {
|
||||
@Override
|
||||
public void readTypeNBT(NBTTagCompound nbt) {
|
||||
readZoneNBT(nbt, 300);
|
||||
this.radius = nbt.hasKey("radius") ? nbt.getFloat("radius") : 2.0f;
|
||||
this.damagePerSecond = nbt.hasKey("damagePerSecond") ? nbt.getFloat("damagePerSecond") : 1.0f;
|
||||
this.damageInterval = nbt.hasKey("damageInterval") ? nbt.getInteger("damageInterval") : 20;
|
||||
this.ignoreInvulnFrames = nbt.hasKey("ignoreInvulnFrames") && nbt.getBoolean("ignoreInvulnFrames");
|
||||
this.affectsCaster = nbt.hasKey("affectsCaster") && nbt.getBoolean("affectsCaster");
|
||||
this.radius = nbt.getFloat("radius");
|
||||
this.damagePerSecond = nbt.getFloat("damagePerSecond");
|
||||
this.damageInterval = nbt.getInteger("damageInterval");
|
||||
this.ignoreInvulnFrames = nbt.getBoolean("ignoreInvulnFrames");
|
||||
this.affectsCaster = nbt.getBoolean("affectsCaster");
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
@@ -227,13 +227,13 @@ public class AbilityHeal extends Ability implements IAbilityHeal {
|
||||
|
||||
@Override
|
||||
public void readTypeNBT(NBTTagCompound nbt) {
|
||||
this.durationTicks = nbt.hasKey("durationTicks") ? nbt.getInteger("durationTicks") : 60;
|
||||
this.healAmount = nbt.hasKey("healAmount") ? nbt.getFloat("healAmount") : 10.0f;
|
||||
this.healPercent = nbt.hasKey("healPercent") ? nbt.getFloat("healPercent") : 0.0f;
|
||||
this.healSelf = !nbt.hasKey("healSelf") || nbt.getBoolean("healSelf");
|
||||
this.healAllies = nbt.hasKey("healAllies") && nbt.getBoolean("healAllies");
|
||||
this.healRadius = nbt.hasKey("healRadius") ? nbt.getFloat("healRadius") : 0.0f;
|
||||
this.instantHeal = !nbt.hasKey("instantHeal") || nbt.getBoolean("instantHeal");
|
||||
this.durationTicks = nbt.getInteger("durationTicks");
|
||||
this.healAmount = nbt.getFloat("healAmount");
|
||||
this.healPercent = nbt.getFloat("healPercent");
|
||||
this.healSelf = nbt.getBoolean("healSelf");
|
||||
this.healAllies = nbt.getBoolean("healAllies");
|
||||
this.healRadius = nbt.getFloat("healRadius");
|
||||
this.instantHeal = nbt.getBoolean("instantHeal");
|
||||
}
|
||||
|
||||
// Getters & Setters
|
||||
|
||||
@@ -135,10 +135,10 @@ public class AbilityHeavyHit extends Ability implements IAbilityHeavyHit {
|
||||
|
||||
@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.hitLength = nbt.hasKey("hitLength") ? nbt.getFloat("hitLength") : 4.0f;
|
||||
this.hitWidth = nbt.hasKey("hitWidth") ? nbt.getFloat("hitWidth") : 3.0f;
|
||||
this.damage = nbt.getFloat("damage");
|
||||
this.knockback = nbt.getFloat("knockback");
|
||||
this.hitLength = nbt.getFloat("hitLength");
|
||||
this.hitWidth = nbt.getFloat("hitWidth");
|
||||
}
|
||||
|
||||
// Getters & Setters
|
||||
|
||||
@@ -190,9 +190,9 @@ public class AbilityLaserShot extends Ability implements IAbilityLaserShot {
|
||||
|
||||
@Override
|
||||
public void readTypeNBT(NBTTagCompound nbt) {
|
||||
this.laserWidth = nbt.hasKey("laserWidth") ? nbt.getFloat("laserWidth") : 0.3f;
|
||||
this.expansionSpeed = nbt.hasKey("expansionSpeed") ? nbt.getFloat("expansionSpeed") : 3.0f;
|
||||
this.lingerTicks = nbt.hasKey("lingerTicks") ? nbt.getInteger("lingerTicks") : 8;
|
||||
this.laserWidth = nbt.getFloat("laserWidth");
|
||||
this.expansionSpeed = nbt.getFloat("expansionSpeed");
|
||||
this.lingerTicks = nbt.getInteger("lingerTicks");
|
||||
anchorData.readNBT(nbt);
|
||||
colorData.readNBT(nbt);
|
||||
combatData.readNBT(nbt);
|
||||
|
||||
@@ -364,12 +364,12 @@ public class AbilityOrb extends Ability implements IAbilityOrb {
|
||||
|
||||
@Override
|
||||
public void readTypeNBT(NBTTagCompound nbt) {
|
||||
this.orbSize = nbt.hasKey("orbSize") ? nbt.getFloat("orbSize") : 1.0f;
|
||||
this.orbSize = nbt.getFloat("orbSize");
|
||||
|
||||
int count = nbt.hasKey("projectileCount") ? nbt.getInteger("projectileCount") : 1;
|
||||
int count = nbt.getInteger("projectileCount");
|
||||
initProjectiles(count);
|
||||
|
||||
this.fireDelay = nbt.hasKey("fireDelay") ? nbt.getInteger("fireDelay") : 0;
|
||||
this.fireDelay = nbt.getInteger("fireDelay");
|
||||
|
||||
// Shared combat/movement data
|
||||
combatData.readNBT(nbt);
|
||||
|
||||
@@ -273,14 +273,14 @@ public class AbilityProjectile extends Ability implements IAbilityProjectile {
|
||||
|
||||
@Override
|
||||
public void readTypeNBT(NBTTagCompound nbt) {
|
||||
this.damage = nbt.hasKey("damage") ? nbt.getFloat("damage") : 6.0f;
|
||||
this.speed = nbt.hasKey("speed") ? nbt.getFloat("speed") : 1.5f;
|
||||
this.knockback = nbt.hasKey("knockback") ? nbt.getFloat("knockback") : 0.5f;
|
||||
this.projectileType = nbt.hasKey("projectileType") ? nbt.getString("projectileType") : "fireball";
|
||||
this.explosive = nbt.hasKey("explosive") && nbt.getBoolean("explosive");
|
||||
this.explosionRadius = nbt.hasKey("explosionRadius") ? nbt.getFloat("explosionRadius") : 0.0f;
|
||||
this.homing = nbt.hasKey("homing") && nbt.getBoolean("homing");
|
||||
this.homingStrength = nbt.hasKey("homingStrength") ? nbt.getFloat("homingStrength") : 0.1f;
|
||||
this.damage = nbt.getFloat("damage");
|
||||
this.speed = nbt.getFloat("speed");
|
||||
this.knockback = nbt.getFloat("knockback");
|
||||
this.projectileType = nbt.getString("projectileType");
|
||||
this.explosive = nbt.getBoolean("explosive");
|
||||
this.explosionRadius = nbt.getFloat("explosionRadius");
|
||||
this.homing = nbt.getBoolean("homing");
|
||||
this.homingStrength = nbt.getFloat("homingStrength");
|
||||
}
|
||||
|
||||
// Getters & Setters
|
||||
|
||||
@@ -127,10 +127,10 @@ public class AbilityShockwave extends Ability implements IAbilityShockwave {
|
||||
|
||||
@Override
|
||||
public void readTypeNBT(NBTTagCompound nbt) {
|
||||
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.maxTargets = nbt.hasKey("maxTargets") ? nbt.getInteger("maxTargets") : 10;
|
||||
this.pushRadius = nbt.getFloat("pushRadius");
|
||||
this.pushStrength = nbt.getFloat("pushStrength");
|
||||
this.damage = nbt.getFloat("damage");
|
||||
this.maxTargets = nbt.getInteger("maxTargets");
|
||||
}
|
||||
|
||||
// Getters & Setters
|
||||
|
||||
@@ -509,11 +509,11 @@ public class AbilitySlam extends Ability implements IAbilitySlam {
|
||||
|
||||
@Override
|
||||
public void readTypeNBT(NBTTagCompound nbt) {
|
||||
damage = nbt.hasKey("damage") ? nbt.getFloat("damage") : 10.0f;
|
||||
radius = nbt.hasKey("radius") ? nbt.getFloat("radius") : 5.0f;
|
||||
knockbackStrength = nbt.hasKey("knockback") ? nbt.getFloat("knockback") : 1.5f;
|
||||
leapSpeed = nbt.hasKey("leapSpeed") ? nbt.getFloat("leapSpeed") : 1.0f;
|
||||
leapHeight = nbt.hasKey("leapHeight") ? nbt.getFloat("leapHeight") : 4.0f;
|
||||
damage = nbt.getFloat("damage");
|
||||
radius = nbt.getFloat("radius");
|
||||
knockbackStrength = nbt.getFloat("knockback");
|
||||
leapSpeed = nbt.getFloat("leapSpeed");
|
||||
leapHeight = nbt.getFloat("leapHeight");
|
||||
}
|
||||
|
||||
// Getters & Setters
|
||||
|
||||
@@ -172,15 +172,15 @@ public class AbilitySweeper extends Ability implements IAbilitySweeper {
|
||||
|
||||
@Override
|
||||
public void readTypeNBT(NBTTagCompound nbt) {
|
||||
this.beamLength = nbt.hasKey("beamLength") ? nbt.getFloat("beamLength") : 10.0f;
|
||||
this.beamWidth = nbt.hasKey("beamWidth") ? nbt.getFloat("beamWidth") : 0.3f;
|
||||
this.beamHeight = nbt.hasKey("beamHeight") ? nbt.getFloat("beamHeight") : 0.5f;
|
||||
this.damage = nbt.hasKey("damage") ? nbt.getFloat("damage") : 5.0f;
|
||||
this.damageInterval = nbt.hasKey("damageInterval") ? nbt.getInteger("damageInterval") : 5;
|
||||
this.piercing = !nbt.hasKey("piercing") || nbt.getBoolean("piercing");
|
||||
this.sweepSpeed = nbt.hasKey("sweepSpeed") ? nbt.getFloat("sweepSpeed") : 3.0f;
|
||||
this.numberOfRotations = nbt.hasKey("numberOfRotations") ? nbt.getInteger("numberOfRotations") : 2;
|
||||
this.lockOnTarget = nbt.hasKey("lockOnTarget") && nbt.getBoolean("lockOnTarget");
|
||||
this.beamLength = nbt.getFloat("beamLength");
|
||||
this.beamWidth = nbt.getFloat("beamWidth");
|
||||
this.beamHeight = nbt.getFloat("beamHeight");
|
||||
this.damage = nbt.getFloat("damage");
|
||||
this.damageInterval = nbt.getInteger("damageInterval");
|
||||
this.piercing = nbt.getBoolean("piercing");
|
||||
this.sweepSpeed = nbt.getFloat("sweepSpeed");
|
||||
this.numberOfRotations = nbt.getInteger("numberOfRotations");
|
||||
this.lockOnTarget = nbt.getBoolean("lockOnTarget");
|
||||
colorData.readNBT(nbt);
|
||||
}
|
||||
|
||||
|
||||
@@ -430,24 +430,20 @@ public class AbilityTeleport extends Ability implements IAbilityTeleport {
|
||||
|
||||
@Override
|
||||
public void readTypeNBT(NBTTagCompound nbt) {
|
||||
if (nbt.hasKey("mode")) {
|
||||
try {
|
||||
this.mode = TeleportMode.valueOf(nbt.getString("mode"));
|
||||
} catch (Exception e) {
|
||||
this.mode = TeleportMode.BLINK;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
this.mode = TeleportMode.valueOf(nbt.getString("mode"));
|
||||
} catch (Exception e) {
|
||||
this.mode = TeleportMode.BLINK;
|
||||
}
|
||||
this.blinkCount = nbt.hasKey("blinkCount") ? nbt.getInteger("blinkCount") : 3;
|
||||
this.blinkDelayTicks = nbt.hasKey("blinkDelayTicks") ? nbt.getInteger("blinkDelayTicks") : 10;
|
||||
this.blinkRadius = nbt.hasKey("blinkRadius") ? nbt.getFloat("blinkRadius") : 8.0f;
|
||||
this.behindDistance = nbt.hasKey("behindDistance") ? nbt.getFloat("behindDistance") : 2.0f;
|
||||
this.requireLineOfSight = !nbt.hasKey("requireLineOfSight") || nbt.getBoolean("requireLineOfSight");
|
||||
this.damageAtStart = nbt.hasKey("damageAtStart") && nbt.getBoolean("damageAtStart");
|
||||
this.damageAtEnd = nbt.hasKey("damageAtEnd") && nbt.getBoolean("damageAtEnd");
|
||||
this.damage = nbt.hasKey("damage") ? nbt.getFloat("damage") : 5.0f;
|
||||
this.damageRadius = nbt.hasKey("damageRadius") ? nbt.getFloat("damageRadius") : 2.0f;
|
||||
this.blinkCount = nbt.getInteger("blinkCount");
|
||||
this.blinkDelayTicks = nbt.getInteger("blinkDelayTicks");
|
||||
this.blinkRadius = nbt.getFloat("blinkRadius");
|
||||
this.behindDistance = nbt.getFloat("behindDistance");
|
||||
this.requireLineOfSight = nbt.getBoolean("requireLineOfSight");
|
||||
this.damageAtStart = nbt.getBoolean("damageAtStart");
|
||||
this.damageAtEnd = nbt.getBoolean("damageAtEnd");
|
||||
this.damage = nbt.getFloat("damage");
|
||||
this.damageRadius = nbt.getFloat("damageRadius");
|
||||
}
|
||||
|
||||
// Getters & Setters
|
||||
|
||||
@@ -119,14 +119,14 @@ public class AbilityTrap extends AbilityZone implements IAbilityTrap {
|
||||
@Override
|
||||
public void readTypeNBT(NBTTagCompound nbt) {
|
||||
readZoneNBT(nbt, 300);
|
||||
this.triggerRadius = nbt.hasKey("triggerRadius") ? nbt.getFloat("triggerRadius") : 2.0f;
|
||||
this.armTime = nbt.hasKey("armTime") ? nbt.getInteger("armTime") : 20;
|
||||
this.maxTriggers = nbt.hasKey("maxTriggers") ? nbt.getInteger("maxTriggers") : 1;
|
||||
this.triggerCooldown = nbt.hasKey("triggerCooldown") ? nbt.getInteger("triggerCooldown") : 20;
|
||||
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.visible = !nbt.hasKey("visible") || nbt.getBoolean("visible");
|
||||
this.triggerRadius = nbt.getFloat("triggerRadius");
|
||||
this.armTime = nbt.getInteger("armTime");
|
||||
this.maxTriggers = nbt.getInteger("maxTriggers");
|
||||
this.triggerCooldown = nbt.getInteger("triggerCooldown");
|
||||
this.damage = nbt.getFloat("damage");
|
||||
this.damageRadius = nbt.getFloat("damageRadius");
|
||||
this.knockback = nbt.getFloat("knockback");
|
||||
this.visible = nbt.getBoolean("visible");
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
@@ -236,14 +236,14 @@ public class AbilityVortex extends Ability implements IAbilityVortex {
|
||||
|
||||
@Override
|
||||
public void readTypeNBT(NBTTagCompound nbt) {
|
||||
this.pullRadius = nbt.hasKey("pullRadius") ? nbt.getFloat("pullRadius") : 8.0f;
|
||||
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.aoe = nbt.hasKey("aoe") && nbt.getBoolean("aoe");
|
||||
this.maxTargets = nbt.hasKey("maxTargets") ? nbt.getInteger("maxTargets") : 5;
|
||||
this.damageOnPull = nbt.hasKey("damageOnPull") && nbt.getBoolean("damageOnPull");
|
||||
this.pullDamage = nbt.hasKey("pullDamage") ? nbt.getFloat("pullDamage") : 0.0f;
|
||||
this.pullRadius = nbt.getFloat("pullRadius");
|
||||
this.pullStrength = nbt.getFloat("pullStrength");
|
||||
this.damage = nbt.getFloat("damage");
|
||||
this.knockback = nbt.getFloat("knockback");
|
||||
this.aoe = nbt.getBoolean("aoe");
|
||||
this.maxTargets = nbt.getInteger("maxTargets");
|
||||
this.damageOnPull = nbt.getBoolean("damageOnPull");
|
||||
this.pullDamage = nbt.getFloat("pullDamage");
|
||||
}
|
||||
|
||||
// Getters & Setters
|
||||
|
||||
@@ -15,6 +15,7 @@ import kamkeel.npcs.entity.EntityAbilityZone.ParticleMotion;
|
||||
import kamkeel.npcs.entity.EntityAbilityZone.ZoneShape;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.constants.EnumPotionType;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -255,7 +256,7 @@ public abstract class AbilityZone extends Ability {
|
||||
particleMotion = 1; particleGlow = true; particleDir = "mc:mobSpell";
|
||||
colorData.innerColor = 0x44DD44; colorData.outerColor = 0x116611;
|
||||
windUpColor = 0x6044DD44; activeColor = 0xC044FF44;
|
||||
effects.add(new AbilityEffect(AbilityEffect.EffectType.POISON, 100, 0));
|
||||
effects.add(new AbilityEffect(EnumPotionType.Poison, 100, 0));
|
||||
break;
|
||||
case "INFERNO":
|
||||
groundFill = true; groundAlpha = 0.35f; rings = true; ringCount = 3;
|
||||
@@ -264,7 +265,7 @@ public abstract class AbilityZone extends Ability {
|
||||
particleMotion = 0; particleGlow = true; particleDir = "mc:flame";
|
||||
colorData.innerColor = 0xFF6611; colorData.outerColor = 0xCC2200;
|
||||
windUpColor = 0x60FF6611; activeColor = 0xC0FF4400;
|
||||
effects.add(new AbilityEffect(AbilityEffect.EffectType.BURN, 60, 0));
|
||||
effects.add(new AbilityEffect(EnumPotionType.Fire, 60, 0));
|
||||
break;
|
||||
case "ARCANE":
|
||||
groundFill = true; groundAlpha = 0.20f; rings = true; ringCount = 1;
|
||||
@@ -273,7 +274,7 @@ public abstract class AbilityZone extends Ability {
|
||||
particleMotion = 1; particleGlow = true; particleDir = "mc:portal";
|
||||
colorData.innerColor = 0xAA44FF; colorData.outerColor = 0x6622BB;
|
||||
windUpColor = 0x60AA44FF; activeColor = 0xC0CC66FF;
|
||||
effects.add(new AbilityEffect(AbilityEffect.EffectType.WEAKNESS, 100, 0));
|
||||
effects.add(new AbilityEffect(EnumPotionType.Weakness, 100, 0));
|
||||
break;
|
||||
case "ELECTRIC":
|
||||
groundFill = true; groundAlpha = 0.15f; rings = false; ringCount = 1;
|
||||
@@ -282,7 +283,7 @@ public abstract class AbilityZone extends Ability {
|
||||
particleMotion = 2; particleGlow = true; particleDir = "mc:enchantmenttable";
|
||||
colorData.innerColor = 0x4488FF; colorData.outerColor = 0x2244BB;
|
||||
windUpColor = 0x604488FF; activeColor = 0xC066AAFF;
|
||||
effects.add(new AbilityEffect(AbilityEffect.EffectType.MINING_FATIGUE, 80, 1));
|
||||
effects.add(new AbilityEffect(EnumPotionType.MiningFatigue, 80, 1));
|
||||
break;
|
||||
case "FROST":
|
||||
groundFill = true; groundAlpha = 0.25f; rings = true; ringCount = 3;
|
||||
@@ -291,7 +292,7 @@ public abstract class AbilityZone extends Ability {
|
||||
particleMotion = 1; particleGlow = true; particleDir = "mc:snowshovel";
|
||||
colorData.innerColor = 0x88CCFF; colorData.outerColor = 0x4488CC;
|
||||
windUpColor = 0x6088CCFF; activeColor = 0xC0AADDFF;
|
||||
effects.add(new AbilityEffect(AbilityEffect.EffectType.SLOWNESS, 100, 1));
|
||||
effects.add(new AbilityEffect(EnumPotionType.Slowness, 100, 1));
|
||||
break;
|
||||
case "DEFAULT":
|
||||
groundFill = true; groundAlpha = 0.25f; rings = true; ringCount = 3;
|
||||
@@ -354,37 +355,33 @@ public abstract class AbilityZone extends Ability {
|
||||
}
|
||||
|
||||
protected void readZoneNBT(NBTTagCompound nbt, int defaultDuration) {
|
||||
this.durationTicks = nbt.hasKey("durationTicks") ? nbt.getInteger("durationTicks") : defaultDuration;
|
||||
if (nbt.hasKey("zoneShape")) {
|
||||
try { this.zoneShape = ZoneShape.valueOf(nbt.getString("zoneShape")); }
|
||||
catch (Exception e) { this.zoneShape = ZoneShape.CIRCLE; }
|
||||
} else {
|
||||
this.zoneShape = ZoneShape.CIRCLE;
|
||||
}
|
||||
this.spawnRadius = nbt.hasKey("spawnRadius") ? nbt.getFloat("spawnRadius") : 10.0f;
|
||||
this.zoneCount = nbt.hasKey("zoneCount") ? nbt.getInteger("zoneCount") : 3;
|
||||
this.zoneHeight = nbt.hasKey("zoneHeight") ? nbt.getFloat("zoneHeight") : 2.0f;
|
||||
this.particleDensity = nbt.hasKey("particleDensity") ? nbt.getFloat("particleDensity") : 1.0f;
|
||||
this.particleScale = nbt.hasKey("particleScale") ? nbt.getFloat("particleScale") : 1.0f;
|
||||
this.animSpeed = nbt.hasKey("animSpeed") ? nbt.getFloat("animSpeed") : 1.0f;
|
||||
this.lightningDensity = nbt.hasKey("lightningDensity") ? nbt.getFloat("lightningDensity") : 1.0f;
|
||||
this.durationTicks = nbt.getInteger("durationTicks");
|
||||
try { this.zoneShape = ZoneShape.valueOf(nbt.getString("zoneShape")); }
|
||||
catch (Exception e) { this.zoneShape = ZoneShape.CIRCLE; }
|
||||
this.spawnRadius = nbt.getFloat("spawnRadius");
|
||||
this.zoneCount = nbt.getInteger("zoneCount");
|
||||
this.zoneHeight = nbt.getFloat("zoneHeight");
|
||||
this.particleDensity = nbt.getFloat("particleDensity");
|
||||
this.particleScale = nbt.getFloat("particleScale");
|
||||
this.animSpeed = nbt.getFloat("animSpeed");
|
||||
this.lightningDensity = nbt.getFloat("lightningDensity");
|
||||
colorData.readNBT(nbt);
|
||||
|
||||
// Visual layer fields
|
||||
this.groundFill = !nbt.hasKey("groundFill") || nbt.getBoolean("groundFill");
|
||||
this.groundAlpha = nbt.hasKey("groundAlpha") ? nbt.getFloat("groundAlpha") : 0.25f;
|
||||
this.rings = !nbt.hasKey("rings") || nbt.getBoolean("rings");
|
||||
this.ringCount = nbt.hasKey("ringCount") ? nbt.getInteger("ringCount") : 3;
|
||||
this.border = !nbt.hasKey("border") || nbt.getBoolean("border");
|
||||
this.borderSpeed = nbt.hasKey("borderSpeed") ? nbt.getFloat("borderSpeed") : 1.0f;
|
||||
this.accents = !nbt.hasKey("accents") || nbt.getBoolean("accents");
|
||||
this.accentStyle = nbt.hasKey("accentStyle") ? nbt.getInteger("accentStyle") : 0;
|
||||
this.lightning = nbt.hasKey("lightning") && nbt.getBoolean("lightning");
|
||||
this.particles = !nbt.hasKey("particles") || nbt.getBoolean("particles");
|
||||
this.particleMotion = nbt.hasKey("particleMotion") ? nbt.getInteger("particleMotion") : 0;
|
||||
this.particleDir = nbt.hasKey("particleDir") ? nbt.getString("particleDir") : "";
|
||||
this.particleSize = nbt.hasKey("particleSize") ? nbt.getInteger("particleSize") : 32;
|
||||
this.particleGlow = !nbt.hasKey("particleGlow") || nbt.getBoolean("particleGlow");
|
||||
this.groundFill = nbt.getBoolean("groundFill");
|
||||
this.groundAlpha = nbt.getFloat("groundAlpha");
|
||||
this.rings = nbt.getBoolean("rings");
|
||||
this.ringCount = nbt.getInteger("ringCount");
|
||||
this.border = nbt.getBoolean("border");
|
||||
this.borderSpeed = nbt.getFloat("borderSpeed");
|
||||
this.accents = nbt.getBoolean("accents");
|
||||
this.accentStyle = nbt.getInteger("accentStyle");
|
||||
this.lightning = nbt.getBoolean("lightning");
|
||||
this.particles = nbt.getBoolean("particles");
|
||||
this.particleMotion = nbt.getInteger("particleMotion");
|
||||
this.particleDir = nbt.getString("particleDir");
|
||||
this.particleSize = nbt.getInteger("particleSize");
|
||||
this.particleGlow = nbt.getBoolean("particleGlow");
|
||||
}
|
||||
|
||||
// ═════════════════════════════════════════════════════════════════
|
||||
|
||||
@@ -20,6 +20,7 @@ public class DataStats {
|
||||
public EnumPotionType potionType = EnumPotionType.None;
|
||||
public int potionDuration = 5; //20 = 1 second
|
||||
public int potionAmp = 0;
|
||||
public int potionManualId = 0;
|
||||
|
||||
public double maxHealth = 20;
|
||||
public int respawnTime = 20;
|
||||
@@ -45,6 +46,7 @@ public class DataStats {
|
||||
public boolean pPhysics = true, pXlr8 = false, pGlows = false, pExplode = false;
|
||||
public boolean pRender3D = false, pSpin = false, pStick = false, pBurnItem = false;
|
||||
public EnumPotionType pEffect = EnumPotionType.None;
|
||||
public int pManualId = 0;
|
||||
public EnumParticleType pTrail = EnumParticleType.None;
|
||||
public ScriptParticle pCustom = new ScriptParticle("");
|
||||
public int pEffAmp = 0;
|
||||
@@ -88,6 +90,8 @@ public class DataStats {
|
||||
compound.setInteger("PotionEffect", potionType.ordinal());
|
||||
compound.setInteger("PotionDuration", potionDuration);
|
||||
compound.setInteger("PotionAmp", potionAmp);
|
||||
if (potionType == EnumPotionType.Manual)
|
||||
compound.setInteger("PotionManualId", potionManualId);
|
||||
|
||||
compound.setInteger("MaxFiringRange", rangedRange);
|
||||
compound.setInteger("FireRate", fireRate);
|
||||
@@ -122,6 +126,8 @@ public class DataStats {
|
||||
compound.setTag("pCustom", pCustom.writeToNBT());
|
||||
if (pEffect == EnumPotionType.Fire)
|
||||
compound.setBoolean("pBurnItem", pBurnItem);
|
||||
if (pEffect == EnumPotionType.Manual)
|
||||
compound.setInteger("pManualId", pManualId);
|
||||
|
||||
compound.setBoolean("ImmuneToFire", immuneToFire);
|
||||
compound.setBoolean("PotionImmune", potionImmune);
|
||||
@@ -145,7 +151,7 @@ public class DataStats {
|
||||
aggroRange = compound.getInteger("AggroRange");
|
||||
respawnTime = compound.getInteger("RespawnTime");
|
||||
spawnCycle = compound.getInteger("SpawnCycle");
|
||||
creatureType = EnumCreatureAttribute.values()[compound.getInteger("CreatureType") % EnumPotionType.values().length];
|
||||
creatureType = EnumCreatureAttribute.values()[compound.getInteger("CreatureType") % EnumCreatureAttribute.values().length];
|
||||
ignoreCobweb = compound.getBoolean("IgnoreCobweb");
|
||||
healthRegen = compound.getFloat("HealthRegen");
|
||||
combatRegen = compound.getFloat("CombatRegen");
|
||||
@@ -155,9 +161,11 @@ public class DataStats {
|
||||
swingWarmUp = ValueUtil.clamp(compound.getInteger("SwingWarmup"), 0, 1000);
|
||||
attackRange = compound.getInteger("AttackRange");
|
||||
knockback = compound.getInteger("KnockBack");
|
||||
potionType = EnumPotionType.values()[compound.getInteger("PotionEffect") % EnumPotionType.values().length];
|
||||
potionType = EnumPotionType.fromOrdinal(compound.getInteger("PotionEffect"));
|
||||
potionDuration = compound.getInteger("PotionDuration");
|
||||
potionAmp = compound.getInteger("PotionAmp");
|
||||
if (potionType == EnumPotionType.Manual)
|
||||
potionManualId = compound.getInteger("PotionManualId");
|
||||
|
||||
rangedRange = compound.getInteger("MaxFiringRange");
|
||||
fireRate = compound.getInteger("FireRate");
|
||||
@@ -180,7 +188,7 @@ public class DataStats {
|
||||
pRender3D = compound.getBoolean("pRender3D");
|
||||
pSpin = compound.getBoolean("pSpin");
|
||||
pStick = compound.getBoolean("pStick");
|
||||
pEffect = EnumPotionType.values()[compound.getInteger("pEffect") % EnumPotionType.values().length];
|
||||
pEffect = EnumPotionType.fromOrdinal(compound.getInteger("pEffect"));
|
||||
pTrail = EnumParticleType.values()[compound.getInteger("pTrail") % EnumParticleType.values().length];
|
||||
pEffAmp = compound.getInteger("pEffAmp");
|
||||
fireSound = compound.getString("FiringSound");
|
||||
@@ -195,6 +203,8 @@ public class DataStats {
|
||||
pCustom = ScriptParticle.fromNBT(compound.getCompoundTag("pCustom"));
|
||||
if (pEffect == EnumPotionType.Fire)
|
||||
pBurnItem = compound.getBoolean("pBurnItem");
|
||||
if (pEffect == EnumPotionType.Manual)
|
||||
pManualId = compound.getInteger("pManualId");
|
||||
|
||||
immuneToFire = compound.getBoolean("ImmuneToFire");
|
||||
potionImmune = compound.getBoolean("PotionImmune");
|
||||
|
||||
@@ -12,7 +12,6 @@ import noppes.npcs.constants.EnumPotionType;
|
||||
|
||||
public class SubGuiNpcMeleeProperties extends SubGuiInterface implements ITextfieldListener {
|
||||
private DataStats stats;
|
||||
private String[] potionNames = new String[]{"gui.none", "tile.fire.name", "potion.poison", "potion.hunger", "potion.weakness", "potion.moveSlowdown", "potion.confusion", "potion.blindness", "potion.wither"};
|
||||
|
||||
public SubGuiNpcMeleeProperties(DataStats stats) {
|
||||
this.stats = stats;
|
||||
@@ -42,18 +41,28 @@ public class SubGuiNpcMeleeProperties extends SubGuiInterface implements ITextfi
|
||||
getTextField(4).integersOnly = true;
|
||||
getTextField(4).setMinMaxDefault(0, Integer.MAX_VALUE, 0);
|
||||
addLabel(new GuiNpcLabel(5, "stats.meleeeffect", guiLeft + 5, guiTop + 135));
|
||||
addButton(new GuiButtonBiDirectional(5, guiLeft + 85, guiTop + 130, 100, 20, potionNames, stats.potionType.ordinal()));
|
||||
addButton(new GuiButtonBiDirectional(5, guiLeft + 85, guiTop + 130, 100, 20, EnumPotionType.getLangKeys(), stats.potionType.ordinal()));
|
||||
if (stats.potionType == EnumPotionType.Manual) {
|
||||
addLabel(new GuiNpcLabel(8, "effect.potionid", guiLeft + 198, guiTop + 119));
|
||||
addTextField(new GuiNpcTextField(8, this, fontRendererObj, guiLeft + 200, guiTop + 132, 40, 18, stats.potionManualId + ""));
|
||||
getTextField(8).integersOnly = true;
|
||||
getTextField(8).setMinMaxDefault(0, Integer.MAX_VALUE, 0);
|
||||
}
|
||||
|
||||
int y = guiTop + 160;
|
||||
if (stats.potionType != EnumPotionType.None) {
|
||||
addLabel(new GuiNpcLabel(6, "gui.time", guiLeft + 5, guiTop + 165));
|
||||
addTextField(new GuiNpcTextField(6, this, fontRendererObj, guiLeft + 85, guiTop + 160, 40, 18, stats.potionDuration + ""));
|
||||
addLabel(new GuiNpcLabel(6, "gui.time", guiLeft + 5, y + 5));
|
||||
addTextField(new GuiNpcTextField(6, this, fontRendererObj, guiLeft + 85, y, 40, 18, stats.potionDuration + ""));
|
||||
getTextField(6).integersOnly = true;
|
||||
getTextField(6).setMinMaxDefault(1, Integer.MAX_VALUE, 5);
|
||||
if (stats.potionType != EnumPotionType.Fire) {
|
||||
addLabel(new GuiNpcLabel(7, "stats.amplify", guiLeft + 5, guiTop + 195));
|
||||
addButton(new GuiButtonBiDirectional(7, guiLeft + 85, guiTop + 190, 52, 20, new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}, stats.potionAmp));
|
||||
y += 30;
|
||||
addLabel(new GuiNpcLabel(7, "stats.amplify", guiLeft + 5, y + 5));
|
||||
addButton(new GuiButtonBiDirectional(7, guiLeft + 85, y, 52, 20, new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}, stats.potionAmp));
|
||||
}
|
||||
}
|
||||
addButton(new GuiNpcButton(66, guiLeft + 190, guiTop + 190, 60, 20, "gui.done"));
|
||||
|
||||
addButton(new GuiNpcButton(66, guiLeft + 190, guiTop + ySize - 26, 60, 20, "gui.done"));
|
||||
}
|
||||
|
||||
public void unFocused(GuiNpcTextField textfield) {
|
||||
@@ -67,13 +76,15 @@ public class SubGuiNpcMeleeProperties extends SubGuiInterface implements ITextfi
|
||||
stats.knockback = textfield.getInteger();
|
||||
} else if (textfield.id == 6) {
|
||||
stats.potionDuration = textfield.getInteger();
|
||||
} else if (textfield.id == 8) {
|
||||
stats.potionManualId = textfield.getInteger();
|
||||
}
|
||||
}
|
||||
|
||||
protected void actionPerformed(GuiButton guibutton) {
|
||||
GuiNpcButton button = (GuiNpcButton) guibutton;
|
||||
if (button.id == 5) {
|
||||
stats.potionType = EnumPotionType.values()[button.getValue()];
|
||||
stats.potionType = EnumPotionType.fromOrdinal(button.getValue());
|
||||
initGui();
|
||||
}
|
||||
if (button.id == 7) {
|
||||
|
||||
@@ -15,7 +15,6 @@ import noppes.npcs.constants.EnumPotionType;
|
||||
|
||||
public class SubGuiNpcProjectiles extends SubGuiInterface implements ITextfieldListener, ISubGuiListener {
|
||||
private DataStats stats;
|
||||
private String[] potionNames = new String[]{"gui.none", "tile.fire.name", "potion.poison", "potion.hunger", "potion.weakness", "potion.moveSlowdown", "potion.confusion", "potion.blindness", "potion.wither"};
|
||||
private String[] trailNames = new String[]{"gui.none", "trail.smoke", "trail.portal", "trail.redstone",
|
||||
"trail.lightning", "trail.largesmoke", "trail.magic", "trail.enchant", "trail.crit",
|
||||
"trail.explode", "trail.music", "trail.flame", "trail.lava", "trail.splash",
|
||||
@@ -76,22 +75,29 @@ public class SubGuiNpcProjectiles extends SubGuiInterface implements ITextfieldL
|
||||
}
|
||||
|
||||
addLabel(new GuiNpcLabel(7, "stats.rangedeffect", guiLeft + 210, y + 5));
|
||||
addButton(new GuiButtonBiDirectional(4, guiLeft + 280, y, 100, 20, potionNames, stats.pEffect.ordinal()));
|
||||
addButton(new GuiButtonBiDirectional(4, guiLeft + 280, y, 100, 20, EnumPotionType.getLangKeys(), stats.pEffect.ordinal()));
|
||||
|
||||
if (stats.pEffect != EnumPotionType.None) {
|
||||
int internalY = y + 30;
|
||||
if (stats.pEffect == EnumPotionType.Manual) {
|
||||
addLabel(new GuiNpcLabel(110, "effect.potionid", guiLeft + 210, internalY + 5));
|
||||
addTextField(new GuiNpcTextField(11, this, fontRendererObj, guiLeft + 330, internalY, 52, 20, stats.pManualId + ""));
|
||||
getTextField(11).integersOnly = true;
|
||||
getTextField(11).setMinMaxDefault(0, Integer.MAX_VALUE, 0);
|
||||
internalY += 30;
|
||||
}
|
||||
addLabel(new GuiNpcLabel(50, "gui.time", guiLeft + 210, internalY + 5));
|
||||
addTextField(new GuiNpcTextField(5, this, fontRendererObj, guiLeft + 330, internalY, 52, 20, stats.pDur + ""));
|
||||
getTextField(5).integersOnly = true;
|
||||
getTextField(5).setMinMaxDefault(1, Integer.MAX_VALUE, 5);
|
||||
if (stats.pEffect != EnumPotionType.Fire) {
|
||||
internalY += 30;
|
||||
addLabel(new GuiNpcLabel(70, "stats.amplify", guiLeft + 210, internalY + 5));
|
||||
addButton(new GuiButtonBiDirectional(10, guiLeft + 280, internalY, 52, 20, new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}, stats.pEffAmp));
|
||||
} else {
|
||||
if (stats.pEffect == EnumPotionType.Fire) {
|
||||
internalY += 30;
|
||||
addLabel(new GuiNpcLabel(100, "stats.burnItem", guiLeft + 210, internalY + 5));
|
||||
addButton(new GuiNpcButtonYesNo(100, guiLeft + 330, internalY, 52, 20, stats.pBurnItem));
|
||||
} else {
|
||||
internalY += 30;
|
||||
addLabel(new GuiNpcLabel(70, "stats.amplify", guiLeft + 210, internalY + 5));
|
||||
addButton(new GuiButtonBiDirectional(10, guiLeft + 280, internalY, 52, 20, new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}, stats.pEffAmp));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,6 +132,8 @@ public class SubGuiNpcProjectiles extends SubGuiInterface implements ITextfieldL
|
||||
stats.pSpeed = textfield.getInteger();
|
||||
} else if (textfield.id == 5) {
|
||||
stats.pDur = textfield.getInteger();
|
||||
} else if (textfield.id == 11) {
|
||||
stats.pManualId = textfield.getInteger();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +154,7 @@ public class SubGuiNpcProjectiles extends SubGuiInterface implements ITextfieldL
|
||||
stats.pArea = button.getValue();
|
||||
}
|
||||
if (button.id == 4) {
|
||||
stats.pEffect = EnumPotionType.values()[button.getValue()];
|
||||
stats.pEffect = EnumPotionType.fromOrdinal(button.getValue());
|
||||
initGui();
|
||||
}
|
||||
if (button.id == 5) {
|
||||
|
||||
@@ -440,8 +440,7 @@ public abstract class GuiNPCInterface extends GuiScreen {
|
||||
int bottomHeight = 0;
|
||||
int bottomTextureV = 0;
|
||||
if (ySize < bgTextureHeight) {
|
||||
// Keep bottom border from texture bottom (last 6 pixels of actual content)
|
||||
bottomHeight = 6;
|
||||
bottomHeight = -1;
|
||||
topHeight = ySize - bottomHeight;
|
||||
bottomTextureV = bgTextureHeight - bottomHeight;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,83 @@
|
||||
package noppes.npcs.constants;
|
||||
|
||||
import net.minecraft.potion.Potion;
|
||||
|
||||
public enum EnumPotionType {
|
||||
None, Fire, Poison, Hunger, Weakness, Slowness, Nausea, Blindness, Wither;
|
||||
None("gui.none", -1),
|
||||
Fire("tile.fire.name", -1),
|
||||
Poison("potion.poison", Potion.poison.id),
|
||||
Hunger("potion.hunger", Potion.hunger.id),
|
||||
Weakness("potion.weakness", Potion.weakness.id),
|
||||
Slowness("potion.moveSlowdown", Potion.moveSlowdown.id),
|
||||
Nausea("potion.confusion", Potion.confusion.id),
|
||||
Blindness("potion.blindness", Potion.blindness.id),
|
||||
Wither("potion.wither", Potion.wither.id),
|
||||
MiningFatigue("potion.digSlowDown", Potion.digSlowdown.id),
|
||||
Manual("effect.manual", -1);
|
||||
|
||||
private final String langKey;
|
||||
private final int potionId;
|
||||
|
||||
EnumPotionType(String langKey, int potionId) {
|
||||
this.langKey = langKey;
|
||||
this.potionId = potionId;
|
||||
}
|
||||
|
||||
public String getLangKey() {
|
||||
return langKey;
|
||||
}
|
||||
|
||||
public int getPotionId() {
|
||||
return potionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the actual potion ID to apply.
|
||||
* For Manual type, returns the provided manualId.
|
||||
* For all others, returns the mapped potionId.
|
||||
*/
|
||||
public int getResolvedPotionId(int manualId) {
|
||||
if (this == Manual) return manualId;
|
||||
return potionId;
|
||||
}
|
||||
|
||||
public static String[] getLangKeys() {
|
||||
EnumPotionType[] types = values();
|
||||
String[] keys = new String[types.length];
|
||||
for (int i = 0; i < types.length; i++) keys[i] = types[i].langKey;
|
||||
return keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns lang keys excluding None. For use in effect lists where None is not a valid choice.
|
||||
*/
|
||||
public static String[] getLangKeysNoNone() {
|
||||
EnumPotionType[] types = values();
|
||||
String[] keys = new String[types.length - 1];
|
||||
for (int i = 1; i < types.length; i++) keys[i - 1] = types[i].langKey;
|
||||
return keys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps a 0-based index (excluding None) back to the corresponding EnumPotionType.
|
||||
* Index 0 = Fire, 1 = Poison, etc.
|
||||
*/
|
||||
public static EnumPotionType fromIndexNoNone(int index) {
|
||||
return fromOrdinal(index + 1);
|
||||
}
|
||||
|
||||
public static EnumPotionType fromOrdinal(int ordinal) {
|
||||
EnumPotionType[] values = values();
|
||||
if (ordinal >= 0 && ordinal < values.length) {
|
||||
return values[ordinal];
|
||||
}
|
||||
return None;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given potion ID is valid and registered in the Minecraft potion registry.
|
||||
*/
|
||||
public static boolean isValidPotionId(int id) {
|
||||
return id >= 0 && id < Potion.potionTypes.length && Potion.potionTypes[id] != null;
|
||||
}
|
||||
}
|
||||
@@ -384,11 +384,13 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
}
|
||||
}
|
||||
|
||||
if (stats.potionType != EnumPotionType.None) {
|
||||
if (stats.potionType != EnumPotionType.Fire)
|
||||
((EntityLivingBase) receiver).addPotionEffect(new PotionEffect(this.getPotionEffect(stats.potionType), stats.potionDuration * 20, stats.potionAmp));
|
||||
else
|
||||
receiver.setFire(stats.potionDuration);
|
||||
if (stats.potionType == EnumPotionType.Fire) {
|
||||
receiver.setFire(stats.potionDuration);
|
||||
} else if (stats.potionType != EnumPotionType.None) {
|
||||
int potionId = stats.potionType.getResolvedPotionId(stats.potionManualId);
|
||||
if (EnumPotionType.isValidPotionId(potionId)) {
|
||||
((EntityLivingBase) receiver).addPotionEffect(new PotionEffect(potionId, stats.potionDuration * 20, stats.potionAmp));
|
||||
}
|
||||
}
|
||||
return didAttack;
|
||||
}
|
||||
@@ -1043,29 +1045,6 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
return weight;
|
||||
}
|
||||
|
||||
/*
|
||||
* Used for getting the applied potion effect from dataStats.
|
||||
*/
|
||||
private int getPotionEffect(EnumPotionType p) {
|
||||
switch (p) {
|
||||
case Poison:
|
||||
return Potion.poison.id;
|
||||
case Hunger:
|
||||
return Potion.hunger.id;
|
||||
case Weakness:
|
||||
return Potion.weakness.id;
|
||||
case Slowness:
|
||||
return Potion.moveSlowdown.id;
|
||||
case Nausea:
|
||||
return Potion.confusion.id;
|
||||
case Blindness:
|
||||
return Potion.blindness.id;
|
||||
case Wither:
|
||||
return Potion.wither.id;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAir(int air) {
|
||||
|
||||
@@ -94,6 +94,7 @@ public class EntityProjectile extends EntityThrowable {
|
||||
public boolean destroyTerrain = true;
|
||||
public int explosiveRadius = 0;
|
||||
public EnumPotionType effect = EnumPotionType.None;
|
||||
public int manualPotionId = 0;
|
||||
public boolean burnItem = true;
|
||||
public int duration = 5;
|
||||
public int amplify = 0;
|
||||
@@ -508,12 +509,12 @@ public class EntityProjectile extends EntityThrowable {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.effect != EnumPotionType.None && entityliving != null) {
|
||||
if (this.effect != EnumPotionType.Fire) {
|
||||
int p = this.getPotionEffect(effect);
|
||||
entityliving.addPotionEffect(new PotionEffect(p, this.duration * 20, this.amplify));
|
||||
} else {
|
||||
movingobjectposition.entityHit.setFire(duration);
|
||||
if (this.effect == EnumPotionType.Fire && entityliving != null) {
|
||||
movingobjectposition.entityHit.setFire(duration);
|
||||
} else if (this.effect != EnumPotionType.None && entityliving != null) {
|
||||
int potionId = this.effect.getResolvedPotionId(this.manualPotionId);
|
||||
if (EnumPotionType.isValidPotionId(potionId)) {
|
||||
entityliving.addPotionEffect(new PotionEffect(potionId, this.duration * 20, this.amplify));
|
||||
}
|
||||
}
|
||||
} else if (this.hasGravity() && (this.isArrow() || this.sticksToWalls())) {
|
||||
@@ -637,21 +638,23 @@ public class EntityProjectile extends EntityThrowable {
|
||||
d1 = 1.0D;
|
||||
}
|
||||
|
||||
int i = this.getPotionEffect(effect);
|
||||
int potionId = this.effect.getResolvedPotionId(this.manualPotionId);
|
||||
|
||||
if (Potion.potionTypes[i].isInstant()) {
|
||||
Potion.potionTypes[i].affectEntity(this.getThrower(), entitylivingbase, this.amplify, d1);
|
||||
} else {
|
||||
int j = (int) (d1 * (double) this.duration + 0.5D);
|
||||
if (EnumPotionType.isValidPotionId(potionId)) {
|
||||
if (Potion.potionTypes[potionId].isInstant()) {
|
||||
Potion.potionTypes[potionId].affectEntity(this.getThrower(), entitylivingbase, this.amplify, d1);
|
||||
} else {
|
||||
int j = (int) (d1 * (double) this.duration + 0.5D);
|
||||
|
||||
if (j > 20) {
|
||||
entitylivingbase.addPotionEffect(new PotionEffect(i, j, this.amplify));
|
||||
if (j > 20) {
|
||||
entitylivingbase.addPotionEffect(new PotionEffect(potionId, j, this.amplify));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.worldObj.playAuxSFX(2002, (int) Math.round(this.posX), (int) Math.round(this.posY), (int) Math.round(this.posZ), this.getPotionColor(this.effect));
|
||||
this.worldObj.playAuxSFX(2002, (int) Math.round(this.posX), (int) Math.round(this.posY), (int) Math.round(this.posZ), this.getPotionColor());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -693,6 +696,8 @@ public class EntityProjectile extends EntityThrowable {
|
||||
par1NBTTagCompound.setBoolean("explosive", explosive);
|
||||
par1NBTTagCompound.setInteger("accuracy", accuracy);
|
||||
par1NBTTagCompound.setInteger("PotionEffect", effect.ordinal());
|
||||
if (effect == EnumPotionType.Manual)
|
||||
par1NBTTagCompound.setInteger("PotionManualId", manualPotionId);
|
||||
par1NBTTagCompound.setString("trail", this.dataWatcher.getWatchableObjectString(22));
|
||||
par1NBTTagCompound.setByte("Render3D", this.dataWatcher.getWatchableObjectByte(28));
|
||||
par1NBTTagCompound.setByte("Spins", this.dataWatcher.getWatchableObjectByte(29));
|
||||
@@ -723,7 +728,9 @@ public class EntityProjectile extends EntityThrowable {
|
||||
this.accelerate = par1NBTTagCompound.getBoolean("accelerate");
|
||||
this.explosive = par1NBTTagCompound.getBoolean("explosive");
|
||||
this.accuracy = par1NBTTagCompound.getInteger("accuracy");
|
||||
this.effect = EnumPotionType.values()[par1NBTTagCompound.getInteger("PotionEffect") % EnumPotionType.values().length];
|
||||
this.effect = EnumPotionType.fromOrdinal(par1NBTTagCompound.getInteger("PotionEffect"));
|
||||
if (effect == EnumPotionType.Manual)
|
||||
this.manualPotionId = par1NBTTagCompound.getInteger("PotionManualId");
|
||||
this.dataWatcher.updateObject(22, par1NBTTagCompound.getString("trail"));
|
||||
this.dataWatcher.updateObject(23, Integer.valueOf(par1NBTTagCompound.getInteger("size")));
|
||||
this.dataWatcher.updateObject(24, Byte.valueOf((byte) (par1NBTTagCompound.getBoolean("glows") ? 1 : 0)));
|
||||
@@ -774,46 +781,12 @@ public class EntityProjectile extends EntityThrowable {
|
||||
return this.thrower;
|
||||
}
|
||||
|
||||
private int getPotionEffect(EnumPotionType p) {
|
||||
switch (p) {
|
||||
case Poison:
|
||||
return Potion.poison.id;
|
||||
case Hunger:
|
||||
return Potion.hunger.id;
|
||||
case Weakness:
|
||||
return Potion.weakness.id;
|
||||
case Slowness:
|
||||
return Potion.moveSlowdown.id;
|
||||
case Nausea:
|
||||
return Potion.confusion.id;
|
||||
case Blindness:
|
||||
return Potion.blindness.id;
|
||||
case Wither:
|
||||
return Potion.wither.id;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private int getPotionColor(EnumPotionType p) {
|
||||
switch (p) {
|
||||
case Poison:
|
||||
return 32660;
|
||||
case Hunger:
|
||||
return 32660;
|
||||
case Weakness:
|
||||
return 32696;
|
||||
case Slowness:
|
||||
return 32698;
|
||||
case Nausea:
|
||||
return 32732;
|
||||
case Blindness:
|
||||
return Potion.blindness.id;
|
||||
case Wither:
|
||||
return 32732;
|
||||
default:
|
||||
return 0;
|
||||
private int getPotionColor() {
|
||||
int potionId = this.effect.getResolvedPotionId(this.manualPotionId);
|
||||
if (EnumPotionType.isValidPotionId(potionId)) {
|
||||
return Potion.potionTypes[potionId].getLiquidColor();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void getStatProperties(DataStats stats) {
|
||||
@@ -823,6 +796,7 @@ public class EntityProjectile extends EntityThrowable {
|
||||
this.explosive = stats.pExplode;
|
||||
this.explosiveRadius = stats.pArea;
|
||||
this.effect = stats.pEffect;
|
||||
this.manualPotionId = stats.pManualId;
|
||||
this.burnItem = stats.pBurnItem;
|
||||
this.duration = stats.pDur;
|
||||
this.amplify = stats.pEffAmp;
|
||||
|
||||
Reference in new issue
Block a user