Posted August 29, 201510 yr 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; }
August 29, 201510 yr 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
August 29, 201510 yr Author 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.
August 30, 201510 yr Hi You might find this link useful http://greyminecraftcoder.blogspot.com.au/2015/07/entity-rotations-and-animation.html -TGG
August 30, 201510 yr Thanks TGG. Any idea what it means by accelerationX/Y/Z? Exactly what it says on the tin. 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.
August 30, 201510 yr Author But what would I set them to so that it accelerates in the direction the player is looking?
August 30, 201510 yr But what would I set them to so that it accelerates in the direction the player is looking? The player's look vector. 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.
August 30, 201510 yr Author 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).
August 30, 201510 yr Vec3 vec = entityPlayer.getLookVec(); //Magic 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.
September 3, 201510 yr Author 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?
September 4, 201510 yr Yes. Although I recommend trying to puzzle the problem out yourself first. 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.
September 7, 201510 yr Author 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; }
September 8, 201510 yr 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). 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.
September 10, 201510 yr Author 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).
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.