Jump to content

[1.7.10] Need a list of the Things To Do when breaking a block


Recommended Posts

Posted

I've been here before looking for a breakBlock(player, world, worldX, worldY, worldZ, fortune) type method. Basically, I want to break a block *exactly* as if the passed player had broken the block at those XYZ coordinates - drop items, drop XP, explode, whatever it does, I want it to do it.

 

Haven't had a lot of luck, so I'm writing it myself. I've got the basic kind of thing done (break block, receive drop(s)) but I'm back looking for how to look up the correct XP drop (0 to many) and how to drop it, and how to trigger other things, like TNT exploding.

 

	private void breakBlock(World gameWorld_,
		BlockWithLocation blockXYZ) {
	//System.out.println(String.format("breakBlock() dropping at %d %d %d", blockXYZ.x, blockXYZ.y, blockXYZ.z));
	int fortune = 0; // TODO: implement me
	ItemStack dropedItemStack = new ItemStack( blockXYZ.b.getItemDropped(0, new Random(), fortune));

	EntityItem drop = new EntityItem(gameWorld_, blockXYZ.x, blockXYZ.y, blockXYZ.z, dropedItemStack);
	gameWorld_.spawnEntityInWorld(drop);
	gameWorld_.setBlockToAir(blockXYZ.x, blockXYZ.y, blockXYZ.z);
}

 

Things I've already tried and had absolutely no luck with:

  • gameworld.setBlockWithNotify()
  • gameworld.removedByPlayer()
  • gameworld.destroyBlockInWorldPartially()

 

Anyone know where I should look? Or can point to an opensource mod with a similar example?

Posted

1) call

block.dropBlockAsItemWithChance(params)

. That will make it drop all its drops.

2) call

block.breakBlock(params)

. That will remove the TileEntity at that location (for eg. furnaces).

3) set the block to air.

 

That should do it.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

1) call

block.dropBlockAsItemWithChance(params)

. That will make it drop all its drops.

 

Do you know the params? from googling around I can figure out that the first four are world, x, y, z, and the 7th is # of items to try to drop, but #5 (an int) and #6 (a float) are cryptic. I can hazard a guess from other functions that 5 might be fortune enchant level... but 6 is still cryptic.

 

2) call
block.breakBlock(params)

. That will remove the TileEntity at that location (for eg. furnaces).

3) set the block to air.

 

Useful things!

 

world.func_147480_a(x, y, z, true);

 

Oh fabulous, fabulous obfuscation... *plays around with*

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.