Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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;

}

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

  • 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.

 

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.

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.

  • 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).

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.

  • 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?

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.

  • 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;

}

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.

  • 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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.