Last active
August 29, 2015 14:11
-
-
Save Cazzar/5eaf2f7ead45d600c50f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.common.base.Predicate | |
import net.minecraft.block.Block | |
import net.minecraft.block.material.Material | |
import net.minecraft.block.properties.PropertyDirection | |
import net.minecraft.block.state.{BlockState, IBlockState} | |
import net.minecraft.util.EnumFacing | |
object BlockExample extends { | |
val FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL.asInstanceOf[Predicate[EnumFacing]]) | |
} with Block(Material.wood) { | |
protected override def createBlockState: BlockState = new BlockState(this, FACING) | |
override def getStateFromMeta(meta: Int): IBlockState = { | |
var facing = EnumFacing.getFront(meta) | |
if (facing.getAxis eq EnumFacing.Axis.Y) facing = EnumFacing.NORTH | |
this.getDefaultState.withProperty(FACING, facing) | |
} | |
override def getMetaFromState(state: IBlockState): Int = state.getValue(FACING).asInstanceOf[EnumFacing].getIndex | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment