mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-20 12:19:48 +00:00
Add display and calculation stuff for maximum damage with thrown weapons
This commit is contained in:
1 parent
92fd2cc222
commit
525baf8aad
6 files changed
+51
-7
No files matched your search
@@ -88,7 +88,7 @@ public abstract class AmmoWeapon extends AmmoItem implements IAccuracy, IWindup
|
||||
|
||||
@Override
|
||||
public String[] getTraits() {
|
||||
return new String[] {"weapon", "projectile", "ammo", "windup"};
|
||||
return new String[] {"weapon", "thrown", "ammo", "windup"};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -115,6 +115,10 @@ public abstract class AmmoWeapon extends AmmoItem implements IAccuracy, IWindup
|
||||
|
||||
protected abstract Entity createProjectile(ItemStack reference, World world, EntityPlayer player, float accuracy);
|
||||
|
||||
/** used for displaying the damage, return the value used for pseed in createProjectile/ProjectileBase constructor
|
||||
*/
|
||||
public abstract float getProjectileSpeed();
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public CrosshairType getCrosshairType() { return CrosshairType.SQUARE; }
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import tconstruct.library.tools.DualHarvestTool;
|
||||
import tconstruct.library.tools.HarvestTool;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.library.util.HarvestLevels;
|
||||
import tconstruct.library.weaponry.AmmoWeapon;
|
||||
import tconstruct.library.weaponry.IAmmo;
|
||||
import tconstruct.library.weaponry.ProjectileWeapon;
|
||||
|
||||
@@ -86,6 +87,9 @@ public final class ToolStationGuiHelper {
|
||||
// weapon?
|
||||
if (categories.contains("weapon"))
|
||||
drawWeaponStats(tool, tags);
|
||||
// throwing weapon?
|
||||
if (categories.contains("thrown") && tool instanceof AmmoWeapon)
|
||||
drawThrowingWeaponStats((AmmoWeapon) tool, tags);
|
||||
// projectile weapon?
|
||||
if (categories.contains("bow") && tool instanceof ProjectileWeapon)
|
||||
drawProjectileWeaponStats((ProjectileWeapon) tool, tags, stack);
|
||||
@@ -192,7 +196,7 @@ public final class ToolStationGuiHelper {
|
||||
private static void drawWeaponStats(ToolCore tool, NBTTagCompound tags)
|
||||
{
|
||||
// DAMAGE
|
||||
int attack = (tags.getInteger("Attack")) + 1;
|
||||
int attack = (tags.getInteger("Attack"));
|
||||
|
||||
// factor in Stonebound
|
||||
float stoneboundDamage = -AbilityHelper.calcStoneboundBonus(tool, tags);
|
||||
@@ -216,6 +220,23 @@ public final class ToolStationGuiHelper {
|
||||
}
|
||||
}
|
||||
|
||||
private static void drawThrowingWeaponStats(AmmoWeapon weapon, NBTTagCompound tags) {
|
||||
float attackf = (tags.getInteger("Attack"));
|
||||
attackf *= weapon.getDamageModifier();
|
||||
attackf *= weapon.getProjectileSpeed();
|
||||
|
||||
if (attackf < 1)
|
||||
attackf = 1;
|
||||
|
||||
int attack = (int)attackf;
|
||||
|
||||
String heart = attack == 2 ? StatCollector.translateToLocal("gui.partcrafter8") : StatCollector.translateToLocal("gui.partcrafter9");
|
||||
if (attack % 2 == 0)
|
||||
write(StatCollector.translateToLocal("gui.toolstation23") + attack / 2 + heart);
|
||||
else
|
||||
write(StatCollector.translateToLocal("gui.toolstation23") + df.format(attack / 2f) + heart);
|
||||
}
|
||||
|
||||
private static void drawProjectileWeaponStats(ProjectileWeapon weapon, NBTTagCompound tags, ItemStack stack)
|
||||
{
|
||||
// drawspeed
|
||||
@@ -245,7 +266,7 @@ public final class ToolStationGuiHelper {
|
||||
|
||||
private static void drawArmorStats(ArmorCore armor, NBTTagCompound tags, ItemStack stack)
|
||||
{
|
||||
// Damage reduction
|
||||
// Damage reduction
|
||||
double damageReduction = tags.getDouble("DamageReduction");
|
||||
if(damageReduction > 0)
|
||||
write(StatCollector.translateToLocal("gui.toolstation19") + df.format(damageReduction));
|
||||
|
||||
@@ -163,14 +163,24 @@ public class Javelin extends AmmoWeapon {
|
||||
return TinkerTools.toughRod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTraits() {
|
||||
return new String[] {"weapon", "thrown", "ammo", "windup"};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Entity createProjectile(ItemStack reference, World world, EntityPlayer player, float accuracy) {
|
||||
reference.getTagCompound().getCompoundTag("InfiTool").removeTag("Throwing"); // needed so the NBTs are equal
|
||||
JavelinEntity entity = new JavelinEntity(world, player, 2.0f, accuracy, reference);
|
||||
JavelinEntity entity = new JavelinEntity(world, player, getProjectileSpeed(), accuracy, reference);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProjectileSpeed() {
|
||||
return 2.0f;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public CrosshairType getCrosshairType() { return CrosshairType.WEIRD; }
|
||||
|
||||
@@ -111,7 +111,12 @@ public class Shuriken extends AmmoWeapon {
|
||||
|
||||
@Override
|
||||
protected Entity createProjectile(ItemStack reference, World world, EntityPlayer player, float accuracy) {
|
||||
return new ShurikenEntity(world, player, 1.9f, 0f, reference);
|
||||
return new ShurikenEntity(world, player, getProjectileSpeed(), 0f, reference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProjectileSpeed() {
|
||||
return 1.9f;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -77,9 +77,12 @@ public class ThrowingKnife extends AmmoWeapon {
|
||||
|
||||
@Override
|
||||
protected Entity createProjectile(ItemStack reference, World world, EntityPlayer player, float accuracy) {
|
||||
float speed = 1.5f;
|
||||
return new ThrowingKnifeEntity(world, player, getProjectileSpeed(), accuracy, reference);
|
||||
}
|
||||
|
||||
return new ThrowingKnifeEntity(world, player, speed, accuracy, reference);
|
||||
@Override
|
||||
public float getProjectileSpeed() {
|
||||
return 1.5f;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
Reference in new issue
Block a user