Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class BlockWooden(uName: String, mat: Material = Material.wood, hardness: Float = 2.0f, resistance: Float = 2.0f) extends {
- final val FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL)
- final val TYPE = PropertyEnum.create("type", classOf[EnumProperty.EnumWoodenType])
- } with BaseBlock(uName, mat, hardness, resistance) with traits.WithTE {
- setDefaultState(this.getBlockState.getBaseState.withProperty(TYPE, EnumProperty.EnumWoodenType.SHELVE).withProperty(FACING, EnumFacing.NORTH))
- override def getSpecialName(stack: ItemStack): String = stack.getItemDamage match {
- case 0 => "shelve"
- case _ => "unforeseen"
- }
- override def createBlockState(): BlockState = new BlockState(this, TYPE, FACING)
- override def isOpaqueCube() = false
- override def isFullCube() = false
- override def getStateFromMeta(meta: Int): IBlockState = {
- getDefaultState().withProperty(TYPE, meta match {
- case 0 => EnumProperty.EnumWoodenType.SHELVE
- })
- }
- override def getMetaFromState(state: IBlockState): Int = state.getValue(TYPE).asInstanceOf[EnumProperty.EnumWoodenType].getID
- override def damageDropped(state: IBlockState): Int = getMetaFromState(state)
- override def onBlockActivated(world: World, pos: BlockPos, state: IBlockState, player: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float) = {
- getMetaFromState(state) match {
- case 0 => false
- case _ => false
- }
- }
- override def onBlockPlaced(world: World, pos: BlockPos, facing: EnumFacing, hitX: Float, hitY: Float, hitZ: Float, meta: Int, placer: EntityLivingBase) = {
- this.getDefaultState.withProperty(FACING, placer.getHorizontalFacing.getOpposite)
- }
- override def getComparatorInputOverride(world: World, pos: BlockPos) = net.minecraft.inventory.Container.calcRedstone(world.getTileEntity(pos))
- @SideOnly(Side.CLIENT)
- override def getSubBlocks(item: Item, tab: CreativeTabs, list: java.util.List[ItemStack]) {
- list.add(new ItemStack(item, 1, 0))
- }
- override def createNewTileEntity(worldIn: World, meta: Int): TileEntity = meta match {
- case 0 => new TileShelve()
- case _ => null
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement