Skip to content

Commit

Permalink
Move the drawspeed calculation to the tool building, so the saved val…
Browse files Browse the repository at this point in the history
…ues are the actual values instead of calculating them every time
  • Loading branch information
bonii-xx committed Oct 28, 2014
1 parent db7e419 commit ff7c6c1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 21 deletions.
Expand Up @@ -4,9 +4,7 @@
import net.minecraft.util.StatCollector;
import tconstruct.client.TProxyClient;
import tconstruct.library.TConstructRegistry;
import tconstruct.weaponry.TinkerWeaponry;
import tconstruct.weaponry.client.CrosshairType;
import tconstruct.util.Reference;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
Expand Down Expand Up @@ -91,11 +89,9 @@ public float getAccuracy(ItemStack itemStack, int time)
/* Windup */
public int getWindupTime(ItemStack itemStack) {
NBTTagCompound toolTag = itemStack.getTagCompound().getCompoundTag("InfiTool");
return (int)((float)toolTag.getInteger("DrawSpeed")*windupModifier(itemStack));
return toolTag.getInteger("DrawSpeed");
}

protected float windupModifier(ItemStack itemStack) { return 1.0f; }

public float getWindupProgress(ItemStack itemStack, EntityPlayer player)
{
// what are you doing!
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/tconstruct/weaponry/WeaponryHandler.java
Expand Up @@ -17,6 +17,8 @@
import tconstruct.library.event.ToolBuildEvent;
import tconstruct.library.event.ToolCraftEvent;
import tconstruct.library.tools.*;
import tconstruct.weaponry.weapons.LongBow;
import tconstruct.weaponry.weapons.ShortBow;

public class WeaponryHandler {
// Provides ammo-items with the necessary NBT
Expand Down Expand Up @@ -97,6 +99,7 @@ public void onProjectileWeaponCrafted(ToolCraftEvent.NormalTool event)
return;

NBTTagCompound tags = event.toolTag.getCompoundTag("InfiTool");
ProjectileWeapon weapon = (ProjectileWeapon)event.tool;

int drawSpeed = 0;
float flightSpeed = 0;
Expand All @@ -112,6 +115,13 @@ public void onProjectileWeaponCrafted(ToolCraftEvent.NormalTool event)

drawSpeed = (int) ((top.drawspeed + bottom.drawspeed) / 2f * string.drawspeedModifier);
flightSpeed = (top.flightSpeedMax + bottom.flightSpeedMax)/2 * string.flightSpeedModifier;

// SHORT bows have a SHORTER windup because they're SHORT. hahahaha.... get it?
if(event.tool instanceof ShortBow)
drawSpeed *= 0.9;
// longbows have LONGER drawspeed. LOGIC!
if(event.tool instanceof LongBow)
drawSpeed *= 1.5f;
}
else if(event.tool instanceof Crossbow)
{
Expand All @@ -120,6 +130,10 @@ else if(event.tool instanceof Crossbow)

drawSpeed = (int) ((float)top.drawspeed * string.drawspeedModifier);
flightSpeed = (top.flightSpeedMax * string.flightSpeedModifier);

// crossbows are more efficient the higher the base drawspeed is. So the higher the drawspeed, the more bonus you get
drawSpeed *= 2.5f;
drawSpeed -= drawSpeed*0.25f;
}
else
return;
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/tconstruct/weaponry/weapons/Crossbow.java
Expand Up @@ -49,12 +49,6 @@ public ItemStack getLoadedAmmo(ItemStack itemStack)
return ItemStack.loadItemStackFromNBT(tags.getCompoundTag("LoadedItem"));
}

@Override
public int getWindupTime(ItemStack itemStack) {
NBTTagCompound toolTag = itemStack.getTagCompound().getCompoundTag("InfiTool");
return (int)((float)toolTag.getInteger("DrawSpeed") * 2.5f);
}

@Override
public float getMinWindupProgress(ItemStack itemStack) {
return 1.0f;
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/tconstruct/weaponry/weapons/LongBow.java
Expand Up @@ -31,11 +31,6 @@ public float getZoom(ItemStack itemStack) {
return 1.7f;
}

@Override
protected float windupModifier(ItemStack itemStack) {
return 1.5f;
}

@Override
protected float projectileSpeedModifier(ItemStack itemStack) {
return 1.5f;
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/tconstruct/weaponry/weapons/ShortBow.java
Expand Up @@ -15,11 +15,6 @@ public ShortBow() {
super(0, "Shortbow");
}

@Override
protected float windupModifier(ItemStack itemStack) {
return 0.9f; // SHORT bows have a SHORTER windup because they're SHORT. hahahaha.... get it?
}

@Override
public float minAccuracy(ItemStack itemStack) {
return 1;
Expand Down

0 comments on commit ff7c6c1

Please sign in to comment.