I need help for deny water and lava flow

I need help for deny water and lava flow. I need full method how to deny please!!!.
Thank you every comment.

What have you tried? What does your code look like now? What specifically are you having trouble with? Are you getting errors? Do you know Java? We need some more details to be able to help effectively. :slight_smile:

1 Like

I need block or deny water and lava flow in every world. Example. Water or water bucket when use it. i need no flowing to another block.

What have you already tried?

i ready to tried i need help now.

You haven’t answered any questions.
Please tell us what you have tried, and what isn’t working.

1 Like

Here you go :slight_smile:

This stops all types of liquid from flowing

    @Listener
    public void stopLiquidFlow(ChangeBlockEvent.Place event, @Root BlockSnapshot snapshot) {
        Optional<MatterProperty> matter = snapshot.getState().getProperty(MatterProperty.class);
        if (matter.isPresent() && matter.get().getValue() == Matter.LIQUID) {
            event.setCancelled(true);
        }
    }

Where file add code ?

Hello. Sponge Developer. Where file add code ?.

In your plugin class
https://docs.spongepowered.org/master/en/plugin/plugin-class.html

I’m not going to go though every step with you, we have docs for that.

I can’t complie finish. Error 1 MatterProperty.class. Sponge API 4.1.0.

Make sure you have imported the classes
here are the required imports:

import org.spongepowered.api.block.BlockSnapshot;
import org.spongepowered.api.data.property.block.MatterProperty;
import org.spongepowered.api.data.property.block.MatterProperty.Matter;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.block.ChangeBlockEvent;
import org.spongepowered.api.event.filter.cause.Root;

import java.util.Optional;

Sorry to re-open this thread, but i tried this code

but the water is still spread :confused:

EDIT:
Looks like the event is not even called, infact if i do this

@Listener
    public void stopLiquidFlow(ChangeBlockEvent.Place event) {
		System.out.println("WATER FLOW");
		BlockSnapshot snapshot = event.getTransactions().get(0).getOriginal();
        Optional<MatterProperty> matter = snapshot.getState().getProperty(MatterProperty.class);
        if (matter.isPresent() && matter.get().getValue() == Matter.LIQUID) {
            event.setCancelled(true);
        }
    }

the event is called but what i get as result is that the water still spread but i can’t place block in the water

Change getOriginal to getFinal.

Doing that will prevent placing water (wich is not what i want). Of course if you can’t place it it can’t spread, but what i want is that you can place water but it will not spread (it will stay as one block where you place it)

in plugin main class