Jump to content

[1.8] update tick...need metadata understanding


Glistre

Recommended Posts

Finally updating mod from 1.7.10 ... realized I do not realize understand the metadata in the updateTick code to begin with....so not sure how to update that part of the code to 1.8

 

So, my original code in my custom BlockSeaweed class, I utilized BlockClay, and it checks for Blocks.water,

as follows:

    public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
        if (par1World.getBlock(par2, par3 + 1, par4) == Blocks.water) {
            int l;
            for (l = 1; par1World.getBlock(par2, par3 - l, par4) == this; ++l);
            if (l < 3) {
                int i1 = par1World.getBlockMetadata(par2, par3, par4);
                if (i1 == 15) {
                    par1World.setBlock(par2, par3 + 1, par4, this);
                    par1World.setBlockMetadataWithNotify(par2, par3, par4, 0, 4);
                } else {
                    par1World.setBlockMetadataWithNotify(par2, par3, par4, i1 + 1, 4);
                }
            }
        }
    }

 

In the code as I have it, i1 getsMetadata value of water, and if equals 15, then sets the block to my Block seaweed.

Could someone explain that? I know blocks have meta data 0-15 but why would check for that? 

 

The next two parts I don't know what the code is doing at all , not sure what the "4" is in either #setBlockMetadataWithNotify.

 

So, I have to update this to 1.8, so far, I have this but I'm stuck on the Metadata parts:

    public void updateTick(World worldIn, BlockPos blockPos, IBlockState state, Random random) {
//   	BlockPos blockPos = new BlockPos(blockPos.getX())
    	int yCheck = blockPos.getY() + 1;
    	BlockPos pos1 = new BlockPos(blockPos.getX(), yCheck, blockPos.getZ());
    	if (worldIn.getBlockState(pos1).getBlock() == Blocks.water) {

            int l;
            for (l = 1; worldIn.getBlockState(blockPos.down()).getBlock() == this; ++l);

           if (l < 3) {
            	
            	int i1 = worldIn.getBlockMetadata(x, y, z);


                if (i1 == 15) {

                    worldIn.setBlockState(blockPos.getX(), blockPos.getY() + 1, blockPos.getZ()).getBlock(), this);
                    worldIn.setBlockMetadataWithNotify(blockPos.getX(), blockPos.getY(), blockPos.getZ(), 0, 4);
                } else {
                    worldIn.setBlockMetadataWithNotify(blockPos.getX(), blockPos.getY(), blockPos.getZ(), i1 + 1, 4);
                }
            }
        }
    }

 

 

Link to comment
Share on other sites

Looks like you copied the code from BlockReeds.

 

The code as you have it does not do what you say you think it does.  Check the block positions again:

"If the block above is water, then loop through the blocks below checking that they are the same block as this.  If there are less than 3 and the metadata of this block is 15, set the metadata to 0 and place this block above."

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Looks like you copied the code from BlockReeds.

 

The code as you have it does not do what you say you think it does.  Check the block positions again:

"If the block above is water, then loop through the blocks below checking that they are the same block as this.  If there are less than 3 and the metadata of this block is 15, set the metadata to 0 and place this block above."

 

yes, I confess I did not understand it. .. why would metadata for water need to be 15 ..is that default for a block that has 16 ?

Link to comment
Share on other sites

"meta:15" and "water" are not related here.

 

The metadata 15 check is "how long has the reeds/seaweed been growing." It's AGE.

Water is merely the "is there water above me?" check so that the seaweed doesn't grow up into air.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.