More arrow tags and display fixes

This commit is contained in:
Bernhard Bonigl committed 2014-10-19 16:23:01 +02:00
1 parent 1194d60678
commit 11fcf21eb6
8 files changed
+52 -19

No files matched your search

@@ -197,11 +197,11 @@ public class Arrow extends ToolCore
int head = tags.getCompoundTag("InfiTool").getInteger("Head");
int handle = tags.getCompoundTag("InfiTool").getInteger("Handle");
String headName = getAbilityNameForType(head);
String headName = getAbilityNameForType(head, 0);
if (!headName.equals(""))
list.add(getStyleForType(head) + headName);
String handleName = getAbilityNameForType(handle);
String handleName = getAbilityNameForType(handle, 0);
if (!handleName.equals("") && handle != head)
list.add(getStyleForType(handle) + handleName);
@@ -148,7 +148,7 @@ public class Shortbow extends BowBase
int binding = tags.getCompoundTag("InfiTool").getInteger("Accessory");
int extra = tags.getCompoundTag("InfiTool").getInteger("Extra");
String headName = getAbilityNameForType(head);
String headName = getAbilityNameForType(head, 0);
if (!headName.equals(""))
list.add(getStyleForType(head) + headName);
@@ -158,14 +158,14 @@ public class Shortbow extends BowBase
if (getPartAmount() >= 3)
{
String bindingName = getAbilityNameForType(binding);
String bindingName = getAbilityNameForType(binding, 0);
if (!bindingName.equals("") && binding != head && binding != handle)
list.add(getStyleForType(binding) + bindingName);
}
if (getPartAmount() >= 4)
{
String extraName = getAbilityNameForType(extra);
String extraName = getAbilityNameForType(extra, 0);
if (!extraName.equals("") && extra != head && extra != handle && extra != binding)
list.add(getStyleForType(extra) + extraName);
}
@@ -328,24 +328,24 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem, IMo
int binding = tags.getCompoundTag("InfiTool").getInteger("Accessory");
int extra = tags.getCompoundTag("InfiTool").getInteger("Extra");
String headName = getAbilityNameForType(head);
String headName = getAbilityNameForType(head, 0);
if (!headName.equals(""))
list.add(getStyleForType(head) + headName);
String handleName = getAbilityNameForType(handle);
String handleName = getAbilityNameForType(handle, 1);
if (!handleName.equals("") && handle != head)
list.add(getStyleForType(handle) + handleName);
if (getPartAmount() >= 3)
{
String bindingName = getAbilityNameForType(binding);
String bindingName = getAbilityNameForType(binding, 2);
if (!bindingName.equals("") && binding != head && binding != handle)
list.add(getStyleForType(binding) + bindingName);
}
if (getPartAmount() >= 4)
{
String extraName = getAbilityNameForType(extra);
String extraName = getAbilityNameForType(extra, 3);
if (!extraName.equals("") && extra != head && extra != handle && extra != binding)
list.add(getStyleForType(extra) + extraName);
}
@@ -386,7 +386,7 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem, IMo
/**
* Returns the localized name of the materials ability. Only use this for display purposes, not for logic.
*/
public String getAbilityNameForType (int type)
public String getAbilityNameForType (int type, int part)
{
return TConstructRegistry.getMaterial(type).ability();
}
@@ -1,5 +1,8 @@
package tconstruct.library.weaponry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.util.StatCollector;
import tconstruct.library.TConstructRegistry;
import tconstruct.weaponry.TinkerWeaponry;
import tconstruct.util.Reference;
@@ -9,6 +12,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import tconstruct.library.tools.ToolCore;
import java.util.List;
public abstract class AmmoItem extends ToolCore implements IAmmo {
public AmmoItem(int baseDamage, String name) {
super(baseDamage);
@@ -56,10 +56,7 @@ public class WeaponryHandler {
float accuracy = fletching.accuracy;
float breakChance = shaft.fragility + fletching.breakChance;
tags.setInteger("TotalDurability", durability);
tags.setFloat("Mass", weight);
tags.setFloat("BreakChance", breakChance);
tags.setFloat("Accuracy", accuracy);
setAmmoData(tags, durability, weight, accuracy, breakChance, head.shoddy(), head.reinforced());
}
else if(event.tool instanceof BoltAmmo)
{
@@ -81,11 +78,10 @@ public class WeaponryHandler {
float weight = head.mass + core.mass;
float accuracy = fletching.accuracy;
float breakChance = fletching.breakChance*3;
float shoddy = (headMat.shoddy() + coreMat.shoddy())/2f;
int reinforced = Math.max(headMat.reinforced(), coreMat.reinforced());
tags.setInteger("TotalDurability", durability);
tags.setFloat("Mass", weight);
tags.setFloat("BreakChance", breakChance);
tags.setFloat("Accuracy", accuracy);
setAmmoData(tags, durability, weight, accuracy, breakChance, shoddy, reinforced);
}
// now that durability has been handled...
@@ -187,4 +183,14 @@ public class WeaponryHandler {
event.handleStack = bolt2;
event.accessoryStack = fletching;
}
private void setAmmoData(NBTTagCompound tags, int durability, float weight, float breakChance, float accuracy, float shoddy, int reinforced)
{
tags.setInteger("TotalDurability", durability);
tags.setFloat("Mass", weight);
tags.setFloat("BreakChance", breakChance);
tags.setFloat("Accuracy", accuracy);
tags.setFloat("Shoddy", shoddy); // we could actually always set this to 0 since it has zero impact on ammo
tags.setInteger("Unbreaking", reinforced);
}
}
@@ -82,6 +82,12 @@ public class ArrowAmmo extends AmmoItem {
return TinkerWeaponry.fletching;
}
// handle is custom material
@Override
public int durabilityTypeHandle() {
return 0;
}
@Override
public String[] getTraits ()
{
@@ -134,4 +140,12 @@ public class ArrowAmmo extends AmmoItem {
return mat.color;
}
// fix tooltip custom materials
@Override
public String getAbilityNameForType(int type, int part) {
if(part >= 1) // only head has ability
return "";
return super.getAbilityNameForType(type, part);
}
}
@@ -107,4 +107,12 @@ public class BoltAmmo extends AmmoItem {
return mat.color;
}
// fix tooltip custom materials
@Override
public String getAbilityNameForType(int type, int part) {
if(part >= 2) // only head and handle have ability
return "";
return super.getAbilityNameForType(type, part);
}
}