Skip to content

Commit

Permalink
Throwing knives now crit when they're aimed long enough
Browse files Browse the repository at this point in the history
  • Loading branch information
bonii-xx committed Nov 21, 2014
1 parent d57f8b6 commit 40a2e91
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/main/java/tconstruct/library/weaponry/AmmoWeapon.java
Expand Up @@ -106,7 +106,7 @@ protected void launchProjectile(ItemStack stack, World world, EntityPlayer playe
ItemStack reference = stack.copy();
reference.stackSize = 1;
reference.getTagCompound().getCompoundTag("InfiTool").setInteger("Ammo", 1);
Entity projectile = createProjectile(reference, world, player, getAccuracy(stack, time));
Entity projectile = createProjectile(reference, world, player, getAccuracy(stack, time), time);
world.spawnEntityInWorld(projectile);
}

Expand All @@ -115,7 +115,7 @@ protected void launchProjectile(ItemStack stack, World world, EntityPlayer playe
this.consumeAmmo(1, stack);
}

protected abstract Entity createProjectile(ItemStack reference, World world, EntityPlayer player, float accuracy);
protected abstract Entity createProjectile(ItemStack reference, World world, EntityPlayer player, float accuracy, int time);

/** used for displaying the damage, return the value used for pseed in createProjectile/ProjectileBase constructor
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tconstruct/weaponry/weapons/Javelin.java
Expand Up @@ -174,7 +174,7 @@ public String[] getTraits() {
}

@Override
protected Entity createProjectile(ItemStack reference, World world, EntityPlayer player, float accuracy) {
protected Entity createProjectile(ItemStack reference, World world, EntityPlayer player, float accuracy, int time) {
reference.getTagCompound().getCompoundTag("InfiTool").removeTag("Throwing"); // needed so the NBTs are equal
JavelinEntity entity = new JavelinEntity(world, player, getProjectileSpeed(), accuracy, reference);

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/tconstruct/weaponry/weapons/Shuriken.java
Expand Up @@ -128,7 +128,7 @@ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer pla
}

@Override
protected Entity createProjectile(ItemStack reference, World world, EntityPlayer player, float accuracy) {
protected Entity createProjectile(ItemStack reference, World world, EntityPlayer player, float accuracy, int time) {
return new ShurikenEntity(world, player, getProjectileSpeed(), 0f, reference);
}

Expand Down
10 changes: 8 additions & 2 deletions src/main/java/tconstruct/weaponry/weapons/ThrowingKnife.java
@@ -1,6 +1,7 @@
package tconstruct.weaponry.weapons;

import net.minecraft.client.entity.EntityPlayerSP;
import tconstruct.library.entity.ProjectileBase;
import tconstruct.weaponry.client.CrosshairType;
import tconstruct.weaponry.entity.ThrowingKnifeEntity;
import tconstruct.library.weaponry.AmmoWeapon;
Expand Down Expand Up @@ -77,8 +78,13 @@ public float minAccuracy(ItemStack itemStack) {
}

@Override
protected Entity createProjectile(ItemStack reference, World world, EntityPlayer player, float accuracy) {
return new ThrowingKnifeEntity(world, player, getProjectileSpeed(), accuracy, reference);
protected Entity createProjectile(ItemStack reference, World world, EntityPlayer player, float accuracy, int time) {
ProjectileBase knife = new ThrowingKnifeEntity(world, player, getProjectileSpeed(), accuracy, reference);
// if you aim long enough, it's a crit!
if(time >= this.getWindupTime(reference)*1.5f)
knife.setIsCritical(true);

return knife;
}

@Override
Expand Down

0 comments on commit 40a2e91

Please sign in to comment.