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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • can someone help me out I'm trying to figure out why I cannot mind nothing with a pickaxe I tried every type of pickaxe and i'm still not get any material on mine a block plz help ps and i add Load My F***ing Tags and still nothing  
    • Hi! This is my first time creating a mod in Minecraft. It will be for personal use, and the goal is to play creepy/scary music at night. I want it to play without overlapping with Minecraft music (C418, etc.). I have almost finished it, but I don't know how to detect if Minecraft music is playing. I tried accessing a "currentMusic" variable in the MusicManager class via reflection, but it doesn't work.   Class<?> musicManagerClass = musicManager.getClass(); java.lang.reflect.Field currentMusicField = musicManagerClass.getDeclaredField("currentMusic"); currentMusicField.setAccessible(true); currentMusic = (SoundInstance) currentMusicField.get(musicManager); Does anyone know how to do it?
    • Please I need help if anyone can I will leave the log below         [15jun2024 18:11:44.134] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, {MINECRAFT_USERNAME}, --version, 1.16.5, --gameDir, C:\Users\{COMPUTER_USERNAME}\AppData\Roaming\com.modrinth.theseus\profiles\xD, --assetsDir, C:\Users\{COMPUTER_USERNAME}\AppData\Roaming\com.modrinth.theseus\meta\assets, --assetIndex, 1.16, --uuid, {MINECRAFT_UUID}, --accessToken, ????????, --userType, msa, --versionType, release, --width, 854, --height, 480, --launchTarget, fmlclient, --fml.forgeVersion, 36.2.39, --fml.mcVersion, 1.16.5, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20210115.111550] [15jun2024 18:11:44.136] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 8.1.3+8.1.3+main-8.1.x.c94d18ec starting: java version 1.8.0_412 by Azul Systems, Inc. [15jun2024 18:11:44.525] [main/INFO] [net.minecraftforge.fml.loading.FixSSL/CORE]: Added Lets Encrypt root certificates as additional trust [15jun2024 18:11:44.574] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.4 Source=file:/C:/Users/{COMPUTER_USERNAME}/AppData/Roaming/com.modrinth.theseus/meta/libraries/org/spongepowered/mixin/0.8.4/mixin-0.8.4.jar Service=ModLauncher Env=CLIENT [15jun2024 18:11:46.205] [main/INFO] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Launching target 'fmlclient' with arguments [--version, 1.16.5, --gameDir, C:\Users\{COMPUTER_USERNAME}\AppData\Roaming\com.modrinth.theseus\profiles\xD, --assetsDir, C:\Users\{COMPUTER_USERNAME}\AppData\Roaming\com.modrinth.theseus\meta\assets, --uuid, {MINECRAFT_UUID}, --username, {MINECRAFT_USERNAME}, --assetIndex, 1.16, --accessToken, ????????, --userType, msa, --versionType, release, --width, 854, --height, 480] [15jun2024 18:11:46.676] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException [15jun2024 18:11:46.677] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:39) [15jun2024 18:11:46.677] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [15jun2024 18:11:46.677] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [15jun2024 18:11:46.677] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [15jun2024 18:11:46.678] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1052]:     at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [15jun2024 18:11:46.678] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]: Caused by: java.lang.reflect.InvocationTargetException [15jun2024 18:11:46.678] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [15jun2024 18:11:46.678] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [15jun2024 18:11:46.678] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [15jun2024 18:11:46.679] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at java.lang.reflect.Method.invoke(Method.java:498) [15jun2024 18:11:46.679] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at net.minecraftforge.fml.loading.FMLClientLaunchProvider.lambda$launchService$0(FMLClientLaunchProvider.java:37) [15jun2024 18:11:46.679] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [15jun2024 18:11:46.679] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:1061]:     ... 4 more [15jun2024 18:11:46.679] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]: Caused by: java.lang.NoSuchMethodError: org.apache.logging.log4j.core.impl.ThrowableProxy.formatExtendedStackTraceTo(Ljava/lang/StringBuilder;Ljava/util/List;Lorg/apache/logging/log4j/core/pattern/TextRenderer;Ljava/lang/String;Ljava/lang/String;)V [15jun2024 18:11:46.680] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at cpw.mods.modlauncher.log.TransformingThrowablePatternConverter.generateEnhancedStackTrace(TransformingThrowablePatternConverter.java:87) [15jun2024 18:11:46.680] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at net.minecraftforge.fml.CrashReportExtender.generateEnhancedStackTrace(CrashReportExtender.java:65) [15jun2024 18:11:46.680] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at net.minecraftforge.fml.CrashReportExtender.generateEnhancedStackTrace(CrashReportExtender.java:55) [15jun2024 18:11:46.680] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at net.minecraft.crash.CrashReport.func_71498_d(CrashReport.java:119) [15jun2024 18:11:46.680] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at net.minecraft.crash.CrashReport.func_71502_e(CrashReport.java:135) [15jun2024 18:11:46.681] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at net.minecraft.crash.CrashReport.func_230188_h_(CrashReport.java:248) [15jun2024 18:11:46.681] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     at net.minecraft.client.main.Main.main(Main.java:122) [15jun2024 18:11:46.681] [main/INFO] [STDERR/]: [java.lang.Throwable:printStackTrace:644]:     ... 10 more    
    • the installer fails to download files it needs. below is an excerpt from the logs.   Error checking https://files.minecraftforge.net/: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target  
    • Whenever i load up any forge version, even without mods, it will crash, even if it's a pre-constructed, very popular, public one, it'll still crash, here's the current modpack i'm trying to load's log (popular create mod one, + not enough crashes); https://pastebin.com/gtuAhVJ8 , and without mods; https://pastebin.com/qVJCdxcN
  • Topics

×
×
  • Create New...

Important Information

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