Skip to content

Instantly share code, notes, and snippets.

@Caellian
Created September 27, 2015 11:32
Show Gist options
  • Save Caellian/0abcddc977ac30ccafb3 to your computer and use it in GitHub Desktop.
Save Caellian/0abcddc977ac30ccafb3 to your computer and use it in GitHub Desktop.
package com.caellian.codeBlocks.block;
import com.caellian.codeBlocks.lib.Constants;
import com.caellian.codeBlocks.lib.Reference;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.fml.common.registry.GameRegistry;
import java.util.HashMap;
/**
* @author Caellian
*/
public class BlockManager
{
private static HashMap<String, Block> modBlocks = new HashMap<>(0);
public static void populateBlockMap(){
modBlocks.put(Constants.CODE_BLOCK,new CodeBlock());
}
public static void registerBlocks()
{
modBlocks.entrySet().forEach(it->GameRegistry.registerBlock(it.getValue(), it.getKey()));
}
public static void bindItemModels()
{
if (!modBlocks.isEmpty())
{
modBlocks.entrySet().forEach(it->Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(it.getValue()), it.getValue().getMetaFromState(it.getValue().getDefaultState()), new ModelResourceLocation(Reference.RESOURCE_LOCATION + it.getKey(), "inventory")));
}
}
public static Block getBlock(String blockID)
{
return modBlocks.get(blockID);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment