mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-26 23:13:07 +00:00
Update modifiers, start travellers gear
This commit is contained in:
1 parent
0230307f0a
commit
c525493545
96 files changed
+2827
-1573
No files matched your search
@@ -0,0 +1,49 @@
|
||||
package tconstruct.library.crafting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import tconstruct.library.armor.ArmorMod;
|
||||
import tconstruct.library.modifier.IModifyable;
|
||||
import tconstruct.library.modifier.ItemModifier;
|
||||
|
||||
public class ModifyBuilder
|
||||
{
|
||||
public static ModifyBuilder instance = new ModifyBuilder();
|
||||
public List<ItemModifier> itemModifiers = new ArrayList<ItemModifier>();
|
||||
|
||||
public ItemStack modifyItem(ItemStack input, ItemStack[] modifiers)
|
||||
{
|
||||
ItemStack copy = input.copy(); //Prevent modifying the original
|
||||
if (copy.getItem() instanceof IModifyable)
|
||||
{
|
||||
IModifyable item = (IModifyable) copy.getItem();
|
||||
NBTTagCompound tags = input.getTagCompound().getCompoundTag(item.getBaseTagName());
|
||||
|
||||
boolean built = false;
|
||||
for (ItemModifier mod : itemModifiers)
|
||||
{
|
||||
if (mod.matches(modifiers, copy))
|
||||
{
|
||||
built = true;
|
||||
mod.addMatchingEffect(copy); //Order matters here
|
||||
mod.modify(modifiers, copy);
|
||||
}
|
||||
}
|
||||
if (built)
|
||||
return copy;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void registerModifier(ItemModifier mod)
|
||||
{
|
||||
if (mod == null)
|
||||
throw new NullPointerException("Modifier cannot be null.");
|
||||
instance.itemModifiers.add(mod);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user