crwdns151861:0crwdne151861:0

crwdns151863:0crwdne151863:0

crwdns151865:0:javadoc:crwdnd151865:0:javadoc:crwdnd151865:0:javadoc:crwdne151865:0

import org.spongepowered.api.Sponge;
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;

public Location<World> getBlockAt(String worldName, int posX, int posY, int posZ) {
    World world = Sponge.getServer().getWorld(worldName).get();
    Location<World> blockLoc = new Location<World>(world, posX, posY, posZ);
    return blockLoc;
}

Warning

crwdns151867:0crwdne151867:0

crwdns151869:0crwdne151869:0

import org.spongepowered.api.block.BlockType;
import org.spongepowered.api.block.BlockTypes;

public boolean isBanner(Location<World> blockLoc) {
    BlockType type = blockLoc.getBlock().getType();
    return type.equals(BlockTypes.STANDING_BANNER)
            || type.equals(BlockTypes.WALL_BANNER);
}

Tip

crwdns151871:0:javadoc:crwdne151871:0

crwdns151873:0crwdne151873:0

crwdns151875:0:javadoc:crwdnd151875:0:javadoc:crwdne151875:0

import org.spongepowered.api.data.key.Keys;
import org.spongepowered.api.data.manipulator.mutable.block.DirectionalData;

public boolean isFacingNorth(Location<World> blockLoc) {
    Optional<DirectionalData> optionalData = blockLoc.get(DirectionalData.class);
    if (!optionalData.isPresent()) {
        return false;
    }
    DirectionalData data = optionalData.get();
    if (data.get(Keys.DIRECTION).get().equals(Direction.NORTH)) {
        return true;
    }
    return false;
}

crwdns151877:0:javadoc:crwdnd151877:0:javadoc:crwdne151877:0

crwdns151879:0:doc:crwdne151879:0

Tip

crwdns151881:0crwdne151881:0

crwdns151883:0crwdne151883:0

crwdns151885:0:javadoc:crwdnd151885:0:javadoc:crwdnd151885:0:javadoc:crwdnd151885:0:javadoc:crwdne151885:0

import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.data.manipulator.immutable.ImmutableWetData;

public void isWet(Location blockLoc) {
    BlockState sponge = blockLoc.getBlock();
    if (!sponge.getType().equals(BlockTypes.SPONGE)) {
        return false;
    }
    Optional<ImmutableWetData> wetness = sponge.get(ImmutableWetData.class);
    return wetness.isPresent();
}

crwdns151887:0:doc:crwdne151887:0

crwdns151889:0crwdne151889:0

crwdns151891:0crwdne151891:0

import org.spongepowered.api.data.property.DoubleProperty;
import org.spongepowered.api.data.property.block.BlastResistanceProperty;

public boolean blastResistanceGreaterThanOne(Location<World> blockLoc) {
    Optional<BlastResistanceProperty> optional =
        blockLoc.getProperty(BlastResistanceProperty.class);

    if(optional.isPresent()) {
        BlastResistanceProperty resistance = optional.get();
        DoubleProperty one = DoubleProperty.greaterThanOrEqual(1);
        return one.matches(resistance);
    }
    return false;
}

crwdns151893:0:javadoc:crwdnd151893:0:javadoc:crwdne151893:0

crwdns151895:0:javadoc:crwdnd151895:0:javadoc:crwdne151895:0

import org.spongepowered.api.data.property.block.PoweredProperty;

public boolean areBlocksPowered(Location<World> blockLoc, Location<World> blockLoc2) {
    Optional<PoweredProperty> optional = blockLoc.getProperty(PoweredProperty.class);
    Optional<PoweredProperty> optional2 = blockLoc2.getProperty(PoweredProperty.class);

    if(optional.isPresent() && optional2.isPresent()) {
        PoweredProperty property1 = optional2.get();
        PoweredProperty property2 = optional2.get();
        BooleanProperty booleanProperty = BooleanProperty.of(property1);
        BooleanProperty booleanProperty2 = BooleanProperty.of(true);

        if(booleanProperty2.matches(property1)) {
            return booleanProperty.matches(property2);
        }
    }
    return false;
}

crwdns151897:0crwdne151897:0

crwdns151899:0:javadoc:crwdne151899:0

crwdns151901:0crwdne151901:0

crwdns151903:0:javadoc:crwdnd151903:0:javadoc:crwdne151903:0

import org.spongepowered.api.block.trait.BooleanTraits;

public boolean isBedOccupied(Location<World> blockLoc) {
    if(blockLoc.getBlock().getType().equals(BlockTypes.BED)) {
        return blockLoc.getBlock().getTraitValue(BooleanTraits.BED_OCCUPIED).get();
    }
    return false;
}

Warning

crwdns151905:0crwdne151905:0