Jump to content

Recommended Posts

Posted

Hi forge community! I've been reluctant to ask for help in an attempt to figure out things for myself but it seems I'm a little stumped on something I figured would be rather simple.

 

Goal:

 

My goal is to get my player entity to right click on a block (onBlockActivated) and be automatically made to jump in the air and ready to fly. So far all I have been able to find throughout the API is to set the player entity's capabilities to allow them to fly in survival (allowFlying set to true), as well as tell the program that the entity is flying (isFlying set to true) even though it is not.

 

Problem:

 

So my problem is small but I'm still new to the forge API. I want the player to automatically jump into the air ready to move around in flight mode, but I simply do not have the expertise to make this happen.

 

So I'm calling upon my fellow modders to lend me a hand!

 

Thanks in advance. ;D

Posted

public boolean onBlockActivated(World world, int xCoord, int yCoord, int zCoord, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9)
    {
	entityPlayer.capabilities.allowFlying = true;
	entityPlayer.motionY += 1.0;
	entityPlayer.capabilities.isFlying = true;
	entityPlayer.fallDistance = 0;		
        return true;
    }

 

works for me

Posted

Oh my god... it wasn't your code that fixed the problem - but the "lack of it" (bad way of explaining it I know).

 

here was mine...

 

public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
    {
        if (par1World.isRemote)
        {
            return true;
        }
        else
        {
        	//Check Activation by player
        	String var1 = par5EntityPlayer.username;
        	par5EntityPlayer.sendChatToPlayer("Activated by: " + var1 + "");

        //Make the player fly
        	par5EntityPlayer.capabilities.allowFlying = true;
                par5EntityPlayer.fallDistance = 0; 
        	par5EntityPlayer.motionY += 1.0;
        	par5EntityPlayer.capabilities.isFlying = true;
        	
            
            return true;
        }
    }

 

turns out it needs to return to both cases.

 

Thanks - four days on such a silly problem!

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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