BlockWithItem - Lemonszz/LKLib GitHub Wiki

The BlockWithItem interface can be added to any block you wish to have a BlockItem associated with it. BlockItems will be automatically registered when using the BlockWithItemCallback (See RegistryHelper for more information)

Methods

Usually there is no extra work involved when using BlockWithItem as each method has a default implementation. You can override these if you need to have more control.

Generally you will not need to call any of these methods yourself. If you are not using the BlockWithItemCallback callback, you will need to call registerItem to register the item.

hasItem

By default this simply returns true. You can override this to return false if you do not wish for the BlockItem to be created. This may be useful if you have a child class of a block that does need an item, but this block doesn't.

makeItemSettings

This is where the Item.Settings is created for the BlockItem. By default this simply makes a Item.Settings instance with the given ItemGroup. You may wish to override this if you need to modify the Item's settings, such as stack size.

makeItem

This creates the BlockItem instance. It will call makeItemSettings to create the Item's settings. You may wish to override this if your block needs a custom Item class.

registerItem

This will call makeItem (which calls makeItemSettings) and register the item.

Convenience Classes

LKLib provides a large variety of convenience implementations of BlockWithItem. These are generally children of vanilla blocks with specific behavior.

  • LKBlock extends Block
  • LKButtonBlock extends WoodenButtonBlock
  • LKDoorBlock extends DoorBlock
  • LKFenceBlock extends FenceBlock
  • LKFenceGateBlock extends FenceGateBlock
  • LKLeavesBlock extends MushroomBlock
  • LKMushroomBlock extends Block
  • LKMushroomPlantBlock extends MushroomPlantBlock
  • LKPillarBlock extends PillarBlock
  • LKPressurePlateBlock extends PressurePlateBlock
  • LKSaplingBlock extends SaplingBlock
  • LKStairBlock extends StairsBlock
  • LKTallFlowerBlock extends TallFlowerBlock
  • LKTrapdoorBlock extends TrapdoorBlock