Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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?

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/

  • Author

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.