Jump to content

Recommended Posts

Posted

How do I find all the packages holding the code for minecraft, I used to be able to read it to figure out. Thank you in advance.[sOLVED]

 

Also, how do I get have a block do something when it is placed and/or broken? what is the method in doing so?

Posted

the minecraft src is in "Referenced Libraries/forgeSrc"

 

Break/placed(from Block.class):

    /**
     * Called right before the block is destroyed by a player.  Args: world, x, y, z, metaData
     */
    public void onBlockDestroyedByPlayer(World p_149664_1_, int p_149664_2_, int p_149664_3_, int p_149664_4_, int p_149664_5_) {}

    /**
     * Called whenever the block is added into the world. Args: world, x, y, z
     */
    public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) {}

 

don't forget the thank you button.

Here could be your advertisement!

Posted

I did those methods doing this.

@SubscribeEvent
public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) {
	p_149726_1_.setBlockToAir(p_149726_2_ - 1, p_149726_3_ - 1, p_149726_4_ - 1);

}

But nothing happened when I placed a block.

Posted

If those were events, you would also have to register your class with the correct event handler.

 

But they are not events, so you merely need to

@Override

the methods in your Block descendant.

 

Enjoy :)

Posted

I think I might know what the problem is. I set up a base block that use a subclass of the original block. and the block where I placed the method was a subclass of that, so I don't know if that really affects anything, but it isn't working. so I don't know

Posted

That will still work.

 

Did you use

@Override

instead of

@SubscribeEvent

?

 

If you're still having issues, showing your code and any errors you get is a good start :)

Posted

Found them in the Block.class in 10 second:

 

public void onBlockDestroyedByPlayer(World p_149664_1_, int p_149664_2_, int p_149664_3_, int p_149664_4_, int p_149664_5_){}

 

public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) {}

 

Posted

oh, I was being so stupid... I forgot in my blocks folder to make my block the instance of my new class instead of my base one. :-[ im sorry for all the trouble but thank you all!

 

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.