2013-07-26 21:18:53 -07:00
|
|
|
package tconstruct.library.tools;
|
|
|
|
|
|
2014-08-20 17:08:12 +02:00
|
|
|
import net.minecraft.util.StatCollector;
|
|
|
|
|
|
2013-07-26 21:18:53 -07:00
|
|
|
/*
|
|
|
|
|
* Dynamic substitute for an enum. It carries a lot of information
|
|
|
|
|
*/
|
2014-06-30 22:26:00 -08:00
|
|
|
public class ToolMaterial
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
public final String materialName;
|
|
|
|
|
public final int harvestLevel;
|
|
|
|
|
public final int durability;
|
|
|
|
|
public final int miningspeed; // <-- divided by 100
|
|
|
|
|
public final int attack;
|
|
|
|
|
public final float handleModifier;
|
|
|
|
|
public final int reinforced;
|
|
|
|
|
public final float stonebound;
|
|
|
|
|
public final String tipStyle;
|
2014-09-09 19:54:50 +10:00
|
|
|
public final int primaryColor;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2014-09-10 18:39:06 +02:00
|
|
|
private final String localizationString;
|
|
|
|
|
|
2014-09-03 13:34:26 +02:00
|
|
|
@Deprecated
|
|
|
|
|
public String displayName;
|
2014-09-02 16:32:49 -07:00
|
|
|
@Deprecated
|
2014-09-04 09:28:40 +02:00
|
|
|
public String ability;
|
2014-09-09 18:30:15 +10:00
|
|
|
|
2014-09-04 09:28:40 +02:00
|
|
|
@Deprecated
|
2014-09-02 16:32:49 -07:00
|
|
|
public ToolMaterial(String name, String displayName, int level, int durability, int speed, int damage, float handle, int reinforced, float stonebound, String style, String ability)
|
|
|
|
|
{
|
2014-09-09 19:54:50 +10:00
|
|
|
this(name, level, durability, speed, damage, handle, reinforced, stonebound, style, 0xFFFFFF);
|
2014-09-03 13:34:26 +02:00
|
|
|
this.displayName = prefixName();
|
2014-09-04 09:28:40 +02:00
|
|
|
this.ability = ability();
|
2014-09-02 16:32:49 -07:00
|
|
|
}
|
|
|
|
|
|
2014-09-04 09:26:56 +02:00
|
|
|
@Deprecated
|
|
|
|
|
public ToolMaterial(String name, int level, int durability, int speed, int damage, float handle, int reinforced, float stonebound, String style, String ability)
|
|
|
|
|
{
|
2014-09-09 19:54:50 +10:00
|
|
|
this(name, level, durability, speed, damage, handle, reinforced, stonebound, style, 0xFFFFFF);
|
2014-09-04 09:26:56 +02:00
|
|
|
this.displayName = prefixName();
|
2014-09-04 09:28:40 +02:00
|
|
|
this.ability = ability();
|
2014-09-04 09:26:56 +02:00
|
|
|
}
|
|
|
|
|
|
2014-09-09 19:54:50 +10:00
|
|
|
public ToolMaterial(String name, int level, int durability, int speed, int damage, float handle, int reinforced, float stonebound, String style, int primaryColor)
|
2014-09-10 18:39:06 +02:00
|
|
|
{
|
|
|
|
|
this(name, "material." + name.toLowerCase().replaceAll(" ", ""), level, durability, speed, damage, handle, reinforced, stonebound, style, primaryColor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ToolMaterial(String name, String localizationString, int level, int durability, int speed, int damage, float handle, int reinforced, float stonebound, String style, int primaryColor)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
this.materialName = name;
|
|
|
|
|
this.harvestLevel = level;
|
|
|
|
|
this.durability = durability;
|
|
|
|
|
this.miningspeed = speed;
|
|
|
|
|
this.attack = damage;
|
|
|
|
|
this.handleModifier = handle;
|
|
|
|
|
this.reinforced = reinforced;
|
|
|
|
|
this.stonebound = stonebound;
|
|
|
|
|
this.tipStyle = style;
|
2014-09-09 19:54:50 +10:00
|
|
|
this.primaryColor = primaryColor;
|
2014-09-10 18:39:06 +02:00
|
|
|
|
|
|
|
|
this.localizationString = localizationString;
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String name ()
|
|
|
|
|
{
|
|
|
|
|
return materialName;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-09 18:30:15 +10:00
|
|
|
public String localizedName ()
|
|
|
|
|
{
|
2014-09-10 18:39:06 +02:00
|
|
|
return StatCollector.translateToLocal(localizationString);
|
2014-09-09 18:30:15 +10:00
|
|
|
}
|
2014-09-01 22:40:00 +02:00
|
|
|
|
2014-09-09 18:30:15 +10:00
|
|
|
public String prefixName ()
|
2014-09-01 22:40:00 +02:00
|
|
|
{
|
|
|
|
|
// check if there's a special name, otherwise use the regular one
|
2014-09-10 18:39:06 +02:00
|
|
|
if (StatCollector.canTranslate(String.format("%s.display", localizationString)))
|
|
|
|
|
return StatCollector.translateToLocal(String.format("%s.display", localizationString));
|
2014-09-01 22:40:00 +02:00
|
|
|
return localizedName();
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-26 21:18:53 -07:00
|
|
|
public int durability ()
|
|
|
|
|
{
|
|
|
|
|
return this.durability;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int toolSpeed ()
|
|
|
|
|
{
|
|
|
|
|
return this.miningspeed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int attack ()
|
|
|
|
|
{
|
|
|
|
|
return this.attack;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int harvestLevel ()
|
|
|
|
|
{
|
|
|
|
|
return this.harvestLevel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float handleDurability ()
|
|
|
|
|
{
|
|
|
|
|
return this.handleModifier;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int reinforced ()
|
|
|
|
|
{
|
|
|
|
|
return this.reinforced;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float shoddy ()
|
|
|
|
|
{
|
|
|
|
|
return this.stonebound;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String style ()
|
|
|
|
|
{
|
|
|
|
|
return this.tipStyle;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-09 19:54:50 +10:00
|
|
|
public int primaryColor ()
|
|
|
|
|
{
|
|
|
|
|
return this.primaryColor;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-03 11:50:57 +02:00
|
|
|
/**
|
|
|
|
|
* Returns the ability of the tool to display.
|
|
|
|
|
* ONLY USE THIS FOR DISPLAY PURPOSES. It is not data you can rely on. Use the material-ids for that.
|
|
|
|
|
*/
|
2013-07-26 21:18:53 -07:00
|
|
|
public String ability ()
|
|
|
|
|
{
|
2014-09-10 18:39:06 +02:00
|
|
|
if (StatCollector.canTranslate(String.format("%s.ability", localizationString)))
|
|
|
|
|
return StatCollector.translateToLocal(String.format("%s.ability", localizationString));
|
2014-09-03 11:50:57 +02:00
|
|
|
return "";
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
}
|