fabric icon indicating copy to clipboard operation
fabric copied to clipboard

Add BlockBreakEffectsCallback

Open TheBrokenRail opened this issue 5 years ago • 6 comments

Sometimes you might not want the block break particles and sounds to appear for a block. However, the only good way to do this (if you want access to the breaking entity) is a @Redirect in World#breakBlock. This has already caused a conflict between Magna and EnergonRelics.

		BlockBreakEffectsCallback.EVENT.register((world, breakingEntity, pos) -> {
			BlockState state = world.getBlockState(pos);
			return state.getBlock() == Blocks.BEDROCK ? ActionResult.FAIL : ActionResult.PASS;
		});

TheBrokenRail avatar Aug 18 '20 00:08 TheBrokenRail

Should probably add a testmod too

Geometrically avatar Aug 18 '20 16:08 Geometrically

I did add a testmod though?

TheBrokenRail avatar Aug 18 '20 16:08 TheBrokenRail

What do you mean? There isn't any information that isn't common between the two mixins. They both have the entity that broke the block, the position of the block, the block state, and the world. The Block.onBreak mxin only has two world and two players because of how @Redirects work, they are literally the same object. player == player2

TheBrokenRail avatar Aug 26 '20 12:08 TheBrokenRail

Is there anything else I should do?

TheBrokenRail avatar Aug 29 '20 21:08 TheBrokenRail

Any update on this? Should I rebaee it on 1.17?

TheBrokenRail avatar Dec 14 '20 19:12 TheBrokenRail

Keep this on 1.16, we can cherry pick at merge time

i509VCB avatar Dec 14 '20 19:12 i509VCB