2015-08-29 14:33:25 +02:00
|
|
|
|
/*
|
|
|
|
|
* This file ("BlockUtil.java") is part of the Actually Additions Mod for Minecraft.
|
|
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
|
* under the Actually Additions License to be found at
|
|
|
|
|
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
|
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
|
*
|
|
|
|
|
* <EFBFBD> 2015 Ellpeck
|
|
|
|
|
*/
|
|
|
|
|
|
2015-03-29 15:29:05 +02:00
|
|
|
|
package ellpeck.actuallyadditions.util;
|
|
|
|
|
|
|
|
|
|
import cpw.mods.fml.common.registry.GameRegistry;
|
|
|
|
|
import ellpeck.actuallyadditions.creative.CreativeTab;
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
|
import net.minecraft.item.ItemBlock;
|
2015-04-04 05:20:19 +02:00
|
|
|
|
|
2015-03-29 15:29:05 +02:00
|
|
|
|
public class BlockUtil{
|
|
|
|
|
|
2015-10-03 10:19:40 +02:00
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
public static void register(Block block){
|
|
|
|
|
register(block, true);
|
2015-04-04 05:20:19 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-12 21:26:51 +02:00
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
public static void register(Block block, boolean addTab){
|
2015-06-28 21:28:58 +02:00
|
|
|
|
block.setCreativeTab(addTab ? CreativeTab.instance : null);
|
2015-04-04 05:20:19 +02:00
|
|
|
|
block.setBlockName(createUnlocalizedName(block));
|
2015-09-12 21:26:51 +02:00
|
|
|
|
|
|
|
|
|
for(Class sub : block.getClass().getDeclaredClasses()){
|
|
|
|
|
if(sub.getSuperclass() == ItemBlock.class){
|
2015-10-01 23:20:31 +02:00
|
|
|
|
GameRegistry.registerBlock(block, sub, ((IActAddItemOrBlock)block).getName());
|
2015-09-12 21:26:51 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-03-29 15:29:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-03 10:19:40 +02:00
|
|
|
|
public static String createUnlocalizedName(Block block){
|
|
|
|
|
return ModUtil.MOD_ID_LOWER+"."+((IActAddItemOrBlock)block).getName();
|
2015-05-20 22:39:43 +02:00
|
|
|
|
}
|
2015-03-29 15:29:05 +02:00
|
|
|
|
}
|