Posted July 19, 201312 yr I am fairly new to making mods, and I am making an item that launches you up and sends you launching in the direction you are looking. Here is the code I am currently using to make the player launch up when they right click with the item: @Override public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { player.motionY = 0.7; return itemStack; } Any ideas? Thanks!
July 19, 201312 yr my teleport spell uses thsi double motionX = 20 * (double) (-MathHelper.sin(player.rotationYaw/ 180.0F * (float) Math.PI)* MathHelper.cos(player.rotationPitch / 180.0F* (float) Math.PI) * f); double motionZ = 20 * (double) (MathHelper.cos(player.rotationYaw / 180.0F * (float) Math.PI)* MathHelper.cos(player.rotationPitch / 180.0F* (float) Math.PI) * f); double motionY = 20 * (double) (-MathHelper.sin((player.rotationPitch)/ 180.0F * (float) Math.PI) * f); how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
July 19, 201312 yr Author my teleport spell uses thsi double motionX = 20 * (double) (-MathHelper.sin(player.rotationYaw/ 180.0F * (float) Math.PI)* MathHelper.cos(player.rotationPitch / 180.0F* (float) Math.PI) * f); double motionZ = 20 * (double) (MathHelper.cos(player.rotationYaw / 180.0F * (float) Math.PI)* MathHelper.cos(player.rotationPitch / 180.0F* (float) Math.PI) * f); double motionY = 20 * (double) (-MathHelper.sin((player.rotationPitch)/ 180.0F * (float) Math.PI) * f); On "* f" It gives me an error, are you using a variable that you had or something? It crashes when I use the item.
July 19, 201312 yr lolol, yes, its technily 0.4f but you could tottally remove it and it wouldnt change anything how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
July 19, 201312 yr Author lolol, yes, its technily 0.4f but you could tottally remove it and it wouldnt change anything Hmm..I put it in my onItemRightclick method and it does nothing...here is this code: @Override public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { player.motionY = 0.7; double motionX = 20 * (double) (-MathHelper.sin(player.rotationYaw/ 180.0F * (float) Math.PI)* MathHelper.cos(player.rotationPitch / 180.0F* (float) Math.PI) * 0.4f); double motionZ = 20 * (double) (MathHelper.cos(player.rotationYaw / 180.0F * (float) Math.PI)* MathHelper.cos(player.rotationPitch / 180.0F* (float) Math.PI) * 0.4f); double motionY = 20 * (double) (-MathHelper.sin((player.rotationPitch)/ 180.0F * (float) Math.PI) * 0.4f); return itemStack; } Sorry about my noobishness, I am new to modding like I said Edit: Is Pi already in Eclipse/Forge/Minecraft, or is it another class you have? Same with MathHelper.
July 19, 201312 yr new to coding ? ok lets take it step by step double motionX = 20 * (double) (-MathHelper.sin(player.rotationYaw/ 180.0F * (float) Math.PI)* MathHelper.cos(player.rotationPitch / 180.0F* (float) Math.PI) * 0.4f); double motionZ = 20 * (double) (MathHelper.cos(player.rotationYaw / 180.0F * (float) Math.PI)* MathHelper.cos(player.rotationPitch / 180.0F* (float) Math.PI) * 0.4f); double motionY = 20 * (double) (-MathHelper.sin((player.rotationPitch)/ 180.0F * (float) Math.PI) * 0.4f); so heres my code, basicly it will calculate the translation on all 3 different axis double motionX = 3; double motionY = 3; double motionZ = 3; so this code would technicly tell the program "yo btw i have 3 variable, one called motionX and value of 3, one called motionY and value of 3 and a last one called motionZ and value of 3" now this does NOTHIGN on its own because all it says is "hey i have these values" it doesnt do anythign with them now lets take a look at your line of code player.motionY = 0.7; basicly this is saying to the program "btw buddy, can you take the "player" and take a look at its "motionY" value, and while you're there can you assign it the value of 0.7" now im going to write one of the 3 lines requires to make this work and youll write the 2 other public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { player.motionY = 0.7; double calculatedX= 20 * (double) (-MathHelper.sin(player.rotationYaw/ 180.0F * (float) Math.PI)* MathHelper.cos(player.rotationPitch / 180.0F* (float) Math.PI) * 0.4f); double calculatedZ = 20 * (double) (MathHelper.cos(player.rotationYaw / 180.0F * (float) Math.PI)* MathHelper.cos(player.rotationPitch / 180.0F* (float) Math.PI) * 0.4f); double calculatedY = 20 * (double) (-MathHelper.sin((player.rotationPitch)/ 180.0F * (float) Math.PI) * 0.4f); player.motionY = calculatedY; //another line of code for another axis //another line of code for the last axis return itemStack; } how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
July 19, 201312 yr Author Lol I feel like such a noob...says calculated(x y and z) cannot be resolved to a variable I am trying to get better
July 19, 201312 yr look at my secodn code, notice [glow=red,2,300]the variable names[/glow] ive change them to make thigns clearer how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
July 19, 201312 yr Author look at my secodn code, notice [glow=red,2,300]the variable names[/glow] ive change them to make thigns clearer Thank you sooooooooo much!!! Applause for you! Works perfectly! Now how to figure out how to negate fall damage!
July 20, 201312 yr to negate fall damage do this: (based on hydro's code) public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { double calculatedX= 20 * (double) (-MathHelper.sin(player.rotationYaw/ 180.0F * (float) Math.PI)* MathHelper.cos(player.rotationPitch / 180.0F* (float) Math.PI) * 0.4f); double calculatedZ = 20 * (double) (MathHelper.cos(player.rotationYaw / 180.0F * (float) Math.PI)* MathHelper.cos(player.rotationPitch / 180.0F* (float) Math.PI) * 0.4f); double calculatedY = 20 * (double) (-MathHelper.sin((player.rotationPitch)/ 180.0F * (float) Math.PI) * 0.4f); player.fallDamage = 0.0F; player.motionY = calculatedY; //another line of code for another axis //another line of code for the last axis return itemStack; } http://www.minecraftforum.net/topic/1722025-151forgewands-ores-mod-wip021 Wands & Ores Mod!
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.