Search in sources :

Example 11 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<>(state.getPropertyKeys());
        propertyNames.sort(Comparator.comparing(IProperty::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 12 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 || block == Blocks.LIT_REDSTONE_ORE) {
        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<>(state.getPropertyKeys());
            propertyNames.sort(Comparator.comparing(IProperty::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 13 with IProperty

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

the class ItemBlockReinforcedSlabs2 method canPlaceBlockOnSide.

@Override
@SideOnly(Side.CLIENT)
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack) {
    BlockPos blockpos1 = pos;
    IProperty iproperty = singleSlab.getVariantProperty();
    Object object = singleSlab.getVariant(stack);
    IBlockState iblockstate = worldIn.getBlockState(pos);
    if (iblockstate.getBlock() == 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() == 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.BlockPos) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 14 with IProperty

use of net.minecraft.block.properties.IProperty in project Almura by AlmuraDev.

the class StatefulLazyBlockState method createState.

@Override
<T extends Comparable<T>> IBlockState createState() {
    final Block block = (Block) this.block.require();
    IBlockState state = block.getDefaultState();
    for (final Map.Entry<IProperty<? extends Comparable<?>>, StateValue<? extends Comparable<?>>> entry : this.properties.get().entrySet()) {
        @Nullable final IProperty<T> property = (IProperty<T>) entry.getKey();
        if (property != null) {
            @Nullable final T value = ((StateValue<T>) entry.getValue()).get(property);
            if (value != null) {
                state = state.withProperty(property, value);
            }
        }
    }
    return state;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IProperty(net.minecraft.block.properties.IProperty) Block(net.minecraft.block.Block) StateValue(com.almuradev.content.type.block.state.value.StateValue) HashMap(java.util.HashMap) Map(java.util.Map) Nullable(javax.annotation.Nullable)

Example 15 with IProperty

use of net.minecraft.block.properties.IProperty in project malmo by Microsoft.

the class BlockDrawingHelper method endDrawing.

public void endDrawing(World w) {
    // Post-drawing code.
    for (StateCheck sc : this.checkList) {
        IBlockState stateActual = w.getBlockState(sc.pos);
        Block blockActual = stateActual.getBlock();
        Block blockDesired = sc.desiredState.getBlock();
        if (blockActual == blockDesired) {
            // Now check the block states:
            if (stateActual != sc.desiredState) {
                if (sc.propertiesToCheck == null) {
                    // No specific properties to check - just do a blanket reset.
                    w.setBlockState(sc.pos, sc.desiredState);
                } else {
                    // Reset only the properties we've been asked to check:
                    for (IProperty prop : sc.propertiesToCheck) {
                        stateActual = stateActual.withProperty(prop, sc.desiredState.getValue(prop));
                    }
                    w.setBlockState(sc.pos, stateActual);
                }
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IProperty(net.minecraft.block.properties.IProperty) DrawBlock(com.microsoft.Malmo.Schemas.DrawBlock) Block(net.minecraft.block.Block)

Aggregations

IProperty (net.minecraft.block.properties.IProperty)29 IBlockState (net.minecraft.block.state.IBlockState)19 ItemStack (net.minecraft.item.ItemStack)8 Block (net.minecraft.block.Block)7 ResourceLocation (net.minecraft.util.ResourceLocation)6 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)6 DrawBlock (com.microsoft.Malmo.Schemas.DrawBlock)5 TileEntity (net.minecraft.tileentity.TileEntity)5 BlockStateContainer (net.minecraft.block.state.BlockStateContainer)4 JsonObject (com.google.gson.JsonObject)3 Variation (com.microsoft.Malmo.Schemas.Variation)3 ItemBlock (net.minecraft.item.ItemBlock)3 ComparableItemStack (blusunrize.immersiveengineering.api.ComparableItemStack)2 StateValue (com.almuradev.content.type.block.state.value.StateValue)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 BlockType (com.microsoft.Malmo.Schemas.BlockType)2 Colour (com.microsoft.Malmo.Schemas.Colour)2 DrawItem (com.microsoft.Malmo.Schemas.DrawItem)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2