Search in sources :

Example 1 with PropertyDirection

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

the class BlockIETileProvider method getActualState.

@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
    state = super.getActualState(state, world, pos);
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof IAttachedIntegerProperies) {
        for (String s : ((IAttachedIntegerProperies) tile).getIntPropertyNames()) state = applyProperty(state, ((IAttachedIntegerProperies) tile).getIntProperty(s), ((IAttachedIntegerProperies) tile).getIntPropertyValue(s));
    }
    if (tile instanceof IDirectionalTile && (state.getPropertyNames().contains(IEProperties.FACING_ALL) || state.getPropertyNames().contains(IEProperties.FACING_HORIZONTAL))) {
        PropertyDirection prop = state.getPropertyNames().contains(IEProperties.FACING_HORIZONTAL) ? IEProperties.FACING_HORIZONTAL : IEProperties.FACING_ALL;
        state = applyProperty(state, prop, ((IDirectionalTile) tile).getFacing());
    } else if (state.getPropertyNames().contains(IEProperties.FACING_HORIZONTAL))
        state = state.withProperty(IEProperties.FACING_HORIZONTAL, getDefaultFacing());
    else if (state.getPropertyNames().contains(IEProperties.FACING_ALL))
        state = state.withProperty(IEProperties.FACING_ALL, getDefaultFacing());
    if (tile instanceof IActiveState) {
        IProperty boolProp = ((IActiveState) tile).getBoolProperty(IActiveState.class);
        if (state.getPropertyNames().contains(boolProp))
            state = applyProperty(state, boolProp, ((IActiveState) tile).getIsActive());
    }
    if (tile instanceof IDualState) {
        IProperty boolProp = ((IDualState) tile).getBoolProperty(IDualState.class);
        if (state.getPropertyNames().contains(boolProp))
            state = applyProperty(state, boolProp, ((IDualState) tile).getIsSecondState());
    }
    if (tile instanceof TileEntityMultiblockPart)
        state = applyProperty(state, IEProperties.MULTIBLOCKSLAVE, ((TileEntityMultiblockPart) tile).isDummy());
    else if (tile instanceof IHasDummyBlocks)
        state = applyProperty(state, IEProperties.MULTIBLOCKSLAVE, ((IHasDummyBlocks) tile).isDummy());
    if (tile instanceof IMirrorAble)
        state = applyProperty(state, ((IMirrorAble) tile).getBoolProperty(IMirrorAble.class), ((IMirrorAble) tile).getIsMirrored());
    return state;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IProperty(net.minecraft.block.properties.IProperty) PropertyDirection(net.minecraft.block.properties.PropertyDirection)

Example 2 with PropertyDirection

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

the class BlockIETileProvider method rotateBlock.

@Override
public boolean rotateBlock(World world, BlockPos pos, EnumFacing axis) {
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof IDirectionalTile) {
        if (!((IDirectionalTile) tile).canRotate(axis))
            return false;
        IBlockState state = world.getBlockState(pos);
        if (state.getPropertyNames().contains(IEProperties.FACING_ALL) || state.getPropertyNames().contains(IEProperties.FACING_HORIZONTAL)) {
            PropertyDirection prop = state.getPropertyNames().contains(IEProperties.FACING_HORIZONTAL) ? IEProperties.FACING_HORIZONTAL : IEProperties.FACING_ALL;
            EnumFacing f = ((IDirectionalTile) tile).getFacing();
            int limit = ((IDirectionalTile) tile).getFacingLimitation();
            if (limit == 0)
                f = EnumFacing.VALUES[(f.ordinal() + 1) % EnumFacing.VALUES.length];
            else if (limit == 1)
                f = axis.getAxisDirection() == AxisDirection.POSITIVE ? f.rotateAround(axis.getAxis()).getOpposite() : f.rotateAround(axis.getAxis());
            else if (limit == 2 || limit == 5)
                f = axis.getAxisDirection() == AxisDirection.POSITIVE ? f.rotateY() : f.rotateYCCW();
            if (f != ((IDirectionalTile) tile).getFacing()) {
                EnumFacing old = ((IDirectionalTile) tile).getFacing();
                ((IDirectionalTile) tile).setFacing(f);
                ((IDirectionalTile) tile).afterRotation(old, f);
                state = applyProperty(state, prop, ((IDirectionalTile) tile).getFacing());
                world.setBlockState(pos, state.cycleProperty(prop));
            }
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) PropertyDirection(net.minecraft.block.properties.PropertyDirection) EnumFacing(net.minecraft.util.EnumFacing)

Example 3 with PropertyDirection

use of net.minecraft.block.properties.PropertyDirection in project Railcraft by Railcraft.

the class ComponentWorkshop method addComponentParts.

@Override
public boolean addComponentParts(World world, Random random, StructureBoundingBox sbb) {
    if (averageGroundLevel < 0) {
        this.averageGroundLevel = getAverageGroundLevel(world, sbb);
        if (averageGroundLevel < 0)
            return true;
        boundingBox.offset(0, averageGroundLevel - boundingBox.maxY + 4, 0);
    }
    IBlockState torch = Blocks.TORCH.getDefaultState();
    IBlockState blockBrick = Blocks.BRICK_BLOCK.getDefaultState();
    IBlockState glassPane = Blocks.GLASS_PANE.getDefaultState();
    IBlockState stainedGlass = Blocks.STAINED_GLASS.getDefaultState().withProperty(BlockStainedGlass.COLOR, EnumDyeColor.CYAN);
    IBlockState stoneBrick = Blocks.STONEBRICK.getDefaultState();
    IBlockState mossyStoneBrick = stoneBrick.withProperty(BlockStoneBrick.VARIANT, BlockStoneBrick.EnumType.MOSSY);
    IBlockState crackedStoneBrick = stoneBrick.withProperty(BlockStoneBrick.VARIANT, BlockStoneBrick.EnumType.CRACKED);
    IBlockState roofEast = Blocks.STONE_BRICK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, EnumFacing.EAST);
    IBlockState roofWest = Blocks.STONE_BRICK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, EnumFacing.WEST);
    IBlockState roofNorth = Blocks.STONE_BRICK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, EnumFacing.NORTH);
    IBlockState roofSouth = Blocks.STONE_BRICK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, EnumFacing.SOUTH);
    //Clear area
    fillWithAir(world, sbb, 1, 1, 2, 3, 3, 4);
    fillWithAir(world, sbb, 5, 1, 0, 9, 4, 10);
    // floor
    //        fillWithBlocks(world, sbb, 0, 0, 0, 11, 0, 11, Blocks.GRAVEL, Blocks.GRAVEL, false);
    fillWithBlocks(world, sbb, 4, 0, 0, 10, 0, 10, Blocks.DOUBLE_STONE_SLAB.getDefaultState(), Blocks.DOUBLE_STONE_SLAB.getDefaultState(), false);
    fillWithBlocks(world, sbb, 0, 0, 1, 3, 0, 5, Blocks.DOUBLE_STONE_SLAB.getDefaultState(), Blocks.DOUBLE_STONE_SLAB.getDefaultState(), false);
    // track
    fillWithBlocks(world, sbb, 7, 1, 2, 7, 1, 8, Blocks.RAIL.getDefaultState(), Blocks.RAIL.getDefaultState(), false);
    //        placeOutfittedTrack(TrackTypes.IRON, TrackKits.BUFFER_STOP, world, 7, 1, 1, sbb, EnumRailDirection.NORTH_SOUTH, false);
    //        placeOutfittedTrack(TrackTypes.IRON, TrackKits.BUFFER_STOP, world, 7, 1, 9, sbb, EnumRailDirection.NORTH_SOUTH, true);
    // hall walls
    fillWithBlocks(world, sbb, 4, 0, 0, 4, 3, 10, blockBrick, blockBrick, false);
    fillWithBlocks(world, sbb, 10, 0, 0, 10, 3, 10, blockBrick, blockBrick, false);
    fillWithBlocks(world, sbb, 5, 0, 0, 5, 4, 0, blockBrick, blockBrick, false);
    fillWithBlocks(world, sbb, 9, 0, 0, 9, 4, 0, blockBrick, blockBrick, false);
    fillWithBlocks(world, sbb, 5, 0, 10, 5, 4, 10, blockBrick, blockBrick, false);
    fillWithBlocks(world, sbb, 9, 0, 10, 9, 4, 10, blockBrick, blockBrick, false);
    // hall molding
    IBlockState roofSupportWest = Blocks.BRICK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, EnumFacing.WEST).withProperty(BlockStairs.HALF, BlockStairs.EnumHalf.TOP);
    IBlockState roofSupportEast = Blocks.BRICK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, EnumFacing.EAST).withProperty(BlockStairs.HALF, BlockStairs.EnumHalf.TOP);
    fillWithBlocks(world, sbb, 5, 4, 1, 5, 4, 9, roofSupportWest, roofSupportWest, false);
    fillWithBlocks(world, sbb, 9, 4, 1, 9, 4, 9, roofSupportEast, roofSupportEast, false);
    // hall door
    setBlockState(world, roofSupportWest, 6, 4, 0, sbb);
    setBlockState(world, roofSupportEast, 8, 4, 0, sbb);
    setBlockState(world, roofSupportWest, 6, 4, 10, sbb);
    setBlockState(world, roofSupportEast, 8, 4, 10, sbb);
    // hall windows
    fillWithBlocks(world, sbb, 10, 2, 2, 10, 2, 3, glassPane, glassPane, false);
    fillWithBlocks(world, sbb, 10, 2, 7, 10, 2, 8, glassPane, glassPane, false);
    fillWithBlocks(world, sbb, 4, 2, 7, 4, 2, 8, glassPane, glassPane, false);
    // hall roof slope
    fillWithBlocks(world, sbb, 4, 4, 0, 4, 4, 10, roofEast, roofEast, false);
    fillWithBlocks(world, sbb, 5, 5, 0, 5, 5, 10, roofEast, roofEast, false);
    fillWithBlocks(world, sbb, 10, 4, 0, 10, 4, 10, roofWest, roofWest, false);
    fillWithBlocks(world, sbb, 9, 5, 0, 9, 5, 10, roofWest, roofWest, false);
    // hall roof
    BlockSelector roofSelector = new BlockSelector() {

        @Override
        public void selectBlocks(Random rand, int x, int y, int z, boolean boundary) {
            float f = rand.nextFloat();
            if (f < 0.2F) {
                this.blockstate = crackedStoneBrick;
            } else if (f < 0.5F) {
                this.blockstate = mossyStoneBrick;
            // is this too mean?
            //                } else if (f < 0.55F) {
            //                    this.blockstate = Blocks.MONSTER_EGG.getStateFromMeta(BlockSilverfish.EnumType.STONEBRICK.getMetadata());
            } else {
                this.blockstate = stoneBrick;
            }
        }
    };
    fillWithRandomizedBlocks(world, sbb, 6, 5, 0, 8, 5, 10, false, random, roofSelector);
    setBlockState(world, stainedGlass, 7, 5, 2, sbb);
    setBlockState(world, stainedGlass, 7, 5, 5, sbb);
    setBlockState(world, stainedGlass, 7, 5, 8, sbb);
    PropertyDirection facing = BlockTorch.FACING;
    // hall torches
    //        int meta = getMetadataWithOffset(torch, 4);
    torch = torch.withProperty(facing, EnumFacing.WEST);
    setBlockState(world, torch, 9, 3, 1, sbb);
    setBlockState(world, torch, 9, 3, 5, sbb);
    setBlockState(world, torch, 9, 3, 9, sbb);
    //        meta = getMetadataWithOffset(torch, 3);
    torch = torch.withProperty(facing, EnumFacing.EAST);
    setBlockState(world, torch, 5, 3, 1, sbb);
    setBlockState(world, torch, 5, 3, 5, sbb);
    setBlockState(world, torch, 5, 3, 9, sbb);
    // hut walls
    fillWithBlocks(world, sbb, 0, 0, 1, 0, 3, 5, blockBrick, blockBrick, false);
    fillWithBlocks(world, sbb, 1, 0, 1, 3, 3, 1, blockBrick, blockBrick, false);
    fillWithBlocks(world, sbb, 1, 0, 5, 3, 3, 5, blockBrick, blockBrick, false);
    // hut roof
    fillWithRandomizedBlocks(world, sbb, 1, 4, 2, 4, 4, 4, false, random, roofSelector);
    fillWithBlocks(world, sbb, 0, 4, 1, 0, 4, 5, roofEast, roofEast, false);
    fillWithBlocks(world, sbb, 1, 4, 1, 3, 4, 1, roofNorth, roofNorth, false);
    fillWithBlocks(world, sbb, 1, 4, 5, 3, 4, 5, roofSouth, roofSouth, false);
    // hut door
    fillWithAir(world, sbb, 4, 1, 3, 4, 2, 3);
    fillWithAir(world, sbb, 4, 1, 3, 4, 2, 3);
    setBlockState(world, Blocks.DOUBLE_STONE_SLAB.getDefaultState(), 4, 0, 3, sbb);
    func_189927_a(world, boundingBox, random, 4, 1, 3, EnumFacing.NORTH);
    // hut windows
    fillWithBlocks(world, sbb, 2, 2, 1, 2, 2, 1, glassPane, glassPane, false);
    fillWithBlocks(world, sbb, 2, 2, 5, 2, 2, 5, glassPane, glassPane, false);
    fillWithBlocks(world, sbb, 0, 2, 3, 0, 2, 3, glassPane, glassPane, false);
    // hut torches
    //        meta = getMetadataWithOffset(torch, 1);
    torch = torch.withProperty(facing, EnumFacing.NORTH);
    setBlockState(world, torch, 2, 3, 2, sbb);
    //        meta = getMetadataWithOffset(torch, 2);
    torch = torch.withProperty(facing, EnumFacing.SOUTH);
    setBlockState(world, torch, 2, 3, 4, sbb);
    // machines
    if (EquipmentVariant.ROLLING_MACHINE_MANUAL.isAvailable()) {
        //noinspection ConstantConditions
        setBlockState(world, EquipmentVariant.ROLLING_MACHINE_MANUAL.getDefaultState(), 9, 1, 5, sbb);
    }
    // foundation
    for (int k = 0; k < 11; ++k) {
        for (int l = 4; l < 11; ++l) {
            clearCurrentPositionBlocksUpwards(world, l, 6, k, sbb);
            replaceAirAndLiquidDownwards(world, Blocks.COBBLESTONE.getDefaultState(), l, -1, k, sbb);
        }
    }
    for (int k = 1; k < 6; ++k) {
        for (int l = 0; l < 4; ++l) {
            clearCurrentPositionBlocksUpwards(world, l, 6, k, sbb);
            replaceAirAndLiquidDownwards(world, Blocks.COBBLESTONE.getDefaultState(), l, -1, k, sbb);
        }
    }
    generateChest(world, sbb, random, 1, 1, 3, LootPlugin.CHESTS_VILLAGE_WORKSHOP);
    //        generateChest(world, sbb, random, 1, 1, 6, LootTableList.CHESTS_VILLAGE_BLACKSMITH);
    //        generateChest(world, sbb, random, 1, 1, 8, LootTableList.CHESTS_ABANDONED_MINESHAFT);
    //
    //        generateChest(world, sbb, random, 1, 1, 10, LootTableList.CHESTS_STRONGHOLD_CORRIDOR);
    spawnVillagers(world, sbb, 0, 0, 0, 2);
    return true;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Random(java.util.Random) PropertyDirection(net.minecraft.block.properties.PropertyDirection)

Aggregations

PropertyDirection (net.minecraft.block.properties.PropertyDirection)3 IBlockState (net.minecraft.block.state.IBlockState)2 TileEntity (net.minecraft.tileentity.TileEntity)2 Random (java.util.Random)1 IProperty (net.minecraft.block.properties.IProperty)1 EnumFacing (net.minecraft.util.EnumFacing)1