2013-07-26 21:18:53 -07:00
|
|
|
package tconstruct.library.tools;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
|
import net.minecraft.client.entity.EntityPlayerSP;
|
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
|
import net.minecraft.item.EnumAction;
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
|
|
public abstract class Weapon extends ToolCore
|
|
|
|
|
{
|
|
|
|
|
|
2013-12-31 11:58:36 -05:00
|
|
|
public Weapon(int baseDamage)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2013-12-31 11:58:36 -05:00
|
|
|
super(baseDamage);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected float baseSpeed ()
|
|
|
|
|
{
|
|
|
|
|
return 1.5f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected float effectiveSpeed ()
|
|
|
|
|
{
|
|
|
|
|
return 15f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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
|
|
|
{
|
|
|
|
|
if (stack.getTagCompound().getCompoundTag("InfiTool").getBoolean("Broken"))
|
|
|
|
|
return 0.1f;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < web.length; i++)
|
|
|
|
|
{
|
2014-02-05 08:28:53 -05:00
|
|
|
if (web[i] == block.getMaterial())
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
return effectiveSpeed();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return baseSpeed();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-02-16 14:23:50 -05:00
|
|
|
* returns the action that specifies what animation to play when the items
|
|
|
|
|
* is being used
|
2013-07-26 21:18:53 -07:00
|
|
|
*/
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2013-07-26 21:18:53 -07:00
|
|
|
public EnumAction getItemUseAction (ItemStack par1ItemStack)
|
|
|
|
|
{
|
|
|
|
|
return EnumAction.block;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* How long it takes to use or consume an item
|
|
|
|
|
*/
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2013-07-26 21:18:53 -07:00
|
|
|
public int getMaxItemUseDuration (ItemStack par1ItemStack)
|
|
|
|
|
{
|
|
|
|
|
return 72000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-02-16 14:23:50 -05:00
|
|
|
* Called whenever this item is equipped and the right mouse button is
|
|
|
|
|
* pressed. Args: itemStack, world, entityPlayer
|
2013-07-26 21:18:53 -07:00
|
|
|
*/
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2013-07-26 21:18:53 -07:00
|
|
|
public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player)
|
|
|
|
|
{
|
|
|
|
|
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
|
|
|
|
|
return stack;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2013-07-26 21:18:53 -07:00
|
|
|
public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float clickX, float clickY, float clickZ)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns if the item (tool) can harvest results from the block type.
|
|
|
|
|
*/
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2014-01-16 03:57:21 -05:00
|
|
|
public boolean canHarvestBlock (Block block, ItemStack is)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
for (int i = 0; i < web.length; i++)
|
|
|
|
|
{
|
2014-02-05 08:28:53 -05:00
|
|
|
if (block.getMaterial() == web[i])
|
2013-07-26 21:18:53 -07:00
|
|
|
return true;
|
|
|
|
|
}
|
2014-01-16 03:57:21 -05:00
|
|
|
return super.canHarvestBlock(block, is);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected Material[] getEffectiveMaterials ()
|
|
|
|
|
{
|
|
|
|
|
return web;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
|
public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5)
|
|
|
|
|
{
|
|
|
|
|
super.onUpdate(stack, world, entity, par4, par5);
|
|
|
|
|
if (entity instanceof EntityPlayerSP)
|
|
|
|
|
{
|
|
|
|
|
EntityPlayerSP player = (EntityPlayerSP) entity;
|
|
|
|
|
ItemStack usingItem = player.getItemInUse();
|
|
|
|
|
if (usingItem != null && usingItem.getItem() == this)
|
|
|
|
|
{
|
|
|
|
|
player.movementInput.moveForward *= 2.5F;
|
|
|
|
|
player.movementInput.moveStrafe *= 2.5F;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 14:23:50 -05:00
|
|
|
/*
|
|
|
|
|
* @Override public boolean onLeftClickEntity (ItemStack stack, EntityPlayer
|
|
|
|
|
* player, Entity entity) { TContent.modL.midStreamModify(stack); return
|
|
|
|
|
* super.onLeftClickEntity(stack, player, entity); }
|
|
|
|
|
*/
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String[] toolCategories ()
|
|
|
|
|
{
|
|
|
|
|
return new String[] { "weapon", "melee" };
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-05 08:28:53 -05:00
|
|
|
public static Material[] web = new Material[] { Material.web };
|
2013-07-26 21:18:53 -07:00
|
|
|
public static Material[] none = new Material[0];
|
2013-11-10 13:57:35 -08:00
|
|
|
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|