1.6.2 test - Finished liquids, added connected textures on glass

This commit is contained in:
mDiyo committed 2013-07-26 21:18:53 -07:00
1 parent 40c6f445a2
commit a80fcbce86
704 files changed
+60909

No files matched your search

+85
View File
@@ -0,0 +1,85 @@
package tconstruct.modifiers;
import tconstruct.library.tools.ToolMod;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class ModAntiSpider extends ToolMod
{
String tooltipName;
int increase;
int max = 4;
String guiType;
public ModAntiSpider(String type, ItemStack[] items, int effect, int inc)
{
super(items, effect, "ModAntiSpider");
tooltipName = "\u00a72Bane of Arthropods";
guiType = type;
increase = inc;
}
@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] + increase <= 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");
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);
}
}
+125
View File
@@ -0,0 +1,125 @@
package tconstruct.modifiers;
import java.util.Arrays;
import java.util.List;
import tconstruct.library.tools.ToolCore;
import tconstruct.library.tools.ToolMod;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class ModAttack extends ToolMod
{
String tooltipName;
int increase;
int max = 72;
String guiType;
public ModAttack(String type, ItemStack[] items, int effect, int inc)
{
super(items, effect, "ModAttack");
tooltipName = "\u00a7fSharpness";
guiType = type;
increase = inc;
}
@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] + increase <= 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");
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 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);
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);
}
public boolean validType (ToolCore tool)
{
return true;
/*List list = Arrays.asList(tool.toolCategories());
return list.contains("melee") || list.contains("harvest") || list.contains("ammo");*/
}
public boolean nerfType (ToolCore tool)
{
List list = Arrays.asList(tool.toolCategories());
return list.contains("throwing") || list.contains("ammo");
}
}
+23
View File
@@ -0,0 +1,23 @@
package tconstruct.modifiers;
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
}
}
+103
View File
@@ -0,0 +1,103 @@
package tconstruct.modifiers;
import java.util.Arrays;
import java.util.List;
import tconstruct.library.tools.ToolCore;
import tconstruct.library.tools.ToolMod;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class ModBlaze extends ToolMod
{
String tooltipName;
int increase;
int max;
public ModBlaze(ItemStack[] items, int effect, int inc)
{
super(items, effect, "Blaze");
tooltipName = "\u00a76Fiery";
increase = inc;
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] + increase <= 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");
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.toolCategories());
return list.contains("melee") || list.contains("ammo");
}
}
+42
View File
@@ -0,0 +1,42 @@
package tconstruct.modifiers;
import tconstruct.library.tools.ToolMod;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
/* 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);
//System.out.println("Key: "+key+" "+tags.getBoolean(key));
int modifiers = tags.getInteger("Modifiers");
modifiers -= 1;
tags.setInteger("Modifiers", modifiers);
addToolTip(tool, color + tooltipName, color + key);
}
}
+117
View File
@@ -0,0 +1,117 @@
package tconstruct.modifiers;
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)
{
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("ench");
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.toolCategories());
return list.contains("weapon") || list.contains("harvest");
}
}
+69
View File
@@ -0,0 +1,69 @@
package tconstruct.modifiers;
import tconstruct.library.tools.ToolMod;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
/* 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);
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);
}
}
+88
View File
@@ -0,0 +1,88 @@
package tconstruct.modifiers;
import ic2.api.item.IElectricItem;
import java.util.ArrayList;
import tconstruct.library.tools.ToolCore;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
/* IC2 support */
public class ModElectric extends ModBoolean
{
public ArrayList<ItemStack> circuits = new ArrayList<ItemStack>();
public ArrayList<ItemStack> batteries = new ArrayList<ItemStack>();
public ModElectric()
{
super(new ItemStack[0], 9, "Electric", "\u00a7e", "");
}
@Override
public boolean matches (ItemStack[] input, ItemStack tool)
{
if (input[0] == null || input[1] == null)
return false;
boolean circuit = false;
boolean battery = false;
for (ItemStack stack : circuits)
{
if (stack.isItemEqual(input[0]) || stack.isItemEqual(input[1]))
circuit = true;
}
for (ItemStack stack : batteries)
{
if (stack.itemID == input[0].itemID && input[0].getItem() instanceof IElectricItem)
{
battery = true;
}
if (stack.itemID == input[1].itemID && input[1].getItem() instanceof IElectricItem)
{
battery = true;
}
}
return circuit && battery && canModify(tool, input);
}
/*@Override
protected boolean canModify (ItemStack tool, ItemStack[] input)
{
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (!tags.hasKey(key))
return tags.getInteger("Modifiers") > 0;
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].getItem() instanceof IElectricItem && input[0].hasTagCompound())
charge = input[0].getTagCompound().getInteger("charge");
if (input[1].getItem() instanceof IElectricItem && input[1].hasTagCompound())
charge = input[1].getTagCompound().getInteger("charge");
tags.setInteger("charge", charge);
tags.setInteger(key, 1);
addModifierTip(tool, "\u00a7eElectric");
ToolCore toolcore = (ToolCore) tool.getItem();
tool.setItemDamage(1 + (toolcore.getMaxCharge(tool) - charge) * (tool.getMaxDamage() - 1) / toolcore.getMaxCharge(tool));
}
}
}
@@ -0,0 +1,39 @@
package tconstruct.modifiers;
import tconstruct.library.tools.ToolMod;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
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);
}
public void addMatchingEffect (ItemStack tool)
{
}
}
+55
View File
@@ -0,0 +1,55 @@
package tconstruct.modifiers;
import tconstruct.library.tools.ToolMod;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
/* 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);
}
}
+210
View File
@@ -0,0 +1,210 @@
package tconstruct.modifiers;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import tconstruct.library.tools.ToolCore;
import tconstruct.library.tools.ToolMod;
import tconstruct.library.tools.Weapon;
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 ModLapis extends ToolMod
{
String tooltipName;
int increase;
int max = 450;
public ModLapis(ItemStack[] items, int effect, int inc)
{
super(items, effect, "Lapis");
tooltipName = "\u00a79Luck";
increase = inc;
}
@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] + increase <= 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, "\u00a79Luck", modName);
int[] keyPair = new int[] { 0, tooltipIndex };
tags.setIntArray(key, keyPair);
int modifiers = tags.getInteger("Modifiers");
modifiers -= 1;
tags.setInteger("Modifiers", modifiers);
}
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] >= 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] >= 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("ench");
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.toolCategories());
return list.contains("weapon") || list.contains("harvest");
}
}
+103
View File
@@ -0,0 +1,103 @@
package tconstruct.modifiers;
import java.util.Arrays;
import java.util.List;
import tconstruct.library.tools.ToolCore;
import tconstruct.library.tools.ToolMod;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class ModPiston extends ToolMod
{
String tooltipName;
int increase;
int max;
public ModPiston(ItemStack[] items, int effect, int inc)
{
super(items, effect, "Piston");
tooltipName = "\u00a77Knockback";
increase = inc;
max = 10;
}
@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] + increase <= 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");
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.toolCategories());
return list.contains("weapon");
}
}
+32
View File
@@ -0,0 +1,32 @@
package tconstruct.modifiers;
import tconstruct.library.tools.ToolMod;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class ModPotion extends ToolMod
{
public ModPotion(ItemStack[] items, int effect, String dataKey)
{
super(new ItemStack[] { new ItemStack(Item.potion, 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)
{
}
}
+118
View File
@@ -0,0 +1,118 @@
package tconstruct.modifiers;
import java.util.Arrays;
import java.util.List;
import tconstruct.library.tools.ToolCore;
import tconstruct.library.tools.ToolMod;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class ModRedstone extends ToolMod
{
String tooltipName;
int increase;
int max;
public ModRedstone(ItemStack[] items, int effect, int inc)
{
super(items, effect, "Redstone");
tooltipName = "\u00a74Haste";
increase = inc;
max = 50;
}
@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] + increase <= 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;
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 = "\u00a74Redstone (" + 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);
if (tags.hasKey("MiningSpeed2"))
{
int miningSpeed2 = tags.getInteger("MiningSpeed2");
miningSpeed2 += (increase * 8);
tags.setInteger("MiningSpeed2", miningSpeed2);
}
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 = "\u00a74Redstone (" + keys[0] + "/" + keys[1] + ")";
tags.setString(tip, modName);
}
public boolean validType (ToolCore tool)
{
List list = Arrays.asList(tool.toolCategories());
return list.contains("harvest") || list.contains("utility") || list.contains("bow");
}
}
+70
View File
@@ -0,0 +1,70 @@
package tconstruct.modifiers;
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;
}
}
}
}
}
+100
View File
@@ -0,0 +1,100 @@
package tconstruct.modifiers;
import tconstruct.library.crafting.PatternBuilder;
import tconstruct.library.tools.AbilityHelper;
import tconstruct.library.tools.ToolCore;
import tconstruct.library.tools.ToolMod;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
/* 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) || (input[0] != null && input[1] != null)) //Only valid for one itemstack
return false;
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
if (tags.getInteger("Damage") > 0)
{
int headID = tags.getInteger("Head");
int matID = -1;
if (input[0] != null)
matID = PatternBuilder.instance.getPartID(input[0]);
else
matID = PatternBuilder.instance.getPartID(input[1]);
if (matID == headID)
return true;
}
return false;
}
@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 materialValue = 0;
if (input[0] != null)
materialValue = PatternBuilder.instance.getPartValue(input[0]);
else
materialValue = PatternBuilder.instance.getPartValue(input[1]);
int increase = (int) (50 + (dur * 0.4f * materialValue));
//System.out.println("Increase: "+increase);
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");
repair += 1;
tags.setInteger("RepairCount", repair);
float repairCount = (100 - repair) / 100f;
if (repairCount < 0.5f)
repairCount = 0.5f;
increase *= repairCount;
increase /= ((ToolCore) tool.getItem()).getRepairCost();
damage -= increase;
if (damage < 0)
damage = 0;
tags.setInteger("Damage", damage);
AbilityHelper.damageTool(tool, 0, null, true);
//tool.setItemDamage(damage * 100 / dur);
}
@Override
public void addMatchingEffect (ItemStack tool)
{
}
}
+85
View File
@@ -0,0 +1,85 @@
package tconstruct.modifiers;
import tconstruct.library.tools.ToolMod;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class ModSmite extends ToolMod
{
String tooltipName;
int increase;
int max = 36;
String tagName;
public ModSmite(String type, ItemStack[] items, int effect, int inc)
{
super(items, effect, "ModSmite");
tooltipName = "\u00a7eSmite";
tagName = type;
increase = inc;
}
@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] + increase <= 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");
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);
}
}
+215
View File
@@ -0,0 +1,215 @@
package tconstruct.modifiers;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import tconstruct.common.TContent;
import tconstruct.library.ActiveToolMod;
import tconstruct.library.tools.AbilityHelper;
import tconstruct.library.tools.ToolCore;
import tconstruct.util.PHConstruct;
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;
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)
{
if (entity instanceof EntityPlayer && ((EntityPlayer) entity).capabilities.isCreativeMode)
return false;
List list = Arrays.asList(tool.toolCategories());
if (list.contains("harvest"))
TContent.modL.midStreamModify(stack, tool);
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
World world = entity.worldObj;
int bID = entity.worldObj.getBlockId(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
Block block = Block.blocksList[bID];
if (block == null || bID < 1 || bID > 4095)
return false;
if (tags.getBoolean("Lava") && block.quantityDropped(meta, 0, random) != 0)
{
ItemStack smeltStack = new ItemStack(block.idDropped(meta, random, 0), block.quantityDropped(meta, 0, random), block.damageDropped(meta));
if (smeltStack.itemID < 0 || smeltStack.itemID >= 32000 || smeltStack.getItem() == null)
return false;
ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(smeltStack);
if (result != null)
{
world.setBlockToAir(x, y, z);
if (entity instanceof EntityPlayer && !((EntityPlayer) entity).capabilities.isCreativeMode)
tool.onBlockDestroyed(stack, world, bID, 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, bID + (meta << 12));
int i = spawnme.stackSize;
float f = FurnaceRecipes.smelting().getExperience(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)
{
List list = Arrays.asList(tool.toolCategories());
if (list.contains("weapon"))
TContent.modL.midStreamModify(stack, tool);
return 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 == TContent.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;
}
public boolean doesCriticalHit (ToolCore tool, NBTTagCompound tags, NBTTagCompound toolTags, ItemStack stack, EntityLivingBase player, Entity entity)
{
if (tool == TContent.cutlass && random.nextInt(10) == 0)
return true;
return false;
}
}