2013-07-26 21:18:53 -07:00
|
|
|
package tconstruct.library.tools;
|
|
|
|
|
|
2014-01-16 01:36:18 -05:00
|
|
|
import mantle.world.WorldHelper;
|
2013-07-26 21:18:53 -07:00
|
|
|
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;
|
2013-07-26 21:18:53 -07:00
|
|
|
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;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
/* 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-07-26 21:18:53 -07:00
|
|
|
{
|
2013-12-31 16:37:46 -05:00
|
|
|
super(baseDamage);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2014-02-03 10:02:49 -05:00
|
|
|
public float getDigSpeed (ItemStack stack, Block block, int meta)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
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())
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
float speed = tags.getInteger("MiningSpeed");
|
|
|
|
|
speed /= 100f;
|
2014-02-01 15:43:24 -05:00
|
|
|
int hlvl = block.getHarvestLevel(meta);
|
2013-07-26 21:18:53 -07:00
|
|
|
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())
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
float speed = tags.getInteger("MiningSpeed2");
|
|
|
|
|
speed /= 100f;
|
2014-02-01 15:43:24 -05:00
|
|
|
int hlvl = block.getHarvestLevel(meta);
|
2013-07-26 21:18:53 -07:00
|
|
|
int durability = tags.getInteger("Damage");
|
|
|
|
|
|
|
|
|
|
float shoddy = tags.getFloat("Shoddy");
|
|
|
|
|
speed += shoddy * durability / 100f;
|
|
|
|
|
|
|
|
|
|
if (hlvl <= tags.getInteger("HarvestLevel2"))
|
|
|
|
|
return speed;
|
|
|
|
|
return 0.1f;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-02-03 10:02:49 -05:00
|
|
|
return super.getDigSpeed(stack, block, meta);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2014-03-19 19:38:35 +03:00
|
|
|
public boolean func_150897_b (Block block)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2014-02-05 08:28:53 -05:00
|
|
|
if (block.getMaterial().isToolNotRequired())
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
for (Material m : getEffectiveMaterials())
|
|
|
|
|
{
|
2014-02-05 08:28:53 -05:00
|
|
|
if (m == block.getMaterial())
|
2013-07-26 21:18:53 -07:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
for (Material m : getEffectiveSecondaryMaterials())
|
|
|
|
|
{
|
2014-02-05 08:28:53 -05:00
|
|
|
if (m == block.getMaterial())
|
2013-07-26 21:18:53 -07:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-19 19:55:37 +03:00
|
|
|
@Override
|
2014-04-03 22:28:37 -04:00
|
|
|
public boolean canHarvestBlock (Block block, ItemStack itemStack)
|
2014-03-19 19:55:37 +03:00
|
|
|
{
|
|
|
|
|
return func_150897_b(block);
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-26 21:18:53 -07:00
|
|
|
@Override
|
2014-06-30 22:26:00 -08:00
|
|
|
public String[] getTraits ()
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
return new String[] { "harvest", "dualharvest" };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected abstract Material[] getEffectiveSecondaryMaterials ();
|
|
|
|
|
|
|
|
|
|
protected abstract String getSecondHarvestType ();
|
|
|
|
|
}
|