2015-06-23 22:29:05 +00:00
package gregtech.common.tools ;
import gregtech.GT_Mod ;
2015-05-16 00:51:56 +00:00
import gregtech.api.GregTech_API ;
2015-06-23 22:29:05 +00:00
import gregtech.api.enums.Materials ;
import gregtech.api.interfaces.IIconContainer ;
import gregtech.api.items.GT_MetaGenerated_Tool ;
import gregtech.api.util.GT_Recipe ;
import gregtech.api.util.GT_Recipe.GT_Recipe_Map ;
import gregtech.api.util.GT_Utility ;
import gregtech.common.items.behaviors.Behaviour_Prospecting ;
2015-04-23 16:14:22 +00:00
2015-06-23 22:29:05 +00:00
import java.util.Arrays ;
import java.util.List ;
import java.util.Map ;
2015-04-23 16:14:22 +00:00
2015-06-23 22:29:05 +00:00
import net.minecraft.block.Block ;
import net.minecraft.block.material.Material ;
import net.minecraft.entity.Entity ;
import net.minecraft.entity.EntityLivingBase ;
import net.minecraft.entity.monster.EntityIronGolem ;
import net.minecraft.entity.player.EntityPlayer ;
import net.minecraft.item.ItemStack ;
2015-05-16 00:51:56 +00:00
import net.minecraft.stats.AchievementList ;
2015-06-23 22:29:05 +00:00
import net.minecraft.util.ChatComponentText ;
import net.minecraft.util.EnumChatFormatting ;
import net.minecraft.util.IChatComponent ;
2015-04-23 16:14:22 +00:00
import net.minecraftforge.event.world.BlockEvent ;
2015-06-23 22:29:05 +00:00
import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent ;
public class GT_Tool_HardHammer
extends GT_Tool
{
public static final List < String > mEffectiveList = Arrays . asList ( new String [ ] { EntityIronGolem . class . getName ( ) , " EntityTowerGuardian " } ) ;
public float getNormalDamageAgainstEntity ( float aOriginalDamage , Entity aEntity , ItemStack aStack , EntityPlayer aPlayer )
{
String tName = aEntity . getClass ( ) . getName ( ) ;
tName = tName . substring ( tName . lastIndexOf ( " . " ) + 1 ) ;
return ( mEffectiveList . contains ( tName ) ) | | ( tName . contains ( " Golem " ) ) ? aOriginalDamage * 2 . 0F : aOriginalDamage ;
}
public int getToolDamagePerBlockBreak ( )
{
return 50 ;
}
public int getToolDamagePerDropConversion ( )
{
return 200 ;
}
public int getToolDamagePerContainerCraft ( )
{
return 400 ;
}
public int getToolDamagePerEntityAttack ( )
{
return 200 ;
}
public int getBaseQuality ( )
{
return 0 ;
}
public float getBaseDamage ( )
{
return 3 . 0F ;
}
public int getHurtResistanceTime ( int aOriginalHurtResistance , Entity aEntity )
{
return aOriginalHurtResistance * 2 ;
}
public float getSpeedMultiplier ( )
{
return 0 . 75F ;
}
public float getMaxDurabilityMultiplier ( )
{
return 1 . 0F ;
}
public String getCraftingSound ( )
{
return ( String ) GregTech_API . sSoundList . get ( Integer . valueOf ( 1 ) ) ;
}
public String getEntityHitSound ( )
{
return null ;
}
public String getBreakingSound ( )
{
return ( String ) GregTech_API . sSoundList . get ( Integer . valueOf ( 2 ) ) ;
}
public String getMiningSound ( )
{
return null ;
}
public boolean canBlock ( )
{
return true ;
}
public boolean isCrowbar ( )
{
return false ;
}
public boolean isWeapon ( )
{
return true ;
}
public boolean isMinableBlock ( Block aBlock , byte aMetaData )
{
String tTool = aBlock . getHarvestTool ( aMetaData ) ;
return ( ( tTool ! = null ) & & ( ( tTool . equals ( " hammer " ) ) | | ( tTool . equals ( " pickaxe " ) ) ) ) | | ( aBlock . getMaterial ( ) = = Material . rock ) | | ( aBlock . getMaterial ( ) = = Material . glass ) | | ( aBlock . getMaterial ( ) = = Material . ice ) | | ( aBlock . getMaterial ( ) = = Material . packedIce ) | | ( GT_Recipe . GT_Recipe_Map . sHammerRecipes . containsInput ( new ItemStack ( aBlock , 1 , aMetaData ) ) ) ;
}
public int convertBlockDrops ( List < ItemStack > aDrops , ItemStack aStack , EntityPlayer aPlayer , Block aBlock , int aX , int aY , int aZ , byte aMetaData , int aFortune , boolean aSilkTouch , BlockEvent . HarvestDropsEvent aEvent )
{
int rConversions = 0 ;
GT_Recipe tRecipe = GT_Recipe . GT_Recipe_Map . sHammerRecipes . findRecipe ( null , true , 2147483647L , null , new ItemStack [ ] { new ItemStack ( aBlock , 1 , aMetaData ) } ) ;
if ( ( tRecipe = = null ) | | ( aBlock . hasTileEntity ( aMetaData ) ) )
{
for ( ItemStack tDrop : aDrops )
{
tRecipe = GT_Recipe . GT_Recipe_Map . sHammerRecipes . findRecipe ( null , true , 2147483647L , null , new ItemStack [ ] { GT_Utility . copyAmount ( 1L , new Object [ ] { tDrop } ) } ) ;
if ( tRecipe ! = null )
{
ItemStack tHammeringOutput = tRecipe . getOutput ( 0 ) ;
if ( tHammeringOutput ! = null )
{
rConversions + = tDrop . stackSize ;
tDrop . stackSize * = tHammeringOutput . stackSize ;
tHammeringOutput . stackSize = tDrop . stackSize ;
GT_Utility . setStack ( tDrop , tHammeringOutput ) ;
}
}
}
}
else
{
aDrops . clear ( ) ;
aDrops . add ( tRecipe . getOutput ( 0 ) ) ;
rConversions + + ;
}
return rConversions ;
}
public ItemStack getBrokenItem ( ItemStack aStack )
{
return null ;
}
public IIconContainer getIcon ( boolean aIsToolHead , ItemStack aStack )
{
return aIsToolHead ? GT_MetaGenerated_Tool . getPrimaryMaterial ( aStack ) . mIconSet . mTextures [ gregtech . api . enums . OrePrefixes . toolHeadHammer . mTextureIndex ] : GT_MetaGenerated_Tool . getSecondaryMaterial ( aStack ) . mIconSet . mTextures [ gregtech . api . enums . OrePrefixes . stick . mTextureIndex ] ;
}
public short [ ] getRGBa ( boolean aIsToolHead , ItemStack aStack )
{
return aIsToolHead ? GT_MetaGenerated_Tool . getPrimaryMaterial ( aStack ) . mRGBa : GT_MetaGenerated_Tool . getSecondaryMaterial ( aStack ) . mRGBa ;
}
public void onStatsAddedToTool ( GT_MetaGenerated_Tool aItem , int aID )
{
aItem . addItemBehavior ( aID , new Behaviour_Prospecting ( 1 , 1000 ) ) ;
}
public IChatComponent getDeathMessage ( EntityLivingBase aPlayer , EntityLivingBase aEntity )
{
return new ChatComponentText ( EnumChatFormatting . RED + aEntity . getCommandSenderName ( ) + EnumChatFormatting . WHITE + " was squashed by " + EnumChatFormatting . GREEN + aPlayer . getCommandSenderName ( ) + EnumChatFormatting . WHITE ) ;
}
2015-05-16 00:51:56 +00:00
public void onToolCrafted ( ItemStack aStack , EntityPlayer aPlayer )
2015-06-23 22:29:05 +00:00
{
super . onToolCrafted ( aStack , aPlayer ) ;
2015-05-18 21:56:48 +00:00
try { GT_Mod . instance . achievements . issueAchievement ( aPlayer , " tools " ) ; } catch ( Exception e ) { }
2015-06-23 22:29:05 +00:00
}
}