Jump to content

[1.7.10]How to make blocks work with beacon bases.


DerpyHoovesMC

Recommended Posts

@Override
public boolean isBeaconBase(IBlockAccess world, int x, int y, int z, int beaconX, int beaconX, int beaconY, int beaconZ) {
    return true;
}

 

Next time, search for beacon in vanilla sources.

 

What he said but if you use a single block file for all non-special blocks like me I would recommend adding a new method in it:

 

First you need to add a variable at the top:

private Block beaconBase;

after that we simple add a method called setBeaconBase which is going to return a block:

	public Block setBeaconBase(){
	return beaconBase = this;
}

Now we do pretty much what he said with a twist:

	@Override
public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ)
{
	return this == beaconBase;
}

 

Now we simply add ".setBeaconBase()" to make a block a beacon base block:

		blockBronze = new SmBlock(Material.iron, "blockBronze", Block.soundTypeMetal, 5.0F, 8.0F).setBeaconBase();

 

I'm sorry I can't help but make random tutorials in the forums sometimes :/

If I helped please press the Thank You button.

Link to comment
Share on other sites

*She.

 

Additionally, why use a

Block

and not a

boolean

as the private flag for whether the block is a beacon base or not?

 

private boolean isBeaconBase;

public void setBeaconBase() {
    isBeaconBase = true;
}

@Override
public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) {
    return isBeaconBase;
}

Link to comment
Share on other sites

*She.

 

Additionally, why use a

Block

and not a

boolean

as the private flag for whether the block is a beacon base or not?

 

private boolean isBeaconBase;

public void setBeaconBase() {
    isBeaconBase = true;
}

@Override
public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) {
    return isBeaconBase;
}

If you look at all methods which sets stuff in block all of them returns a block i.e. texture name, block name, hardness, resistance, step sound all methods must return a block to be usable.

Ofcourse you can use the boolean as a flag but the method must return a block anyway.

If I helped please press the Thank You button.

Link to comment
Share on other sites

You are indeed correct, my mistake.

 

public Block setBeaconBase() {
    isBeaconBase = true;
    return this;
}

 

The reason they return a

Block

is not to make them usable, but chainable.

 

I know I just made a bad choice of words I just meant usable as in usable when defining your blocks :)

also using a block instead of a boolean is just like 1 line less of code so thats why I used a block.

If I helped please press the Thank You button.

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.