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

Creating block I override methods that take block state as parameter and do something with it(for example onBlockPlacedBy). But I don't know must I call setBlockState from World to update block state?

49 minutes ago, AntonBespoiasov said:

Creating block I override methods that take block state as parameter and do something with it(for example onBlockPlacedBy). But I don't know must I call setBlockState from World to update block state?

Post your code. And explain what you are trying to do.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

  • Author
23 minutes ago, Animefan8888 said:

Post your code. And explain what you are trying to do.

@Override
ย  ย  public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
ย  ย  {
ย ย  ย ย ย  ย state.withProperty(BlockBed.FACING, placer.getHorizontalFacing());
ย ย  ย ย ย  ย calculateBedTileBorders(worldIn, pos, state);
ย ย  ย ย ย  ย calculateBedTilePillow(worldIn, pos, state, placer.getHorizontalFacing());
ย ย  ย ย ย  ย notifyNeighborsOfBorderRecalculation(worldIn, pos);ย ย  ย 
ย ย  ย ย ย  ย worldIn.setBlockState(pos, state);
ย  ย  }

calculateBedTileBorders(...) and calculateBedTilePillows(...) are functions that affectย state, they don't set blcok state in world.ย notifyNeighborsOfBorderRecalculation(...) is a function that tells blocks around that they mustย callย calculateBedTileBorders(...).ย TillingBed(block where this method is overridden) is a bed with connected textures.

ย 

What I think happens there? All these methods that areย called inย onBlockPlacedBy(...)ย don't copy stateย but just change("mutate") it and then this block state is set in world inย onBlockPlacedBy(...). Whyย methods that areย called inย onBlockPlacedBy(...) just changeย it and don't copy?ย Each of these methods has its own parameter state in it that refer to single instance of block state due to IBlockState is mutable.

5 minutes ago, AntonBespoiasov said:

Each of these methods has its own parameter state in it that refer to single instance of block state due to IBlockState is mutable.

They might exist because there are two BlockStates for a bed. The pillow part of the bed and foot part of the bed. However, I don't know because you are looking at rather old code.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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.