Skip to content
AleXndrTheGr8st edited this page Dec 14, 2014 · 2 revisions

Using SimpleBlock

Creates a basic block, such as an ore or a storage block.

Usage:

yourBlock = new SimpleBlock(Material material);

Customising Methods:

You can customise your block using the below methods. In most cases, they will be appended to your initialization code (above, see the example below).

  • modId(String modId):

Sets the modId for the block. This is very important, if you don't specify it, textures won't be located for your block, among other things. You should normally set it before any other methods.

yourBlock = new SimpleBlock(Material.iron).modId("yourModId");
  • isOre():

Sets the block as an ore. This is important for the ContentRegistry, which allows plugins to get content by type, such as "ore", "machine".

yourBlock = new SimpleBlock(Material.iron).modId("yourModId").isOre(); 
  • setBeaconBase(boolean isBeaconBase):

Sets the block as a valid beacon base block.

yourBlock = new SimpleBlock(Material.iron).modId("yourModId").setBeaconBase(true);
  • setBlockName(String blockName):

Sets the code name of the block. Not the name that shows in-game. Also registers the block with both GameRegistry and ContentRegistry.

yourBlock = new SimpleBlock(Material.iron).modId("yourModId").setBlockName("your_block");
  • setHarvestLvl(String toolClass, int harvestLevel):

Sets the harvest level of the block, and which tool is most effective against it.

yourBlock = new SimpleBlock(Material.iron).modId("yourModId").setHarvestLvl("pickaxe", 3);
  • _ setStackToDrop(ItemStack stackToDrop):_

Sets what itemstack will be dropped when the block is broken. Only set if the block should drop something other than itself.

yourBlock = new SimpleBlock(Material.iron).modId("yourModId").setStackToDrop(new ItemStack(yourItem));
  • setTab(CreativeTabs creativetab):

Sets which creative tab the block will appear in.

yourBlock = new SimpleBlock(Material.iron).modId("yourModId").setTab(CreativeTabs.tabDecorations);
  • List getBlockListFromModId(String modId):

Gets a list of all the SimpleBlock's with the specified modId.

List<SimpleBlock> blocks = SimpleBlock.getBlockListFromModId("yourModId");
for(SimpleBlock b : blocks) {
	//do something with the blocks
}

Example:

yourBlock = new SimpleBlock(Material.iron).modId("yourModId").setBeaconBase(true).setStackToDrop(new ItemStack(yourItem)).setTab(CreativeTabs.tabDecorations).setBlockName("your_block");

Clone this wiki locally