Temporary fix for lag in imbuement updating, ultimately this needs a rewrite but *effort*...

This commit is contained in:
Electroblob77
2020-10-23 15:09:19 +01:00
parent 9f3e09498d
commit 7f84f3daef
@@ -75,6 +75,8 @@ public class WizardData implements INBTSerializable<NBTTagCompound> {
/** The maximum number of recent spells to track. */ /** The maximum number of recent spells to track. */
public static final int MAX_RECENT_SPELLS = ItemWand.BASE_SPELL_SLOTS; 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. */ /** The player this WizardData instance belongs to. */
private final EntityPlayer player; private final EntityPlayer player;
@@ -360,7 +362,7 @@ public class WizardData implements INBTSerializable<NBTTagCompound> {
// If the imbuement is still active: // If the imbuement is still active:
if(duration > 0){ if(duration > 0){
// Decrements the timer // 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 // Adds this imbuement to the set of imbuements that need to be kept
activeImbuements.add((Imbuement)enchantment); activeImbuements.add((Imbuement)enchantment);
}else{ }else{
@@ -490,7 +492,7 @@ public class WizardData implements INBTSerializable<NBTTagCompound> {
// This new system removes a lot of repetitive event handler code and inflexible data which had duplicate // This new system removes a lot of repetitive event handler code and inflexible data which had duplicate
// functions, just for different enchantments. // functions, just for different enchantments.
updateImbuedItems(); if(player.ticksExisted % IMBUEMENT_UPDATE_INTERVAL == 0) updateImbuedItems();
updateContinuousSpellCasting(); updateContinuousSpellCasting();
this.spellData.forEach((k, v) -> this.spellData.put(k, k.update(player, v))); this.spellData.forEach((k, v) -> this.spellData.put(k, k.update(player, v)));