pmardle Posted March 13, 2013 Posted March 13, 2013 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, Quote
mnn Posted March 13, 2013 Posted March 13, 2013 use setBlockAndMetadataWithNotify? Quote mnn.getNativeLang() != English If I helped you please click on the "thank you" button.
pmardle Posted March 13, 2013 Author Posted March 13, 2013 I had considered this, but then I have to change literally thousands of lines of code.. was hoping I was just missing something (Happens ALL the time ) Quote
Chibill Posted March 13, 2013 Posted March 13, 2013 It's there but it's still named f_(a number)_a in the world class. Quote
pmardle Posted March 14, 2013 Author Posted March 14, 2013 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.. Quote
Chibill Posted March 14, 2013 Posted March 14, 2013 func_94578_a is .setblock MCP did not name it .setblock Quote
robustus Posted March 14, 2013 Posted March 14, 2013 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? Quote
SanAndreaP Posted March 14, 2013 Posted March 14, 2013 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. Quote 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.
Vogner Posted March 15, 2013 Posted March 15, 2013 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. Quote
pmardle Posted March 15, 2013 Author Posted March 15, 2013 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 Also is the renaming a Forge or MCP thing ? (Sorry only started modding for 1.4.7 so this is my first version update ) Quote
erik19borgnia Posted March 19, 2013 Posted March 19, 2013 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 Quote
opssemnik Posted March 19, 2013 Posted March 19, 2013 OMG guys just search in the minecraft code, setblock is func_94575_c Quote
erik19borgnia Posted March 19, 2013 Posted March 19, 2013 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. Quote
opssemnik Posted March 19, 2013 Posted March 19, 2013 but he haves a lot of code, so its better use func_94575_c, so he will not need to add arguments... (he dont want metadata) Quote
TheyCallMeDanger Posted March 22, 2013 Posted March 22, 2013 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! Quote Odds are good I've been programming since before you were born. Yeah. I'm OLD school.
Chibill Posted March 22, 2013 Posted March 22, 2013 Or in your main class make a function the calls on the odd one and name it setblock Quote
Lomeli12 Posted March 22, 2013 Posted March 22, 2013 1.5.1 seems to have brought back .setBlock and overloads it with what used to be .setBlockMetadataWithNotify Quote
Recommended Posts
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.