From 40a2e9194395d53dad3682f2f912c1207d1cd109 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Fri, 21 Nov 2014 18:50:04 +0100 Subject: [PATCH] Throwing knives now crit when they're aimed long enough --- .../java/tconstruct/library/weaponry/AmmoWeapon.java | 4 ++-- src/main/java/tconstruct/weaponry/weapons/Javelin.java | 2 +- .../java/tconstruct/weaponry/weapons/Shuriken.java | 2 +- .../tconstruct/weaponry/weapons/ThrowingKnife.java | 10 ++++++++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/tconstruct/library/weaponry/AmmoWeapon.java b/src/main/java/tconstruct/library/weaponry/AmmoWeapon.java index 026749bed5e..fac9cc2804e 100644 --- a/src/main/java/tconstruct/library/weaponry/AmmoWeapon.java +++ b/src/main/java/tconstruct/library/weaponry/AmmoWeapon.java @@ -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); } @@ -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 */ diff --git a/src/main/java/tconstruct/weaponry/weapons/Javelin.java b/src/main/java/tconstruct/weaponry/weapons/Javelin.java index 936c8b44bba..3510e9210cd 100644 --- a/src/main/java/tconstruct/weaponry/weapons/Javelin.java +++ b/src/main/java/tconstruct/weaponry/weapons/Javelin.java @@ -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); diff --git a/src/main/java/tconstruct/weaponry/weapons/Shuriken.java b/src/main/java/tconstruct/weaponry/weapons/Shuriken.java index d0bf8328fab..b8912f78b2e 100644 --- a/src/main/java/tconstruct/weaponry/weapons/Shuriken.java +++ b/src/main/java/tconstruct/weaponry/weapons/Shuriken.java @@ -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); } diff --git a/src/main/java/tconstruct/weaponry/weapons/ThrowingKnife.java b/src/main/java/tconstruct/weaponry/weapons/ThrowingKnife.java index f1d0205cb1e..862939e19f9 100644 --- a/src/main/java/tconstruct/weaponry/weapons/ThrowingKnife.java +++ b/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; @@ -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