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
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.util.StatCollector;
|
|
|
|
import net.minecraftforge.oredict.OreDictionary;
|
|
|
|
|
|
|
|
import java.util.List;
|
2015-03-29 15:29:05 +02:00
|
|
|
|
|
|
|
public class BlockUtil{
|
|
|
|
|
|
|
|
public static String createUnlocalizedName(Block block){
|
2015-04-04 05:20:19 +02:00
|
|
|
return ModUtil.MOD_ID_LOWER + "." + ((INameableItem)block).getName();
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
2015-05-04 17:26:50 +02:00
|
|
|
public static void addInformation(Block block, List list, int lines, String extraName){
|
2015-04-04 05:20:19 +02:00
|
|
|
if(KeyUtil.isShiftPressed()){
|
2015-04-06 15:51:59 +02:00
|
|
|
for(int i = 0; i < lines; i++){
|
|
|
|
list.add(StatCollector.translateToLocal("tooltip." + ModUtil.MOD_ID_LOWER + "." + ((INameableItem)block).getName() + extraName + ".desc" + (lines > 1 ? "." +(i+1) : "")));
|
|
|
|
}
|
2015-04-04 05:20:19 +02:00
|
|
|
}
|
|
|
|
else list.add(ItemUtil.shiftForInfo());
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void register(Block block, Class<? extends ItemBlock> itemBlock, Enum[] list){
|
|
|
|
block.setCreativeTab(CreativeTab.instance);
|
|
|
|
block.setBlockName(createUnlocalizedName(block));
|
|
|
|
GameRegistry.registerBlock(block, itemBlock, ((INameableItem)block).getName());
|
|
|
|
for(Enum current : list){
|
2015-04-28 20:54:23 +02:00
|
|
|
if(!((INameableItem)current).getOredictName().isEmpty()) OreDictionary.registerOre(((INameableItem)current).getOredictName(), new ItemStack(block, 1, current.ordinal()));
|
2015-04-04 05:20:19 +02:00
|
|
|
}
|
2015-03-29 15:29:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void register(Block block, Class<? extends ItemBlock> itemBlock){
|
|
|
|
block.setCreativeTab(CreativeTab.instance);
|
|
|
|
block.setBlockName(createUnlocalizedName(block));
|
2015-04-04 05:20:19 +02:00
|
|
|
GameRegistry.registerBlock(block, itemBlock, ((INameableItem)block).getName());
|
2015-05-04 17:26:50 +02:00
|
|
|
if(!((INameableItem)block).getOredictName().isEmpty()) OreDictionary.registerOre(((INameableItem)block).getOredictName(), new ItemStack(block, 1, Util.WILDCARD));
|
2015-03-29 15:29:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|