crwdns122221:0crwdne122221:0

crwdns122223:0crwdne122223:0

crwdns122225:0:javadoc:crwdnd122225:0:javadoc:crwdnd122225:0:javadoc:crwdne122225: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

crwdns122227:0crwdne122227:0

crwdns122229:0crwdne122229: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

crwdns122231:0:javadoc:crwdne122231:0

crwdns122233:0crwdne122233:0

crwdns122235:0:javadoc:crwdnd122235:0:javadoc:crwdne122235: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;
}

crwdns122237:0:javadoc:crwdnd122237:0:javadoc:crwdne122237:0

crwdns122239:0:doc:crwdne122239:0

Tip

crwdns122241:0crwdne122241:0

crwdns122243:0crwdne122243:0

crwdns122245:0:javadoc:crwdnd122245:0:javadoc:crwdnd122245:0:javadoc:crwdnd122245:0:javadoc:crwdne122245:0

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

public boolean 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();
}

crwdns122247:0:doc:crwdne122247:0

crwdns122249:0crwdne122249:0

crwdns122251:0crwdne122251:0

import org.spongepowered.api.data.Property;
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 = new DoubleProperty(1, Property.Operator.GEQUAL);
        return one.matches(resistance);
    }
    return false;
}

crwdns122253:0:javadoc:crwdnd122253:0:javadoc:crwdne122253:0

crwdns122255:0:javadoc:crwdnd122255:0:javadoc:crwdne122255:0

import org.spongepowered.api.data.property.BooleanProperty;
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 = new BooleanProperty(true, Property.Operator.EQUAL);

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

crwdns122257:0crwdne122257:0

crwdns122259:0:javadoc:crwdne122259:0

crwdns122261:0crwdne122261:0

crwdns122263:0:javadoc:crwdnd122263:0:javadoc:crwdne122263: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

crwdns122265:0crwdne122265:0