2013-07-26 21:18:53 -07:00
|
|
|
package tconstruct.items.tools;
|
|
|
|
|
|
2014-09-09 18:30:15 +10:00
|
|
|
import cpw.mods.fml.relauncher.*;
|
2013-07-26 21:18:53 -07:00
|
|
|
import java.util.List;
|
|
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2014-09-09 18:30:15 +10:00
|
|
|
import net.minecraft.item.*;
|
2013-07-26 21:18:53 -07:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2014-03-15 07:11:06 -04:00
|
|
|
import net.minecraft.util.StatCollector;
|
2013-07-26 21:18:53 -07:00
|
|
|
import net.minecraft.world.World;
|
2014-09-30 19:45:37 +02:00
|
|
|
import tconstruct.library.TConstructRegistry;
|
2014-02-05 10:28:54 -05:00
|
|
|
import tconstruct.library.crafting.ToolBuilder;
|
2014-09-30 19:45:37 +02:00
|
|
|
import tconstruct.library.tools.BowstringMaterial;
|
|
|
|
|
import tconstruct.library.tools.FletchingMaterial;
|
2014-02-05 10:28:54 -05:00
|
|
|
import tconstruct.library.tools.ToolCore;
|
2014-06-04 21:44:48 -08:00
|
|
|
import tconstruct.tools.TinkerTools;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
public class Arrow extends ToolCore
|
|
|
|
|
{
|
|
|
|
|
|
2013-12-31 16:37:46 -05:00
|
|
|
public Arrow()
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2013-12-31 16:37:46 -05:00
|
|
|
super(3);
|
2013-07-26 21:18:53 -07:00
|
|
|
this.setUnlocalizedName("InfiTool.Arrow");
|
|
|
|
|
this.setMaxStackSize(64);
|
|
|
|
|
this.setMaxDamage(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getIconSuffix (int partType)
|
|
|
|
|
{
|
|
|
|
|
switch (partType)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
return "_arrow_head";
|
|
|
|
|
case 1:
|
2014-02-16 14:23:50 -05:00
|
|
|
return ""; // Doesn't break
|
2013-07-26 21:18:53 -07:00
|
|
|
case 2:
|
|
|
|
|
return "_arrow_shaft";
|
|
|
|
|
case 3:
|
|
|
|
|
return "_arrow_fletching";
|
|
|
|
|
default:
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-30 19:45:37 +02:00
|
|
|
@Override
|
|
|
|
|
protected int getDefaultColor(int renderPass, int materialID) {
|
|
|
|
|
// fletchling uses custom material
|
|
|
|
|
if(renderPass == 2)
|
|
|
|
|
return TConstructRegistry.getCustomMaterial(materialID, FletchingMaterial.class).color;
|
|
|
|
|
|
|
|
|
|
return super.getDefaultColor(renderPass, materialID);
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-26 21:18:53 -07:00
|
|
|
@Override
|
|
|
|
|
public String getEffectSuffix ()
|
|
|
|
|
{
|
|
|
|
|
return "_arrow_effect";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getDefaultFolder ()
|
|
|
|
|
{
|
|
|
|
|
return "arrow";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void registerPartPaths (int index, String[] location)
|
|
|
|
|
{
|
|
|
|
|
headStrings.put(index, location[0]);
|
|
|
|
|
handleStrings.put(index, location[2]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void registerAlternatePartPaths (int index, String[] location)
|
|
|
|
|
{
|
|
|
|
|
accessoryStrings.put(index, location[3]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Item getHeadItem ()
|
|
|
|
|
{
|
2014-06-04 21:44:48 -08:00
|
|
|
return TinkerTools.arrowhead;
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Item getAccessoryItem ()
|
|
|
|
|
{
|
2014-06-04 21:44:48 -08:00
|
|
|
return TinkerTools.fletching;
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2014-06-30 22:26:00 -08:00
|
|
|
public String[] getTraits ()
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
return new String[] { "ammo" };
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-16 13:51:33 -07:00
|
|
|
@Override
|
|
|
|
|
public float getDamageModifier ()
|
|
|
|
|
{
|
|
|
|
|
return 0.5f;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-26 21:18:53 -07:00
|
|
|
@Override
|
2014-02-07 17:11:03 -05:00
|
|
|
public void getSubItems (Item id, CreativeTabs tab, List list)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2014-02-16 14:23:50 -05:00
|
|
|
// Vanilla style arrow
|
2013-07-26 21:18:53 -07:00
|
|
|
Item accessory = getAccessoryItem();
|
|
|
|
|
ItemStack accessoryStack = accessory != null ? new ItemStack(getAccessoryItem(), 1, 0) : null;
|
|
|
|
|
Item extra = getExtraItem();
|
|
|
|
|
ItemStack extraStack = extra != null ? new ItemStack(extra, 1, 0) : null;
|
|
|
|
|
ItemStack tool = ToolBuilder.instance.buildTool(new ItemStack(getHeadItem(), 1, 3), new ItemStack(getHandleItem(), 1, 0), accessoryStack, extraStack, "");
|
2014-08-08 10:26:51 +02:00
|
|
|
if (tool != null)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
tool.stackSize = 1;
|
|
|
|
|
tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true);
|
|
|
|
|
list.add(tool);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
// Random arrow
|
2013-07-26 21:18:53 -07:00
|
|
|
accessory = getAccessoryItem();
|
|
|
|
|
accessoryStack = accessory != null ? new ItemStack(getAccessoryItem(), 1, random.nextInt(4)) : null;
|
|
|
|
|
extra = getExtraItem();
|
|
|
|
|
extraStack = extra != null ? new ItemStack(extra, 1, 0) : null;
|
2014-09-09 18:30:15 +10:00
|
|
|
tool = ToolBuilder.instance.buildTool(new ItemStack(getHeadItem(), 1, random.nextInt(18)), new ItemStack(getHandleItem(), 1, random.nextInt(18)), accessoryStack, extraStack, StatCollector.translateToLocal("item.tool.randomarrow"));
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2014-08-08 10:26:51 +02:00
|
|
|
if (tool != null)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
tool.stackSize = 1;
|
|
|
|
|
tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true);
|
|
|
|
|
list.add(tool);
|
|
|
|
|
}
|
|
|
|
|
super.getSubItems(id, tab, list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void buildTool (int id, String name, List list)
|
|
|
|
|
{
|
|
|
|
|
Item accessory = getAccessoryItem();
|
|
|
|
|
ItemStack accessoryStack = accessory != null ? new ItemStack(getAccessoryItem(), 1, 0) : null;
|
|
|
|
|
Item extra = getExtraItem();
|
|
|
|
|
ItemStack extraStack = extra != null ? new ItemStack(getExtraItem(), 1, id) : null;
|
2014-09-15 22:53:23 +02:00
|
|
|
ItemStack tool = ToolBuilder.instance.buildTool(new ItemStack(getHeadItem(), 1, id), new ItemStack(getHandleItem(), 1, id), accessoryStack, extraStack, name);
|
2014-08-08 10:26:51 +02:00
|
|
|
if (tool != null)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
tool.stackSize = 1;
|
|
|
|
|
tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true);
|
|
|
|
|
list.add(tool);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2013-07-26 21:18:53 -07:00
|
|
|
public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float clickX, float clickY, float clickZ)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
|
public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)
|
|
|
|
|
{
|
|
|
|
|
if (!stack.hasTagCompound())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
NBTTagCompound tags = stack.getTagCompound();
|
2013-11-25 15:36:32 -05:00
|
|
|
if (tags.hasKey("Energy"))
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
String color = "";
|
2014-02-16 14:23:50 -05:00
|
|
|
// double joules = this.getJoules(stack);
|
2013-11-25 15:36:32 -05:00
|
|
|
int power = tags.getInteger("Energy");
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
if (power != 0)
|
|
|
|
|
{
|
2013-11-25 15:36:32 -05:00
|
|
|
if (power <= this.getMaxEnergyStored(stack) / 3)
|
2013-07-26 21:18:53 -07:00
|
|
|
color = "\u00a74";
|
2013-11-25 15:36:32 -05:00
|
|
|
else if (power > this.getMaxEnergyStored(stack) * 2 / 3)
|
2013-07-26 21:18:53 -07:00
|
|
|
color = "\u00a72";
|
|
|
|
|
else
|
|
|
|
|
color = "\u00a76";
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-25 15:36:32 -05:00
|
|
|
String energy = new StringBuilder().append(color).append(tags.getInteger("Energy")).append("/").append(getMaxEnergyStored(stack)).append(" RF").toString();
|
|
|
|
|
list.add(energy);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
if (tags.hasKey("InfiTool"))
|
|
|
|
|
{
|
|
|
|
|
boolean broken = tags.getCompoundTag("InfiTool").getBoolean("Broken");
|
|
|
|
|
if (broken)
|
|
|
|
|
list.add("\u00A7oBroken");
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int head = tags.getCompoundTag("InfiTool").getInteger("Head");
|
|
|
|
|
int handle = tags.getCompoundTag("InfiTool").getInteger("Handle");
|
|
|
|
|
|
|
|
|
|
String headName = getAbilityNameForType(head);
|
|
|
|
|
if (!headName.equals(""))
|
|
|
|
|
list.add(getStyleForType(head) + headName);
|
|
|
|
|
|
|
|
|
|
String handleName = getAbilityNameForType(handle);
|
|
|
|
|
if (!handleName.equals("") && handle != head)
|
|
|
|
|
list.add(getStyleForType(handle) + handleName);
|
|
|
|
|
|
|
|
|
|
boolean displayToolTips = true;
|
|
|
|
|
int tipNum = 0;
|
|
|
|
|
while (displayToolTips)
|
|
|
|
|
{
|
|
|
|
|
tipNum++;
|
|
|
|
|
String tooltip = "Tooltip" + tipNum;
|
|
|
|
|
if (tags.getCompoundTag("InfiTool").hasKey(tooltip))
|
|
|
|
|
{
|
|
|
|
|
String tipName = tags.getCompoundTag("InfiTool").getString(tooltip);
|
|
|
|
|
if (!tipName.equals(""))
|
|
|
|
|
list.add(tipName);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
displayToolTips = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-15 07:11:06 -04:00
|
|
|
int attack = (int) (tags.getCompoundTag("InfiTool").getInteger("Attack") * this.getDamageModifier());
|
|
|
|
|
list.add("\u00A79+" + attack + " " + StatCollector.translateToLocalFormatted("attribute.name.generic.attackDamage"));
|
|
|
|
|
list.add("\u00A79+" + tags.getCompoundTag("InfiTool").getInteger("Attack") + " " + StatCollector.translateToLocalFormatted("attribute.name.ammo.attackDamage"));
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
2013-11-08 17:53:58 -05:00
|
|
|
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|