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

Hi! I recently got into minecraft modding and I'm having a bit of trouble finding the right function to make the blocks behave as they normally do in the vanilla game. Basically I spawn the water block, however it will just sit there upon spawning. I want it to flow as a normal water block would (Similar to a water bucket when its clicked on a block).

 

Here's my current code:

BlockPos pos = new BlockPos((myChunk.xPosition * 16) + x + 1, y + 2, (myChunk.zPosition * 16) + z);
//Set block to current position and set it to flow.
//State 8 is flowing water, 9 is water. 
//TODO: Test differences between state 8 and 9.
world.setBlockState(pos, BlockLiquid.getFlowingBlock(Material.water).getDefaultState());

 

Right now the code obviously isn't correct. I was experimenting with a few different changes. The ones I stumbled across mentioned setBlockMetadataWithNotify, however that seems to be deprecated with IBlockStates, however I'm not sure what state to change it to to make it flow. I've also tried notify however I'm probably using it wrong. If there's any function to say "Hey world/chunk, you need to update this block according to vanilla water properties", that would be great.

 

Any advice/tips/response would be appreciated. -Thanks.

I don't know the answer off the top of my head.

I'd suggest you put a breakpoint into ItemBucket.tryPlaceContainedLiquid(), use a bucket to place some water, and see what vanilla does.

 

-TGG

  • Author

I don't know the answer off the top of my head.

I'd suggest you put a breakpoint into ItemBucket.tryPlaceContainedLiquid(), use a bucket to place some water, and see what vanilla does.

 

-TGG

I like that idea, a lot, its a little late tonight, so I'll play around with that tomorrow and see how that goes.

 

Thanks!

  • Author

So a bit of progress and non progress. I can now raise the water and make it act dynamically, however the engine doesn't do this for me. I do it in my own code.

world.setBlockState(pos, BlockDynamicLiquid.getFlowingBlock(Material.water).getStateFromMeta(0x1), 3);

I've tried marking the block for update, and a couple of other things, but it still seems to just hover in the air and not fill in the gaps.

 

At this point I'm thinking of doing it in my own code, but any suggestions would be appreciated.

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.