Guest User

Chest Block

a guest
Jun 3rd, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.40 KB | None | 0 0
  1. package com.monsterhunter.block;
  2.  
  3. import com.monsterhunter.MonsterHunter;
  4. import com.monsterhunter.tileentity.MaterialChestTileEntity;
  5.  
  6. import net.minecraft.block.BlockBed.EnumPartType;
  7. import net.minecraft.block.BlockContainer;
  8. import net.minecraft.block.SoundType;
  9. import net.minecraft.block.material.Material;
  10. import net.minecraft.block.properties.PropertyDirection;
  11. import net.minecraft.block.state.BlockStateContainer;
  12. import net.minecraft.block.state.IBlockState;
  13. import net.minecraft.creativetab.CreativeTabs;
  14. import net.minecraft.inventory.InventoryHelper;
  15. import net.minecraft.tileentity.TileEntity;
  16. import net.minecraft.util.EnumBlockRenderType;
  17. import net.minecraft.util.EnumFacing;
  18. import net.minecraft.util.math.BlockPos;
  19. import net.minecraft.world.World;
  20.  
  21. public class MaterialChestBlock extends BlockContainer {
  22.  
  23.     public static final String unlocalizedName = "materialChest";
  24.     public static final Material material = Material.wood;
  25.  
  26.     public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
  27.  
  28.     public MaterialChestBlock() {
  29.         super(material);
  30.  
  31.         this.setRegistryName(MonsterHunter.MODID, unlocalizedName);
  32.         this.setCreativeTab(CreativeTabs.tabBlock);
  33.         this.setHardness(2.0F);
  34.         this.setResistance(10.0F);
  35.         this.setHarvestLevel("axe", 1);
  36.         this.setStepSound(SoundType.WOOD);
  37.     }
  38.  
  39.     @Override
  40.     public void breakBlock(World world, BlockPos pos, IBlockState blockstate) {
  41.         MaterialChestTileEntity te = (MaterialChestTileEntity) world.getTileEntity(pos);
  42.         InventoryHelper.dropInventoryItems(world,  pos, te);
  43.  
  44.         super.breakBlock(world, pos, blockstate);
  45.     }
  46.  
  47.     @Override
  48.     public EnumBlockRenderType getRenderType(IBlockState state) {
  49.         return EnumBlockRenderType.ENTITYBLOCK_ANIMATED;
  50.     }
  51.  
  52.     @Override
  53.     public boolean isOpaqueCube(IBlockState state) {
  54.         return false;
  55.     }
  56.  
  57.     @Override
  58.     public TileEntity createNewTileEntity(World worldIn, int meta) {
  59.         return new MaterialChestTileEntity();
  60.     }
  61.  
  62.     @Override
  63.     public int getMetaFromState(IBlockState state) {
  64.         return ((EnumFacing)state.getValue(FACING)).getHorizontalIndex();
  65.     }
  66.  
  67.     @Override
  68.     public IBlockState getStateFromMeta(int meta) {
  69.         EnumFacing enumfacing = EnumFacing.getHorizontal(meta);
  70.         return this.getDefaultState().withProperty(FACING, enumfacing);
  71.     }
  72.  
  73.     protected BlockStateContainer createBlockState() {
  74.         return new BlockStateContainer(this, FACING);
  75.     }
  76.  
  77. }
Add Comment
Please, Sign In to add comment