So I was making a mod and part of it required shooting arrows at the players crosshairs, so I began with a getYaw and getPitch. Then I realized that geometry was not my best subject, and I have no clue how to cause an arrow at top velocity shoot where the players crosshairs are. So basically I can't convert the x y z coords of the player and their yaw and pitch into spawning the arrow. Any help? Also, any other important geometric functions like this?
So I was making a mod and part of it required shooting arrows at the players crosshairs, so I began with a getYaw and getPitch. Then I realized that geometry was not my best subject, and I have no clue how to cause an arrow at top velocity shoot where the players crosshairs are. So basically I can't convert the x y z coords of the player and their yaw and pitch into spawning the arrow. Any help? Also, any other important geometric functions like this?
I have nothing to say...
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumYou can do it like in this Mod:
https://www.dropbox.com/s/aav7599ipxrhbjc/TorchGun.js?dl=0
look at line 83 and the following lines.
D: I'm using this it doesn't do anything there's no error message:
function useItem(x,y,z,itemId,blockId,side,itemDamage,blockDamage) {
if (itemId==289) {
var yaw=Entity.getYaw(getPlayerEnt());
var myX;
var myZ;
yaw=yaw-90;
while(yaw>360){
yaw=yaw-360;
}
while(yaw<0){
yaw=yaw+360;
}
if(yaw>0 && yaw<22){
myX=-0.5;
myZ=0;
}
if(yaw>22 && yaw<45){
myX=-0.35;
myZ=-0.2;
}
if(yaw>45 && yaw<67){
myX=-0.2;
myZ=-0.35;
}
if(yaw>67 && yaw<90){
myX=0;
myZ=-0.5;
}
if(yaw>90 && yaw<112){
myX=0;
myZ=-0.5;
}
if(yaw>112 && yaw<135){
myX=0.2;
myZ=-0.35;
}
if(yaw>135 && yaw<157){
myX=0.35;
myZ=-0.2;
}
if(yaw>157 && yaw<180){
myX=0.5;
myZ=0;
}
if(yaw>180 && yaw<202){
myX=0.5;
myZ=0;
}
if(yaw>202 && yaw<225){
myX=0.35;
myZ=0.2;
}
if(yaw>225 && yaw<247){
myX=0.2;
myZ=0.35;
}
if(yaw>247 && yaw<270){
myX=0;
myZ=0.5;
}
if(yaw>270 && yaw<292){
myX=0;
myZ=0.5;
}
if(yaw>292 && yaw<315){
myX=-0.2;
myZ=0.35;
}
if(yaw>315 && yaw<337){
myX=-0.35;
myZ=0.2;
}
if(yaw>337 && yaw<360){
myX=-0.5;
myZ=0;
}
try{
arrow=Level.spawnMob(Player.getX()+myX*5, Player.getY(), Player.getZ()+myZ*5, 80);
Entity.setVelX(arrow, myX*1.7);
Entity.setVelY(arrow, 0.15);
Entity.setVelZ(arrow, myZ*1.7);
arrow=0;
}catch(err){
print("Error: " + err);
}
}
}
Taken from the torchgun mod, btw
I have nothing to say...
-
View User Profile
-
View Posts
-
Send Message
Curse PremiumDid you wrote
var arrow;
at the top of your Mod?
Now I did. It still doesn't work. I really don't understand it.
I have nothing to say...
I feel like such a noob... I finally found out I was using id 289 instead of 180.
I have nothing to say...