Search in sources :

Example 1 with BrewingStandData

use of org.spongepowered.api.data.manipulator.mutable.tileentity.BrewingStandData in project SpongeCommon by SpongePowered.

the class SpongeBrewingStandBuilder method buildContent.

@Override
protected Optional<BrewingStand> buildContent(DataView container) throws InvalidDataException {
    return super.buildContent(container).map(brewingStand -> {
        if (!container.contains(BREW_TIME_QUERY)) {
            throw new InvalidDataException("The provided container does not contain the data to make a Banner!");
        }
        // Have to consider custom names as an option
        if (container.contains(DataQueries.CUSTOM_NAME)) {
            ((TileEntityBrewingStand) brewingStand).setName(container.getString(DataQueries.CUSTOM_NAME).get());
        }
        final BrewingStandData brewingData = Sponge.getDataManager().getManipulatorBuilder(BrewingStandData.class).get().create();
        brewingData.remainingBrewTime().set(container.getInt(BREW_TIME_QUERY).get());
        brewingStand.offer(brewingData);
        ((TileEntityBrewingStand) brewingStand).validate();
        return brewingStand;
    });
}
Also used : BrewingStandData(org.spongepowered.api.data.manipulator.mutable.tileentity.BrewingStandData) TileEntityBrewingStand(net.minecraft.tileentity.TileEntityBrewingStand) InvalidDataException(org.spongepowered.api.data.persistence.InvalidDataException)

Aggregations

TileEntityBrewingStand (net.minecraft.tileentity.TileEntityBrewingStand)1 BrewingStandData (org.spongepowered.api.data.manipulator.mutable.tileentity.BrewingStandData)1 InvalidDataException (org.spongepowered.api.data.persistence.InvalidDataException)1