Jump to content

[1.5] World.setBlock removed?


pmardle

Recommended Posts

I have been using...

 

world.setBlock(blockX, blockY, blockZ + 3,Block.dirt.blockID);

 

Successfully as part of a worldgen.class for a structure build in Forge 6.6.2.533, however now with 7.7.0.575 it is throwing an error, and the ability to set a block has disappeared??

 

Any Advice?

 

Thanks,

 

Link to comment
Share on other sites

is there any kind of clever line of code that could be used to avoid having to rename and edit every single file of a mod to fix this?

 

If you use eclipse, then you can simply make a search/replace.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

But why if it was .setBlock in 1.4.7 would they not include it in the 1.5 version.. Seems backward to me, to make your software WORSE on a new release.. :(

They have to manually rename methods after major updates. It takes time to get them all caught up. Chill, mon.
Link to comment
Share on other sites

I think it's actually func_96440_m

 

Thanks, was wondering why the "Function_xxxxx_a wasn't working lol"

 

I still don't understand why if they figured out that was .setBlock in the last version and it hasn't changed then why not just rename the thing for this version :P

 

Also is the renaming a Forge or MCP thing ?

 

(Sorry only started modding for 1.4.7 so this is my first version update :D)

Link to comment
Share on other sites

I think it's actually func_96440_m

MMMM I disagree, that method is different from the "setBlock" in the 1.4.7.

[spoiler=func_96440_m from Forge for 1.5]public void func_96440_m(int par1, int par2, int par3, int par4)

    {

        for (int i1 = 0; i1 < 4; ++i1)

        {

            int j1 = par1 + Direction.offsetX[i1];

            int k1 = par3 + Direction.offsetZ[i1];

            int l1 = this.getBlockId(j1, par2, k1);

 

            if (l1 != 0)

            {

                Block block = Block.blocksList[l1];

 

                if (Block.field_94346_cn.func_94487_f(l1))

                {

                    block.onNeighborBlockChange(this, j1, par2, k1, par4);

                }

                else if (Block.isNormalCube(l1))

                {

                    j1 += Direction.offsetX[i1];

                    k1 += Direction.offsetZ[i1];

                    l1 = this.getBlockId(j1, par2, k1);

                    block = Block.blocksList[l1];

 

                    if (Block.field_94346_cn.func_94487_f(l1))

                    {

                        block.onNeighborBlockChange(this, j1, par2, k1, par4);

                    }

                }

            }

        }

    }

 

[spoiler=setBlock from Forge for 1.4.7]public boolean setBlock(int par1, int par2, int par3, int par4)

    {

        if (par1 >= -30000000 && par3 >= -30000000 && par1 < 30000000 && par3 < 30000000)

        {

            if (par2 < 0)

            {

                return false;

            }

            else if (par2 >= 256)

            {

                return false;

            }

            else

            {

                Chunk var5 = this.getChunkFromChunkCoords(par1 >> 4, par3 >> 4);

                boolean var6 = var5.setBlockID(par1 & 15, par2, par3 & 15, par4);

                this.theProfiler.startSection("checkLight");

                this.updateAllLightTypes(par1, par2, par3);

                this.theProfiler.endSection();

 

                if (var6 && (this.isRemote || var5.deferRender))

                {

                    this.markBlockForUpdate(par1, par2, par3);

                }

 

                return var6;

            }

        }

        else

        {

            return false;

        }

    }

 

 

EDIT:

The only solution I've got is using the setBlockAndMetadataWithNotify.

Example:

 

setBlockAndMetadataWithNotify(xCoord,yCoord,zCoord,blockID,metadata,notify)

I THINK THAT metadata should be 0 if you're not using metadata in the block. The notify is an integer and is used in a bitwise operation:

((par6 & 1) != 0)

SO, every integer different to 1 wil return 0. Again, I THINK THAT it shoul be 0 to be equal to the setBlock method. So a real example would be:

setBlockAndMetadataWithNotify(xCoord,yCoord,zCoord,blockID,0,0) to be equal to the setBlock method in 1.4.7

 

 

Hope this helps :3

Link to comment
Share on other sites

OMG guys just search in the minecraft code, setblock is func_94575_c

It's not. func_94575_c only uses the setBlockAndMetadataWithNotify:

[spoiler=func_94575_c]public boolean func_94575_c(int par1, int par2, int par3, int par4)

    {

        return this.setBlockAndMetadataWithNotify(par1, par2, par3, par4, 0, 3);

    }

 

 

As I said, the setBlockAndMetadataWithNotify:

[spoiler=setBlockAndMetadataWithNotify]public boolean setBlockAndMetadataWithNotify(int par1, int par2, int par3, int par4, int par5, int par6)

    {

        if (par1 >= -30000000 && par3 >= -30000000 && par1 < 30000000 && par3 < 30000000)

        {

            if (par2 < 0)

            {

                return false;

            }

            else if (par2 >= 256)

            {

                return false;

            }

            else

            {

                Chunk chunk = this.getChunkFromChunkCoords(par1 >> 4, par3 >> 4);

                int k1 = 0;

 

                if ((par6 & 1) != 0)

                {

                    k1 = chunk.getBlockID(par1 & 15, par2, par3 & 15);

                }

 

                boolean flag = chunk.setBlockIDWithMetadata(par1 & 15, par2, par3 & 15, par4, par5);

                this.theProfiler.startSection("checkLight");

                this.updateAllLightTypes(par1, par2, par3);

                this.theProfiler.endSection();

 

                if (flag)

                {

                    if ((par6 & 2) != 0 && (!this.isRemote || (par6 & 4) == 0))

                    {

                        this.markBlockForUpdate(par1, par2, par3);

                    }

 

                    if (!this.isRemote && (par6 & 1) != 0)

                    {

                        this.notifyBlockChange(par1, par2, par3, k1);

                        Block block = Block.blocksList[par4];

 

                        if (block != null && block.func_96468_q_())

                        {

                            this.func_96440_m(par1, par2, par3, par4);

                        }

                    }

                }

 

                return flag;

            }

        }

        else

        {

            return false;

        }

    }

 

The red text is the part where the notify is used, with func_94575_c it enters the if. (3 & 1 returns 1)

Searching more I found that the function called is: setBlockIDWithMetadata (in green), and in the old "setBlock" use setBlockID. Searching in the Chunk class I've found that... there is no setBlockID method anymore. So setBlock method in the World class doesn't exist. I think that now we can only use the setBlockAndMetadataWithNotify.

 

BUT WELL, we can use that function, the only bad thing is that is weird to use a method named func_94575_c and remember what it do.

Link to comment
Share on other sites

I have been using...

 

world.setBlock(blockX, blockY, blockZ + 3,Block.dirt.blockID);

 

Successfully as part of a worldgen.class for a structure build in Forge 6.6.2.533, however now with 7.7.0.575 it is throwing an error, and the ability to set a block has disappeared??

 

Any Advice?

 

Thanks,

 

 

Use setBlockAndMetadataWithNotify(). It's a pain to convert it all...

You'll have to add two args(world, x,y,z, blockid, meta, notify);

meta is the metadata that goes along with your block, usually 0.

notify is critical here... it appears that it in most cases it should be a 2,

otherwise the block doesn't get updated to the client.

 

Don't use eclipse to make your changes. Use a real editor, then restart eclipse.

I used 'vim'. Much faster!

Good luck!

 

Odds are good I've been programming since before you were born. Yeah. I'm OLD school.

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.

×
×
  • Create New...

Important Information

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