mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 03:49:29 +00:00
pull in some armor stuff from 1.6
This commit is contained in:
1 parent
8fdef45de4
commit
86f8a2003f
15 files changed
+198
-20
No files matched your search
@@ -7,6 +7,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import tconstruct.library.armor.ArmorCore;
|
||||
import tconstruct.library.armor.ArmorModTypeFilter;
|
||||
import tconstruct.library.armor.EnumArmorPart;
|
||||
|
||||
//TODO: Condense attribute modifiers into one class
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package tconstruct.modifiers.armor;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.armor.AModInteger;
|
||||
import tconstruct.library.armor.ArmorCore;
|
||||
import tconstruct.library.armor.EnumArmorPart;
|
||||
|
||||
public class AModDoubleJump extends AModInteger
|
||||
{
|
||||
public AModDoubleJump(ItemStack[] items)
|
||||
{
|
||||
super(6, "Double-Jump", EnumSet.of(EnumArmorPart.SHOES), items, 5, 1, "\u00a7a", "Double-Jump");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack armor, ItemStack[] input)
|
||||
{
|
||||
ArmorCore item = (ArmorCore) armor.getItem();
|
||||
if (armorTypes.contains(item.armorPart))
|
||||
{
|
||||
NBTTagCompound tags = armor.getTagCompound().getCompoundTag(getTagName());
|
||||
return tags.getInteger("Modifiers") >= modifyCount && tags.getInteger("Double-Jump") < 3;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int addToolTip (ItemStack tool, String tooltip, String modifierTip)
|
||||
{
|
||||
NBTTagCompound tags = tool.getTagCompound().getCompoundTag(getTagName());
|
||||
int tipNum = 0;
|
||||
while (true)
|
||||
{
|
||||
tipNum++;
|
||||
String tip = "Tooltip" + tipNum;
|
||||
if (!tags.hasKey(tip))
|
||||
{
|
||||
tags.setString(tip, tooltip);
|
||||
String modTip = "ModifierTip" + tipNum;
|
||||
tags.setString(modTip, modifierTip);
|
||||
return tipNum;
|
||||
}
|
||||
else
|
||||
{
|
||||
String tag = tags.getString(tip);
|
||||
if (tag.contains("Double-Jump") || tag.contains("Triple-Jump"))
|
||||
{
|
||||
tags.setString(tip, getProperName(tooltip, tag));
|
||||
String modTip = "ModifierTip" + tipNum;
|
||||
tag = tags.getString(modTip);
|
||||
tags.setString(modTip, getProperName(modifierTip, tag));
|
||||
return tipNum;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProperName (String tooltip, String tag)
|
||||
{
|
||||
if (tag.contains("Double-Jump"))
|
||||
return color+"Triple-Jump";
|
||||
|
||||
if (tag.contains("Triple-Jump"))
|
||||
return color+"Quadruple-Jump";
|
||||
|
||||
return color+"Double-Jump";
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import tconstruct.library.armor.ArmorCore;
|
||||
import tconstruct.library.armor.ArmorModTypeFilter;
|
||||
import tconstruct.library.armor.EnumArmorPart;
|
||||
|
||||
//TODO: Condense attribute modifiers into one class
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package tconstruct.modifiers.armor;
|
||||
|
||||
public class AModJumpBoost
|
||||
{
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import tconstruct.library.armor.ArmorCore;
|
||||
import tconstruct.library.armor.ArmorModTypeFilter;
|
||||
import tconstruct.library.armor.EnumArmorPart;
|
||||
|
||||
//TODO: Condense attribute modifiers into one class
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import tconstruct.library.armor.ArmorCore;
|
||||
import tconstruct.library.armor.ArmorModTypeFilter;
|
||||
import tconstruct.library.armor.EnumArmorPart;
|
||||
|
||||
public class AModMoveSpeed extends ArmorModTypeFilter
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.armor.ArmorModTypeFilter;
|
||||
import tconstruct.library.armor.EnumArmorPart;
|
||||
|
||||
public class AModProtection extends ArmorModTypeFilter
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
package tconstruct.modifiers.armor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import tconstruct.library.armor.ArmorMod;
|
||||
import tconstruct.library.armor.EnumArmorPart;
|
||||
|
||||
public abstract class ArmorModTypeFilter extends ArmorMod
|
||||
{
|
||||
public final List<Integer> increase;
|
||||
|
||||
public ArmorModTypeFilter(int effect, String dataKey, EnumSet<EnumArmorPart> armorTypes, ItemStack[] items, int[] values)
|
||||
{
|
||||
super(effect, dataKey, armorTypes, items);
|
||||
assert items.length == values.length : "Itemstacks and their values for armor 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;
|
||||
}
|
||||
|
||||
public int matchingItems (ItemStack[] input)
|
||||
{
|
||||
int amount = 0;
|
||||
for (ItemStack inputStack : input)
|
||||
{
|
||||
if (inputStack != null)
|
||||
amount++;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user