From 7f84f3daef7023e31aae9d0449e539991f6da675 Mon Sep 17 00:00:00 2001 From: Electroblob77 <35599699+Electroblob77@users.noreply.github.com> Date: Fri, 23 Oct 2020 15:09:19 +0100 Subject: [PATCH] Temporary fix for lag in imbuement updating, ultimately this needs a rewrite but *effort*... --- src/main/java/electroblob/wizardry/data/WizardData.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/electroblob/wizardry/data/WizardData.java b/src/main/java/electroblob/wizardry/data/WizardData.java index 7ef5d858..2b723acf 100644 --- a/src/main/java/electroblob/wizardry/data/WizardData.java +++ b/src/main/java/electroblob/wizardry/data/WizardData.java @@ -75,6 +75,8 @@ public class WizardData implements INBTSerializable { /** The maximum number of recent spells to track. */ public static final int MAX_RECENT_SPELLS = ItemWand.BASE_SPELL_SLOTS; + private static final int IMBUEMENT_UPDATE_INTERVAL = 20; + /** The player this WizardData instance belongs to. */ private final EntityPlayer player; @@ -360,7 +362,7 @@ public class WizardData implements INBTSerializable { // If the imbuement is still active: if(duration > 0){ // Decrements the timer - this.imbuementDurations.put((Imbuement)enchantment, duration - 1); + this.imbuementDurations.put((Imbuement)enchantment, duration - IMBUEMENT_UPDATE_INTERVAL); // Adds this imbuement to the set of imbuements that need to be kept activeImbuements.add((Imbuement)enchantment); }else{ @@ -490,7 +492,7 @@ public class WizardData implements INBTSerializable { // This new system removes a lot of repetitive event handler code and inflexible data which had duplicate // functions, just for different enchantments. - updateImbuedItems(); + if(player.ticksExisted % IMBUEMENT_UPDATE_INTERVAL == 0) updateImbuedItems(); updateContinuousSpellCasting(); this.spellData.forEach((k, v) -> this.spellData.put(k, k.update(player, v)));