Search in sources :

Example 1 with Property

use of net.modificationstation.stationapi.api.state.property.Property in project StationAPI by ModificationStation.

the class BlockStateHelper method fromBlockState.

public static CompoundTag fromBlockState(BlockState state) {
    CompoundTag compoundTag = new CompoundTag();
    compoundTag.put("Name", BlockRegistry.INSTANCE.getIdentifier(state.getBlock()).toString());
    ImmutableMap<Property<?>, Comparable<?>> immutableMap = state.getEntries();
    if (!immutableMap.isEmpty()) {
        CompoundTag compoundTag2 = new CompoundTag();
        for (Map.Entry<Property<?>, Comparable<?>> propertyComparableEntry : immutableMap.entrySet()) {
            Property<?> property = propertyComparableEntry.getKey();
            compoundTag2.put(property.getName(), nameValue(property, propertyComparableEntry.getValue()));
        }
        compoundTag.put("Properties", compoundTag2);
    }
    return compoundTag;
}
Also used : Property(net.modificationstation.stationapi.api.state.property.Property) ImmutableMap(com.google.common.collect.ImmutableMap) CompoundTag(net.minecraft.util.io.CompoundTag)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)1 CompoundTag (net.minecraft.util.io.CompoundTag)1 Property (net.modificationstation.stationapi.api.state.property.Property)1