Posted June 12, 201411 yr i'm a noob at coding, just to let u know. i want to make a block. when placed in the world, after 6 sec, it disappears. i tried to come up with something my self. did not go well. package Talimagics.blocks; import Talimagics.mod.talibase; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.world.World; public class wallblock extends Block { public wallblock(int par1, Material par2Material) { super(par1, par2Material); this.setUnlocalizedName("wallblock"); this.setLightOpacity(1); this.setLightValue(0.6f); this.setBlockUnbreakable(); } public boolean despawn(World world,int x,int y,int z){ if(world.setBlock(x, y, z, talibase.wallblock.blockID)== true){ try { Thread.sleep(120); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } world.destroyBlock(x, y, z, false); return true; }else return false; } @Override public void registerIcons(IconRegister reg){ this.blockIcon = reg.registerIcon("talimagics:magicwall_block"); } } any ideas how to get this working? thanks in advance
June 12, 201411 yr You never ever put the client or server thread to sleep in a realtime game!!! You will cause major problems. Use tick events or a timer thread or almost anything else. -S- (if I helped, please click Thank and applaud) http://6upnqa.dm2301.livefilestore.com/y2mtf-vG7Tqq1TiiVpIm53KWj7294NDPoHfSHHb4PzZiMAUfRCfK0UY0MwOu7Q3zTBNVTKqWjr2-xgBfFRpQT5p-QivtvknPpoABMNUw9br9WuZcBFkjePhnAbW500gVm-P/sequiturian.png[/img]
June 13, 201411 yr Author Use world.scheduleBlockUpdate. It will trigger a call to the updateTick method of your block after the number of ticks you specify. thanks for the tip. but i dont know what to do with it. could you explain what i need to do with it
June 13, 201411 yr Spoiler tags... ...Please use them for code. [ spoiler ][/ spoiler ] (without spaces) We all stuff up sometimes... But I seem to be at the bottom of that pot.
June 13, 201411 yr Author let me be more specific. like i stated in my first post, i'm a noob. 1. there is 5 parameters in world.scheduleBlockUpdate(par1, par2, par3, par4, par5); i can guess its something with ticks. but what 2. do i just call world.scheduleBlockUpdate(); and then world.destroyBlock() or do i make a method for that? i may have more questions but dont have any atm.
June 13, 201411 yr Author ok here is what i have. package Talimagics.blocks; import Talimagics.mod.talibase; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.world.World; public class wallblock extends Block { public wallblock(int par1, Material par2Material) { super(par1, par2Material); this.setUnlocalizedName("wallblock"); this.setLightOpacity(1); this.setLightValue(0.6f); this.setBlockUnbreakable(); } public void despawn(World world,int x,int y,int z){ world.scheduleBlockUpdate(x, y, z, talibase.wallblock.blockID, 120); this.updateTick(world, x, y, z, null); } @Override public void registerIcons(IconRegister reg){ this.blockIcon = reg.registerIcon("talimagics:magicwall_block"); } } i know this is wrong. i dont know updateTick() at all or how to use it, same with scheduleBlockUpdate but i guess that is right. is it?
June 14, 201411 yr Author i figured it out. after 2 hours of emptying the internet for information @Override public void onBlockAdded(World world,int x,int y,int z){ world.scheduleBlockUpdate(x, y, z, talibase.wallblock.blockID, 120); } @Override public void updateTick(World world, int x, int y, int z, Random rand){ world.destroyBlock(x, y, z, false); } that was all i needed. thanks for the help
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.