GT5-Unofficial/main/java/gregtech/common/tools/GT_Tool_BranchCutter.java

106 lines
3.5 KiB
Java
Raw Normal View History

2015-06-23 22:29:05 +00:00
package gregtech.common.tools;
import gregtech.api.enums.Materials;
2015-04-23 16:14:22 +00:00
import gregtech.api.enums.Textures;
2015-06-23 22:29:05 +00:00
import gregtech.api.enums.Textures.ItemIcons;
import gregtech.api.interfaces.IIconContainer;
import gregtech.api.items.GT_MetaGenerated_Tool;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Utility;
2015-04-23 16:14:22 +00:00
2015-06-23 22:29:05 +00:00
import java.util.List;
import java.util.Random;
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.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IChatComponent;
import net.minecraft.world.World;
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_BranchCutter
extends GT_Tool
{
public float getBaseDamage()
{
return 2.5F;
}
public float getSpeedMultiplier()
{
return 0.25F;
}
public float getMaxDurabilityMultiplier()
{
return 0.25F;
}
public boolean isGrafter()
{
return true;
}
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)
{
if (aBlock.getMaterial() == Material.leaves)
{
aEvent.dropChance = Math.min(1.0F, Math.max(aEvent.dropChance, (aStack.getItem().getHarvestLevel(aStack, "") + 1) * 0.2F));
if (aBlock == Blocks.leaves)
{
aDrops.clear();
if (((aMetaData & 0x3) == 0) && (aPlayer.worldObj.rand.nextInt(9) <= aFortune * 2)) {
aDrops.add(new ItemStack(Items.apple, 1, 0));
} else {
aDrops.add(new ItemStack(Blocks.sapling, 1, aMetaData & 0x3));
}
}
else if (aBlock == Blocks.leaves2)
{
aDrops.clear();
aDrops.add(new ItemStack(Blocks.sapling, 1, (aMetaData & 0x3) + 4));
}
else if (aBlock == GT_Utility.getBlockFromStack(GT_ModHandler.getIC2Item("rubberLeaves", 1L)))
{
aDrops.clear();
aDrops.add(GT_ModHandler.getIC2Item("rubberSapling", 1L));
}
}
return 0;
}
public boolean isMinableBlock(Block aBlock, byte aMetaData)
{
String tTool = aBlock.getHarvestTool(aMetaData);
return ((tTool != null) && (tTool.equals("grafter"))) || (aBlock.getMaterial() == Material.leaves);
}
public IIconContainer getIcon(boolean aIsToolHead, ItemStack aStack)
{
return aIsToolHead ? Textures.ItemIcons.GRAFTER : null;
}
public short[] getRGBa(boolean aIsToolHead, ItemStack aStack)
{
return aIsToolHead ? GT_MetaGenerated_Tool.getPrimaryMaterial(aStack).mRGBa : GT_MetaGenerated_Tool.getSecondaryMaterial(aStack).mRGBa;
}
public IChatComponent getDeathMessage(EntityLivingBase aPlayer, EntityLivingBase aEntity)
{
return new ChatComponentText(EnumChatFormatting.RED + aEntity.getCommandSenderName() + EnumChatFormatting.WHITE + " has been trimmed by " + EnumChatFormatting.GREEN + aPlayer.getCommandSenderName() + EnumChatFormatting.WHITE);
}
}
2015-04-23 16:14:22 +00:00
/* Location: F:\Torrent\minecraft\jd-gui-0.3.6.windows\gregtech_1.7.10-5.07.07-dev.jar
* Qualified Name: gregtech.common.tools.GT_Tool_BranchCutter
* JD-Core Version: 0.7.0.1
*/