diff --git a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java index bd6b56de8..2247d4448 100644 --- a/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java +++ b/src/main/java/noppes/npcs/ScriptPlayerEventHandler.java @@ -23,6 +23,7 @@ import net.minecraftforge.event.entity.player.*; import net.minecraftforge.event.world.BlockEvent; import noppes.npcs.api.entity.IPlayer; import noppes.npcs.api.item.IItemCustomizable; +import noppes.npcs.attribute.PlayerAttributeManager; import noppes.npcs.constants.EnumQuestType; import noppes.npcs.controllers.CustomEffectController; import noppes.npcs.controllers.PartyController; @@ -47,7 +48,7 @@ public class ScriptPlayerEventHandler { if (event.side == Side.SERVER && event.phase == TickEvent.Phase.START) { EntityPlayer player = event.player; - if (player.ticksExisted%10 == 0) { + if (player.ticksExisted % 10 == 0) { PlayerDataScript handler = ScriptController.Instance.playerScripts; IPlayer scriptPlayer = (IPlayer) NpcAPI.Instance().getIEntity(player); EventHooks.onPlayerTick(handler, scriptPlayer); @@ -59,6 +60,8 @@ public class ScriptPlayerEventHandler { EventHooks.onScriptItemUpdate(isw, player); } } + + PlayerAttributeManager.getTracker(player.getUniqueID()).updateIfChanged(player); } if (PlayerDataController.Instance != null) { diff --git a/src/main/java/noppes/npcs/attribute/ModAttributes.java b/src/main/java/noppes/npcs/attribute/ModAttributes.java index 1000e8efe..d780b88bf 100644 --- a/src/main/java/noppes/npcs/attribute/ModAttributes.java +++ b/src/main/java/noppes/npcs/attribute/ModAttributes.java @@ -16,15 +16,15 @@ public class ModAttributes { public static final AttributeDefinition MAGIC_RESISTANCE_PERCENT; static { - MAIN_ATTACK_FLAT = AttributeController.registerAttribute(AttributeKeys.MAIN_ATTACK_FLAT, "Main Attack Damage (Flat)", AttributeValueType.FLAT); + MAIN_ATTACK_FLAT = AttributeController.registerAttribute(AttributeKeys.MAIN_ATTACK_FLAT, "Main Attack Damage", AttributeValueType.FLAT); MAIN_ATTACK_PERCENT = AttributeController.registerAttribute(AttributeKeys.MAIN_ATTACK_PERCENT, "Main Attack Damage (%)", AttributeValueType.PERCENT); HEALTH = AttributeController.registerAttribute(AttributeKeys.HEALTH, "Health", AttributeValueType.FLAT); CRITICAL_CHANCE_PERCENT = AttributeController.registerAttribute(AttributeKeys.CRITICAL_CHANCE_PERCENT, "Critical Chance (%)", AttributeValueType.PERCENT); - CRITICAL_DAMAGE_FLAT = AttributeController.registerAttribute(AttributeKeys.CRITICAL_DAMAGE_FLAT, "Critical Damage Bonus (Flat)", AttributeValueType.FLAT); + CRITICAL_DAMAGE_FLAT = AttributeController.registerAttribute(AttributeKeys.CRITICAL_DAMAGE_FLAT, "Critical Damage Bonus", AttributeValueType.FLAT); - MAGIC_DAMAGE_FLAT = AttributeController.registerAttribute(AttributeKeys.MAGIC_DAMAGE_FLAT, "Magic Damage (Flat)", AttributeValueType.MAGIC); + MAGIC_DAMAGE_FLAT = AttributeController.registerAttribute(AttributeKeys.MAGIC_DAMAGE_FLAT, "Magic Damage", AttributeValueType.MAGIC); MAGIC_DAMAGE_PERCENT = AttributeController.registerAttribute(AttributeKeys.MAGIC_DAMAGE_PERCENT, "Magic Damage (%)", AttributeValueType.MAGIC); - MAGIC_DEFENSE_FLAT = AttributeController.registerAttribute(AttributeKeys.MAGIC_DEFENSE_FLAT, "Magic Defense (Flat)", AttributeValueType.MAGIC); + MAGIC_DEFENSE_FLAT = AttributeController.registerAttribute(AttributeKeys.MAGIC_DEFENSE_FLAT, "Magic Defense", AttributeValueType.MAGIC); MAGIC_RESISTANCE_PERCENT = AttributeController.registerAttribute(AttributeKeys.MAGIC_RESISTANCE_PERCENT, "Magic Resistance (%)", AttributeValueType.MAGIC); } } diff --git a/src/main/java/noppes/npcs/attribute/PlayerAttributeTickHandler.java b/src/main/java/noppes/npcs/attribute/PlayerAttributeTickHandler.java deleted file mode 100644 index a65f70479..000000000 --- a/src/main/java/noppes/npcs/attribute/PlayerAttributeTickHandler.java +++ /dev/null @@ -1,22 +0,0 @@ -package noppes.npcs.attribute; - -import net.minecraft.server.MinecraftServer; -import net.minecraft.entity.player.EntityPlayer; - -/** - * Tick handler that runs every tick and, every 10 ticks, checks all players - * for equipment changes to update their attribute trackers. - */ -public class PlayerAttributeTickHandler { - private int tickCount = 0; - - public void onTick() { - tickCount++; - if (tickCount % 10 == 0) { - for (Object o : MinecraftServer.getServer().getConfigurationManager().playerEntityList) { - EntityPlayer player = (EntityPlayer) o; - PlayerAttributeManager.getTracker(player.getUniqueID()).updateIfChanged(player); - } - } - } -} diff --git a/src/main/java/noppes/npcs/attribute/PlayerAttributeTracker.java b/src/main/java/noppes/npcs/attribute/PlayerAttributeTracker.java index 7cd849d5e..b4aae36bb 100644 --- a/src/main/java/noppes/npcs/attribute/PlayerAttributeTracker.java +++ b/src/main/java/noppes/npcs/attribute/PlayerAttributeTracker.java @@ -44,15 +44,7 @@ public class PlayerAttributeTracker { * are aggregated by summing values from their NBT maps. */ public void recalcAttributes(EntityPlayer player) { - // Start with a fresh attribute map. - CustomAttributeMap newMap = new CustomAttributeMap(); - // Pre-register core non-magic attributes (if they appear on items). - newMap.registerAttribute(ModAttributes.MAIN_ATTACK_FLAT, 0.0); - newMap.registerAttribute(ModAttributes.MAIN_ATTACK_PERCENT, 0.0); - newMap.registerAttribute(ModAttributes.CRITICAL_CHANCE_PERCENT, 0.0); - newMap.registerAttribute(ModAttributes.CRITICAL_DAMAGE_FLAT, 0.0); - // (HEALTH is handled separately.) - aggregatedAttributes = newMap; + aggregatedAttributes = new CustomAttributeMap(); // Reset magic aggregates. aggregatedMagicDamageFlat.clear();