Search in sources :

Example 36 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 37 with IProperty

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

the class ExtraUtilsHelper method registerXUPlant.

static void registerXUPlant(ItemStack seed, Block block, ItemStack soil, ItemStack[] output, final int maxAge, final float growthStep, final boolean useFertilizer) {
    IProperty propGrowth = null;
    final IBlockState state = block.getDefaultState();
    for (IProperty prop : state.getPropertyKeys()) if ("growth".equals(prop.getName()))
        propGrowth = prop;
    if (propGrowth != null) {
        IProperty finalPropGrowth = propGrowth;
        DefaultPlantHandler handler = new DefaultPlantHandler() {

            private HashSet<ComparableItemStack> validSeeds = new HashSet<>();

            @Override
            protected HashSet<ComparableItemStack> getSeedSet() {
                return validSeeds;
            }

            @Override
            public float getGrowthStep(ItemStack seed, ItemStack soil, float growth, TileEntity tile, float fertilizer, boolean render) {
                return !useFertilizer ? growthStep : (growthStep * fertilizer);
            }

            @Override
            @SideOnly(Side.CLIENT)
            public IBlockState[] getRenderedPlant(ItemStack seed, ItemStack soil, float growth, TileEntity tile) {
                return new IBlockState[] { state.withProperty(finalPropGrowth, Math.min(maxAge, Math.round(maxAge * growth))) };
            }
        };
        handler.register(seed, output, soil, state);
        BelljarHandler.registerHandler(handler);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) DefaultPlantHandler(blusunrize.immersiveengineering.api.tool.BelljarHandler.DefaultPlantHandler) ComparableItemStack(blusunrize.immersiveengineering.api.ComparableItemStack) IBlockState(net.minecraft.block.state.IBlockState) IProperty(net.minecraft.block.properties.IProperty) ComparableItemStack(blusunrize.immersiveengineering.api.ComparableItemStack) ItemStack(net.minecraft.item.ItemStack) HashSet(java.util.HashSet)

Example 38 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, 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));
    }
    List<T> sorted = Lists.newArrayList(name.getAllowedValues());
    Collections.sort(sorted);
    TableCellEnum<T> cell = new TableCellEnum<>(null, (T) state.getValue(name), sorted.stream().map(t1 -> new TableCellEnum.Option<>(t1, name.getName(currentProperty))).collect(Collectors.toList()));
    cell.addListener(t -> {
        setBlockStateAndNotify(state.withProperty(name, t));
        delegate.reloadData();
    });
    cell.setEnabled(!extended);
    return new TitledCell(name.getName(), cell);
}
Also used : IvTranslations(ivorius.ivtoolkit.tools.IvTranslations) GuiTable(ivorius.reccomplex.gui.table.GuiTable) TableDataSourceSegmented(ivorius.reccomplex.gui.table.datasource.TableDataSourceSegmented) ivorius.reccomplex.gui.table.cell(ivorius.reccomplex.gui.table.cell) BlockStates(ivorius.ivtoolkit.blocks.BlockStates) Collectors(java.util.stream.Collectors) TableCells(ivorius.reccomplex.gui.table.TableCells) TableNavigator(ivorius.reccomplex.gui.table.TableNavigator) 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) Side(net.minecraftforge.fml.relauncher.Side) ResourceLocation(net.minecraft.util.ResourceLocation) RecurrentComplex(ivorius.reccomplex.RecurrentComplex) TableDelegate(ivorius.reccomplex.gui.table.TableDelegate) TableDataSourceBTNatural(ivorius.reccomplex.gui.editstructure.transformers.TableDataSourceBTNatural) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) 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)

Example 39 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.blockRegistry.getNameForObject(block).getResourceDomain();
    for (IBlockState state : block.getBlockState().getValidStates()) {
        int meta = state.getBlock().getMetaFromState(state);
        List<IProperty> propertyNames = new ArrayList<>(state.getPropertyNames());
        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 40 with IProperty

use of net.minecraft.block.properties.IProperty in project SecurityCraft by Geforce132.

the class ItemBlockReinforcedSlabs method canPlaceBlockOnSide.

@Override
@SideOnly(Side.CLIENT)
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack) {
    BlockPos blockpos1 = pos;
    IProperty iproperty = this.singleSlab.getVariantProperty();
    Object object = this.singleSlab.getTypeForItem(stack);
    IBlockState iblockstate = worldIn.getBlockState(pos);
    if (iblockstate.getBlock() == this.singleSlab) {
        boolean flag = iblockstate.getValue(BlockSlab.HALF) == BlockSlab.EnumBlockHalf.TOP;
        if ((side == EnumFacing.UP && !flag || side == EnumFacing.DOWN && flag) && object == iblockstate.getValue(iproperty)) {
            return true;
        }
    }
    pos = pos.offset(side);
    IBlockState iblockstate1 = worldIn.getBlockState(pos);
    return iblockstate1.getBlock() == this.singleSlab && object == iblockstate1.getValue(iproperty) ? true : super.canPlaceBlockOnSide(worldIn, blockpos1, side, player, stack);
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IProperty(net.minecraft.block.properties.IProperty) BlockPos(net.minecraft.util.math.BlockPos) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

IProperty (net.minecraft.block.properties.IProperty)78 IBlockState (net.minecraft.block.state.IBlockState)43 Block (net.minecraft.block.Block)23 EnumFacing (net.minecraft.util.EnumFacing)15 ResourceLocation (net.minecraft.util.ResourceLocation)15 ItemStack (net.minecraft.item.ItemStack)14 Map (java.util.Map)11 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)11 ArrayList (java.util.ArrayList)10 BlockPos (net.minecraft.util.math.BlockPos)10 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)10 TileEntity (net.minecraft.tileentity.TileEntity)8 List (java.util.List)7 BlockStateContainer (net.minecraft.block.state.BlockStateContainer)7 World (net.minecraft.world.World)7 JsonObject (com.google.gson.JsonObject)6 Collectors (java.util.stream.Collectors)6 ExtendedBlockState (net.minecraftforge.common.property.ExtendedBlockState)6 FluidStack (net.minecraftforge.fluids.FluidStack)6 Lists (com.google.common.collect.Lists)5