Jump to content

Quick question about overriding methods


Z@Nka

Recommended Posts

I have a quick question, if I have a method in the block class doesn't have a parameter I need, how can I add a parameter to it with it still getting called?

If I helped then you help, hit that Thank You button or Applaud.

Link to comment
Share on other sites

The method is

    public void updateTick(World world, int x, int y, int z, Random random)

The parameter I need is EntityPlayer. I need my block to scan for players in a radius of a few blocks.

If I helped then you help, hit that Thank You button or Applaud.

Link to comment
Share on other sites

In:

world.getClosestVulnerablePlayer(1, x, y, z)

What does the 1 stand for? Is it the gamemode? If so, when I have it at 1, does that mean that players with gamemode 1 will be counted or anything that isn't 1?

If I helped then you help, hit that Thank You button or Applaud.

Link to comment
Share on other sites

Ok, so this is the code I used, and it didn't work. Nothing happend.

    public void updateTick(World world, int x, int y, int z, Random random)
    {
    	EntityPlayer player = world.getClosestVulnerablePlayer(5, x, y, z);
    	
    	if(player != null)
    	{
    		System.out.println("gf");
    	}
    }

Ohh yeah, sorry for posting this here but, when I log out and back in, my block isn't there.

If I helped then you help, hit that Thank You button or Applaud.

Link to comment
Share on other sites

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.