Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package degubi.teamcraft.things.blocks;
- import net.minecraft.block.Block;
- import net.minecraft.block.BlockDirectional;
- import net.minecraft.block.material.Material;
- import net.minecraft.block.properties.IProperty;
- import net.minecraft.block.state.BlockState;
- import net.minecraft.block.state.IBlockState;
- import net.minecraft.init.Blocks;
- import net.minecraft.util.AxisAlignedBB;
- import net.minecraft.util.BlockPos;
- import net.minecraft.util.EnumFacing;
- import net.minecraft.util.EnumWorldBlockLayer;
- import net.minecraft.world.IBlockAccess;
- import net.minecraft.world.World;
- import net.minecraftforge.fml.relauncher.Side;
- import net.minecraftforge.fml.relauncher.SideOnly;
- import degubi.teamcraft.TeamCraft;
- public class BlockHalfBlocks extends BlockDirectional{
- private int number;
- public BlockHalfBlocks(int count, Block infBlock) {
- super(Material.wood);
- setDefaultState(blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
- number = count;
- setStepSound(infBlock.stepSound);
- setHardness(infBlock.blockHardness);
- setResistance(infBlock.blockResistance);
- setCreativeTab(TeamCraft.tcmtabBlocks);
- setUnlocalizedName("HalfBlock" + number);
- if(infBlock == Blocks.ice || infBlock == Blocks.packed_ice){
- slipperiness = 0.98F;
- }
- }
- @SideOnly(Side.CLIENT)
- public EnumWorldBlockLayer getBlockLayer() {
- return number > 15 && number < 33 || number == 39 ? EnumWorldBlockLayer.TRANSLUCENT : EnumWorldBlockLayer.CUTOUT;
- }
- public IBlockState getStateFromMeta(int meta)
- {
- EnumFacing enumfacing = EnumFacing.getFront(meta);
- if (enumfacing.getAxis() == EnumFacing.Axis.Y)
- {
- enumfacing = EnumFacing.NORTH;
- }
- return this.getDefaultState().withProperty(FACING, enumfacing);
- }
- public int getMetaFromState(IBlockState state)
- {
- return ((EnumFacing)state.getValue(FACING)).getIndex();
- }
- protected BlockState createBlockState()
- {
- return new BlockState(this, new IProperty[] {FACING});
- }
- public boolean isOpaqueCube(){return false;}
- public void setBlockBoundsForItemRender() {
- setBlockBounds(0.0F, 0.0F, 0.25F, 1.0F, 1.0F, 0.75F);
- }
- public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
- {
- this.setBlockBoundsBasedOnState(worldIn, pos);
- return super.getCollisionBoundingBox(worldIn, pos, state);
- }
- public void setBlockBoundsBasedOnState(IBlockAccess acc, BlockPos pos)
- {
- IBlockState iblockstate = acc.getBlockState(pos);
- int meta = acc.getBlockState(pos).getBlock().getMetaFromState(iblockstate);
- if(meta == 3){
- setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.5F);
- }else if(meta == 5){
- setBlockBounds(0.0F, 0.0F, 0.0F, 0.5F, 1.0F, 1.0F);
- }else if(meta == 4){
- setBlockBounds(0.5F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
- }else{
- setBlockBounds(0.0F, 0.0F, 0.5F, 1.0F, 1.0F, 1.0F);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement