King_Arthur_III Posted August 29, 2015 Share Posted August 29, 2015 I am trying to make a sword that shoots a large fireball when right clicked in the direction that the player is pointing. But the fireball takes three parameters at the end that I don't know what they do. When I make them 10, 10, 10, the fireball always goes in a set direction no matter which way I am pointing. It seems like these parameters would be coordinates or something, but I don't know how to have them change depending on where the mouse is pointing. ? = mystery parameter @Override public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World,EntityPlayer par3EntityPlayer) { if(par3EntityPlayer.capabilities.isCreativeMode||par3EntityPlayer.inventory.consumeInventoryItem(Items.redstone)) { par2World.playSoundAtEntity(par3EntityPlayer, "fireball", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!par2World.isRemote) { par2World.spawnEntityInWorld(new EntityLargeFireball(par2World, par3EntityPlayer, ?, ?, ?)); } } return par1ItemStack; } Quote Link to comment Share on other sites More sharing options...
Failender Posted August 29, 2015 Share Posted August 29, 2015 u can take these values from the player. should be pitch yaw aaaaand.. dont know what the third was.. raw? search ur ide for it EDIT: i think it was roll pitch and yaw Quote Link to comment Share on other sites More sharing options...
King_Arthur_III Posted August 29, 2015 Author Share Posted August 29, 2015 Thanks for the answer, I tried to find what would I could use but I figured out that they are accelerationX, accelerationY, and accelerationZ, so it doesn't sound like it has anything to do with pitch, yaw, and roll. Also, I don't think roll would be one of them because Minecraft only has pitch and yaw. Quote Link to comment Share on other sites More sharing options...
TheGreyGhost Posted August 30, 2015 Share Posted August 30, 2015 Hi You might find this link useful http://greyminecraftcoder.blogspot.com.au/2015/07/entity-rotations-and-animation.html -TGG Quote Link to comment Share on other sites More sharing options...
King_Arthur_III Posted August 30, 2015 Author Share Posted August 30, 2015 Thanks TGG. Any idea what it means by accelerationX/Y/Z? Quote Link to comment Share on other sites More sharing options...
Draco18s Posted August 30, 2015 Share Posted August 30, 2015 Thanks TGG. Any idea what it means by accelerationX/Y/Z? Exactly what it says on the tin. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
King_Arthur_III Posted August 30, 2015 Author Share Posted August 30, 2015 But what would I set them to so that it accelerates in the direction the player is looking? Quote Link to comment Share on other sites More sharing options...
Draco18s Posted August 30, 2015 Share Posted August 30, 2015 But what would I set them to so that it accelerates in the direction the player is looking? The player's look vector. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
King_Arthur_III Posted August 30, 2015 Author Share Posted August 30, 2015 I found net.minecraft.util.Vec3 and net.minecraft.entity.player.EntityPlayer, but I couldn't find anything that worked. Am I looking in the right place? And do you know what the third parameter be, because the look vectors only use pitch and yaw, (y and x). Quote Link to comment Share on other sites More sharing options...
Draco18s Posted August 30, 2015 Share Posted August 30, 2015 Vec3 vec = entityPlayer.getLookVec(); //Magic Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
King_Arthur_III Posted September 3, 2015 Author Share Posted September 3, 2015 Thanks! I got it to work and shoot in the general direction the player is looking, but it seemed to have a certain amount of randomness. I confirmed this by looking in the fireball class. Do you know if there is anyway to stop it from shooting somewhat randomly? Quote Link to comment Share on other sites More sharing options...
Draco18s Posted September 4, 2015 Share Posted September 4, 2015 Yes. Although I recommend trying to puzzle the problem out yourself first. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
King_Arthur_III Posted September 7, 2015 Author Share Posted September 7, 2015 So I now the code looks like this, and it works better than before, with a few exceptions. The good part is that the fireball shoots in a much less random direction. However, much of the time it seems to get very buggy once it goes relatively far. Also, it shoots much faster than normal, which is not necessarily bad, but strange. @Override public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if(par3EntityPlayer.capabilities.isCreativeMode||par3EntityPlayer.inventory.consumeInventoryItem(Items.redstone)) { par2World.playSoundAtEntity(par3EntityPlayer, "fireball", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!par2World.isRemote){ //Minecraft minecraft = Minecraft.getMinecraft(); //EntityPlayerSP player = minecraft.thePlayer; //par2World.spawnEntityInWorld(new EntityLargeFireball(par2World, par3EntityPlayer, vec3.xCoord, vec3.yCoord, vec3.zCoord)); Vec3 vec3 = par3EntityPlayer.getLookVec(); EntityLargeFireball entitylargefireball = new EntityLargeFireball(par2World, par3EntityPlayer, vec3.xCoord, vec3.yCoord, vec3.zCoord); entitylargefireball.accelerationX = vec3.xCoord; entitylargefireball.accelerationY = vec3.yCoord; entitylargefireball.accelerationZ = vec3.zCoord; par2World.spawnEntityInWorld(entitylargefireball); } } return par1ItemStack; } Quote Link to comment Share on other sites More sharing options...
Draco18s Posted September 8, 2015 Share Posted September 8, 2015 Changing the acceleration is easy, just divide or multiply the vec3 values when you assign them. As for buggy, I don't know. I do know that there's a vanilla bug that the motion/acceleration values aren't saved when the game unloads, causing fireballs to get stuck mid-air (despite being reported to Mojang back in 1.4.4, they didn't fix it until last week's snapshot, 15w36c). Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given. Link to comment Share on other sites More sharing options...
King_Arthur_III Posted September 10, 2015 Author Share Posted September 10, 2015 Thanks so much! It's finally working, and when I slowed down the speed it seems to be much less buggy. (I noticed the bugged floating fireballs you mentioned). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.