/*
 * This file is part of Sponge, licensed under the MIT License (MIT).
 *
 * Copyright (c) SpongePowered.org <http://www.spongepowered.org>
 * Copyright (c) contributors
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package org.spongepowered.api.block;

import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import org.spongepowered.api.world.extent.Extent;

import java.util.Collection;

/**
 * Represents a block with type and data.
 */
public interface BlockState {

    /**
     * Get the base type of block.
     *
     * <p>The type does not include block data such as the contents of
     * inventories.</p>
     *
     * @return The type of block
     */
    BlockType getType();

    /**
     * Get all properties defined on this BlockState, with their current values.
     *
     * @return Map of all current properties
     */
    ImmutableMap<BlockProperty<?>, ? extends Comparable<?>> getProperties();

    /**
     * Get all property names defined on this BlockState
     *
     * @return Collection of property names
     */
    Collection<String> getPropertyNames();

    /**
     * Get a property from its name.
     *
     * @param name The name of the property
     * @return The property with the given name
     */
    Optional<BlockProperty<?>> getPropertyByName(String name);

    /**
     * Get the current value of a given property.
     *
     * @param name Property to get value of
     * @return Current value of the property
     */
    Optional<? extends Comparable<?>> getPropertyValue(String name);

    /**
     * Get an altered BlockState with the given property set to the given value.
     *
     * <p>This does not alter the current BlockState instance</p>
     *
     * @param property Property to change value of
     * @param value New value of property
     * @return A BlockState with the property's value modified
     */
    BlockState withProperty(BlockProperty<?> property, Comparable<?> value);

    /**
     * Get an altered BlockState with the given property set to the next valid
     * value for that property, cycling to the lowest value after the highest
     * value.
     *
     * <p>This does not alter the current BlockState instance</p>
     *
     * @param property Property to change value of
     * @return A BlockState with the property's value modified
     */
    BlockState cycleProperty(BlockProperty<?> property);

    /**
     * Get the data value of the block at the given position.
     *
     * <p>The data value is a number between 0 and 15 (inclusive) that
     * represents a value for differentiation with certain blocks. For example,
     * the base dirt block has a data value that changes the variant of dirt.
     * The base data value is generally 0.</p>
     *
     * <p>However, be aware that data values are being deprecated in
     * Minecraft because they are a waste of bytes and add extra complexity to
     * block differentiation. Most blocks don't use a data value, so that's
     * a waste of four bits of data per block. In the future, there will
     * only be <em>one</em> number to represent each 'state' of a block.</p>
     *
     * @return The data value
     * @deprecated Exists for backwards-compatibility/transitional use
     */
    @Deprecated
    byte getDataValue();
}

@@ -1373,58 +1373,8 @@
 Map;
-%0Aimport org.spongepowered.api.world.extent.Extent;
 %0A%0Aim
@@ -4285,10 +4285,549 @@
 alue();%0A
+%0A    /**%0A     * Get an instance of the given data class for this block.%0A     *%0A     * %3Cp%3EFor example, if this block represents a sign,%0A     * %7B@code getData(Sign.class)%7D would yield an instance of%0A     * %7B@code Sign%7D to change the contents of the sign. However, if%0A     * this block does not represent a sign, then an instance will not%0A     * be returned.%3C/p%3E%0A     *%0A     * @param dataClass The data class%0A     * @param %3CT%3E The type of data%0A     * @return An instance of the class%0A     */%0A    %3CT%3E Optional%3CT%3E getData(Class%3CT%3E dataClass);%0A%0A
 %7D%0A

Add getData(Class<T> dataClass) to BlockState for getting TE data.