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

I need to monitor all of the instances of some of the less common vanilla blocks, beds, doors furnaces and the like.

Repeatedly scanning for them is not lag friendly, so I was looking for place / remove hooks.

I found BlockEvent.BreakEvent but I can't find the matching PlaceEvent.

I tried using PlayerInteractEvent's but since these fire before the actual placement figuring out what was placed is awkward, I guess I could stash the coordinates and look them up on the next tick but that seems cumbersome.

I looked into replacing the vanilla blocks with ones wrapped with monitoring stuff, but trying to replace vanilla blocks looks like a bad idea.

Soooo, what's the correct way of doing this?

You can use Java Reflection, to solve that issue.

 

There is a method (onBlockPlaced) in vanilla Minecraft classes, (super.onBlockPlaced(***)) is required of course.

If you would like to cancel it, you could use Reflection and modify the Block class at runtime.

  • Author

I wasn't aware that you could make mods like that through the reflection system and I'm not sure what to Google for, what am I looking for?

I did find redefineClasses is that the path you are suggesting?

 

And I presume since we're talking about reflection you know no native Forge way of doing this?

I found BlockEvent.BreakEvent but I can't find the matching PlaceEvent.

I tried using PlayerInteractEvent's but since these fire before the actual placement figuring out what was placed is awkward, I guess I could stash the coordinates and look them up on the next tick but that seems cumbersome.

There is no PlaceEvent probably because block placing occurs from a lot of places. Player, enderman, piston, falling sand/gravel, dispenser...

If you only care about player placed blocks, stashing the coordinates and checking later on is a perfectly valid solution.

  • Author

By the same logic doesn't block breaking happen from many places? yet it has an event.

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.