2016-05-16 22:52:27 +02:00
/ *
* This file ( " ItemToolAA.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 : //ellpeck.de/actaddlicense
* View the source code at https : //github.com/Ellpeck/ActuallyAdditions
*
2017-01-01 16:23:26 +01:00
* © 2015 - 2017 Ellpeck
2016-05-16 22:52:27 +02:00
* /
2016-03-19 11:36:17 +01:00
package de.ellpeck.actuallyadditions.mod.items.base ;
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.EnumRarity ;
import net.minecraft.item.ItemStack ;
import net.minecraft.item.ItemTool ;
import net.minecraftforge.oredict.OreDictionary ;
import java.util.Set ;
2017-08-02 04:20:47 +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 ;
private final EnumRarity rarity ;
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
public ItemToolAA ( float attack , float speed , ToolMaterial toolMat , String repairItem , String unlocalizedName , EnumRarity 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 ;
}
public ItemToolAA ( float attack , float speed , ToolMaterial toolMat , ItemStack repairItem , String unlocalizedName , EnumRarity rarity , Set < Block > effectiveStuff ) {
super ( attack , speed , toolMat , effectiveStuff ) ;
this . repairItem = repairItem ;
this . name = unlocalizedName ;
this . rarity = rarity ;
2017-08-02 04:20:47 +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 ( ! disabled ) this . register ( ) ;
2016-03-19 11:36:17 +01:00
}
private void register ( ) {
ItemUtil . registerItem ( this , this . getBaseName ( ) , this . shouldAddCreative ( ) ) ;
this . registerRendering ( ) ;
}
protected String getBaseName ( ) {
return this . name ;
}
public boolean shouldAddCreative ( ) {
return true ;
}
protected void registerRendering ( ) {
2016-06-01 00:37:28 +02:00
ActuallyAdditions . proxy . addRenderRegister ( new ItemStack ( this ) , this . getRegistryName ( ) , " inventory " ) ;
2016-03-19 11:36:17 +01:00
}
2016-05-29 23:49:35 +02:00
2016-03-19 11:36:17 +01:00
@Override
public EnumRarity getRarity ( ItemStack stack ) {
return this . rarity ;
}
@Override
2016-05-29 23:49:35 +02:00
public boolean getIsRepairable ( ItemStack itemToRepair , ItemStack stack ) {
2016-11-16 20:31:16 +01:00
if ( StackUtil . isValid ( this . repairItem ) ) {
2016-03-19 11:36:17 +01:00
return ItemUtil . areItemsEqual ( this . repairItem , stack , false ) ;
}
else if ( this . repairOredict ! = null ) {
int [ ] idsStack = OreDictionary . getOreIDs ( stack ) ;
for ( int id : idsStack ) {
if ( OreDictionary . getOreName ( id ) . equals ( this . repairOredict ) ) {
return true ;
}
}
}
return false ;
}
2017-08-02 04:20:47 +02:00
@Override
public boolean isDisabled ( ) {
return disabled ;
}
2016-03-19 11:36:17 +01:00
}