Jump to content

[1.7.2-1085] [SOLVED] block.breakBlock() not working properly


DiabolusNeil

Recommended Posts

This is the code I'm working with: http://pastebin.com/aEAswtBR and I've come across a big problem. Trying to break the block from the block object gathered from world.getBlock() doesn't do anything. Even doing world.getBlockToAir() doesn't do anything. I even tried using a packet handler because I thought the event was only being called client-side only (which it wasn't). Is it a Forge bug?

 

EDIT: It seems that Block.breakBlock() is only for special purposes (i.e. dumping out the contents of an inventory, removing a tile entity, etc) and is not meant for actually breaking a block. What wesserboy said, you need to do something like this:

 

private void breakBlock(World world, int x, int y, int z){
if(world.getBlock(x, y, z) != Blocks.bedrock){
	world.getBlock(x, y, z).dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
	world.setBlockToAir(x, y, z);
}
}

if (user.hasKnowledgeOfJava) {

    if (user.question.hasCode) {

        return interpetHelpfulResponse(user.getQuestion());

    } else {

        return "Could you post your code please?";

    }

} else {

    return "Learn some freaking Java!";

}

Link to comment
Share on other sites

I had problems with that method too, so i wrote my own little method to break the block for me:

 

private void breakBlock(World world, int x, int y, int z){
	if(world.getBlock(x, y, z) != Blocks.bedrock){
		world.getBlock(x, y, z).dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
		world.setBlockToAir(x, y, z);
	}
}

 

it could be a forge bug since i had the same problem, but this method has been working great for me.

I made the Mob Particles mod, you can check it out here: http://www.minecraftforum.net/topic/2709242-172-forge-mob-particles/

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.