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,106 @@
|
||||
package tconstruct.modifiers.tools;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.library.modifier.ItemModifier;
|
||||
|
||||
public abstract class ItemModTypeFilter extends ItemModifier
|
||||
{
|
||||
public final List<Integer> increase;
|
||||
|
||||
public ItemModTypeFilter(int effect, String dataKey, ItemStack[] items, int[] values)
|
||||
{
|
||||
super(items, effect, dataKey);
|
||||
assert items.length == values.length : "Itemstacks and their values for tool modifiers must be the same length";
|
||||
this.increase = new ArrayList<Integer>();
|
||||
for (int i = 0; i < values.length; i++)
|
||||
{
|
||||
increase.add(values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/** Checks to see if the inputs match the stored items
|
||||
* Note: Filters types, doesn't care about amount
|
||||
*
|
||||
* @param input The ItemStacks to compare against
|
||||
* @param tool Item to modify, used for restrictions
|
||||
* @return Whether the recipe matches the input
|
||||
*/
|
||||
@Override
|
||||
public boolean matches (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
if (!canModify(tool, input))
|
||||
return false;
|
||||
|
||||
boolean minimumMatch = false;
|
||||
for (ItemStack inputStack : input)
|
||||
{
|
||||
if (inputStack == null)
|
||||
continue;
|
||||
|
||||
boolean match = false;
|
||||
for (Object check : stacks)
|
||||
{
|
||||
ItemStack stack = (ItemStack) check;
|
||||
if (stack.getItemDamage() == Short.MAX_VALUE)
|
||||
{
|
||||
if (this.areItemsEquivalent(inputStack, stack))
|
||||
match = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.areItemStacksEquivalent(inputStack, stack))
|
||||
match = true;
|
||||
}
|
||||
}
|
||||
if (!match)
|
||||
return false;
|
||||
|
||||
minimumMatch = true;
|
||||
}
|
||||
return minimumMatch;
|
||||
}
|
||||
|
||||
public int matchingAmount (ItemStack[] input)
|
||||
{
|
||||
int amount = 0;
|
||||
for (ItemStack inputStack : input)
|
||||
{
|
||||
if (inputStack == null)
|
||||
continue;
|
||||
else
|
||||
{
|
||||
for (int iter = 0; iter < stacks.size(); iter++)
|
||||
{
|
||||
ItemStack stack = (ItemStack) stacks.get(iter);
|
||||
if (stack.getItemDamage() == Short.MAX_VALUE)
|
||||
{
|
||||
if (this.areItemsEquivalent(inputStack, stack))
|
||||
amount += increase.get(iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.areItemStacksEquivalent(inputStack, stack))
|
||||
amount += increase.get(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
/** Adds a new itemstack to the list for increases
|
||||
*
|
||||
* @param stack ItemStack to compare against
|
||||
* @param amount Amount to increase
|
||||
*/
|
||||
public void addStackToMatchList (ItemStack stack, int amount)
|
||||
{
|
||||
if (stack == null)
|
||||
throw new NullPointerException("ItemStack added to " + this.getClass().getSimpleName() + " cannot be null.");
|
||||
stacks.add(stack);
|
||||
increase.add(amount);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package tconstruct.modifiers.tools;
|
||||
|
||||
import tconstruct.library.modifier.ItemModifier;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ModAntiSpider extends ItemModTypeFilter
|
||||
{
|
||||
String tooltipName;
|
||||
int max = 4;
|
||||
String guiType;
|
||||
|
||||
public ModAntiSpider(String type, int effect, ItemStack[] items, int[] values)
|
||||
{
|
||||
super(effect, "ModAntiSpider", items, values);
|
||||
tooltipName = "\u00a72Bane of Arthropods";
|
||||
guiType = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (!tags.hasKey(key))
|
||||
return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;
|
||||
|
||||
int keyPair[] = tags.getIntArray(key);
|
||||
if (keyPair[0] + matchingAmount(input) <= keyPair[1])
|
||||
return true;
|
||||
|
||||
else if (keyPair[0] == keyPair[1])
|
||||
return tags.getInteger("Modifiers") > 0;
|
||||
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
int increase = matchingAmount(input);
|
||||
if (tags.hasKey(key))
|
||||
{
|
||||
int[] keyPair = tags.getIntArray(key);
|
||||
|
||||
if (keyPair[0] % max == 0)
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
keyPair[1] += max;
|
||||
tags.setIntArray(key, keyPair);
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
else
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
tags.setIntArray(key, keyPair);
|
||||
}
|
||||
updateModTag(tool, keyPair);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
String modName = "\u00a72" + guiType + " (" + increase + "/" + max + ")";
|
||||
int tooltipIndex = addToolTip(tool, tooltipName, modName);
|
||||
int[] keyPair = new int[] { increase, max, tooltipIndex };
|
||||
tags.setIntArray(key, keyPair);
|
||||
}
|
||||
}
|
||||
|
||||
void updateModTag (ItemStack tool, int[] keys)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
String tip = "ModifierTip" + keys[2];
|
||||
String modName = "\u00a72" + guiType + " (" + keys[0] + "/" + keys[1] + ")";
|
||||
tags.setString(tip, modName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package tconstruct.modifiers.tools;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.modifier.IModifyable;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
public class ModAttack extends ItemModTypeFilter
|
||||
{
|
||||
String tooltipName;
|
||||
int max;
|
||||
int threshold;
|
||||
String guiType;
|
||||
String modifierType;
|
||||
|
||||
public ModAttack(String type, int effect, ItemStack[] items, int[] value)
|
||||
{
|
||||
super(effect, "ModAttack", items, value);
|
||||
tooltipName = "\u00a7fSharpness";
|
||||
guiType = type;
|
||||
max = 72;
|
||||
threshold = 24;
|
||||
modifierType = "Tool";
|
||||
}
|
||||
|
||||
public ModAttack(String type, int effect, ItemStack[] items, int[] value, int max, int threshold, String modifierType)
|
||||
{
|
||||
super(effect, "ModAttack", items, value);
|
||||
tooltipName = "\u00a7fKnuckles";
|
||||
guiType = type;
|
||||
this.max = max;
|
||||
this.threshold = threshold;
|
||||
this.modifierType = modifierType;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
if (tool.getItem() instanceof IModifyable)
|
||||
{
|
||||
IModifyable toolItem = (IModifyable) tool.getItem();
|
||||
if (!validType(toolItem))
|
||||
return false;
|
||||
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag(toolItem.getBaseTagName());
|
||||
if (!tags.hasKey(key))
|
||||
return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;
|
||||
|
||||
int keyPair[] = tags.getIntArray(key);
|
||||
if (keyPair[0] + matchingAmount(input) <= keyPair[1])
|
||||
return true;
|
||||
|
||||
else if (keyPair[0] == keyPair[1])
|
||||
return tags.getInteger("Modifiers") > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validType (IModifyable input)
|
||||
{
|
||||
String type = input.getModifyType();
|
||||
return type.equals(modifierType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
IModifyable toolItem = (IModifyable) tool.getItem();
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag(toolItem.getBaseTagName());
|
||||
if (tags.hasKey(key))
|
||||
{
|
||||
int[] keyPair = tags.getIntArray(key);
|
||||
int increase = matchingAmount(input);
|
||||
|
||||
int leftToBoost = threshold - (keyPair[0] % threshold);
|
||||
if (increase >= leftToBoost)
|
||||
{
|
||||
int attack = tags.getInteger("Attack");
|
||||
attack += 1;
|
||||
tags.setInteger("Attack", attack);
|
||||
}
|
||||
|
||||
if (keyPair[0] % max == 0)
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
keyPair[1] += max;
|
||||
tags.setIntArray(key, keyPair);
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
else
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
tags.setIntArray(key, keyPair);
|
||||
}
|
||||
updateModTag(tool, keyPair);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
int increase = matchingAmount(input);
|
||||
String modName = "\u00a7f" + guiType + " (" + increase + "/" + max + ")";
|
||||
int tooltipIndex = addToolTip(tool, tooltipName, modName);
|
||||
int[] keyPair = new int[] { increase, max, tooltipIndex };
|
||||
tags.setIntArray(key, keyPair);
|
||||
|
||||
int attack = tags.getInteger("Attack");
|
||||
attack += 1;
|
||||
tags.setInteger("Attack", attack);
|
||||
}
|
||||
}
|
||||
|
||||
void updateModTag (ItemStack tool, int[] keys)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag(getTagName(tool));
|
||||
String tip = "ModifierTip" + keys[2];
|
||||
String modName = "\u00a7f" + guiType + " (" + keys[0] + "/" + keys[1] + ")";
|
||||
tags.setString(tip, modName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package tconstruct.modifiers.tools;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ModAutoSmelt extends ModBoolean
|
||||
{
|
||||
|
||||
public ModAutoSmelt(ItemStack[] items, int effect, String tag, String c, String tip)
|
||||
{
|
||||
super(items, effect, tag, c, tip);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.getBoolean("Silk Touch"))
|
||||
return false;
|
||||
return tags.getInteger("Modifiers") > 0 && !tags.getBoolean(key); //Will fail if the modifier is false or the tag doesn't exist
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package tconstruct.modifiers.tools;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
public class ModBlaze extends ItemModTypeFilter
|
||||
{
|
||||
String tooltipName;
|
||||
int max;
|
||||
|
||||
public ModBlaze(int effect, ItemStack[] items, int[] values)
|
||||
{
|
||||
super(effect, "Blaze", items, values);
|
||||
tooltipName = "\u00a76Fiery";
|
||||
max = 25;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
if (tool.getItem() instanceof ToolCore)
|
||||
{
|
||||
ToolCore toolItem = (ToolCore) tool.getItem();
|
||||
if (!validType(toolItem))
|
||||
return false;
|
||||
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (!tags.hasKey(key))
|
||||
return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;
|
||||
|
||||
int keyPair[] = tags.getIntArray(key);
|
||||
if (keyPair[0] + matchingAmount(input) <= keyPair[1])
|
||||
return true;
|
||||
|
||||
else if (keyPair[0] == keyPair[1])
|
||||
return tags.getInteger("Modifiers") > 0;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
int increase = matchingAmount(input);
|
||||
if (tags.hasKey(key))
|
||||
{
|
||||
int[] keyPair = tags.getIntArray(key);
|
||||
if (keyPair[0] == max)
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
keyPair[1] += max;
|
||||
tags.setIntArray(key, keyPair);
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
else
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
tags.setIntArray(key, keyPair);
|
||||
}
|
||||
updateModTag(tool, keyPair);
|
||||
}
|
||||
else
|
||||
{
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
String modName = "\u00a76Blaze (" + increase + "/" + max + ")";
|
||||
int tooltipIndex = addToolTip(tool, tooltipName, modName);
|
||||
int[] keyPair = new int[] { increase, max, tooltipIndex };
|
||||
tags.setIntArray(key, keyPair);
|
||||
}
|
||||
|
||||
int fiery = tags.getInteger("Fiery");
|
||||
fiery += (increase);
|
||||
tags.setInteger("Fiery", fiery);
|
||||
|
||||
}
|
||||
|
||||
void updateModTag (ItemStack tool, int[] keys)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
String tip = "ModifierTip" + keys[2];
|
||||
String modName = "\u00a76Blaze (" + keys[0] + "/" + keys[1] + ")";
|
||||
tags.setString(tip, modName);
|
||||
}
|
||||
|
||||
public boolean validType (ToolCore tool)
|
||||
{
|
||||
List list = Arrays.asList(tool.getTraits());
|
||||
return list.contains("melee") || list.contains("ammo");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package tconstruct.modifiers.tools;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.modifier.ItemModifier;
|
||||
|
||||
/* Adds a boolean NBTTag */
|
||||
|
||||
public class ModBoolean extends ItemModifier
|
||||
{
|
||||
String color;
|
||||
String tooltipName;
|
||||
|
||||
public ModBoolean(ItemStack[] items, int effect, String tag, String c, String tip)
|
||||
{
|
||||
super(items, effect, tag);
|
||||
color = c;
|
||||
tooltipName = tip;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
return tags.getInteger("Modifiers") > 0 && !tags.getBoolean(key); //Will fail if the modifier is false or the tag doesn't exist
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
|
||||
tags.setBoolean(key, true);
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
|
||||
addToolTip(tool, color + tooltipName, color + key);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package tconstruct.modifiers.tools;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
public class ModButtertouch extends ModBoolean
|
||||
{
|
||||
|
||||
public ModButtertouch(ItemStack[] items, int effect)
|
||||
{
|
||||
super(items, effect, "Silk Touch", "\u00a7e", "Silky");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
if (tool.getItem() instanceof ToolCore)
|
||||
{
|
||||
ToolCore toolItem = (ToolCore) tool.getItem();
|
||||
if (!validType(toolItem))
|
||||
return false;
|
||||
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (!tags.getBoolean("Lava") && !tags.hasKey("Lapis"))
|
||||
{
|
||||
return tags.getInteger("Modifiers") > 0 && !tags.getBoolean(key);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
tags.setBoolean(key, true);
|
||||
addEnchantment(tool, Enchantment.silkTouch, 1);
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
|
||||
int attack = tags.getInteger("Attack");
|
||||
attack -= 3;
|
||||
if (attack < 0)
|
||||
attack = 0;
|
||||
tags.setInteger("Attack", attack);
|
||||
|
||||
int miningSpeed = tags.getInteger("MiningSpeed");
|
||||
miningSpeed -= 300;
|
||||
if (miningSpeed < 0)
|
||||
miningSpeed = 0;
|
||||
tags.setInteger("MiningSpeed", miningSpeed);
|
||||
|
||||
if (tags.hasKey("MiningSpeed2"))
|
||||
{
|
||||
int miningSpeed2 = tags.getInteger("MiningSpeed2");
|
||||
miningSpeed2 -= 300;
|
||||
if (miningSpeed2 < 0)
|
||||
miningSpeed2 = 0;
|
||||
tags.setInteger("MiningSpeed2", miningSpeed2);
|
||||
}
|
||||
|
||||
addToolTip(tool, color + tooltipName, color + key);
|
||||
}
|
||||
|
||||
public void addEnchantment (ItemStack tool, Enchantment enchant, int level) //TODO: Move this to ItemModifier
|
||||
{
|
||||
NBTTagList tags = new NBTTagList();
|
||||
Map enchantMap = EnchantmentHelper.getEnchantments(tool);
|
||||
Iterator iterator = enchantMap.keySet().iterator();
|
||||
int index;
|
||||
int lvl;
|
||||
boolean hasEnchant = false;
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
NBTTagCompound enchantTag = new NBTTagCompound();
|
||||
index = ((Integer) iterator.next()).intValue();
|
||||
lvl = (Integer) enchantMap.get(index);
|
||||
if (index == enchant.effectId)
|
||||
{
|
||||
hasEnchant = true;
|
||||
enchantTag.setShort("id", (short) index);
|
||||
enchantTag.setShort("lvl", (short) ((byte) level));
|
||||
tags.appendTag(enchantTag);
|
||||
}
|
||||
else
|
||||
{
|
||||
enchantTag.setShort("id", (short) index);
|
||||
enchantTag.setShort("lvl", (short) ((byte) lvl));
|
||||
tags.appendTag(enchantTag);
|
||||
}
|
||||
}
|
||||
if (!hasEnchant)
|
||||
{
|
||||
NBTTagCompound enchantTag = new NBTTagCompound();
|
||||
enchantTag.setShort("id", (short) enchant.effectId);
|
||||
enchantTag.setShort("lvl", (short) ((byte) level));
|
||||
tags.appendTag(enchantTag);
|
||||
}
|
||||
tool.stackTagCompound.setTag("ench", tags);
|
||||
}
|
||||
|
||||
public boolean validType (ToolCore tool)
|
||||
{
|
||||
List list = Arrays.asList(tool.getTraits());
|
||||
return list.contains("weapon") || list.contains("harvest");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package tconstruct.modifiers.tools;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.modifier.ItemModifier;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
public class ModCreativeToolModifier extends ItemModifier
|
||||
{
|
||||
public ModCreativeToolModifier(ItemStack[] items)
|
||||
{
|
||||
super(items, 0, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
if (tool.getItem() instanceof ToolCore)
|
||||
{
|
||||
ToolCore toolItem = (ToolCore) tool.getItem();
|
||||
for (ItemStack stack : input)
|
||||
{
|
||||
if (stack != null && stack.hasTagCompound())
|
||||
{
|
||||
String targetLock = stack.getTagCompound().getString("TargetLock");
|
||||
if (!targetLock.equals("") && !targetLock.equals(toolItem.getToolName()))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers += 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
|
||||
public void addMatchingEffect (ItemStack tool)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package tconstruct.modifiers.tools;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.modifier.ItemModifier;
|
||||
import tconstruct.util.config.PHConstruct;
|
||||
|
||||
/* Adds an integer NBTTag */
|
||||
|
||||
public class ModDurability extends ItemModifier
|
||||
{
|
||||
String tooltipName;
|
||||
String color;
|
||||
int durability;
|
||||
float modifier;
|
||||
int miningLevel;
|
||||
|
||||
public ModDurability(ItemStack[] items, int effect, int dur, float mod, int level, String k, String tip, String c)
|
||||
{
|
||||
super(items, effect, k);
|
||||
durability = dur;
|
||||
modifier = mod;
|
||||
miningLevel = level;
|
||||
tooltipName = tip;
|
||||
color = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.hasKey(key))
|
||||
return false;
|
||||
return super.canModify(tool, input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
|
||||
int base = tags.getInteger("BaseDurability");
|
||||
int bonus = tags.getInteger("BonusDurability");
|
||||
float modDur = tags.getFloat("ModDurability");
|
||||
|
||||
bonus += durability;
|
||||
modDur += modifier;
|
||||
|
||||
int total = (int) ((base + bonus) * (modDur + 1f));
|
||||
if (total <= 0)
|
||||
total = 1;
|
||||
|
||||
tags.setInteger("TotalDurability", total);
|
||||
tags.setInteger("BonusDurability", bonus);
|
||||
tags.setFloat("ModDurability", modDur);
|
||||
|
||||
if (PHConstruct.miningLevelIncrease)
|
||||
{
|
||||
int mLevel = tags.getInteger("HarvestLevel");
|
||||
if (mLevel < miningLevel)
|
||||
tags.setInteger("HarvestLevel", miningLevel);
|
||||
}
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
|
||||
tags.setBoolean(key, true);
|
||||
String modTip = color + key;
|
||||
addToolTip(tool, tooltipName, modTip);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package tconstruct.modifiers.tools;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.modifier.IModifyable;
|
||||
import tconstruct.library.modifier.ItemModifier;
|
||||
|
||||
public class ModExtraModifier extends ItemModifier
|
||||
{
|
||||
public ModExtraModifier(ItemStack[] items, String dataKey)
|
||||
{
|
||||
super(items, 0, dataKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] recipe)
|
||||
{
|
||||
if (tool != null && tool.getItem() instanceof IModifyable)
|
||||
{
|
||||
NBTTagCompound tags = this.getModifierTag(tool);
|
||||
if (tags.getBoolean(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] recipe, ItemStack input)
|
||||
{
|
||||
NBTTagCompound tags = this.getModifierTag(input);
|
||||
tags.setBoolean(key, true);
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers += 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
|
||||
public void addMatchingEffect (ItemStack tool)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package tconstruct.modifiers.tools;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
/* TE3 support */
|
||||
|
||||
public class ModFlux extends ModBoolean
|
||||
{
|
||||
|
||||
public ArrayList<ItemStack> batteries = new ArrayList<ItemStack>();
|
||||
|
||||
public ModFlux()
|
||||
{
|
||||
super(new ItemStack[0], 9, "Flux", "\u00a7e", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
boolean battery = false;
|
||||
|
||||
if (input[0] != null)
|
||||
{
|
||||
for (ItemStack stack : batteries)
|
||||
{
|
||||
if (stack.getItem() == input[0].getItem() && input[0].getItem() instanceof IEnergyContainerItem)
|
||||
{
|
||||
battery = true;
|
||||
}
|
||||
}
|
||||
return battery && canModify(tool, input);
|
||||
}
|
||||
|
||||
if (input[1] != null)
|
||||
{
|
||||
|
||||
for (ItemStack stack : batteries)
|
||||
{
|
||||
if (stack.getItem() == input[1].getItem() && input[1].getItem() instanceof IEnergyContainerItem)
|
||||
{
|
||||
battery = true;
|
||||
}
|
||||
return battery && canModify(tool, input);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound();
|
||||
|
||||
if (!tags.hasKey(key))
|
||||
{
|
||||
tags.setBoolean(key, true);
|
||||
|
||||
int modifiers = tags.getCompoundTag("InfiTool").getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.getCompoundTag("InfiTool").setInteger("Modifiers", modifiers);
|
||||
int charge = 0;
|
||||
if (input[0] != null && input[0].getItem() != null && input[0].getItem() instanceof IEnergyContainerItem && input[0].hasTagCompound())
|
||||
charge = input[0].getTagCompound().getInteger("Energy");
|
||||
if (input[1] != null && input[1].getItem() != null && input[1].getItem() instanceof IEnergyContainerItem && input[1].hasTagCompound())
|
||||
charge = input[1].getTagCompound().getInteger("Energy");
|
||||
tags.setInteger("Energy", charge);
|
||||
tags.setInteger(key, 1);
|
||||
addModifierTip(tool, "\u00a7eFlux");
|
||||
ToolCore toolcore = (ToolCore) tool.getItem();
|
||||
tool.setItemDamage(1 + (toolcore.getMaxEnergyStored(tool) - charge) * (tool.getMaxDamage() - 1) / toolcore.getMaxEnergyStored(tool));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package tconstruct.modifiers.tools;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.modifier.ItemModifier;
|
||||
|
||||
/* Adds an integer NBTTag */
|
||||
|
||||
public class ModInteger extends ItemModifier
|
||||
{
|
||||
String color;
|
||||
String tooltipName;
|
||||
int initialIncrease;
|
||||
int secondaryIncrease;
|
||||
|
||||
public ModInteger(ItemStack[] items, int effect, String dataKey, int increase, String c, String tip)
|
||||
{
|
||||
super(items, effect, dataKey);
|
||||
initialIncrease = secondaryIncrease = increase;
|
||||
color = c;
|
||||
tooltipName = tip;
|
||||
}
|
||||
|
||||
public ModInteger(ItemStack[] items, int effect, String dataKey, int increase1, int increase2, String c, String tip)
|
||||
{
|
||||
super(items, effect, dataKey);
|
||||
initialIncrease = increase1;
|
||||
secondaryIncrease = increase2;
|
||||
color = c;
|
||||
tooltipName = tip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.hasKey(key))
|
||||
{
|
||||
int increase = tags.getInteger(key);
|
||||
increase += secondaryIncrease;
|
||||
tags.setInteger(key, increase);
|
||||
}
|
||||
else
|
||||
{
|
||||
tags.setInteger(key, initialIncrease);
|
||||
}
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
|
||||
addToolTip(tool, color + tooltipName, color + key);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
package tconstruct.modifiers.tools;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.library.tools.Weapon;
|
||||
|
||||
public class ModLapis extends ItemModTypeFilter
|
||||
{
|
||||
String tooltipName;
|
||||
int max = 450;
|
||||
|
||||
public ModLapis(int effect, ItemStack[] items, int[] values)
|
||||
{
|
||||
super(effect, "Lapis", items, values);
|
||||
tooltipName = "\u00a79Luck";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
if (tool.getItem() instanceof ToolCore)
|
||||
{
|
||||
ToolCore toolItem = (ToolCore) tool.getItem();
|
||||
if (!validType(toolItem))
|
||||
return false;
|
||||
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
|
||||
if (tags.getBoolean("Silk Touch"))
|
||||
return false;
|
||||
|
||||
if (!tags.hasKey(key))
|
||||
return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;
|
||||
|
||||
int keyPair[] = tags.getIntArray(key);
|
||||
if (keyPair[0] + matchingAmount(input) <= max)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (!tags.hasKey(key))
|
||||
{
|
||||
tags.setBoolean(key, true);
|
||||
|
||||
String modName = "\u00a79Lapis (0/450)";
|
||||
int tooltipIndex = addToolTip(tool, "\u00a79Luck", modName);
|
||||
int[] keyPair = new int[] { 0, tooltipIndex };
|
||||
tags.setIntArray(key, keyPair);
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
|
||||
int increase = matchingAmount(input);
|
||||
int keyPair[] = tags.getIntArray(key);
|
||||
keyPair[0] += increase;
|
||||
tags.setIntArray(key, keyPair);
|
||||
ToolCore toolcore = (ToolCore) tool.getItem();
|
||||
String[] types = toolcore.getTraits();
|
||||
boolean weapon = false;
|
||||
boolean harvest = false;
|
||||
for (String s : types)
|
||||
{
|
||||
if (s.equals("harvest"))
|
||||
harvest = true;
|
||||
else if (s.equals("weapon"))
|
||||
weapon = true;
|
||||
}
|
||||
if (weapon)
|
||||
{
|
||||
if (keyPair[0] >= 450)
|
||||
addEnchantment(tool, Enchantment.looting, 3);
|
||||
else if (keyPair[0] >= 300)
|
||||
addEnchantment(tool, Enchantment.looting, 2);
|
||||
else if (keyPair[0] >= 100)
|
||||
addEnchantment(tool, Enchantment.looting, 1);
|
||||
}
|
||||
if (harvest)
|
||||
{
|
||||
if (keyPair[0] >= 450)
|
||||
addEnchantment(tool, Enchantment.fortune, 3);
|
||||
else if (keyPair[0] >= 300)
|
||||
addEnchantment(tool, Enchantment.fortune, 2);
|
||||
else if (keyPair[0] >= 100)
|
||||
addEnchantment(tool, Enchantment.fortune, 1);
|
||||
}
|
||||
|
||||
updateModTag(tool, keyPair);
|
||||
}
|
||||
|
||||
public void midStreamModify (ItemStack tool, ToolCore toolItem)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (!tags.hasKey(key))
|
||||
return;
|
||||
|
||||
int keyPair[] = tags.getIntArray(key);
|
||||
if (keyPair[0] == max)
|
||||
return;
|
||||
|
||||
if (random.nextInt(50) == 0)
|
||||
{
|
||||
keyPair[0] += 1;
|
||||
tags.setIntArray(key, keyPair);
|
||||
updateModTag(tool, keyPair);
|
||||
}
|
||||
|
||||
List list = Arrays.asList(toolItem.getTraits());
|
||||
if (list.contains("weapon"))
|
||||
{
|
||||
if (keyPair[0] >= 450)
|
||||
{
|
||||
addEnchantment(tool, Enchantment.looting, 3);
|
||||
}
|
||||
else if (keyPair[0] >= 350)
|
||||
{
|
||||
int chance = keyPair[0] - 300;
|
||||
if (random.nextInt(1000 - chance) == 0)
|
||||
addEnchantment(tool, Enchantment.looting, 3);
|
||||
}
|
||||
else if (keyPair[0] >= 125)
|
||||
{
|
||||
int chance = keyPair[0] - 175;
|
||||
if (random.nextInt(600 - chance) == 0)
|
||||
addEnchantment(tool, Enchantment.looting, 2);
|
||||
}
|
||||
else if (keyPair[0] >= 10)
|
||||
{
|
||||
int chance = keyPair[0] - 25;
|
||||
if (random.nextInt(250 - chance) == 0)
|
||||
addEnchantment(tool, Enchantment.looting, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (list.contains("harvest"))
|
||||
{
|
||||
if (keyPair[0] >= 450)
|
||||
{
|
||||
addEnchantment(tool, Enchantment.fortune, 3);
|
||||
}
|
||||
else if (keyPair[0] >= 350)
|
||||
{
|
||||
int chance = keyPair[0] - 300;
|
||||
if (random.nextInt(1000 - chance) == 0)
|
||||
addEnchantment(tool, Enchantment.fortune, 3);
|
||||
}
|
||||
else if (keyPair[0] >= 125)
|
||||
{
|
||||
int chance = keyPair[0] - 175;
|
||||
if (random.nextInt(600 - chance) == 0)
|
||||
addEnchantment(tool, Enchantment.fortune, 2);
|
||||
}
|
||||
else if (keyPair[0] >= 10)
|
||||
{
|
||||
int chance = keyPair[0] - 25;
|
||||
if (random.nextInt(250 - chance) == 0)
|
||||
addEnchantment(tool, Enchantment.fortune, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addEnchantment (ItemStack tool, Enchantment enchant, int level)
|
||||
{
|
||||
NBTTagList tags = new NBTTagList();
|
||||
Map enchantMap = EnchantmentHelper.getEnchantments(tool);
|
||||
Iterator iterator = enchantMap.keySet().iterator();
|
||||
int index;
|
||||
int lvl;
|
||||
boolean hasEnchant = false;
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
NBTTagCompound enchantTag = new NBTTagCompound();
|
||||
index = ((Integer) iterator.next()).intValue();
|
||||
lvl = (Integer) enchantMap.get(index);
|
||||
if (index == enchant.effectId)
|
||||
{
|
||||
hasEnchant = true;
|
||||
enchantTag.setShort("id", (short) index);
|
||||
enchantTag.setShort("lvl", (short) ((byte) level));
|
||||
tags.appendTag(enchantTag);
|
||||
}
|
||||
else
|
||||
{
|
||||
enchantTag.setShort("id", (short) index);
|
||||
enchantTag.setShort("lvl", (short) ((byte) lvl));
|
||||
tags.appendTag(enchantTag);
|
||||
}
|
||||
}
|
||||
if (!hasEnchant)
|
||||
{
|
||||
NBTTagCompound enchantTag = new NBTTagCompound();
|
||||
enchantTag.setShort("id", (short) enchant.effectId);
|
||||
enchantTag.setShort("lvl", (short) ((byte) level));
|
||||
tags.appendTag(enchantTag);
|
||||
}
|
||||
tool.stackTagCompound.setTag("ench", tags);
|
||||
}
|
||||
|
||||
void updateModTag (ItemStack tool, int[] keys)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
String tip = "ModifierTip" + keys[1];
|
||||
String modName = "\u00a79Lapis (" + keys[0] + "/" + max + ")";
|
||||
tags.setString(tip, modName);
|
||||
}
|
||||
|
||||
public boolean validType (ToolCore tool)
|
||||
{
|
||||
List list = Arrays.asList(tool.getTraits());
|
||||
return list.contains("weapon") || list.contains("harvest");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package tconstruct.modifiers.tools;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import tconstruct.library.modifier.ItemModifier;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ModPiston extends ItemModTypeFilter
|
||||
{
|
||||
String tooltipName;
|
||||
int max = 10;
|
||||
|
||||
public ModPiston(int effect, ItemStack[] items, int[] values)
|
||||
{
|
||||
super(effect, "Piston", items, values);
|
||||
tooltipName = "\u00a77Knockback";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
if (tool.getItem() instanceof ToolCore)
|
||||
{
|
||||
ToolCore toolItem = (ToolCore) tool.getItem();
|
||||
if (!validType(toolItem))
|
||||
return false;
|
||||
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (!tags.hasKey(key))
|
||||
return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;
|
||||
|
||||
int keyPair[] = tags.getIntArray(key);
|
||||
if (keyPair[0] + matchingAmount(input) <= keyPair[1])
|
||||
return true;
|
||||
|
||||
else if (keyPair[0] == keyPair[1])
|
||||
return tags.getInteger("Modifiers") > 0;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
int increase = matchingAmount(input);
|
||||
if (tags.hasKey(key))
|
||||
{
|
||||
int[] keyPair = tags.getIntArray(key);
|
||||
if (keyPair[0] % max == 0)
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
keyPair[1] += max;
|
||||
tags.setIntArray(key, keyPair);
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
else
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
tags.setIntArray(key, keyPair);
|
||||
}
|
||||
updateModTag(tool, keyPair);
|
||||
}
|
||||
else
|
||||
{
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
String modName = "\u00a74Knockback (" + increase + "/" + max + ")";
|
||||
int tooltipIndex = addToolTip(tool, tooltipName, modName);
|
||||
int[] keyPair = new int[] { increase, max, tooltipIndex };
|
||||
tags.setIntArray(key, keyPair);
|
||||
}
|
||||
|
||||
float knockback = tags.getFloat("Knockback");
|
||||
|
||||
knockback += 0.1 * increase;
|
||||
tags.setFloat("Knockback", knockback);
|
||||
}
|
||||
|
||||
void updateModTag (ItemStack tool, int[] keys)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
String tip = "ModifierTip" + keys[2];
|
||||
String modName = "\u00a77Knockback (" + keys[0] + "/" + keys[1] + ")";
|
||||
tags.setString(tip, modName);
|
||||
}
|
||||
|
||||
public boolean validType (ToolCore tool)
|
||||
{
|
||||
List list = Arrays.asList(tool.getTraits());
|
||||
return list.contains("weapon");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package tconstruct.modifiers.tools;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.modifier.ItemModifier;
|
||||
|
||||
public class ModPotion extends ItemModifier
|
||||
{
|
||||
|
||||
public ModPotion(ItemStack[] items, int effect, String dataKey)
|
||||
{
|
||||
super(new ItemStack[] { new ItemStack(Items.potionitem, 1, Short.MAX_VALUE) }, 0, "");
|
||||
}
|
||||
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
NBTTagCompound potion = tool.getTagCompound().getCompoundTag("Potion");
|
||||
if (potion == null)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package tconstruct.modifiers.tools;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
public class ModRedstone extends ItemModTypeFilter
|
||||
{
|
||||
String tooltipName;
|
||||
int max = 50;
|
||||
|
||||
public ModRedstone(int effect, ItemStack[] items, int[] values)
|
||||
{
|
||||
super(effect, "Redstone", items, values);
|
||||
tooltipName = "\u00a74Haste";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
if (tool.getItem() instanceof ToolCore)
|
||||
{
|
||||
ToolCore toolItem = (ToolCore) tool.getItem();
|
||||
if (!validType(toolItem))
|
||||
return false;
|
||||
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (!tags.hasKey(key))
|
||||
return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;
|
||||
|
||||
int keyPair[] = tags.getIntArray(key);
|
||||
if (keyPair[0] + matchingAmount(input) <= keyPair[1])
|
||||
return true;
|
||||
|
||||
else if (keyPair[0] == keyPair[1])
|
||||
return tags.getInteger("Modifiers") > 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
int[] keyPair;
|
||||
int increase = matchingAmount(input);
|
||||
int current = 0;
|
||||
if (tags.hasKey(key))
|
||||
{
|
||||
keyPair = tags.getIntArray(key);
|
||||
if (keyPair[0] % max == 0)
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
keyPair[1] += max;
|
||||
tags.setIntArray(key, keyPair);
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
else
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
tags.setIntArray(key, keyPair);
|
||||
}
|
||||
current = keyPair[0];
|
||||
updateModTag(tool, keyPair);
|
||||
}
|
||||
else
|
||||
{
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
String modName = "\u00a74Redstone (" + increase + "/" + max + ")";
|
||||
int tooltipIndex = addToolTip(tool, tooltipName, modName);
|
||||
keyPair = new int[] { increase, max, tooltipIndex };
|
||||
current = keyPair[0];
|
||||
tags.setIntArray(key, keyPair);
|
||||
}
|
||||
|
||||
int miningSpeed = tags.getInteger("MiningSpeed");
|
||||
int boost = 8 + ((current - 1) / 50 * 2);
|
||||
Item temp = tool.getItem();
|
||||
if (temp instanceof ToolCore)
|
||||
{
|
||||
ToolCore toolcore = (ToolCore) temp;
|
||||
if (toolcore.durabilityTypeHandle() == 2)
|
||||
boost += 2;
|
||||
if (toolcore.durabilityTypeAccessory() == 2)
|
||||
boost += 2;
|
||||
if (toolcore.durabilityTypeExtra() == 2)
|
||||
boost += 2;
|
||||
}
|
||||
miningSpeed += (increase * boost);
|
||||
tags.setInteger("MiningSpeed", miningSpeed);
|
||||
|
||||
String[] type = { "MiningSpeed2", "MiningSpeedHandle", "MiningSpeedExtra" };
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (tags.hasKey(type[i]))
|
||||
{
|
||||
int speed = tags.getInteger(type[i]);
|
||||
speed += (increase * boost);
|
||||
tags.setInteger(type[i], speed);
|
||||
}
|
||||
}
|
||||
|
||||
if (tags.hasKey("DrawSpeed"))
|
||||
{
|
||||
int baseDrawSpeed = tags.getInteger("BaseDrawSpeed");
|
||||
int drawSpeed = (int) (baseDrawSpeed - (0.1f * baseDrawSpeed * (keyPair[0] / 50f)));
|
||||
tags.setInteger("DrawSpeed", drawSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
void updateModTag (ItemStack tool, int[] keys)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
String tip = "ModifierTip" + keys[2];
|
||||
String modName = "\u00a74Redstone (" + keys[0] + "/" + keys[1] + ")";
|
||||
tags.setString(tip, modName);
|
||||
}
|
||||
|
||||
public boolean validType (ToolCore tool)
|
||||
{
|
||||
List list = Arrays.asList(tool.getTraits());
|
||||
return list.contains("harvest") || list.contains("utility") || list.contains("bow");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package tconstruct.modifiers.tools;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ModReinforced extends ModInteger
|
||||
{
|
||||
|
||||
public ModReinforced(ItemStack[] items, int effect, int increase)
|
||||
{
|
||||
super(items, effect, "Reinforced", 1, "\u00a75", "Reinforced");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.hasKey(key))
|
||||
{
|
||||
int increase = tags.getInteger(key);
|
||||
increase += secondaryIncrease;
|
||||
tags.setInteger(key, increase);
|
||||
}
|
||||
else
|
||||
{
|
||||
tags.setInteger(key, initialIncrease);
|
||||
}
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
|
||||
int reinforced = tags.getInteger("Unbreaking");
|
||||
reinforced += 1;
|
||||
tags.setInteger("Unbreaking", reinforced);
|
||||
|
||||
addToolTip(tool, color + tooltipName, color + key);
|
||||
}
|
||||
|
||||
protected int addToolTip (ItemStack tool, String tooltip, String modifierTip)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
int tipNum = 0;
|
||||
while (true)
|
||||
{
|
||||
tipNum++;
|
||||
String tip = "Tooltip" + tipNum;
|
||||
if (!tags.hasKey(tip))
|
||||
{
|
||||
//tags.setString(tip, tooltip);
|
||||
String modTip = "ModifierTip" + tipNum;
|
||||
String tag = tags.getString(modTip);
|
||||
tags.setString(modTip, getProperName(modifierTip, tag));
|
||||
return tipNum;
|
||||
}
|
||||
else
|
||||
{
|
||||
String modTip = "ModifierTip" + tipNum;
|
||||
String tag = tags.getString(modTip);
|
||||
if (tag.contains(modifierTip))
|
||||
{
|
||||
//tags.setString(tip, getProperName(tooltip, tag));
|
||||
tag = tags.getString(modTip);
|
||||
tags.setString(modTip, getProperName(modifierTip, tag));
|
||||
return tipNum;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package tconstruct.modifiers.tools;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.crafting.PatternBuilder;
|
||||
import tconstruct.library.modifier.ItemModifier;
|
||||
import tconstruct.library.tools.AbilityHelper;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
|
||||
/* Little mod for actually adding the lapis modifier */
|
||||
|
||||
public class ModRepair extends ItemModifier
|
||||
{
|
||||
|
||||
public ModRepair()
|
||||
{
|
||||
super(new ItemStack[0], 0, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
return canModify(tool, input);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
if ((input[0] == null && input[1] == null))
|
||||
return false;
|
||||
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.getInteger("Damage") > 0)
|
||||
{
|
||||
int headID = tags.getInteger("Head");
|
||||
if (input[0] != null && input[1] != null)
|
||||
return headID == PatternBuilder.instance.getPartID(input[0]) && headID == PatternBuilder.instance.getPartID(input[1]) && calculateIfNecessary(tool, input);
|
||||
else if (input[0] != null && input[1] == null)
|
||||
return headID == PatternBuilder.instance.getPartID(input[0]);
|
||||
else if (input[0] == null && input[1] != null)
|
||||
return headID == PatternBuilder.instance.getPartID(input[1]);
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean calculateIfNecessary (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
int damage = tags.getInteger("Damage");
|
||||
int valueSlot1 = 0;
|
||||
int valueSlot2 = 0;
|
||||
if (input[0] != null)
|
||||
valueSlot1 = calculateIncrease(tool, PatternBuilder.instance.getPartValue(input[0]));
|
||||
if (input[1] != null)
|
||||
valueSlot2 = calculateIncrease(tool, PatternBuilder.instance.getPartValue(input[1]));
|
||||
|
||||
return ((damage - valueSlot1) > 0) && ((damage - valueSlot2) > 0);
|
||||
}
|
||||
|
||||
private int calculateIncrease (ItemStack tool, int materialValue)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
int damage = tags.getInteger("Damage");
|
||||
int dur = tags.getInteger("BaseDurability");
|
||||
int increase = (int) (50 + (dur * 0.4f * materialValue));
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
float mods = 1.0f;
|
||||
if (modifiers == 2)
|
||||
mods = 0.8f;
|
||||
else if (modifiers == 1)
|
||||
mods = 0.6f;
|
||||
else if (modifiers == 0)
|
||||
mods = 0.4f;
|
||||
|
||||
increase *= mods;
|
||||
|
||||
int repair = tags.getInteger("RepairCount");
|
||||
float repairCount = (100 - repair) / 100f;
|
||||
if (repairCount < 0.5f)
|
||||
repairCount = 0.5f;
|
||||
increase *= repairCount;
|
||||
increase /= ((ToolCore) tool.getItem()).getRepairCost();
|
||||
return increase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
tags.setBoolean("Broken", false);
|
||||
int damage = tags.getInteger("Damage");
|
||||
int dur = tags.getInteger("BaseDurability");
|
||||
int itemsUsed = 0;
|
||||
|
||||
int materialValue = 0;
|
||||
if (input[0] != null)
|
||||
{
|
||||
materialValue += PatternBuilder.instance.getPartValue(input[0]);
|
||||
itemsUsed++;
|
||||
}
|
||||
if (input[1] != null)
|
||||
{
|
||||
materialValue += PatternBuilder.instance.getPartValue(input[1]);
|
||||
itemsUsed++;
|
||||
}
|
||||
|
||||
int increase = calculateIncrease(tool, materialValue);
|
||||
int repair = tags.getInteger("RepairCount");
|
||||
repair += itemsUsed;
|
||||
tags.setInteger("RepairCount", repair);
|
||||
|
||||
damage -= increase;
|
||||
if (damage < 0)
|
||||
damage = 0;
|
||||
tags.setInteger("Damage", damage);
|
||||
|
||||
AbilityHelper.damageTool(tool, 0, null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMatchingEffect (ItemStack tool)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package tconstruct.modifiers.tools;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ModSmite extends ItemModTypeFilter
|
||||
{
|
||||
String tooltipName;
|
||||
int max = 36;
|
||||
String tagName;
|
||||
|
||||
public ModSmite(String type, int effect, ItemStack[] items, int[] values)
|
||||
{
|
||||
super(effect, "ModSmite", items, values);
|
||||
tooltipName = "\u00a7eSmite";
|
||||
tagName = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (!tags.hasKey(key))
|
||||
return tags.getInteger("Modifiers") > 0 && matchingAmount(input) <= max;
|
||||
|
||||
int keyPair[] = tags.getIntArray(key);
|
||||
if (keyPair[0] + matchingAmount(input) <= keyPair[1])
|
||||
return true;
|
||||
|
||||
else if (keyPair[0] == keyPair[1])
|
||||
return tags.getInteger("Modifiers") > 0;
|
||||
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
int increase = matchingAmount(input);
|
||||
if (tags.hasKey(key))
|
||||
{
|
||||
int[] keyPair = tags.getIntArray(key);
|
||||
|
||||
if (keyPair[0] % max == 0)
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
keyPair[1] += max;
|
||||
tags.setIntArray(key, keyPair);
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
}
|
||||
else
|
||||
{
|
||||
keyPair[0] += increase;
|
||||
tags.setIntArray(key, keyPair);
|
||||
}
|
||||
updateModTag(tool, keyPair);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
modifiers -= 1;
|
||||
tags.setInteger("Modifiers", modifiers);
|
||||
String modName = "\u00a7e" + tagName + " (" + increase + "/" + max + ")";
|
||||
int tooltipIndex = addToolTip(tool, tooltipName, modName);
|
||||
int[] keyPair = new int[] { increase, max, tooltipIndex };
|
||||
tags.setIntArray(key, keyPair);
|
||||
}
|
||||
}
|
||||
|
||||
void updateModTag (ItemStack tool, int[] keys)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
String tip = "ModifierTip" + keys[2];
|
||||
String modName = "\u00a7e" + tagName + " (" + keys[0] + "/" + keys[1] + ")";
|
||||
tags.setString(tip, modName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package tconstruct.modifiers.tools;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.crafting.PatternBuilder;
|
||||
import tconstruct.library.modifier.ItemModifier;
|
||||
import tconstruct.library.tools.*;
|
||||
|
||||
public class ModToolRepair extends ItemModifier
|
||||
{
|
||||
|
||||
public ModToolRepair()
|
||||
{
|
||||
super(new ItemStack[0], 0, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
return canModify(tool, input);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.getInteger("Damage") > 0)
|
||||
{
|
||||
int headID = tags.getInteger("Head");
|
||||
boolean areInputsValid = true;
|
||||
for (ItemStack curInput : input)
|
||||
{
|
||||
if (curInput != null && headID != PatternBuilder.instance.getPartID(curInput))
|
||||
{
|
||||
areInputsValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (areInputsValid)
|
||||
{
|
||||
return calculateIfNecessary(tool, input);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean calculateIfNecessary (ItemStack tool, ItemStack[] input)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
int damage = tags.getInteger("Damage");
|
||||
int numInputs = 0;
|
||||
int materialValue = 0;
|
||||
for (ItemStack curInput : input)
|
||||
{
|
||||
if (curInput != null)
|
||||
{
|
||||
materialValue += PatternBuilder.instance.getPartValue(curInput);
|
||||
numInputs++;
|
||||
}
|
||||
}
|
||||
if (numInputs == 0)
|
||||
return false;
|
||||
|
||||
int totalRepairValue = calculateIncrease(tool, materialValue, numInputs);
|
||||
float averageRepairValue = totalRepairValue / numInputs;
|
||||
|
||||
return numInputs == 1 || (damage - totalRepairValue >= -averageRepairValue);
|
||||
}
|
||||
|
||||
private int calculateIncrease (ItemStack tool, int materialValue, int itemsUsed)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
int damage = tags.getInteger("Damage");
|
||||
int dur = tags.getInteger("BaseDurability");
|
||||
int increase = (int) (50 * itemsUsed + (dur * 0.4f * materialValue));
|
||||
|
||||
int modifiers = tags.getInteger("Modifiers");
|
||||
float mods = 1.0f;
|
||||
if (modifiers == 2)
|
||||
mods = 0.9f;
|
||||
else if (modifiers == 1)
|
||||
mods = 0.8f;
|
||||
else if (modifiers == 0)
|
||||
mods = 0.7f;
|
||||
|
||||
increase *= mods;
|
||||
|
||||
int repair = tags.getInteger("RepairCount");
|
||||
float repairCount = (100 - repair) / 100f;
|
||||
if (repairCount < 0.5f)
|
||||
repairCount = 0.5f;
|
||||
increase *= repairCount;
|
||||
increase /= ((ToolCore) tool.getItem()).getRepairCost();
|
||||
return increase;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
|
||||
tags.setBoolean("Broken", false);
|
||||
int damage = tags.getInteger("Damage");
|
||||
int dur = tags.getInteger("BaseDurability");
|
||||
int itemsUsed = 0;
|
||||
|
||||
int materialValue = 0;
|
||||
for (ItemStack curInput : input)
|
||||
{
|
||||
if (curInput != null)
|
||||
{
|
||||
materialValue += PatternBuilder.instance.getPartValue(curInput);
|
||||
itemsUsed++;
|
||||
}
|
||||
}
|
||||
|
||||
int increase = calculateIncrease(tool, materialValue, itemsUsed);
|
||||
int repair = tags.getInteger("RepairCount");
|
||||
repair += itemsUsed;
|
||||
tags.setInteger("RepairCount", repair);
|
||||
|
||||
damage -= increase;
|
||||
if (damage < 0)
|
||||
damage = 0;
|
||||
tags.setInteger("Damage", damage);
|
||||
|
||||
AbilityHelper.damageTool(tool, 0, null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMatchingEffect (ItemStack tool)
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user