ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/mod/util/Util.java

71 lines
3 KiB
Java
Raw Normal View History

2015-08-29 14:33:25 +02:00
/*
* This file ("Util.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
2016-01-03 16:05:51 +01:00
* http://ellpeck.de/actaddlicense/
2015-08-29 14:33:25 +02:00
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2016-01-03 16:05:51 +01:00
* © 2016 Ellpeck
2015-08-29 14:33:25 +02:00
*/
2016-01-05 04:47:35 +01:00
package de.ellpeck.actuallyadditions.mod.util;
2015-07-01 21:32:48 +02:00
import net.minecraft.block.BlockDispenser;
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
import net.minecraft.item.EnumRarity;
2015-07-01 21:32:48 +02:00
import net.minecraft.item.Item;
2016-03-18 23:47:22 +01:00
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.oredict.OreDictionary;
2015-11-22 18:52:11 +01:00
import java.util.Random;
2015-08-28 21:17:09 +02:00
@SuppressWarnings("unused")
2014-12-20 21:34:07 +01:00
public class Util{
2015-11-22 18:52:11 +01:00
public static final Random RANDOM = new Random();
public static final int WILDCARD = OreDictionary.WILDCARD_VALUE;
2016-04-20 21:39:03 +02:00
public static final EnumRarity CRYSTAL_RED_RARITY = EnumHelper.addRarity(ModUtil.MOD_ID+"crystalRed", TextFormatting.DARK_RED, ModUtil.NAME+" Red Crystal");
public static final EnumRarity CRYSTAL_BLUE_RARITY = EnumHelper.addRarity(ModUtil.MOD_ID+"crystalBlue", TextFormatting.DARK_BLUE, ModUtil.NAME+" Blue Crystal");
public static final EnumRarity CRYSTAL_LIGHT_BLUE_RARITY = EnumHelper.addRarity(ModUtil.MOD_ID+"crystalLightBlue", TextFormatting.BLUE, ModUtil.NAME+" Light Blue Crystal");
public static final EnumRarity CRYSTAL_BLACK_RARITY = EnumHelper.addRarity(ModUtil.MOD_ID+"crystalBlack", TextFormatting.DARK_GRAY, ModUtil.NAME+" Black Crystal");
public static final EnumRarity CRYSTAL_GREEN_RARITY = EnumHelper.addRarity(ModUtil.MOD_ID+"crystalGreen", TextFormatting.DARK_GREEN, ModUtil.NAME+" Green Crystal");
public static final EnumRarity CRYSTAL_WHITE_RARITY = EnumHelper.addRarity(ModUtil.MOD_ID+"crystalWhite", TextFormatting.GRAY, ModUtil.NAME+" White Crystal");
2016-04-20 21:39:03 +02:00
public static final EnumRarity FALLBACK_RARITY = EnumHelper.addRarity(ModUtil.MOD_ID+".fallback", TextFormatting.STRIKETHROUGH, ModUtil.NAME+" Fallback");
public static void registerEvent(Object o){
MinecraftForge.EVENT_BUS.register(o);
}
2015-07-01 21:32:48 +02:00
public static boolean isDevVersion(){
return ModUtil.VERSION.equals("@VERSION@");
}
2015-07-01 21:32:48 +02:00
public static void registerDispenserHandler(Item item, BehaviorDefaultDispenseItem handler){
2016-04-20 21:39:03 +02:00
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(item, handler);
2015-07-01 21:32:48 +02:00
}
2015-08-28 21:17:09 +02:00
public static int arrayContains(Object[] array, Object obj){
if(obj != null){
for(int i = 0; i < array.length; i++){
if(array[i] != null && (obj == array[i] || array[i].equals(obj))){
return i;
}
}
}
return -1;
}
public static int arrayContains(int[] array, int num){
for(int i = 0; i < array.length; i++){
if(num == array[i]){
return i;
}
}
return -1;
}
}