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'm updating my mod from 1.16.3 to 1.16.5, and I noticed that the setBlockState method has been replaced with setBlock, but it has two additional integer parameters apart from the standard blockstate and block position arguments. Looking at the implementation of the method didn't help because all the variable names are obfuscated. Anyone have any idea?

method signatures did not change, only method names, due to the mappings change
if the method has a different signature, it may not be the method that you are looking for

  • Author
19 minutes ago, kiou.23 said:

method signatures did not change, only method names, due to the mappings change
if the method has a different signature, it may not be the method that you are looking for

...except it clearly did, here's the snippet from 1.16.3, take a look for yourself if you didn't know:

image.png.0857ffd104b0e9f861f657893f5e5408.png

 

and now in 1.16.5:

image.png.eda8c594afa12bcf9e5378953fcd58c2.png

  • Author

There were several notable changes I noticed refactoring my code from 16.3 to 16.5, not just the above, but also the fact that rotations on the renderer now take quaternions as inputs rather than just a vector representing the rotations.

Still hasn't changed. You're referencing two different methods with two difference signatures. The first method you shown calls the second method with the argument 3. As for what it does, it dictates what flags to execute when setting the block (a bit field). The list of flags can be found within Constants$BlockFlags.

  • Author
1 minute ago, ChampionAsh5357 said:

Still hasn't changed. You're referencing two different methods with two difference signatures. The first method you shown calls the second method with the argument 3. As for what it does, it dictates what flags to execute when setting the block (a bit field). The list of flags can be found within Constants$BlockFlags.

...Again, there is literally no function that takes in just two parameters. But anyways thanks for that, I'll look into the flags, never realized it was a thing when blocks are placed.

image.png.f615cda063246afac27fe9b1937d2238.png

 

7 minutes ago, Turtledove said:

...Again, there is literally no function that takes in just two parameters. But anyways thanks for that, I'll look into the flags, never realized it was a thing when blocks are placed.

 

Yes there is:

image.png.3160d85645f5403599d31b0e4e956eeb.png

If you expect the method names to be the same across mappings including how they're referenced between methods, you won't find what you are referring to.

Edited by ChampionAsh5357

  • Author
5 minutes ago, ChampionAsh5357 said:

Yes there is:

image.png.3160d85645f5403599d31b0e4e956eeb.png

If you expect the method names to be the same across mappings including how they're referenced between methods, you won't find what you are referring to.

I know what it was, I wrote getWorld() as a wrapper method for classes that implement IWorld, but I guess I missed that that method isn't listed as a function in the interface. 0 IQ moment.

Ok, so I have a question about these functions in 1.16.5.  I'm trying to do world.setBlock() commands from within an Item use() override.  No matter what function I use (setBlockAndUpdate, setBlock with Constants.BlockFlags.DEFAULT, etc) the blocks appear in the client but disappear when interacted with (apart from collusions).  If I quit and restart, none of the changes were saved.  Blocks replacing other blocks (like grass) go back to the previous block.  This is launching from the Forge MDK runClient configuration.

Are there contexts from which you're not supposed to update the world?  Are you supposed to queue updates for some worker thread/task to handle?  Mark things for update?

ie: world.setBlock(pos.offset(i, y, 5), ModBlocks.MYBLOCK.get().defaultBlockState(), Constants.BlockFlags.DEFAULT);

Most people's questions about setBlock() seem quite straightforward and like it just works for them.

It's almost like a problem passing in immediate variables that get deleted when they go out of scope ... but the few examples I find are using defaultBlockState() and aren't calling new or anything... ?

I can use the ModBlocks.MYBLOCK blocks normally within the game otherwise... as in, place them as in game blocks from creative/survival mode, etc.. they only misbehave from the Item.use() override...

Edited by wintermaker

16 minutes ago, wintermaker said:

Ok, so I have a question about these functions in 1.16.5.  I'm trying to do world.setBlock() commands from within an Item use() override.  No matter what function I use (setBlockAndUpdate, setBlock with Constants.BlockFlags.DEFAULT, etc) the blocks appear in the client but disappear when interacted with (apart from collusions).  If I quit and restart, none of the changes were saved.  Blocks replacing other blocks (like grass) go back to the previous block.  This is launching from the Forge MDK runClient configuration.

you should make your own threads

 

16 minutes ago, wintermaker said:

Are there contexts from which you're not supposed to update the world?  Are you supposed to queue updates for some worker thread/task to handle?  Mark things for update?

no

 

16 minutes ago, wintermaker said:

It's almost like a problem passing in immediate variables that get deleted when they go out of scope ... but the few examples I find are using defaultBlockState() and aren't calling new or anything... ?

I can use the ModBlocks.MYBLOCK blocks normally within the game otherwise... as in, place them as in game blocks from creative/survival mode, etc.. they only misbehave from the Item.use() override...

we need to see your code. but don't post it here, make a new thread

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.