Reorganize folders for modules

This commit is contained in:
mDiyo committed 2014-06-04 21:44:48 -08:00
1 parent 2c14f315de
commit e2f0558b6f
370 files changed
+4274 -4788

No files matched your search

@@ -1,84 +0,0 @@
package tconstruct.modifiers.tools;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
public class ModAntiSpider extends ToolModTypeFilter
{
String tooltipName;
int max = 4;
String guiType;
public ModAntiSpider(String type, int effect, ItemStack[] items, int[] values)
{
super(effect, "ModAntiSpider", items, values);
tooltipName = "\u00a72" + StatCollector.translateToLocal("modifier.tool.spider");
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;
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);
}
}
@@ -1,121 +0,0 @@
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;
import net.minecraft.util.StatCollector;
public class ModAttack extends ToolModTypeFilter
{
String tooltipName;
int max = 72;
String guiType;
public ModAttack(String type, int effect, ItemStack[] items, int[] value)
{
super(effect, "ModAttack", items, value);
tooltipName = "\u00a7f" + StatCollector.translateToLocal("modifier.tool.quartz");
guiType = type;
}
@Override
protected boolean canModify (ItemStack tool, ItemStack[] input)
{
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;
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");
if (tags.hasKey(key))
{
int amount = 24;
ToolCore toolItem = (ToolCore) tool.getItem();
if (toolItem.pierceArmor() || !nerfType(toolItem))
amount = 36;
int[] keyPair = tags.getIntArray(key);
int increase = matchingAmount(input);
int leftToBoost = amount - (keyPair[0] % amount);
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("InfiTool");
String tip = "ModifierTip" + keys[2];
String modName = "\u00a7f" + guiType + " (" + keys[0] + "/" + keys[1] + ")";
tags.setString(tip, modName);
}
@Override
public boolean validType (ToolCore tool)
{
return true;
}
public boolean nerfType (ToolCore tool)
{
List list = Arrays.asList(tool.toolCategories());
return list.contains("throwing") || list.contains("ammo");
}
}
@@ -1,23 +0,0 @@
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
}
}
@@ -1,101 +0,0 @@
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;
import net.minecraft.util.StatCollector;
public class ModBlaze extends ToolModTypeFilter
{
String tooltipName;
int max;
public ModBlaze(int effect, ItemStack[] items, int[] values)
{
super(effect, "Blaze", items, values);
tooltipName = "\u00a76" + StatCollector.translateToLocal("modifier.tool.blaze");
max = 25;
}
@Override
protected boolean canModify (ItemStack tool, ItemStack[] input)
{
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;
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)
{
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 = "\u00a76" + StatCollector.translateToLocal("gui.modifier.blaze") + "(" + keys[0] + "/" + keys[1] + ")";
tags.setString(tip, modName);
}
@Override
public boolean validType (ToolCore tool)
{
List list = Arrays.asList(tool.toolCategories());
return list.contains("melee") || list.contains("ammo");
}
}
@@ -1,53 +0,0 @@
package tconstruct.modifiers.tools;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.tools.ToolMod;
/* Adds a boolean NBTTag */
public class ModBoolean extends ToolMod
{
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);
// TConstruct.logger.info("Key: "+key+" "+tags.getBoolean(key));
int modifiers = tags.getInteger("Modifiers");
modifiers -= 1;
tags.setInteger("Modifiers", modifiers);
addToolTip(tool, color + tooltipName, color + key);
}
}
@@ -1,117 +0,0 @@
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 net.minecraft.util.StatCollector;
public class ModButtertouch extends ModBoolean
{
public ModButtertouch(ItemStack[] items, int effect)
{
super(items, effect, StatCollector.translateToLocal("gui.modifier.silk"), "\u00a7e", StatCollector.translateToLocal("modifier.tool.silk"));
}
@Override
protected boolean canModify (ItemStack tool, ItemStack[] input)
{
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)
{
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);
}
@Override
public boolean validType (ToolCore tool)
{
List list = Arrays.asList(tool.toolCategories());
return list.contains("weapon") || list.contains("harvest");
}
}
@@ -1,43 +0,0 @@
package tconstruct.modifiers.tools;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.tools.ToolCore;
import tconstruct.library.tools.ToolMod;
public class ModCreativeToolModifier extends ToolMod
{
public ModCreativeToolModifier(ItemStack[] items)
{
super(items, 0, "");
}
@Override
protected boolean canModify (ItemStack tool, ItemStack[] input)
{
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;
}
@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)
{
}
}
@@ -1,73 +0,0 @@
package tconstruct.modifiers.tools;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.tools.ToolMod;
import tconstruct.util.config.PHConstruct;
/* Adds an integer NBTTag */
public class ModDurability extends ToolMod
{
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);
}
}
@@ -1,40 +0,0 @@
package tconstruct.modifiers.tools;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.tools.ToolMod;
public class ModExtraModifier extends ToolMod
{
public ModExtraModifier(ItemStack[] items, String dataKey)
{
super(items, 0, dataKey);
}
@Override
protected boolean canModify (ItemStack tool, ItemStack[] input)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (tags.getBoolean(key))
{
return false;
}
return true;
}
@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);
}
@Override
public void addMatchingEffect (ItemStack tool)
{
}
}
@@ -1,81 +0,0 @@
package tconstruct.modifiers.tools;
import java.util.ArrayList;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.tools.ToolCore;
import cofh.api.energy.IEnergyContainerItem;
import net.minecraft.util.StatCollector;
/* TE3 support */
public class ModFlux extends ModBoolean
{
public ArrayList<ItemStack> batteries = new ArrayList<ItemStack>();
public ModFlux()
{
super(new ItemStack[0], 9, StatCollector.translateToLocal("mofifier.tool.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));
}
}
}
@@ -1,55 +0,0 @@
package tconstruct.modifiers.tools;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.tools.ToolMod;
/* Adds an integer NBTTag */
public class ModInteger extends ToolMod
{
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);
}
}
@@ -1,216 +0,0 @@
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;
import net.minecraft.util.StatCollector;
public class ModLapis extends ToolModTypeFilter
{
String tooltipName;
int max = 450;
public ModLapis(int effect, ItemStack[] items, int[] values)
{
super(effect, "Lapis", items, values);
tooltipName = "\u00a79" + StatCollector.translateToLocal("modifier.tool.lapis");
}
@Override
protected boolean canModify (ItemStack tool, ItemStack[] input)
{
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;
int keyPair[] = tags.getIntArray(key);
if (keyPair[0] + matchingAmount(input) <= max)
return true;
else
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, "\u00a79" + StatCollector.translateToLocal("modifier.tool.lapis"), 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);
if (tool.getItem() instanceof 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);
}
else
{
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.toolCategories());
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 = "\u00a79" + StatCollector.translateToLocal("gui.modifier.lapis") + "(" + keys[0] + "/" + max + ")";
tags.setString(tip, modName);
}
@Override
public boolean validType (ToolCore tool)
{
List list = Arrays.asList(tool.toolCategories());
return list.contains("weapon") || list.contains("harvest");
}
}
@@ -1,100 +0,0 @@
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;
import net.minecraft.util.StatCollector;
public class ModPiston extends ToolModTypeFilter
{
String tooltipName;
int max = 10;
public ModPiston(int effect, ItemStack[] items, int[] values)
{
super(effect, "Piston", items, values);
tooltipName = "\u00a77" + StatCollector.translateToLocal("modifier.tool.piston");
}
@Override
protected boolean canModify (ItemStack tool, ItemStack[] input)
{
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;
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 = "\u00a74" + StatCollector.translateToLocal("modifier.tool.piston") + "(" + 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 = "\u00a77" + StatCollector.translateToLocal("modifier.tool.piston") + "(" + keys[0] + "/" + keys[1] + ")";
tags.setString(tip, modName);
}
@Override
public boolean validType (ToolCore tool)
{
List list = Arrays.asList(tool.toolCategories());
return list.contains("weapon");
}
}
@@ -1,33 +0,0 @@
package tconstruct.modifiers.tools;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.tools.ToolMod;
public class ModPotion extends ToolMod
{
public ModPotion(ItemStack[] items, int effect, String dataKey)
{
super(new ItemStack[] { new ItemStack(Items.potionitem, 1, Short.MAX_VALUE) }, 0, "");
}
@Override
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)
{
}
}
@@ -1,120 +0,0 @@
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;
import net.minecraft.util.StatCollector;
public class ModRedstone extends ToolModTypeFilter
{
String tooltipName;
int max = 50;
public ModRedstone(int effect, ItemStack[] items, int[] values)
{
super(effect, "Redstone", items, values);
tooltipName = "\u00a74" + StatCollector.translateToLocal("modifier.tool.redstone");
}
@Override
protected boolean canModify (ItemStack tool, ItemStack[] input)
{
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;
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[] keyPair;
int increase = matchingAmount(input);
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);
}
updateModTag(tool, keyPair);
}
else
{
int modifiers = tags.getInteger("Modifiers");
modifiers -= 1;
tags.setInteger("Modifiers", modifiers);
String modName = "\u00a74" + StatCollector.translateToLocal("gui.modifier.redstone") + "(" + increase + "/" + max + ")";
int tooltipIndex = addToolTip(tool, tooltipName, modName);
keyPair = new int[] { increase, max, tooltipIndex };
tags.setIntArray(key, keyPair);
}
int miningSpeed = tags.getInteger("MiningSpeed");
miningSpeed += (increase * 8);
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 * 8);
tags.setInteger(type[i], speed);
}
}
if (tags.hasKey("DrawSpeed"))
{
// int drawSpeed = tags.getInteger("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 = "\u00a74" + StatCollector.translateToLocal("gui.modifier.redstone") + "(" + keys[0] + "/" + keys[1] + ")";
tags.setString(tip, modName);
}
@Override
public boolean validType (ToolCore tool)
{
List list = Arrays.asList(tool.toolCategories());
return list.contains("harvest") || list.contains("utility") || list.contains("bow");
}
}
@@ -1,72 +0,0 @@
package tconstruct.modifiers.tools;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
public class ModReinforced extends ModInteger
{
public ModReinforced(ItemStack[] items, int effect, int increase)
{
super(items, effect, StatCollector.translateToLocal("modifier.tool.reinforced"), 1, "\u00a75", StatCollector.translateToLocal("modifier.tool.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);
}
@Override
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;
}
}
}
}
}
@@ -1,126 +0,0 @@
package tconstruct.modifiers.tools;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.crafting.PatternBuilder;
import tconstruct.library.tools.AbilityHelper;
import tconstruct.library.tools.ToolCore;
import tconstruct.library.tools.ToolMod;
/* Little mod for actually adding the lapis modifier */
public class ModRepair extends ToolMod
{
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)
{
}
}
@@ -1,84 +0,0 @@
package tconstruct.modifiers.tools;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
public class ModSmite extends ToolModTypeFilter
{
String tooltipName;
int max = 36;
String tagName;
public ModSmite(String type, int effect, ItemStack[] items, int[] values)
{
super(effect, "ModSmite", items, values);
tooltipName = "\u00a7e" + StatCollector.translateToLocal("modifier.tool.smite");
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;
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);
}
}
@@ -1,229 +0,0 @@
package tconstruct.modifiers.tools;
import java.util.Random;
import mantle.world.WorldHelper;
import net.minecraft.block.Block;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import tconstruct.common.TRepo;
import tconstruct.library.ActiveToolMod;
import tconstruct.library.tools.AbilityHelper;
import tconstruct.library.tools.ToolCore;
import tconstruct.util.config.PHConstruct;
public class TActiveOmniMod extends ActiveToolMod
{
Random random = new Random();
/* Updating */
@Override
public void updateTool (ToolCore tool, ItemStack stack, World world, Entity entity)
{
if (!world.isRemote && entity instanceof EntityLivingBase && !((EntityLivingBase) entity).isSwingInProgress && stack.getTagCompound() != null)
{
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
if (tags.hasKey("Moss"))
{
int chance = tags.getInteger("Moss");
int check = world.canBlockSeeTheSky((int) entity.posX, (int) entity.posY, (int) entity.posZ) ? 350 : 1150;
if (random.nextInt(check) < chance)
{
AbilityHelper.healTool(stack, 1, (EntityLivingBase) entity, true);
}
}
}
}
/* Harvesting */
@Override
public boolean beforeBlockBreak (ToolCore tool, ItemStack stack, int x, int y, int z, EntityLivingBase entity)
{
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
baconator(tool, stack, entity, tags);
if (entity instanceof EntityPlayer && ((EntityPlayer) entity).capabilities.isCreativeMode)
return false;
TRepo.modLapis.midStreamModify(stack, tool);
World world = entity.worldObj;
Block block = entity.worldObj.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
// TODO do we need the next to lines????????
if (block == null)
return false;
if (tags.getBoolean("Lava") && block.quantityDropped(meta, 0, random) != 0)
{
ItemStack smeltStack = new ItemStack(block.getItemDropped(meta, random, 0), block.quantityDropped(meta, 0, random), block.damageDropped(meta));
if (smeltStack.getItem() == null)
return false;
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(smeltStack);
if (result != null)
{
WorldHelper.setBlockToAir(world, x, y, z);
if (entity instanceof EntityPlayer && !((EntityPlayer) entity).capabilities.isCreativeMode)
tool.onBlockDestroyed(stack, world, block, x, y, z, entity);
if (!world.isRemote)
{
ItemStack spawnme = result.copy();
if (!(result.getItem() instanceof ItemBlock) && PHConstruct.lavaFortuneInteraction)
{
int loot = EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, stack);
if (loot > 0)
{
spawnme.stackSize *= (random.nextInt(loot + 1) + 1);
}
}
EntityItem entityitem = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, spawnme);
entityitem.delayBeforeCanPickup = 10;
world.spawnEntityInWorld(entityitem);
world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12));
int i = spawnme.stackSize;
float f = FurnaceRecipes.smelting().func_151398_b(spawnme);
int j;
if (f == 0.0F)
{
i = 0;
}
else if (f < 1.0F)
{
j = MathHelper.floor_float((float) i * f);
if (j < MathHelper.ceiling_float_int((float) i * f) && (float) Math.random() < (float) i * f - (float) j)
{
++j;
}
i = j;
}
while (i > 0)
{
j = EntityXPOrb.getXPSplit(i);
i -= j;
entity.worldObj.spawnEntityInWorld(new EntityXPOrb(world, x, y + 0.5, z, j));
}
}
for (int i = 0; i < 5; i++)
{
float f = (float) x + random.nextFloat();
float f1 = (float) y + random.nextFloat();
float f2 = (float) z + random.nextFloat();
float f3 = 0.52F;
float f4 = random.nextFloat() * 0.6F - 0.3F;
world.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
world.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
}
return true;
}
}
return false;
}
/* Attacking */
@Override
public int baseAttackDamage (int earlyModDamage, int damage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity)
{
TRepo.modLapis.midStreamModify(stack, tool);
baconator(tool, stack, player, tags);
return 0;
}
private void baconator (ToolCore tool, ItemStack stack, EntityLivingBase entity, NBTTagCompound tags)
{
int bacon = 0;
bacon += tags.getInteger("Head") == 18 ? 1 : 0;
bacon += tags.getInteger("Handle") == 18 ? 1 : 0;
bacon += tags.getInteger("Accessory") == 18 ? 1 : 0;
bacon += tags.getInteger("Extra") == 18 ? 1 : 0;
int chance = tool.getPartAmount() * 100;
if (random.nextInt(chance) < bacon)
{
if (entity instanceof EntityPlayer)
AbilityHelper.spawnItemAtPlayer((EntityPlayer) entity, new ItemStack(TRepo.strangeFood, 1, 2));
else
AbilityHelper.spawnItemAtEntity(entity, new ItemStack(TRepo.strangeFood, 1, 2), 0);
}
}
@Override
public int attackDamage (int modDamage, int currentDamage, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity)
{
int bonus = 0;
if (entity instanceof EntityLivingBase)
{
EnumCreatureAttribute attribute = ((EntityLivingBase) entity).getCreatureAttribute();
if (attribute == EnumCreatureAttribute.UNDEAD)
{
if (tool == TRepo.hammer)
{
int level = 2;
bonus += random.nextInt(level * 2 + 1) + level * 2;
}
if (toolTags.hasKey("ModSmite"))
{
int[] array = toolTags.getIntArray("ModSmite");
int base = array[0] / 18;
bonus += 1 + base + random.nextInt(base + 1);
}
}
if (attribute == EnumCreatureAttribute.ARTHROPOD)
{
if (toolTags.hasKey("ModAntiSpider"))
{
int[] array = toolTags.getIntArray("ModAntiSpider");
int base = array[0] / 2;
bonus += 1 + base + random.nextInt(base + 1);
}
}
}
return bonus;
}
@Override
public float knockback (float modKnockback, float currentKnockback, ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity)
{
float bonus = 0f;
if (toolTags.hasKey("Knockback"))
{
float level = toolTags.getFloat("Knockback");
bonus += level;
}
return bonus;
}
@Override
public boolean doesCriticalHit (ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity)
{
if (tool == TRepo.cutlass && random.nextInt(10) == 0)
return true;
return false;
}
}
@@ -1,112 +0,0 @@
package tconstruct.modifiers.tools;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.ItemStack;
import tconstruct.library.tools.ToolMod;
public abstract class ToolModTypeFilter extends ToolMod
{
public final List<Integer> increase;
public ToolModTypeFilter(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);
}
}