Jump to content

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


TheMoleTractor

Recommended Posts

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?

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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

Link to comment
Share on other sites

@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;

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.