Search in sources :

Example 1 with MatterProperty

use of org.spongepowered.api.data.property.block.MatterProperty in project AdamantineShield by Karanum.

the class LiquidFlowListener method onLiquidFlow.

@Listener(order = Order.POST)
public void onLiquidFlow(ChangeBlockEvent.Pre e) {
    if (e.getLocations().isEmpty())
        return;
    Location<World> loc = e.getLocations().get(0);
    BlockSnapshot snapshot = loc.getExtent().createSnapshot(loc.getBlockPosition());
    Optional<MatterProperty> matter = snapshot.getState().getProperty(MatterProperty.class);
    if (matter.isPresent() && matter.get().getValue() == Matter.LIQUID) {
        String name = "Water";
        BlockType type = snapshot.getState().getType();
        if (type == BlockTypes.LAVA || type == BlockTypes.FLOWING_LAVA)
            name = "Lava";
        db.addToQueue(new BlockQueueEntry(snapshot, ActionType.FLOW, name, new Date().getTime()));
    }
}
Also used : MatterProperty(org.spongepowered.api.data.property.block.MatterProperty) BlockType(org.spongepowered.api.block.BlockType) BlockQueueEntry(com.karanumcoding.adamantineshield.db.queue.BlockQueueEntry) BlockSnapshot(org.spongepowered.api.block.BlockSnapshot) World(org.spongepowered.api.world.World) Date(java.util.Date) Listener(org.spongepowered.api.event.Listener)

Aggregations

BlockQueueEntry (com.karanumcoding.adamantineshield.db.queue.BlockQueueEntry)1 Date (java.util.Date)1 BlockSnapshot (org.spongepowered.api.block.BlockSnapshot)1 BlockType (org.spongepowered.api.block.BlockType)1 MatterProperty (org.spongepowered.api.data.property.block.MatterProperty)1 Listener (org.spongepowered.api.event.Listener)1 World (org.spongepowered.api.world.World)1