Files
TinkersConstruct/src/main/java/tconstruct/library/tools/DualHarvestTool.java
T

105 lines
3.0 KiB
Java
Raw Normal View History

package tconstruct.library.tools;
2014-01-16 01:36:18 -05:00
import mantle.world.WorldHelper;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
2014-01-10 21:14:54 -05:00
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
2014-02-05 10:28:54 -05:00
import tconstruct.library.ActiveToolMod;
import tconstruct.library.TConstructRegistry;
/* Base class for harvest tools with each head having a different purpose */
public abstract class DualHarvestTool extends HarvestTool
{
2013-12-31 16:37:46 -05:00
public DualHarvestTool(int baseDamage)
{
2013-12-31 16:37:46 -05:00
super(baseDamage);
}
@Override
public float getDigSpeed (ItemStack stack, Block block, int meta)
{
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
if (tags.getBoolean("Broken"))
return 0.1f;
Material[] materials = getEffectiveMaterials();
for (int i = 0; i < materials.length; i++)
{
2014-02-05 08:28:53 -05:00
if (materials[i] == block.getMaterial())
{
float speed = tags.getInteger("MiningSpeed");
speed /= 100f;
2014-02-01 15:43:24 -05:00
int hlvl = block.getHarvestLevel(meta);
int durability = tags.getInteger("Damage");
float shoddy = tags.getFloat("Shoddy");
speed += shoddy * durability / 100f;
if (hlvl <= tags.getInteger("HarvestLevel"))
return speed;
return 0.1f;
}
}
materials = getEffectiveSecondaryMaterials();
for (int i = 0; i < materials.length; i++)
{
2014-02-05 08:28:53 -05:00
if (materials[i] == block.getMaterial())
{
float speed = tags.getInteger("MiningSpeed2");
speed /= 100f;
2014-02-01 15:43:24 -05:00
int hlvl = block.getHarvestLevel(meta);
int durability = tags.getInteger("Damage");
float shoddy = tags.getFloat("Shoddy");
speed += shoddy * durability / 100f;
if (hlvl <= tags.getInteger("HarvestLevel2"))
return speed;
return 0.1f;
}
}
return super.getDigSpeed(stack, block, meta);
}
2014-02-17 00:31:43 -05:00
@Override
2014-03-19 19:38:35 +03:00
public boolean func_150897_b (Block block)
{
2014-02-05 08:28:53 -05:00
if (block.getMaterial().isToolNotRequired())
{
return true;
}
for (Material m : getEffectiveMaterials())
{
2014-02-05 08:28:53 -05:00
if (m == block.getMaterial())
return true;
}
for (Material m : getEffectiveSecondaryMaterials())
{
2014-02-05 08:28:53 -05:00
if (m == block.getMaterial())
return true;
}
return false;
}
@Override
public boolean canHarvestBlock (Block block, ItemStack itemStack)
{
return func_150897_b(block);
}
@Override
2014-06-30 22:26:00 -08:00
public String[] getTraits ()
{
return new String[] { "harvest", "dualharvest" };
}
protected abstract Material[] getEffectiveSecondaryMaterials ();
protected abstract String getSecondHarvestType ();
}