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 ;
2014-11-10 16:47:04 +01:00
2016-01-05 04:47:35 +01:00
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI ;
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe ;
import de.ellpeck.actuallyadditions.api.recipe.LensNoneRecipe ;
2015-07-01 21:32:48 +02:00
import net.minecraft.block.BlockDispenser ;
import net.minecraft.dispenser.BehaviorDefaultDispenseItem ;
2015-12-03 20:15:07 +01:00
import net.minecraft.item.EnumRarity ;
2015-07-01 21:32:48 +02:00
import net.minecraft.item.Item ;
2015-08-28 21:17:09 +02:00
import net.minecraft.item.crafting.CraftingManager ;
import net.minecraft.item.crafting.IRecipe ;
2015-12-03 20:15:07 +01:00
import net.minecraft.util.EnumChatFormatting ;
2015-03-07 02:23:31 +01:00
import net.minecraftforge.common.MinecraftForge ;
2015-12-03 20:15:07 +01:00
import net.minecraftforge.common.util.EnumHelper ;
2015-02-09 17:25:05 +01:00
import net.minecraftforge.oredict.OreDictionary ;
2014-11-10 16:47:04 +01:00
2015-08-28 21:17:09 +02:00
import java.util.List ;
2015-11-22 18:52:11 +01:00
import java.util.Random ;
2015-08-28 21:17:09 +02:00
2015-02-17 16:15:16 +01:00
@SuppressWarnings ( " unused " )
2014-12-20 21:34:07 +01:00
public class Util {
2014-11-10 16:47:04 +01:00
2015-11-22 18:52:11 +01:00
public static final Random RANDOM = new Random ( ) ;
2015-02-09 17:25:05 +01:00
public static final int WILDCARD = OreDictionary . WILDCARD_VALUE ;
2016-01-01 23:54:36 +01:00
public static final EnumRarity CRYSTAL_RED_RARITY = EnumHelper . addRarity ( ModUtil . MOD_ID_LOWER + " crystalRed " , EnumChatFormatting . DARK_RED , ModUtil . NAME + " Red Crystal " ) ;
public static final EnumRarity CRYSTAL_BLUE_RARITY = EnumHelper . addRarity ( ModUtil . MOD_ID_LOWER + " crystalBlue " , EnumChatFormatting . DARK_BLUE , ModUtil . NAME + " Blue Crystal " ) ;
public static final EnumRarity CRYSTAL_LIGHT_BLUE_RARITY = EnumHelper . addRarity ( ModUtil . MOD_ID_LOWER + " crystalLightBlue " , EnumChatFormatting . BLUE , ModUtil . NAME + " Light Blue Crystal " ) ;
public static final EnumRarity CRYSTAL_BLACK_RARITY = EnumHelper . addRarity ( ModUtil . MOD_ID_LOWER + " crystalBlack " , EnumChatFormatting . DARK_GRAY , ModUtil . NAME + " Black Crystal " ) ;
public static final EnumRarity CRYSTAL_GREEN_RARITY = EnumHelper . addRarity ( ModUtil . MOD_ID_LOWER + " crystalGreen " , EnumChatFormatting . DARK_GREEN , ModUtil . NAME + " Green Crystal " ) ;
public static final EnumRarity CRYSTAL_WHITE_RARITY = EnumHelper . addRarity ( ModUtil . MOD_ID_LOWER + " crystalWhite " , EnumChatFormatting . GRAY , ModUtil . NAME + " White Crystal " ) ;
public static final EnumRarity FALLBACK_RARITY = EnumHelper . addRarity ( ModUtil . MOD_ID_LOWER + " .fallback " , EnumChatFormatting . STRIKETHROUGH , ModUtil . NAME + " Fallback " ) ;
2015-02-09 17:25:05 +01:00
2015-03-07 02:23:31 +01:00
public static void registerEvent ( Object o ) {
MinecraftForge . EVENT_BUS . register ( o ) ;
2015-02-20 22:45:33 +01:00
}
2015-07-01 21:32:48 +02:00
2015-12-13 23:01:56 +01: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 ) {
2015-07-02 00:35:38 +02:00
BlockDispenser . dispenseBehaviorRegistry . putObject ( item , handler ) ;
2015-07-01 21:32:48 +02:00
}
2015-08-28 21:17:09 +02:00
2015-09-30 19:18:13 +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 ;
}
2015-10-03 23:28:32 +02:00
2015-11-20 20:52:03 +01:00
public static int arrayContains ( int [ ] array , int num ) {
for ( int i = 0 ; i < array . length ; i + + ) {
if ( num = = array [ i ] ) {
return i ;
}
}
return - 1 ;
}
2015-10-03 23:28:32 +02:00
public static class GetRecipes {
2016-01-05 04:47:35 +01:00
public static LensNoneRecipe lastReconstructorRecipe ( ) {
List < LensNoneRecipe > list = ActuallyAdditionsAPI . reconstructorLensNoneRecipes ;
2015-11-25 22:13:51 +01:00
return list . get ( list . size ( ) - 1 ) ;
}
2016-01-05 04:47:35 +01:00
public static CrusherRecipe lastCrusherRecipe ( ) {
List < CrusherRecipe > list = ActuallyAdditionsAPI . crusherRecipes ;
2015-10-03 23:28:32 +02:00
return list . get ( list . size ( ) - 1 ) ;
}
public static IRecipe lastIRecipe ( ) {
List list = CraftingManager . getInstance ( ) . getRecipeList ( ) ;
Object recipe = list . get ( list . size ( ) - 1 ) ;
return recipe instanceof IRecipe ? ( IRecipe ) recipe : null ;
}
}
2015-02-17 16:15:16 +01:00
}