summaryrefslogtreecommitdiff
path: root/src/main/java/gmail/Lance5057/modifiers
diff options
context:
space:
mode:
authorLance5057 <Lance5057@gmail.com>2015-06-04 08:17:23 -0500
committerLance5057 <Lance5057@gmail.com>2015-06-04 08:17:23 -0500
commit08f88daf103c955b92eb29409cddca7647bfbfdb (patch)
treed44bcb6ce9289880b73f37e65a69d1cadc327a29 /src/main/java/gmail/Lance5057/modifiers
parentd37b290bd6843832ed8d557cac9dcf94f17d6d6e (diff)
Added Event handler, crest modifiers, sheath
Diffstat (limited to 'src/main/java/gmail/Lance5057/modifiers')
-rw-r--r--src/main/java/gmail/Lance5057/modifiers/TDefenseActiveToolMod.java24
-rw-r--r--src/main/java/gmail/Lance5057/modifiers/shields/modifierCrestofFeathers.java87
-rw-r--r--src/main/java/gmail/Lance5057/modifiers/shields/modifierCrestofMirrors.java87
3 files changed, 198 insertions, 0 deletions
diff --git a/src/main/java/gmail/Lance5057/modifiers/TDefenseActiveToolMod.java b/src/main/java/gmail/Lance5057/modifiers/TDefenseActiveToolMod.java
index d03779b..a6ea354 100644
--- a/src/main/java/gmail/Lance5057/modifiers/TDefenseActiveToolMod.java
+++ b/src/main/java/gmail/Lance5057/modifiers/TDefenseActiveToolMod.java
@@ -2,16 +2,40 @@ package gmail.Lance5057.modifiers;
import java.util.Random;
+import mods.battlegear2.api.PlayerEventChild;
+import mods.battlegear2.api.core.IBattlePlayer;
+import mods.battlegear2.api.core.InventoryPlayerBattle;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.projectile.EntityFireball;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.PotionEffect;
+import net.minecraft.world.World;
+import net.minecraftforge.event.entity.player.PlayerEvent;
import tconstruct.library.ActiveToolMod;
import tconstruct.library.tools.ToolCore;
public class TDefenseActiveToolMod extends ActiveToolMod {
@Override
+ public void updateTool(ToolCore tool, ItemStack stack, World world, Entity entity)
+ {
+// NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
+//
+// if (!tags.hasKey("Broken")) {
+// if(((IBattlePlayer)entity).isBlockingWithShield())
+// {
+// if(ShieldEvent.source.getEntity() instanceof EntityFireball)
+// {
+//
+// }
+// }
+// }
+ }
+
+ @Override
+
public int baseAttackDamage(int earlyModDamage, int damage, ToolCore tool,
NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack,
EntityLivingBase player, Entity entity) {
diff --git a/src/main/java/gmail/Lance5057/modifiers/shields/modifierCrestofFeathers.java b/src/main/java/gmail/Lance5057/modifiers/shields/modifierCrestofFeathers.java
new file mode 100644
index 0000000..53fdbed
--- /dev/null
+++ b/src/main/java/gmail/Lance5057/modifiers/shields/modifierCrestofFeathers.java
@@ -0,0 +1,87 @@
+package gmail.Lance5057.modifiers.shields;
+
+import tconstruct.modifiers.tools.ItemModTypeFilter;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class modifierCrestofFeathers extends ItemModTypeFilter
+{
+ String tooltipName;
+ int max = 5;
+ String guiType;
+
+ public modifierCrestofFeathers(String type, int effect, ItemStack[] items, int[] values)
+ {
+ super(effect, "Crest of Feathers", items, values);
+ tooltipName = "\u00A7fCrest of Feathers";
+ 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);
+ }
+}
diff --git a/src/main/java/gmail/Lance5057/modifiers/shields/modifierCrestofMirrors.java b/src/main/java/gmail/Lance5057/modifiers/shields/modifierCrestofMirrors.java
new file mode 100644
index 0000000..22d053f
--- /dev/null
+++ b/src/main/java/gmail/Lance5057/modifiers/shields/modifierCrestofMirrors.java
@@ -0,0 +1,87 @@
+package gmail.Lance5057.modifiers.shields;
+
+import tconstruct.modifiers.tools.ItemModTypeFilter;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class modifierCrestofMirrors extends ItemModTypeFilter
+{
+ String tooltipName;
+ int max = 5;
+ String guiType;
+
+ public modifierCrestofMirrors(String type, int effect, ItemStack[] items, int[] values)
+ {
+ super(effect, "Crest of Mirrors", items, values);
+ tooltipName = "\u00A7bCrest of Mirrors";
+ 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);
+ }
+}