crwdns132437:0crwdne132437:0

crwdns132439:0crwdne132439:0

crwdns132441:0crwdne132441:0

crwdns132443:0:javadoc:crwdnd132443:0:javadoc:crwdne132443:0

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

public boolean isTileEntity(Location<World> blockLoc) {
    return blockLoc.getTileEntity().isPresent();
}

crwdns132445:0:javadoc:crwdnd132445:0:javadoc:crwdnd132445:0:javadoc:crwdnd132445:0:javadoc:crwdne132445:0

import org.spongepowered.api.block.tileentity.Jukebox;
import org.spongepowered.api.block.tileentity.TileEntity;
import org.spongepowered.api.block.tileentity.TileEntityTypes;

public boolean isJukebox(TileEntity entity) {
    return entity.getType().equals(TileEntityTypes.JUKEBOX);
}

public void ejectDiscFromJukebox(TileEntity entity) {
    if (isJukebox(entity)) {
        Jukebox jukebox = (Jukebox) entity;
        jukebox.ejectRecord();
    }
}

crwdns132447:0:javadoc:crwdnd132447:0:javadoc:crwdne132447:0

crwdns132449:0crwdne132449:0

crwdns132451:0:javadoc:crwdne132451:0

crwdns132453:0crwdne132453:0

import org.spongepowered.api.data.manipulator.mutable.tileentity.SignData;
import org.spongepowered.api.text.Text;

import java.util.Optional;

public Optional<Text> getFirstLine(TileEntity entity) {
    Optional<SignData> data = entity.getOrCreate(SignData.class);
    if (data.isPresent()) {
        return Optional.of(data.get().lines().get(0));
    }
    return Optional.empty();
}

public boolean setFirstLine(TileEntity entity, Text line) {
    if (entity.supports(SignData.class)) {
        SignData sign = entity.getOrCreate(SignData.class).get();
        sign.set(sign.lines().set(0, line));
        entity.offer(sign);
        return true;
    }
    return false;
}

crwdns132455:0:javadoc:crwdne132455:0

crwdns132457:0crwdne132457:0

crwdns132459:0:javadoc:crwdne132459:0

import org.spongepowered.api.block.tileentity.carrier.TileEntityCarrier;
import org.spongepowered.api.item.inventory.Inventory;

public void useInventory(TileEntity entity) {
    if (entity instanceof TileEntityCarrier) {
        TileEntityCarrier carrier = (TileEntityCarrier) entity;
        Inventory inventory = carrier.getInventory();
        ...
    }
}

crwdns132461:0crwdne132461:0