Include offhand inventory in imbued item updating (and armour, while we're at it), fixes #493
This commit is contained in:
@@ -346,35 +346,47 @@ public class WizardData implements INBTSerializable<NBTTagCompound> {
|
|||||||
|
|
||||||
// For each item in the player's inventory
|
// For each item in the player's inventory
|
||||||
for(ItemStack stack : player.inventory.mainInventory){
|
for(ItemStack stack : player.inventory.mainInventory){
|
||||||
if(stack.isItemEnchanted()){
|
updateImbutedItem(stack, activeImbuements);
|
||||||
|
}
|
||||||
|
for(ItemStack stack : player.inventory.armorInventory){
|
||||||
|
updateImbutedItem(stack, activeImbuements);
|
||||||
|
}
|
||||||
|
for(ItemStack stack : player.inventory.offHandInventory){
|
||||||
|
updateImbutedItem(stack, activeImbuements);
|
||||||
|
}
|
||||||
|
|
||||||
NBTTagList enchantmentList = stack.getItem() == Items.ENCHANTED_BOOK ?
|
// Removes all imbuements from the map that are no longer active
|
||||||
ItemEnchantedBook.getEnchantments(stack) : stack.getEnchantmentTagList();
|
this.imbuementDurations.keySet().retainAll(activeImbuements);
|
||||||
|
}
|
||||||
|
|
||||||
Iterator<NBTBase> iterator = enchantmentList.iterator();
|
private void updateImbutedItem(ItemStack stack, Set<Imbuement> activeImbuements){
|
||||||
// For each of the item's enchantments
|
|
||||||
while(iterator.hasNext()){
|
if(stack.isItemEnchanted()){
|
||||||
NBTTagCompound enchantmentTag = (NBTTagCompound) iterator.next();
|
|
||||||
Enchantment enchantment = Enchantment.getEnchantmentByID(enchantmentTag.getShort("id"));
|
NBTTagList enchantmentList = stack.getItem() == Items.ENCHANTED_BOOK ?
|
||||||
// Ignores the enchantment unless it is an imbuement
|
ItemEnchantedBook.getEnchantments(stack) : stack.getEnchantmentTagList();
|
||||||
if(enchantment instanceof Imbuement){
|
|
||||||
int duration = this.getImbuementDuration(enchantment);
|
Iterator<NBTBase> iterator = enchantmentList.iterator();
|
||||||
// If the imbuement is still active:
|
// For each of the item's enchantments
|
||||||
if(duration > 0){
|
while(iterator.hasNext()){
|
||||||
// Decrements the timer
|
NBTTagCompound enchantmentTag = (NBTTagCompound) iterator.next();
|
||||||
this.imbuementDurations.put((Imbuement)enchantment, duration - IMBUEMENT_UPDATE_INTERVAL);
|
Enchantment enchantment = Enchantment.getEnchantmentByID(enchantmentTag.getShort("id"));
|
||||||
// Adds this imbuement to the set of imbuements that need to be kept
|
// Ignores the enchantment unless it is an imbuement
|
||||||
activeImbuements.add((Imbuement)enchantment);
|
if(enchantment instanceof Imbuement){
|
||||||
}else{
|
int duration = this.getImbuementDuration(enchantment);
|
||||||
// Otherwise, removes the enchantment from the item
|
// If the imbuement is still active:
|
||||||
iterator.remove(); // FIXME: Apparently this can cause a CME
|
if(duration > 0){
|
||||||
}
|
// Decrements the timer
|
||||||
|
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{
|
||||||
|
// Otherwise, removes the enchantment from the item
|
||||||
|
iterator.remove(); // FIXME: Apparently this can cause a CME
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Removes all imbuements from the map that are no longer active
|
|
||||||
this.imbuementDurations.keySet().retainAll(activeImbuements);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ally designation system
|
// Ally designation system
|
||||||
|
|||||||
Reference in New Issue
Block a user