Jump to content

Registering ItemBlock not working


cmchenry

Recommended Posts

I'm trying to register an ItemBlock for my custom block. It's just not appearing in the creative tab for whatever reason or from what I can tell in the game at all. All other items register fine, just not the ItemBlock. PS: I'm coding in Scala

 

@SubscribeEvent
def registerItems(e: RegistryEvent.Register[Item]): Unit = {
  e.getRegistry.registerAll(ItemHempBud, ItemHempSeed, ItemHempBioManipulator)
}

 

object BlockHempBioManipulator extends BlockContainer(Material.IRON) {

  var PROP_TOP: IProperty[java.lang.Integer] = _

  setRegistryName(DrugMod.modid, "hemp_bio_manipulator")
  setUnlocalizedName(DrugMod.modid + ":hemp_bio_manipulator")
  setDefaultState(this.blockState.getBaseState.withProperty(PROP_TOP, 0: java.lang.Integer))

  override def createNewTileEntity(worldIn: World, meta: Int): TileEntity = new TileEntityHempBioManipulator

  override def getRenderType(state: IBlockState): EnumBlockRenderType = EnumBlockRenderType.MODEL

  override def getStateFromMeta(meta: Int): IBlockState = getDefaultState.withProperty(PROP_TOP, meta: java.lang.Integer)

  override def getMetaFromState(state: IBlockState): Int = state.getValue(PROP_TOP)

  override def createBlockState(): BlockStateContainer = {
    PROP_TOP = PropertyInteger.create("top", 0, 1)
    new BlockStateContainer(this, PROP_TOP)
  }

  override def onBlockActivated(worldIn: World, pos: BlockPos, state: IBlockState, playerIn: EntityPlayer, hand: EnumHand, facing: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): Boolean = {
    if (!worldIn.isRemote) playerIn.openGui(DrugMod, GuiHandler.GUI_HEMP_BIO_MANIPULATOR, worldIn, pos.getX, pos.getY, pos.getZ)
    super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ)
  }

}

object HempBioManipulatorStateMapper extends StateMapperBase {
  override def getModelResourceLocation(state: IBlockState): ModelResourceLocation = new ModelResourceLocation(state.getBlock.getRegistryName, "top=" + state.getValue(BlockHempBioManipulator.PROP_TOP))
}

object ItemHempBioManipulator extends ItemBlock(BlockHempBioManipulator) {
  setRegistryName(DrugMod.modid, "hemp_bio_manipulator")
  setUnlocalizedName(DrugMod.modid + ":hemp_bio_manipulator")
  setCreativeTab(CreativeTabs.BREWING)
}

 

EDIT: So it is registering, just not in the creative tabs at all.

Edited by cmchenry
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.