mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-19 01:29:05 +00:00
Lots of Fixes
This commit is contained in:
1 parent
0ad15e674a
commit
61d08882a9
20 files changed
+55
-27
No files matched your search
@@ -395,7 +395,8 @@ public class AbilityController implements IAbilityHandler {
|
||||
|
||||
// Clean up online players' unlocked ability lists
|
||||
if (PlayerDataController.Instance != null) {
|
||||
for (PlayerData pData : PlayerDataController.Instance.getAllPlayerData()) {
|
||||
List<PlayerData> snapshot = new ArrayList<>(PlayerDataController.Instance.getAllPlayerData());
|
||||
for (PlayerData pData : snapshot) {
|
||||
if (pData.abilityData != null) {
|
||||
boolean changed = false;
|
||||
if (uuid != null && !uuid.isEmpty() && pData.abilityData.hasUnlockedAbility(uuid)) {
|
||||
@@ -437,7 +438,7 @@ public class AbilityController implements IAbilityHandler {
|
||||
return customAbilities;
|
||||
}
|
||||
|
||||
public void setCustomAbilities(Map<String, Ability> synced) {
|
||||
public synchronized void setCustomAbilities(Map<String, Ability> synced) {
|
||||
customAbilities.clear();
|
||||
customAbilitiesById.clear();
|
||||
customAbilities.putAll(synced);
|
||||
@@ -613,7 +614,8 @@ public class AbilityController implements IAbilityHandler {
|
||||
|
||||
// Clean up online players' unlocked ability lists (chain keys use "chain:" prefix)
|
||||
if (PlayerDataController.Instance != null) {
|
||||
for (PlayerData pData : PlayerDataController.Instance.getAllPlayerData()) {
|
||||
List<PlayerData> snapshot = new ArrayList<>(PlayerDataController.Instance.getAllPlayerData());
|
||||
for (PlayerData pData : snapshot) {
|
||||
if (pData.abilityData != null) {
|
||||
String chainKey = "chain:" + (uuid != null && !uuid.isEmpty() ? uuid : name);
|
||||
if (pData.abilityData.hasUnlockedAbility(chainKey)) {
|
||||
@@ -722,7 +724,7 @@ public class AbilityController implements IAbilityHandler {
|
||||
return chainedAbilityRevision;
|
||||
}
|
||||
|
||||
public void setChainedAbilities(Map<String, ChainedAbility> synced) {
|
||||
public synchronized void setChainedAbilities(Map<String, ChainedAbility> synced) {
|
||||
chainedAbilities.clear();
|
||||
chainedAbilitiesById.clear();
|
||||
chainedAbilities.putAll(synced);
|
||||
|
||||
@@ -1531,7 +1531,7 @@ public abstract class Ability implements IAbility, IAbilityAction {
|
||||
dazedAnimationId = nbt.hasKey("dazedAnimationId") ? nbt.getInteger("dazedAnimationId") : -1;
|
||||
windUpAnimationName = nbt.getString("windUpAnimationName");
|
||||
activeAnimationName = nbt.getString("activeAnimationName");
|
||||
dazedAnimationName = nbt.getString("dazedAnimationName");
|
||||
dazedAnimationName = nbt.hasKey("dazedAnimationName") ? nbt.getString("dazedAnimationName") : "Ability_Generic_Dazed";
|
||||
showTelegraph = nbt.hasKey("showTelegraph") ? nbt.getBoolean("showTelegraph") : true;
|
||||
try {
|
||||
telegraphType = TelegraphType.valueOf(nbt.getString("telegraphType"));
|
||||
@@ -2356,7 +2356,7 @@ public abstract class Ability implements IAbility, IAbilityAction {
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// SHIT FROM THE ASS
|
||||
// WINDUP DURATION CALCULATION
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
private int calculateWindupFromAnimation() {
|
||||
|
||||
@@ -308,6 +308,7 @@ public class AbilityAction {
|
||||
}
|
||||
|
||||
// Inline ability
|
||||
if (AbilityController.Instance == null) return null;
|
||||
Ability ability = AbilityController.Instance.fromNBT(nbt);
|
||||
if (ability == null) return null;
|
||||
return inline(ability);
|
||||
|
||||
@@ -126,7 +126,7 @@ public class CustomAbility extends Ability implements ICustomAbility {
|
||||
|
||||
@Override
|
||||
public void readTypeNBT(NBTTagCompound nbt) {
|
||||
this.durationTicks = nbt.getInteger("durationTicks");
|
||||
this.durationTicks = Math.max(0, nbt.getInteger("durationTicks"));
|
||||
}
|
||||
|
||||
// ==================== GUI ====================
|
||||
|
||||
+2
-2
@@ -76,7 +76,7 @@ public class ConditionHitCount extends AbilityCondition {
|
||||
|
||||
@Override
|
||||
public void readTypeNBT(NBTTagCompound nbt) {
|
||||
requiredHits = nbt.getInteger("requiredHits");
|
||||
withinTicks = nbt.getInteger("withinTicks");
|
||||
requiredHits = Math.max(0, nbt.getInteger("requiredHits"));
|
||||
withinTicks = Math.max(0, nbt.getInteger("withinTicks"));
|
||||
}
|
||||
}
|
||||
@@ -174,7 +174,7 @@ public class ConditionItem extends AbilityCondition {
|
||||
itemName = nbt.getString("itemName");
|
||||
usageType = UsageType.fromOrdinal(nbt.getInteger("usageType"));
|
||||
armorSlot = ArmorSlot.fromOrdinal(nbt.getInteger("armorSlot"));
|
||||
requiredCount = nbt.getInteger("requiredCount");
|
||||
requiredCount = Math.max(1, nbt.getInteger("requiredCount"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
-1
@@ -30,7 +30,9 @@ public class ConditionQuestCompleted extends AbilityCondition {
|
||||
if (questId < 0) return false;
|
||||
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
return PlayerData.get(player).questData.hasFinishedQuest(questId);
|
||||
PlayerData data = PlayerData.get(player);
|
||||
if (data == null || data.questData == null) return false;
|
||||
return data.questData.hasFinishedQuest(questId);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -289,9 +289,15 @@ public class ChainedAbility implements IChainedAbility, IAbilityAction {
|
||||
*/
|
||||
public boolean checkConditions(EntityLivingBase caster, EntityLivingBase target) {
|
||||
for (AbilityCondition c : conditions) {
|
||||
if (!c.check(caster, target)) {
|
||||
return false;
|
||||
if (!c.getUserType().allowsNpc()) continue;
|
||||
Boolean extendedCondition = AbilityController.Instance.fireCheckConditions(c, caster, target);
|
||||
|
||||
if (extendedCondition != null) {
|
||||
if (!extendedCondition) return false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!c.check(caster, target)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -301,10 +307,16 @@ public class ChainedAbility implements IChainedAbility, IAbilityAction {
|
||||
*/
|
||||
public boolean checkConditionsForPlayer(EntityLivingBase caster) {
|
||||
for (AbilityCondition c : conditions) {
|
||||
if (!c.getUserType().allowsPlayer()) continue;
|
||||
if (c.requiresTarget()) continue;
|
||||
if (!c.check(caster, null)) {
|
||||
return false;
|
||||
Boolean extendedCondition = AbilityController.Instance.fireCheckConditionsForPlayer(c, caster);
|
||||
|
||||
if (extendedCondition != null) {
|
||||
if (!extendedCondition) return false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!c.check(caster, null)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -809,7 +809,6 @@ public class EntityAbilityBeam extends EntityEnergyProjectile {
|
||||
nbt.setDouble("HeadOffsetY", headOffsetY);
|
||||
nbt.setDouble("HeadOffsetZ", headOffsetZ);
|
||||
nbt.setBoolean("AttachedToOwner", isAnchoredMode());
|
||||
nbt.setBoolean("RenderTailOrb", isAnchoredMode());
|
||||
nbt.setString("BeamMode", beamMode.name());
|
||||
writeChargingNBT(nbt);
|
||||
nbt.setFloat("ChargeOffsetDistance", chargeOffsetDistance);
|
||||
|
||||
@@ -779,10 +779,8 @@ public class EntityAbilityLaser extends EntityEnergyProjectile {
|
||||
@Override
|
||||
protected void readProjectileNBT(NBTTagCompound nbt) {
|
||||
this.laserWidth = sanitize(nbt.hasKey("LaserWidth") ? nbt.getFloat("LaserWidth") : 0.2f, 0.2f, MAX_ENTITY_SIZE);
|
||||
this.expansionSpeed = nbt.hasKey("ExpansionSpeed") ? nbt.getFloat("ExpansionSpeed") : 2.0f;
|
||||
if (Float.isNaN(expansionSpeed) || Float.isInfinite(expansionSpeed) || expansionSpeed <= 0) expansionSpeed = 2.0f;
|
||||
this.maxLength = nbt.hasKey("MaxLength") ? nbt.getFloat("MaxLength") : 32.0f;
|
||||
if (Float.isNaN(maxLength) || Float.isInfinite(maxLength) || maxLength <= 0) maxLength = 32.0f;
|
||||
this.expansionSpeed = sanitize(nbt.hasKey("ExpansionSpeed") ? nbt.getFloat("ExpansionSpeed") : 2.0f, 0.1f, MAX_ENTITY_SIZE);
|
||||
this.maxLength = sanitize(nbt.hasKey("MaxLength") ? nbt.getFloat("MaxLength") : 32.0f, 1.0f, MAX_ENTITY_SIZE);
|
||||
this.dirX = nbt.getDouble("DirX");
|
||||
this.dirY = nbt.getDouble("DirY");
|
||||
this.dirZ = nbt.getDouble("DirZ");
|
||||
|
||||
@@ -790,7 +790,8 @@ public class EntityAbilityZone extends Entity implements IEntityAdditionalSpawnD
|
||||
this.shape = ZoneShape.CIRCLE;
|
||||
}
|
||||
this.ownerEntityId = buffer.readInt();
|
||||
this.radius = buffer.readFloat();
|
||||
this.radius = Math.max(0.1f, Math.min(100.0f, buffer.readFloat()));
|
||||
if (Float.isNaN(radius) || Float.isInfinite(radius)) radius = 5.0f;
|
||||
this.durationTicks = buffer.readInt();
|
||||
this.maxTicks = buffer.readInt();
|
||||
this.innerColor = buffer.readInt();
|
||||
|
||||
@@ -116,8 +116,6 @@ public abstract class EntityEnergyProjectile extends EntityEnergyAbility {
|
||||
// ==================== HOMING PROPERTIES ====================
|
||||
protected EnergyHomingData homingData = new EnergyHomingData();
|
||||
|
||||
protected Map<Integer, Integer> pathDelays;
|
||||
|
||||
// ==================== TRACKING ====================
|
||||
protected double startX, startY, startZ;
|
||||
protected int targetEntityId = -1;
|
||||
|
||||
@@ -81,6 +81,10 @@ public final class AbilityHotbarSyncPacket extends AbstractPacket {
|
||||
|
||||
if (valid && data.abilityData != null) {
|
||||
valid = data.abilityData.hasUnlockedAbility(slot.abilityKey);
|
||||
// For chains, also check with resolved key in case key format differs
|
||||
if (!valid && slot.isChainKey()) {
|
||||
valid = data.abilityData.hasUnlockedAbility("chain:" + slot.getResolveKey());
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid) {
|
||||
|
||||
@@ -51,6 +51,7 @@ public final class AbilityHotbarSavePacket extends AbstractPacket {
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
int slot = in.readInt();
|
||||
NBTTagCompound compound = ByteBufUtils.readNBT(in);
|
||||
if (compound == null) return;
|
||||
|
||||
if (slot < 0 || slot >= AbilityHotbarData.TOTAL_SLOTS) return;
|
||||
|
||||
@@ -73,6 +74,10 @@ public final class AbilityHotbarSavePacket extends AbstractPacket {
|
||||
|
||||
if (valid && data.abilityData != null) {
|
||||
valid = data.abilityData.hasUnlockedAbility(slotData.abilityKey);
|
||||
// For chains, also check with resolved key in case key format differs
|
||||
if (!valid && slotData.isChainKey()) {
|
||||
valid = data.abilityData.hasUnlockedAbility("chain:" + slotData.getResolveKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -66,6 +66,7 @@ public final class CustomAbilitySavePacket extends AbstractPacket {
|
||||
return;
|
||||
|
||||
NBTTagCompound compound = ByteBufUtils.readNBT(in);
|
||||
if (compound == null) return;
|
||||
Ability ability = AbilityController.Instance.fromNBT(compound);
|
||||
if (ability != null) {
|
||||
AbilityController.Instance.saveCustomAbility(ability);
|
||||
|
||||
@@ -81,7 +81,9 @@ public final class AbilityScriptPacket extends AbstractPacket {
|
||||
if (!ConfigScript.canScript(player, CustomNpcsPermissions.SCRIPT))
|
||||
return;
|
||||
|
||||
Action requestedAction = Action.values()[in.readInt()];
|
||||
int actionOrd = in.readInt();
|
||||
if (actionOrd < 0 || actionOrd >= Action.values().length) return;
|
||||
Action requestedAction = Action.values()[actionOrd];
|
||||
String id = ByteBufUtils.readUTF8String(in);
|
||||
|
||||
Ability ability = AbilityController.Instance.resolveAbility(id);
|
||||
|
||||
+3
-1
@@ -81,7 +81,9 @@ public final class ChainedAbilityScriptPacket extends AbstractPacket {
|
||||
if (!ConfigScript.canScript(player, CustomNpcsPermissions.SCRIPT))
|
||||
return;
|
||||
|
||||
Action requestedAction = Action.values()[in.readInt()];
|
||||
int actionOrd = in.readInt();
|
||||
if (actionOrd < 0 || actionOrd >= Action.values().length) return;
|
||||
Action requestedAction = Action.values()[actionOrd];
|
||||
String id = ByteBufUtils.readUTF8String(in);
|
||||
|
||||
ChainedAbility chain = AbilityController.Instance.resolveChainedAbility(id);
|
||||
|
||||
@@ -268,7 +268,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
|
||||
}
|
||||
|
||||
if (conditions.size() < MAX_CONDITIONS) {
|
||||
sw.addButton(new GuiNpcButton(BTN_ADD_COND, L_LABEL_X, y, 50, 20, "gui.add"));;
|
||||
sw.addButton(new GuiNpcButton(BTN_ADD_COND, L_LABEL_X, y, 50, 20, "gui.add"));
|
||||
y += ROW_H;
|
||||
}
|
||||
|
||||
|
||||
@@ -309,7 +309,7 @@ public class FieldDef {
|
||||
}
|
||||
|
||||
public boolean hasRange() {
|
||||
return min != Float.NEGATIVE_INFINITY || max != Float.POSITIVE_INFINITY;
|
||||
return min != 0 || max != Float.POSITIVE_INFINITY;
|
||||
}
|
||||
|
||||
public Class<? extends Enum<?>> getEnumClass() {
|
||||
|
||||
@@ -49,5 +49,6 @@ public class ScriptEnergyOrb<T extends EntityAbilityOrb> extends ScriptEnergyPro
|
||||
entity.motionY = (dy / len) * entity.getSpeed();
|
||||
entity.motionZ = (dz / len) * entity.getSpeed();
|
||||
}
|
||||
entity.startMoving(null);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user