Skip to content
This repository has been archived by the owner on Mar 10, 2021. It is now read-only.

Commit

Permalink
Fix Redstone and Attack modifiers eating your free modifiers on part …
Browse files Browse the repository at this point in the history
…replacement.
  • Loading branch information
bonii-xx committed Aug 12, 2014
1 parent 99f9dfd commit 7763ea4
Showing 1 changed file with 12 additions and 1 deletion.
Expand Up @@ -224,6 +224,7 @@ private static void handleMaterialTraits(NBTTagCompound tags, int oldMaterialId,
// nothing to do fi they're the same :)
if(oldMaterialId == newMaterialId)
return;

ToolMaterial oldMat = TConstructRegistry.getMaterial(oldMaterialId);
ToolMaterial newMat = TConstructRegistry.getMaterial(newMaterialId);

Expand Down Expand Up @@ -259,6 +260,8 @@ private static void reapplyRedstone(NBTTagCompound tags, ItemStack itemStack)
if(!tags.hasKey("Redstone"))
return;

int modifiers = tags.getInteger("Modifiers"); // backup modifiers

// find the redstone modifier
for(ItemModifier mod : ModifyBuilder.instance.itemModifiers)
if(mod instanceof ModRedstone)
Expand All @@ -282,6 +285,9 @@ private static void reapplyRedstone(NBTTagCompound tags, ItemStack itemStack)
while(rLvl-- > 0)
modRedstone.modify(new ItemStack[]{new ItemStack(Items.redstone)}, itemStack); // tags belong to oldTool
}

// restore modifiers
tags.setInteger("Modifiers", modifiers);
}

// same as reapplyRedstone but for Attack modifier
Expand All @@ -291,7 +297,9 @@ private static void reapplyAttack(NBTTagCompound tags, ItemStack itemStack)
if(!tags.hasKey("ModAttack"))
return;

// find the redstone modifier
int modifiers = tags.getInteger("Modifiers"); // backup modifiers

// find the correct(!!, not glove attack) modifier
for(ItemModifier mod : ModifyBuilder.instance.itemModifiers)
if(mod.key.equals("ModAttack"))
{
Expand All @@ -312,6 +320,9 @@ private static void reapplyAttack(NBTTagCompound tags, ItemStack itemStack)
while(qLvl-- > 0)
modAttack.modify(new ItemStack[]{new ItemStack(Items.quartz)}, itemStack); // tags belong to oldTool
}

// restore modifiers
tags.setInteger("Modifiers", modifiers);
}

// removes the mobhead modifier and rendering
Expand Down

0 comments on commit 7763ea4

Please sign in to comment.