Push golem block shot as per request

This commit is contained in:
libraryaddict 2015-08-27 11:10:17 -07:00
parent ba41118da7
commit 102fcd8e73
2 changed files with 22 additions and 23 deletions

View File

@ -354,7 +354,7 @@ public class UtilAlg
return bestLoc;
}
public static Vector calculateVelocity(Vector from, Vector to, int heightGain)
public static Vector calculateVelocity(Vector from, Vector to, double heightGain)
{
// Gravity of a potion
double gravity = 0.115;
@ -366,8 +366,7 @@ public class UtilAlg
double horizDist = Math.sqrt(dx1 * dx1 + dz1 * dz1);
// Height gain
int gain = heightGain;
double maxGain = gain > (endGain + gain) ? gain : (endGain + gain);
double maxGain = heightGain > (endGain + heightGain) ? heightGain : (endGain + heightGain);
// Solve quadratic equation for velocity
double a = -horizDist * horizDist / (4 * maxGain);
double b = horizDist;

View File

@ -173,8 +173,8 @@ public class GolemBlockShot extends GolemAbility
net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) cur).getHandle();
Vec3D vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ);
Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY, nmsEntity.locZ
+ nmsEntity.motZ);
Vec3D vec3d1 = Vec3D.a(nmsEntity.locX + nmsEntity.motX, nmsEntity.locY + nmsEntity.motY,
nmsEntity.locZ + nmsEntity.motZ);
MovingObjectPosition finalObjectPosition = nmsEntity.world.rayTrace(vec3d, vec3d1, false, true, false);
vec3d = Vec3D.a(nmsEntity.locX, nmsEntity.locY, nmsEntity.locZ);
@ -185,8 +185,7 @@ public class GolemBlockShot extends GolemAbility
vec3d1 = Vec3D.a(finalObjectPosition.pos.a, finalObjectPosition.pos.b, finalObjectPosition.pos.c);
}
for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities(
((CraftEntity) cur).getHandle(),
for (Object entity : ((CraftWorld) cur.getWorld()).getHandle().getEntities(((CraftEntity) cur).getHandle(),
((CraftEntity) cur).getHandle().boundingBox.a(((CraftEntity) cur).getHandle().motX,
((CraftEntity) cur).getHandle().motY, ((CraftEntity) cur).getHandle().motZ).grow(2, 2, 2)))
{
@ -225,11 +224,9 @@ public class GolemBlockShot extends GolemAbility
{
cur.getWorld().playEffect(victim.getEyeLocation().subtract(0, 0.5, 0), Effect.STEP_SOUND, cur.getBlockId());
getGolem()
.getEvent()
.getDamageManager()
.NewDamageEvent((LivingEntity) victim, getEntity(), null, DamageCause.CONTACT, 6, true, true, false,
"Iron Wizard Block Shot", "Iron Wizard Block Shot");
getGolem().getEvent().getDamageManager().NewDamageEvent((LivingEntity) victim, getEntity(), null,
DamageCause.CONTACT, 6 * getGolem().getDifficulty(), true, true, false, "Iron Wizard Block Shot",
"Iron Wizard Block Shot");
cur.remove();
fallingIterator.remove();
@ -255,8 +252,8 @@ public class GolemBlockShot extends GolemAbility
nmsEntity.motX = ((float) (finalObjectPosition.pos.a - nmsEntity.locX));
nmsEntity.motY = ((float) (finalObjectPosition.pos.b - nmsEntity.locY));
nmsEntity.motZ = ((float) (finalObjectPosition.pos.c - nmsEntity.locZ));
float f2 = MathHelper.sqrt(nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ
* nmsEntity.motZ);
float f2 = MathHelper.sqrt(
nmsEntity.motX * nmsEntity.motX + nmsEntity.motY * nmsEntity.motY + nmsEntity.motZ * nmsEntity.motZ);
nmsEntity.locX -= nmsEntity.motX / f2 * 0.0500000007450581D;
nmsEntity.locY -= nmsEntity.motY / f2 * 0.0500000007450581D;
nmsEntity.locZ -= nmsEntity.motZ / f2 * 0.0500000007450581D;
@ -268,8 +265,9 @@ public class GolemBlockShot extends GolemAbility
}
else
{
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0), cur.getLocation()
.add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL, UtilServer.getPlayers());
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(Material.STONE, 0),
cur.getLocation().add(0, 0.5, 0), 0.3F, 0.3F, 0.3F, 0, 2, UtilParticle.ViewDist.NORMAL,
UtilServer.getPlayers());
}
}
}
@ -361,8 +359,8 @@ public class GolemBlockShot extends GolemAbility
UtilPlayer.sendPacket(player, packet, packet2);
}
_shotAt.put(_target.getUniqueId(), (_shotAt.containsKey(_target.getUniqueId()) ? _shotAt.get(_target.getUniqueId())
: 0) + 1);
_shotAt.put(_target.getUniqueId(),
(_shotAt.containsKey(_target.getUniqueId()) ? _shotAt.get(_target.getUniqueId()) : 0) + 1);
_target = getTarget();
}
@ -382,7 +380,7 @@ public class GolemBlockShot extends GolemAbility
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(new int[]
{
id
id
});
for (Player player : Bukkit.getOnlinePlayers())
@ -416,16 +414,18 @@ public class GolemBlockShot extends GolemAbility
loc1.setY(l.getY() + 1);
}
Vector vector = UtilAlg.getTrajectory(l, loc1);
int dist = (int) Math.ceil(loc1.toVector().setY(0).distance(l.toVector().setY(0)));
vector.multiply(13).add(new Vector(UtilMath.r(3) - 1, 0, UtilMath.r(3) - 1)).normalize();
Vector vector = UtilAlg.calculateVelocity(l.toVector(), loc1.toVector(), dist / 13);
falling.setVelocity(vector.multiply(0.5 + (l.distance(target.getEyeLocation()) / 10)));
falling.setVelocity(vector);// .multiply(0.5 + (l.distance(target.getEyeLocation()) / 10)).multiply(0.7));
}
}
}
if (_thrown >= 3 && !UtilPlayer.getNearby(getLocation(), 10, true).isEmpty())
if (_thrown >= 3 && !UtilPlayer.getNearby(
getLocation(), 10, true).isEmpty())
{
_thrown = 99;
}