Skip to content

Commit

Permalink
Change battlesign-blocking to actually require you to look at the arr…
Browse files Browse the repository at this point in the history
…ow + reflection speed depends on how much you looked at it (+buffed)
  • Loading branch information
bonii-xx committed Nov 30, 2014
1 parent 076b66b commit 4981355
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/main/java/tconstruct/tools/TinkerToolEvents.java
Expand Up @@ -229,15 +229,25 @@ public void onAttack (LivingAttackEvent event)
{
if (source.isProjectile())
{
Entity projectile = source.getSourceOfDamage();
Vec3 motion = Vec3.createVectorHelper(projectile.motionX, projectile.motionY, projectile.motionZ);
Vec3 look = player.getLookVec();

// this gives a factor of how much we're looking at the incoming arrow
double strength = -look.dotProduct(motion.normalize());
// we're looking away. oh no.
if(strength < 0.1)
return;

// no damage, hooraaay
event.setCanceled(true);

Entity projectile = source.getSourceOfDamage();

double speed = projectile.motionX*projectile.motionX + projectile.motionY*projectile.motionY + projectile.motionZ*projectile.motionZ;
speed = Math.sqrt(speed);

Vec3 look = player.getLookVec();
speed = (speed+2)*strength;



// now we simply set the look vector with the speed and get our new vector!
projectile.motionX = look.xCoord * speed;
Expand Down

0 comments on commit 4981355

Please sign in to comment.