diff options
| author | Lance5057 <Lance5057@gmail.com> | 2015-05-06 06:47:03 -0500 |
|---|---|---|
| committer | Lance5057 <Lance5057@gmail.com> | 2015-05-06 06:47:03 -0500 |
| commit | d37b290bd6843832ed8d557cac9dcf94f17d6d6e (patch) | |
| tree | d0e07b37a332b2e574b370b723f598d327f70594 /src/main/java/gmail/Lance5057/modifiers | |
| parent | 061df55c4c0f21a5a0c2003a86ecf87462133cde (diff) | |
Added Daze Modifier, Texture not working
Diffstat (limited to 'src/main/java/gmail/Lance5057/modifiers')
| -rw-r--r-- | src/main/java/gmail/Lance5057/modifiers/TDefenseActiveToolMod.java | 41 | ||||
| -rw-r--r-- | src/main/java/gmail/Lance5057/modifiers/modifierDaze.java | 87 |
2 files changed, 128 insertions, 0 deletions
diff --git a/src/main/java/gmail/Lance5057/modifiers/TDefenseActiveToolMod.java b/src/main/java/gmail/Lance5057/modifiers/TDefenseActiveToolMod.java new file mode 100644 index 0000000..d03779b --- /dev/null +++ b/src/main/java/gmail/Lance5057/modifiers/TDefenseActiveToolMod.java @@ -0,0 +1,41 @@ +package gmail.Lance5057.modifiers; + +import java.util.Random; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.PotionEffect; +import tconstruct.library.ActiveToolMod; +import tconstruct.library.tools.ToolCore; + +public class TDefenseActiveToolMod extends ActiveToolMod { + @Override + public int baseAttackDamage(int earlyModDamage, int damage, ToolCore tool, + NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, + EntityLivingBase player, Entity entity) { + if (!toolTags.hasKey("Broken")) { + if (toolTags.hasKey("Daze")) { + int[] array = toolTags.getIntArray("Daze"); + int chance = array[0] * 5; + + Random roll = new Random(); + int num = roll.nextInt(100) + 1; + + if (num <= chance) { + ((EntityLivingBase) entity) + .addPotionEffect(new PotionEffect(2, 3 * 20, 100)); + ((EntityLivingBase) entity) + .addPotionEffect(new PotionEffect(9, 3 * 20, 100)); + ((EntityLivingBase) entity) + .addPotionEffect(new PotionEffect(15, 3 * 20, 100)); + ((EntityLivingBase) entity) + .addPotionEffect(new PotionEffect(18, 3 * 20, 100)); + } + } + } + + return 0; + } +} diff --git a/src/main/java/gmail/Lance5057/modifiers/modifierDaze.java b/src/main/java/gmail/Lance5057/modifiers/modifierDaze.java new file mode 100644 index 0000000..8b63791 --- /dev/null +++ b/src/main/java/gmail/Lance5057/modifiers/modifierDaze.java @@ -0,0 +1,87 @@ +package gmail.Lance5057.modifiers; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import tconstruct.modifiers.tools.ItemModTypeFilter; + +public class modifierDaze extends ItemModTypeFilter +{ + String tooltipName; + int max = 5; + String guiType; + + public modifierDaze(String type, int effect, ItemStack[] items, int[] values) + { + super(effect, "Daze", items, values); + tooltipName = "\u00A76Daze"; + 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; + + if (matchingAmount(input) > max) + return false; + + 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 = "\u00A76" + 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 = "\u00A76" + guiType + " (" + keys[0] + "/" + keys[1] + ")"; + tags.setString(tip, modName); + } +}
\ No newline at end of file |
