Advertisement
Rinart73

Untitled

Jul 30th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.69 KB | None | 0 0
  1. package rinart73.samplemod.blocks;
  2.  
  3. import net.minecraft.block.Block;
  4. import net.minecraft.block.material.Material;
  5. import net.minecraft.block.properties.IProperty;
  6. import net.minecraft.block.properties.PropertyBool;
  7. import net.minecraft.block.state.BlockStateContainer;
  8. import net.minecraft.block.state.IBlockState;
  9. import net.minecraft.creativetab.CreativeTabs;
  10. import net.minecraft.util.math.BlockPos;
  11. import net.minecraft.world.IBlockAccess;
  12. import net.minecraft.world.World;
  13.  
  14. public class AerialBlock extends Block {
  15.  
  16.     public static final PropertyBool SKY = PropertyBool.create("sky");
  17.  
  18.     public AerialBlock(String registryName, float hardness, float resistance) {
  19.         super(Material.CLAY);
  20.         this.setRegistryName(registryName);
  21.         this.setUnlocalizedName(registryName);
  22.  
  23.         this.blockHardness = hardness;
  24.         this.blockResistance = resistance;
  25.         this.setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
  26.  
  27.         this.setDefaultState(this.blockState.getBaseState().withProperty(SKY, Boolean.valueOf(false)));
  28.     }
  29.  
  30.     @Override
  31.     public IBlockState getStateFromMeta(int meta) {
  32.         return this.getDefaultState();
  33.     }
  34.  
  35.     @Override
  36.     public int getMetaFromState(IBlockState state) {
  37.         return 0;
  38.     }
  39.  
  40.     @Override
  41.     protected BlockStateContainer createBlockState() {
  42.         return new BlockStateContainer(this, new IProperty[]{ SKY });
  43.     }
  44.  
  45.  
  46.     @Override
  47.     public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
  48.         boolean seesSky = ((World) worldIn).canBlockSeeSky(pos.up());
  49.         state = state.withProperty(SKY, Boolean.valueOf(seesSky));
  50.         return state;
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement