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.

[SOLVED][1.7.10] world.getBlock() treating lava and flowing_lava the same

Featured Replies

Posted

Hi there!

 

Back after a long hiatus for school! Anyways, on to the point.

 

I am trying to have my block check each of the 8 spots around it (each diagonal and adjacent) for a lava block. My problem is flowing_lava is being treated the same as lava when I do my check.

 

       Block lava = Blocks.lava;

    	// Check 8 sides around block and return if all are lava
    	if(world.getBlock(x + 1, y, z).equals(lava) && world.getBlock(x - 1, y, z).equals(lava) &&
    		world.getBlock(x, y, z + 1).equals(lava) && world.getBlock(x, y, z - 1).equals(lava) &&
    		world.getBlock(x + 1, y, z + 1).equals(lava) && world.getBlock(x + 1, y, z - 1).equals(lava) &&
    		world.getBlock(x - 1, y, z + 1).equals(lava) && world.getBlock(x - 1, y, z - 1).equals(lava))
    		return true;

 

I know there is a different block for each in the code currently but for some reason if I place a lava source block at two opposite corners and let the lava flow in the remaining 2 slots, the updateTick sees the setup as valid when it should not.

 

Any ideas?

Maybe that's because (if I remember correctly) flowing lava is not a separate type of block rather another damage value.

Maybe that's because (if I remember correctly) flowing lava is not a separate type of block rather another damage value.

 

Right. It is the same block, but with different metadata. Here is an explanation of how the metadata values (or block state in 1.8 ) work. http://minecraft.gamepedia.com/Lava#Data_values

 

Note also what it says about how the blocks are mostly set as stationary even if they are in a position to flow -- the flowing is only set temporarily during block updates.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Maybe that's because (if I remember correctly) flowing lava is not a separate type of block rather another damage value.

Yes that is correct,

All liquids have multiple damage values

 

I think 0 is idle (not flowing), 1 and on is like the different heights and directions and all that

So then, using that information, to fix this problem you would have to also check to see if the metadata is 0, as well as that the block is lava.

Hope that helps. And thanks everyone for backing me up. ;)

  • Author

@Awesome_Spider

@Jabelar

@tiffit

 

After 5-6 different tries of things (was looking at Blocks.getDamageValue(World, int, int, int) for help, didn't work) I finally got it. This would have gone a LOT faster if the darn tickUpdate wasn't so slow. I'll post the new, working code (removed that big ugly if structure and replaced it with some fancy for loops and a smaller if).

 

Thanks so much everybody!

 

    	Block lava = Blocks.lava;
    	
    	for(int i = -1; i <= 1; i++)
    		for(int j = -1; j <= 1; j++)
    			if(i != 0 & j != 0)
    				if(!world.getBlock(x + i, y, z + j).equals(lava) ||
    					world.getBlockMetadata(x + i, y, z + j) != 0)
    					return false;
    	
    	return true;

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.