Jump to content

1.19.2 can't detroy/remove water


Daziel

Recommended Posts

I tried to make a projectile that put water on nearby it falls. I just need that water source pop and directly disapear. I do :

Spoiler
@Override
	public void onHitBlock(BlockHitResult blockHitResult) {
		super.onHitBlock(blockHitResult);
		if (level instanceof ServerLevel _level){
			FallingBlockEntity waterfall =	FallingBlockEntity.fall(_level, new BlockPos(blockHitResult.getBlockPos().getX(), blockHitResult.getBlockPos().getY()+1, blockHitResult.getBlockPos().getZ()),
						Blocks.WATER.defaultBlockState());
			System.out.println("HI " + waterfall.getBlockX() + waterfall.getBlockY() + waterfall.getBlockZ());
			if ((_level.getFluidState(new BlockPos(waterfall.getBlockX(), waterfall.getBlockY(), waterfall.getBlockZ())).createLegacyBlock()).getFluidState().isSource()) {
				System.out.println("I M WATER");
				_level.removeBlock(new BlockPos(waterfall.getBlockX(), waterfall.getBlockY(), waterfall.getBlockZ()),false);
				_level.destroyBlock(new BlockPos(waterfall.getBlockX(), waterfall.getBlockY(), waterfall.getBlockZ()),false);
			}
			if ((_level.getFluidState(new BlockPos(waterfall.getBlockX(), waterfall.getBlockY(), waterfall.getBlockZ())).createLegacyBlock()).getFluidState().isSource()) {
				System.out.println("I M STILL WATER");
			}
		}
	}

 

Water appears but still remains despite removeBlock or DestroyBlock. Any idea ?

Link to comment
Share on other sites

remove/destroyBlock() don't remove the fluid . Did you look at the code?

 

Those methods are intended for things like breaking a waterlogged fence post.

It will remove the post but leave the water behind.

 

Try doing something like:

Level.setBlockAndUpdate(pos, Blocks.AIR.defaultState());

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

Doesn't work 😞  Water still there.

But if i use Blocks.STONE.defaultBlockState()  ...  it works and change the source water by a Stone block immediately.
I have tried to look inside BucketItem to look how it works when bucket is used but i don't understand how water disappear and is replaced by air on targeting pos 😞

Link to comment
Share on other sites

That effectively uses LiquidBlock.pickupBlock() - assuming you are dealing with a LiquidBlock?

That calls setBlock() with flags = 11 while setBlockAndUpdate() calls setBlock() with flags = 3

Which means it is setting the "UPDATE_IMMEDIATE" flag as well - see the Block class.

I don't know what difference that makes? It's not a flag I am familiar with.

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

You know when you create a falling block the actual fall will be delayed to later processing?

So, it could be you are setting the block to air, then on a later tick the block is failling and creating the source block.

Setting the block to stone would likely stop the falling block from creating the source block? Probably it tries to spawn the ItemEntity drop for water which doesn't have one.

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

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.