Guest User

Untitled

a guest
Feb 2nd, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.55 KB | None | 0 0
  1. package net.chaos.rfchaos.common.blocks;
  2.  
  3. import net.chaos.rfchaos.RefinedChaosMod;
  4. import net.chaos.rfchaos.common.CommonProxy;
  5. import net.chaos.rfchaos.common.ModFinals;
  6. import net.chaos.rfchaos.util.EnumSize;
  7. import net.chaos.rfchaos.util.EnumWeight;
  8. import net.minecraft.block.Block;
  9. import net.minecraft.block.BlockGrass;
  10. import net.minecraft.block.SoundType;
  11. import net.minecraft.block.material.Material;
  12. import net.minecraft.block.properties.IProperty;
  13. import net.minecraft.block.properties.PropertyBool;
  14. import net.minecraft.block.state.BlockStateContainer;
  15. import net.minecraft.block.state.IBlockState;
  16. import net.minecraft.client.renderer.block.model.ModelResourceLocation;
  17. import net.minecraft.init.Blocks;
  18. import net.minecraft.item.Item;
  19. import net.minecraft.util.BlockRenderLayer;
  20. import net.minecraft.util.math.BlockPos;
  21. import net.minecraft.world.IBlockAccess;
  22. import net.minecraftforge.client.model.ModelLoader;
  23. import net.minecraftforge.fml.relauncher.Side;
  24. import net.minecraftforge.fml.relauncher.SideOnly;
  25.  
  26. public class BlockTerraGrass extends BlockGrass {
  27.  
  28.     public static final PropertyBool SNOWY = PropertyBool.create("snowy");
  29.  
  30.     public BlockTerraGrass(String registryReplacement, String name) {
  31.         super();
  32.         this.setUnlocalizedName(ModFinals.MODID + "." + name);
  33.         this.setRegistryName(registryReplacement);
  34.         this.setCreativeTab(RefinedChaosMod.TAB);
  35.         this.setSoundType(SoundType.PLANT);
  36.     }
  37.  
  38.     @SideOnly(Side.CLIENT)
  39.     public void registerModel() {
  40.         ModelLoader.setCustomStateMapper(this, RefinedChaosMod.proxy.mapper);
  41.         ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), 0, new ModelResourceLocation(ModFinals.MODID + ":rf_grass", "inventory"));
  42.     }
  43.  
  44.     /**
  45.      * Get the actual Block state of this Block at the given position. This applies properties not visible in the
  46.      * metadata, such as fence connections.
  47.      */
  48.     @Override
  49.     public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
  50.     {
  51.         Block block = worldIn.getBlockState(pos.up()).getBlock();
  52.         return state.withProperty(SNOWY, Boolean.valueOf(block == Blocks.SNOW || block == Blocks.SNOW_LAYER));
  53.     }
  54.  
  55.     /**
  56.      * Convert the BlockState into the correct metadata value
  57.      * */
  58.     @Override
  59.     public int getMetaFromState(IBlockState state)
  60.     {
  61.         return 0;
  62.     }
  63.  
  64.     @Override
  65.     protected BlockStateContainer createBlockState()
  66.     {
  67.         return new BlockStateContainer(this, new IProperty[] {SNOWY});
  68.     }
  69.  
  70.     @Override
  71.     @SideOnly(Side.CLIENT)
  72.     public BlockRenderLayer getBlockLayer()
  73.     {
  74.         return BlockRenderLayer.CUTOUT_MIPPED;
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment