Search in sources :

Example 6 with IProperty

use of net.minecraft.block.properties.IProperty in project ImmersiveEngineering by BluSunrize.

the class BlockMetalDevice1 method createBlockState.

@Override
protected BlockStateContainer createBlockState() {
    BlockStateContainer base = super.createBlockState();
    IUnlistedProperty[] unlisted = (base instanceof ExtendedBlockState) ? ((ExtendedBlockState) base).getUnlistedProperties().toArray(new IUnlistedProperty[0]) : new IUnlistedProperty[0];
    unlisted = Arrays.copyOf(unlisted, unlisted.length + 1);
    unlisted[unlisted.length - 1] = IEProperties.CONNECTIONS;
    return new ExtendedBlockState(this, base.getProperties().toArray(new IProperty[0]), unlisted);
}
Also used : IUnlistedProperty(net.minecraftforge.common.property.IUnlistedProperty) IProperty(net.minecraft.block.properties.IProperty) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) ExtendedBlockState(net.minecraftforge.common.property.ExtendedBlockState) BlockStateContainer(net.minecraft.block.state.BlockStateContainer)

Example 7 with IProperty

use of net.minecraft.block.properties.IProperty in project ImmersiveEngineering by BluSunrize.

the class BlockConnector method createBlockState.

@Override
protected BlockStateContainer createBlockState() {
    BlockStateContainer base = super.createBlockState();
    IUnlistedProperty[] unlisted = (base instanceof ExtendedBlockState) ? ((ExtendedBlockState) base).getUnlistedProperties().toArray(new IUnlistedProperty[0]) : new IUnlistedProperty[0];
    unlisted = Arrays.copyOf(unlisted, unlisted.length + 1);
    unlisted[unlisted.length - 1] = IEProperties.CONNECTIONS;
    return new ExtendedBlockState(this, base.getProperties().toArray(new IProperty[0]), unlisted);
}
Also used : IUnlistedProperty(net.minecraftforge.common.property.IUnlistedProperty) IProperty(net.minecraft.block.properties.IProperty) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) ExtendedBlockState(net.minecraftforge.common.property.ExtendedBlockState) BlockStateContainer(net.minecraft.block.state.BlockStateContainer)

Example 8 with IProperty

use of net.minecraft.block.properties.IProperty in project RFToolsDimensions by McJty.

the class KnownDimletConfiguration method initMaterialDimlet.

private static void initMaterialDimlet(Block block) {
    if (block instanceof BlockLiquid) {
        return;
    }
    Set<Filter.Feature> features = getBlockFeatures(block);
    ResourceLocation nameForObject = Block.REGISTRY.getNameForObject(block);
    String mod = nameForObject.getResourceDomain();
    for (IBlockState state : block.getBlockState().getValidStates()) {
        int meta = state.getBlock().getMetaFromState(state);
        ItemStack stack = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state));
        if (stack.getItem() != null) {
            // Protection
            List<IProperty<?>> propertyNames = new ArrayList<>(CompatBlock.getPropertyKeys(state));
            propertyNames.sort((o1, o2) -> o1.getName().compareTo(o2.getName()));
            ImmutableMap<IProperty<?>, Comparable<?>> properties = state.getProperties();
            Map<String, String> props = new HashMap<>();
            for (Map.Entry<IProperty<?>, Comparable<?>> entry : properties.entrySet()) {
                props.put(entry.getKey().getName(), entry.getValue().toString());
            }
            DimletKey key = new DimletKey(DimletType.DIMLET_MATERIAL, block.getRegistryName() + "@" + meta);
            Settings settings = DimletRules.getSettings(key, mod, features, props);
            if (!settings.isBlacklisted()) {
                knownDimlets.put(key, settings);
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) IProperty(net.minecraft.block.properties.IProperty) ResourceLocation(net.minecraft.util.ResourceLocation) ItemStack(net.minecraft.item.ItemStack) ImmutableMap(com.google.common.collect.ImmutableMap) Settings(mcjty.rftoolsdim.config.Settings)

Example 9 with IProperty

use of net.minecraft.block.properties.IProperty in project RFToolsDimensions by McJty.

the class DimletDebug method dumpBlock.

private static void dumpBlock(Block block) {
    if (block instanceof BlockLiquid) {
        return;
    }
    Set<Filter.Feature> features = KnownDimletConfiguration.getBlockFeatures(block);
    String mod = Block.REGISTRY.getNameForObject(block).getResourceDomain();
    for (IBlockState state : block.getBlockState().getValidStates()) {
        int meta = state.getBlock().getMetaFromState(state);
        List<IProperty> propertyNames = new ArrayList<>(CompatBlock.getPropertyKeys(state));
        propertyNames.sort((o1, o2) -> o1.getName().compareTo(o2.getName()));
        ImmutableMap<IProperty<?>, Comparable<?>> properties = state.getProperties();
        Map<String, String> props = new HashMap<>();
        for (Map.Entry<IProperty<?>, Comparable<?>> entry : properties.entrySet()) {
            props.put(entry.getKey().getName(), entry.getValue().toString());
        }
        DimletKey key = new DimletKey(DimletType.DIMLET_MATERIAL, block.getRegistryName() + "@" + meta);
        Settings settings = DimletRules.getSettings(key, mod, features, props);
        Logging.log(key + " (" + state.toString() + "): " + settings.toString());
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) IProperty(net.minecraft.block.properties.IProperty) ImmutableMap(com.google.common.collect.ImmutableMap) Settings(mcjty.rftoolsdim.config.Settings)

Example 10 with IProperty

use of net.minecraft.block.properties.IProperty in project RecurrentComplex by Ivorforce.

the class TableDataSourceBlockState method getPropertyElement.

@Nonnull
protected <T extends Comparable<T>> TitledCell getPropertyElement(int index, boolean extended) {
    IBlockState state = computeBlockState();
    @SuppressWarnings("unchecked") IProperty<T> name = (IProperty<T>) getSortedPropertyNames(state, extended).get(index);
    List<T> properties = getSortedProperties(name);
    T currentProperty = state.getValue(name);
    if (properties.size() <= 4) {
        List<TableCellButton> buttons = properties.stream().map(property -> {
            TableCellButton button = new TableCellButton(null, null, (property == currentProperty ? TextFormatting.GREEN : "") + name.getName(property));
            button.setEnabled(!extended);
            button.addAction(() -> {
                setBlockStateAndNotify(state.withProperty(name, property));
                delegate.reloadData();
            });
            if (property == currentProperty)
                button.setEnabled(false);
            return button;
        }).collect(Collectors.toList());
        return new TitledCell(name.getName(), new TableCellMulti(buttons));
    }
    TableCellButton button = new TableCellButton(null, null, TextFormatting.GREEN + name.getName(currentProperty));
    button.setEnabled(!extended);
    button.addAction(() -> {
        setBlockStateAndNotify(state.cycleProperty(name));
        delegate.reloadData();
    });
    return new TitledCell(name.getName(), button);
}
Also used : IvTranslations(ivorius.ivtoolkit.tools.IvTranslations) ivorius.reccomplex.gui.table(ivorius.reccomplex.gui.table) TableDataSourceSegmented(ivorius.reccomplex.gui.table.datasource.TableDataSourceSegmented) TextFormatting(net.minecraft.util.text.TextFormatting) ivorius.reccomplex.gui.table.cell(ivorius.reccomplex.gui.table.cell) BlockStates(ivorius.ivtoolkit.blocks.BlockStates) Collectors(java.util.stream.Collectors) Consumer(java.util.function.Consumer) IBlockState(net.minecraft.block.state.IBlockState) List(java.util.List) Lists(com.google.common.collect.Lists) IProperty(net.minecraft.block.properties.IProperty) Block(net.minecraft.block.Block) ResourceLocation(net.minecraft.util.ResourceLocation) RecurrentComplex(ivorius.reccomplex.RecurrentComplex) TableDataSourceBTNatural(ivorius.reccomplex.gui.editstructure.transformers.TableDataSourceBTNatural) Comparator(java.util.Comparator) Nonnull(javax.annotation.Nonnull) Collections(java.util.Collections) IBlockState(net.minecraft.block.state.IBlockState) IProperty(net.minecraft.block.properties.IProperty) Nonnull(javax.annotation.Nonnull)

Aggregations

IProperty (net.minecraft.block.properties.IProperty)19 IBlockState (net.minecraft.block.state.IBlockState)11 DrawBlock (com.microsoft.Malmo.Schemas.DrawBlock)4 ItemStack (net.minecraft.item.ItemStack)4 TileEntity (net.minecraft.tileentity.TileEntity)4 ResourceLocation (net.minecraft.util.ResourceLocation)4 Variation (com.microsoft.Malmo.Schemas.Variation)3 Block (net.minecraft.block.Block)3 BlockStateContainer (net.minecraft.block.state.BlockStateContainer)3 ExtendedBlockState (net.minecraftforge.common.property.ExtendedBlockState)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 ComparableItemStack (blusunrize.immersiveengineering.api.ComparableItemStack)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 BlockType (com.microsoft.Malmo.Schemas.BlockType)2 Colour (com.microsoft.Malmo.Schemas.Colour)2 ArrayList (java.util.ArrayList)2 Settings (mcjty.rftoolsdim.config.Settings)2 BlockLiquid (net.minecraft.block.BlockLiquid)2 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)2 IUnlistedProperty (net.minecraftforge.common.property.IUnlistedProperty)2