Skip to content

Commit

Permalink
More arrow tags and display fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bonii-xx committed Oct 19, 2014
1 parent 1194d60 commit 11fcf21
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 19 deletions.
2 changes: 1 addition & 1 deletion resources/assets/tinker/lang/en_US.lang
Expand Up @@ -819,7 +819,7 @@ modifier.tool.beheading=Beheading

creativeModLock.tooltip=Target Lock:

attribute.name.ammo.attackDamage=Average Shot Damage
attribute.name.ammo.attackDamage=Base Damage

tool.pickaxe=Pickaxe
tool.shovel=Shovel
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/tconstruct/items/tools/Arrow.java
Expand Up @@ -197,11 +197,11 @@ else if (power > this.getMaxEnergyStored(stack) * 2 / 3)
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);

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/tconstruct/items/tools/Shortbow.java
Expand Up @@ -148,7 +148,7 @@ else if (power > this.getMaxEnergyStored(stack) * 2 / 3)
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);

Expand All @@ -158,14 +158,14 @@ else if (power > this.getMaxEnergyStored(stack) * 2 / 3)

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);
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/tconstruct/library/tools/ToolCore.java
Expand Up @@ -328,24 +328,24 @@ else if (RF > this.getMaxEnergyStored(stack) * 2 / 3)
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);
}
Expand Down Expand Up @@ -386,7 +386,7 @@ public static String getStyleForType (int type)
/**
* 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();
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/tconstruct/library/weaponry/AmmoItem.java
@@ -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;
Expand All @@ -9,6 +12,8 @@
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);
Expand Down
22 changes: 14 additions & 8 deletions src/main/java/tconstruct/weaponry/WeaponryHandler.java
Expand Up @@ -56,10 +56,7 @@ public void onAmmoCrafted(ToolCraftEvent.NormalTool event)
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)
{
Expand All @@ -81,11 +78,10 @@ else if(event.tool instanceof BoltAmmo)
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...
Expand Down Expand Up @@ -187,4 +183,14 @@ public void buildBolt(ToolBuildEvent event)
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);
}
}
14 changes: 14 additions & 0 deletions src/main/java/tconstruct/weaponry/ammo/ArrowAmmo.java
Expand Up @@ -82,6 +82,12 @@ public Item getAccessoryItem ()
return TinkerWeaponry.fletching;
}

// handle is custom material
@Override
public int durabilityTypeHandle() {
return 0;
}

@Override
public String[] getTraits ()
{
Expand Down Expand Up @@ -134,4 +140,12 @@ protected int getDefaultColor(int renderPass, int materialID) {

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);
}
}
8 changes: 8 additions & 0 deletions src/main/java/tconstruct/weaponry/ammo/BoltAmmo.java
Expand Up @@ -107,4 +107,12 @@ protected int getDefaultColor(int renderPass, int materialID) {

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);
}
}

0 comments on commit 11fcf21

Please sign in to comment.