Skip to content

Instantly share code, notes, and snippets.

@Cazzar
Last active August 29, 2015 14:11
Show Gist options
  • Save Cazzar/5eaf2f7ead45d600c50f to your computer and use it in GitHub Desktop.
Save Cazzar/5eaf2f7ead45d600c50f to your computer and use it in GitHub Desktop.
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