{"body":"package me.rushmead.stagecraft.blocks;\n\nimport me.rushmead.stagecraft.util.Names;\nimport net.minecraft.block.properties.IProperty;\nimport net.minecraft.block.properties.PropertyDirection;\nimport net.minecraft.block.state.BlockState;\nimport net.minecraft.block.state.IBlockState;\nimport net.minecraft.entity.EntityLivingBase;\nimport net.minecraft.util.AxisAlignedBB;\nimport net.minecraft.util.BlockPos;\nimport net.minecraft.util.EnumFacing;\nimport net.minecraft.world.IBlockAccess;\nimport net.minecraft.world.World;\nimport net.minecraftforge.fml.relauncher.Side;\nimport net.minecraftforge.fml.relauncher.SideOnly;\n\n/**\n * Created by Rushmead for StageCraft 1.8\n */\npublic class StageFlat extends StageCraftBlock {\n    public static final PropertyDirection FACING = PropertyDirection.create(\"facing\", EnumFacing.Plane.HORIZONTAL);\n\n    public StageFlat() {\n        this.setUnlocalizedName(Names.Blocks.StageFlat);\n        this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));\n        this.setBlockBounds(0F, 0F, 0F, 1F, 1F, 0.3F);\n    }\n\n    @Override\n    public boolean isOpaqueCube() {\n        return false;\n    }\n\n    @SideOnly(Side.CLIENT)\n    public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos) {\n        this.setBlockBoundsBasedOnState(worldIn, pos);\n        return super.getSelectedBoundingBox(worldIn, pos);\n    }\n\n    @Override\n    public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state) {\n        this.setBlockBoundsBasedOnState(worldIn, pos);\n        return super.getCollisionBoundingBox(worldIn, pos, state);\n    }\n\n    public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos) {\n        this.setBounds(worldIn.getBlockState(pos));\n    }\n\n    /**\n     * Sets the block's bounds for rendering it as an item\n     */\n    public void setBlockBoundsForItemRender() {\n        float f = 0.1875F;\n        this.setBlockBounds(0.0F, 0.40625F, 0.0F, 1.0F, 0.59375F, 1.0F);\n    }\n\n    public void setBounds(IBlockState state) {\n        if (state.getBlock() == this) {\n            EnumFacing enumfacing = (EnumFacing) state.getValue(FACING);\n            if (enumfacing == EnumFacing.NORTH) {\n                this.setBlockBounds(0.0F, 0.0F, 0.8125F, 1.0F, 1.0F, 1.0F);\n            }\n            if (enumfacing == EnumFacing.SOUTH) {\n                this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.1875F);\n            }\n            if (enumfacing == EnumFacing.WEST) {\n                this.setBlockBounds(0.8125F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);\n            }\n            if (enumfacing == EnumFacing.EAST) {\n                this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.1875F, 1.0F, 1.0F);\n            }\n        }\n    }\n\n    @Override\n    public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {\n        IBlockState iblockstate = this.getDefaultState();\n\n\n        iblockstate = iblockstate.withProperty(FACING, facing);\n\n\n        return iblockstate;\n    }\n\n    protected static EnumFacing getFacing(int meta) {\n        switch (meta & 3) {\n            case 0:\n                return EnumFacing.NORTH;\n            case 1:\n                return EnumFacing.SOUTH;\n            case 2:\n                return EnumFacing.WEST;\n            case 3:\n            default:\n                return EnumFacing.EAST;\n        }\n    }\n\n    protected static int getMetaForFacing(EnumFacing facing) {\n        switch (facing) {\n            case NORTH:\n                return 0;\n            case SOUTH:\n                return 1;\n            case WEST:\n                return 2;\n            case EAST:\n            default:\n                return 3;\n        }\n    }\n\n    @Override\n    public IBlockState getStateFromMeta(int meta) {\n        return this.getDefaultState().withProperty(FACING, getFacing(meta));\n    }\n\n    @Override\n    public int getMetaFromState(IBlockState state) {\n        int i = 0;\n        i = i | getMetaForFacing((EnumFacing) state.getValue(FACING));\n        return i;\n    }\n\n    @Override\n    protected BlockState createBlockState() {\n        return new BlockState(this, new IProperty[]{FACING});\n    }\n}\n","name":"Code","extension":"txt","url":"https://www.irccloud.com/pastebin/FCIIwXVi/Code","modified":1451300750,"id":"FCIIwXVi","size":4210,"lines":131,"own_paste":false,"theme":"","date":1451300750}