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

Is there a way to detect which blocks were placed by a player and which were naturally generated? I am trying to make a autobuilder, and I don't want it to overwrite anyone's blocks.

As diesieben said you can't do this however simply check if it's Blocks.air before you set the block or check if everythings air before it sets any block at all.

If I helped please press the Thank You button.

Hi

 

>How does minecraft do it (leaf blocks)?

Not sure what you mean?  Leaf blocks don't overwrite existing blocks, only empty space.

 

If you just want your autobuild to overwrite air only, it's easy.  Get the block using world.getBlock, check block.isAirBlock(x,y,z), and only overwrite if it's air.

 

If you want your autobuild to overwrite (eg) naturally generated stone, but not stone placed by a player, then that is possible but very complicated (and almost certainly not worth the trouble)

 

-TGG

 

I am not sure what leaves do to differentiate between having been placed by a player, and having been spawned by a tree, but it seems like something akin to using a single bit of metadata - the third least significant bit, in this case.

 

While you can of course not use this for blocks that have directions, etc., perhaps this can be of use when determining whether, say, dirt or stone was placed by a player.

 

There would be several ways to go about this, I presume - but relying on metadata in blocks that don't expect metadata is just asking for trouble.

If you mean leaves disappear when placed by a player when you say what you said, then try sticking a wood block next to those leaves.

 

If that isn't what you meant... * shrugs * learn how to use ASM and add a flag to blocks as to whether or not they were placed by a player. As TGG said, a lot of hassle and not really worth it.

We all stuff up sometimes... But I seem to be at the bottom of that pot.

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.