2015-06-23 22:29:05 +00:00
package gregtech.common.tools ;
2015-04-23 16:14:22 +00:00
2015-06-23 22:29:05 +00:00
import gregtech.api.interfaces.IIconContainer ;
import gregtech.api.items.GT_MetaGenerated_Tool ;
import gregtech.common.items.behaviors.Behaviour_Sense ;
import net.minecraft.block.Block ;
import net.minecraft.block.material.Material ;
import net.minecraft.entity.EntityLivingBase ;
import net.minecraft.entity.player.EntityPlayer ;
import net.minecraft.entity.player.EntityPlayerMP ;
import net.minecraft.item.ItemStack ;
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-10-22 02:06:25 +00:00
import java.util.List ;
2015-06-23 22:29:05 +00:00
public class GT_Tool_Sense
2015-10-22 02:06:25 +00:00
extends GT_Tool {
private ThreadLocal < Object > sIsHarvestingRightNow = new ThreadLocal ( ) ;
public float getBaseDamage ( ) {
return 3 . 0F ;
}
2016-03-17 22:35:10 +00:00
public float getMaxDurabilityMultiplier ( ) {
return 4 . 0F ;
}
2015-10-22 02:06:25 +00:00
public boolean isMinableBlock ( Block aBlock , byte aMetaData ) {
String tTool = aBlock . getHarvestTool ( aMetaData ) ;
return ( ( tTool ! = null ) & & ( ( tTool . equals ( " sense " ) ) | | ( tTool . equals ( " scythe " ) ) ) ) | | ( aBlock . getMaterial ( ) = = Material . plants ) | | ( aBlock . getMaterial ( ) = = Material . leaves ) ;
}
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 ;
if ( ( this . sIsHarvestingRightNow . get ( ) = = null ) & & ( ( aPlayer instanceof EntityPlayerMP ) ) ) {
this . sIsHarvestingRightNow . set ( this ) ;
2016-03-17 22:35:10 +00:00
for ( int i = - 2 ; i < 3 ; i + + ) {
for ( int j = - 2 ; j < 3 ; j + + ) {
for ( int k = - 2 ; k < 3 ; k + + ) {
2015-10-22 02:06:25 +00:00
if ( ( ( i ! = 0 ) | | ( j ! = 0 ) | | ( k ! = 0 ) ) & & ( aStack . getItem ( ) . getDigSpeed ( aStack , aPlayer . worldObj . getBlock ( aX + i , aY + j , aZ + k ) , aPlayer . worldObj . getBlockMetadata ( aX + i , aY + j , aZ + k ) ) > 0 . 0F ) & & ( ( ( EntityPlayerMP ) aPlayer ) . theItemInWorldManager . tryHarvestBlock ( aX + i , aY + j , aZ + k ) ) ) {
rConversions + + ;
}
}
}
2015-06-23 22:29:05 +00:00
}
2015-10-22 02:06:25 +00:00
this . sIsHarvestingRightNow . set ( null ) ;
2015-06-23 22:29:05 +00:00
}
2015-10-22 02:06:25 +00:00
return rConversions ;
}
public IIconContainer getIcon ( boolean aIsToolHead , ItemStack aStack ) {
return aIsToolHead ? GT_MetaGenerated_Tool . getPrimaryMaterial ( aStack ) . mIconSet . mTextures [ gregtech . api . enums . OrePrefixes . toolHeadSense . 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_Sense ( getToolDamagePerBlockBreak ( ) ) ) ;
}
public IChatComponent getDeathMessage ( EntityLivingBase aPlayer , EntityLivingBase aEntity ) {
return new ChatComponentText ( EnumChatFormatting . GREEN + aPlayer . getCommandSenderName ( ) + EnumChatFormatting . WHITE + " has taken the Soul of " + EnumChatFormatting . RED + aEntity . getCommandSenderName ( ) + EnumChatFormatting . WHITE ) ;
2015-06-23 22:29:05 +00:00
}
}