crwdns141813:0crwdne141813:0

crwdns141817:0crwdne141817:0

crwdns156439:0:javadoc:crwdnd156439:0:javadoc:crwdnd156439:0:javadoc:crwdne156439:0

import org.spongepowered.api.Sponge;
import org.spongepowered.api.world.server.ServerLocation;
import org.spongepowered.api.world.server.ServerWorld;
import org.spongepowered.api.ResourceKey;

public ServerLocation getBlockAt(ResourceKey worldKey, int posX, int posY, int posZ) {
    ServerWorld world = Sponge.server().worldManager().world(worldKey).get();
    ServerLocation blockLocation = world.location(posX, posY, posZ);
    return blockLoc;
}

Warning

crwdns156441:0crwdne156441:0

crwdns156443:0crwdne156443:0

import org.spongepowered.api.block.BlockType;
import org.spongepowered.api.block.BlockTypes;
import org.spongepowered.api.tag.BlockTypeTag;
import org.spongepowered.api.world.server.ServerLocation;

public boolean isBanner(ServerLocation blockLoc) {
    Tag<BlockType> bannerTag = BlockTypeTags.BANNERS.get();
    BlockType blockType = blockLoc.blockType();
    return bannerTag.contains(blockType);
}

Tip

crwdns156445:0:javadoc:crwdne156445:0

crwdns141827:0crwdne141827:0

crwdns156447:0:javadoc:crwdnd156447:0:javadoc:crwdne156447:0

import org.spongepowered.api.util.Direction;
import org.spongepowered.api.data.Keys;

public boolean isFacingNorth(ServerLocation blockLoc) {
    Optional<Direction> optionalBlockDirection = blockLoc.get(Keys.DIRECTION).get();
    if(!optionalBlockDirection.isPresent()){
        return false;
    }
    Direction blockDirection = optionalBlockDirection.get();
    if(blockDirection.equals(Direction.NORTH)){
        return true;
    }
    return false;
}

crwdns156449:0crwdne156449:0

crwdns156953:0:doc:crwdne156953:0

Tip

crwdns156451:0crwdne156451:0

crwdns141837:0crwdne141837:0

crwdns156453:0:javadoc:crwdnd156453:0:javadoc:crwdnd156453:0:javadoc:crwdnd156453:0:javadoc:crwdne156453:0

import org.spongepowered.api.block.BlockState;

public boolean isWet(ServerLocation blockLoc) {
    BlockState sponge = blockLoc.getBlock();
    if (!sponge.getType().equals(BlockTypes.SPONGE.get())) {
        return false;
    }
    Optional<Boolean> wetness = sponge.get(Keys.IS_WET);
    if (wetness.isPresent()){
        return wetness.get();
    }
    return false;
}

crwdns156955:0:doc:crwdne156955:0

crwdns156455:0crwdne156455:0

crwdns156457:0:javadoc:crwdnd156457:0:javadoc:crwdne156457:0

import org.spongepowered.api.state.BooleanStateProperties;

public boolean isBlueBedOccupied(ServerLocation blockLoc) {
    if(blockLoc.state().type().equals(BlockTypes.BLUE_BED.get())) {
        return blockLoc.state().stateProperty(BooleanStateProperties.BLUE_BED_OCCUPIED).get();
    }
    return false;
}

Warning

crwdns156459:0crwdne156459:0