2016-03-19 11:36:17 +01:00
package de.ellpeck.actuallyadditions.mod.items.base ;
2019-05-02 09:08:15 +02:00
import java.util.Set ;
2017-08-02 04:20:47 +02:00
import de.ellpeck.actuallyadditions.api.misc.IDisableableItem ;
2016-03-19 11:36:17 +01:00
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions ;
2017-08-02 04:20:47 +02:00
import de.ellpeck.actuallyadditions.mod.config.ConfigurationHandler ;
2016-03-19 11:36:17 +01:00
import de.ellpeck.actuallyadditions.mod.util.ItemUtil ;
2016-11-16 20:31:16 +01:00
import de.ellpeck.actuallyadditions.mod.util.StackUtil ;
2017-08-02 04:20:47 +02:00
import de.ellpeck.actuallyadditions.mod.util.StringUtil ;
2016-03-19 11:36:17 +01:00
import net.minecraft.block.Block ;
import net.minecraft.item.ItemStack ;
import net.minecraft.item.ItemTool ;
2019-05-02 09:08:15 +02:00
import net.minecraftforge.common.IRarity ;
2016-03-19 11:36:17 +01:00
import net.minecraftforge.oredict.OreDictionary ;
2019-05-02 09:08:15 +02:00
public class ItemToolAA extends ItemTool implements IDisableableItem {
2016-03-19 11:36:17 +01:00
2016-05-19 20:05:12 +02:00
private final String name ;
2019-05-02 09:08:15 +02:00
private final IRarity rarity ;
2016-05-19 20:05:12 +02:00
private final ItemStack repairItem ;
2016-03-19 11:36:17 +01:00
private String repairOredict ;
2017-08-02 04:20:47 +02:00
private final boolean disabled ;
2016-03-19 11:36:17 +01:00
2019-05-02 09:08:15 +02:00
public ItemToolAA ( float attack , float speed , ToolMaterial toolMat , String repairItem , String unlocalizedName , IRarity rarity , Set < Block > effectiveStuff ) {
2017-11-02 22:49:53 +01:00
this ( attack , speed , toolMat , ItemStack . EMPTY , unlocalizedName , rarity , effectiveStuff ) ;
2016-03-19 11:36:17 +01:00
this . repairOredict = repairItem ;
}
2019-05-02 09:08:15 +02:00
public ItemToolAA ( float attack , float speed , ToolMaterial toolMat , ItemStack repairItem , String unlocalizedName , IRarity rarity , Set < Block > effectiveStuff ) {
2016-03-19 11:36:17 +01:00
super ( attack , speed , toolMat , effectiveStuff ) ;
this . repairItem = repairItem ;
this . name = unlocalizedName ;
this . rarity = rarity ;
2019-05-02 09:08:15 +02:00
this . disabled = ConfigurationHandler . config . getBoolean ( " Disable: " + StringUtil . badTranslate ( unlocalizedName ) , " Tool Control " , false , " This will disable the " + StringUtil . badTranslate ( unlocalizedName ) + " . It will not be registered. " ) ;
if ( ! this . disabled ) this . register ( ) ;
2016-03-19 11:36:17 +01:00
}
2019-05-02 09:08:15 +02:00
private void register ( ) {
2016-03-19 11:36:17 +01:00
ItemUtil . registerItem ( this , this . getBaseName ( ) , this . shouldAddCreative ( ) ) ;
this . registerRendering ( ) ;
}
2019-05-02 09:08:15 +02:00
protected String getBaseName ( ) {
2016-03-19 11:36:17 +01:00
return this . name ;
}
2019-05-02 09:08:15 +02:00
public boolean shouldAddCreative ( ) {
2016-03-19 11:36:17 +01:00
return true ;
}
2019-05-02 09:08:15 +02:00
protected void registerRendering ( ) {
2018-05-10 11:38:58 +02:00
ActuallyAdditions . PROXY . addRenderRegister ( new ItemStack ( this ) , this . getRegistryName ( ) , " inventory " ) ;
2016-03-19 11:36:17 +01:00
}
@Override
2019-05-02 09:08:15 +02:00
public IRarity getForgeRarity ( ItemStack stack ) {
2016-03-19 11:36:17 +01:00
return this . rarity ;
}
@Override
2019-05-02 09:08:15 +02:00
public boolean getIsRepairable ( ItemStack itemToRepair , ItemStack stack ) {
if ( StackUtil . isValid ( this . repairItem ) ) {
2016-03-19 11:36:17 +01:00
return ItemUtil . areItemsEqual ( this . repairItem , stack , false ) ;
2019-05-02 09:08:15 +02:00
} else if ( this . repairOredict ! = null ) {
2016-03-19 11:36:17 +01:00
int [ ] idsStack = OreDictionary . getOreIDs ( stack ) ;
2019-05-02 09:08:15 +02:00
for ( int id : idsStack ) {
if ( OreDictionary . getOreName ( id ) . equals ( this . repairOredict ) ) { return true ; }
2016-03-19 11:36:17 +01:00
}
}
return false ;
}
2017-08-02 04:20:47 +02:00
2019-02-27 19:53:05 +01:00
@Override
public boolean isDisabled ( ) {
return this . disabled ;
}
2016-03-19 11:36:17 +01:00
}