/******************************************************************************* * AbyssalCraft * Copyright (c) 2012 - 2017 Shinoow. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v3 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl-3.0.txt * * Contributors: * Shinoow - implementation ******************************************************************************/ package com.shinoow.abyssalcraft.common.blocks; import java.util.Random; import net.minecraft.block.BlockLog; import net.minecraft.block.material.MapColor; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.item.Item; import com.shinoow.abyssalcraft.lib.ACTabs; public class BlockACLog extends BlockLog { private MapColor mapColor; public BlockACLog(MapColor mapColor) { setDefaultState(blockState.getBaseState().withProperty(LOG_AXIS, BlockLog.EnumAxis.Y)); setCreativeTab(ACTabs.tabBlock); this.mapColor = mapColor; } @Override public MapColor getMapColor(IBlockState state) { return mapColor; } @Override public int quantityDropped(Random par1Random) { return 1; } @Override public Item getItemDropped(IBlockState state, Random par2Random, int par3) { return Item.getItemFromBlock(this); } @Override public IBlockState getStateFromMeta(int meta) { IBlockState iblockstate = getDefaultState(); switch (meta & 12) { case 0: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y); break; case 4: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X); break; case 8: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z); break; default: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE); } return iblockstate; } @Override @SuppressWarnings("incomplete-switch") public int getMetaFromState(IBlockState state) { int i = 0; switch (state.getValue(LOG_AXIS)) { case X: i |= 4; break; case Z: i |= 8; break; case NONE: i |= 12; } return i; } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer.Builder(this).add(LOG_AXIS).build(); } }