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

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?

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!

  • Author

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.

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 :)

  • Author

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

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 :)

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_) {}

 

  • Author

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

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.