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;
|
2014-09-09 18:30:15 +10:00
|
|
|
import net.minecraft.item.*;
|
2013-07-26 21:18:53 -07:00
|
|
|
import net.minecraft.world.World;
|
2014-12-23 14:36:07 +01:00
|
|
|
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
2023-01-28 18:04:28 -08:00
|
|
|
|
2014-12-23 14:36:07 +01:00
|
|
|
import cpw.mods.fml.common.Optional;
|
2014-09-09 18:30:15 +10:00
|
|
|
import cpw.mods.fml.relauncher.*;
|
2023-05-15 15:07:18 +09:00
|
|
|
import mods.battlegear2.api.PlayerEventChild;
|
|
|
|
|
import mods.battlegear2.api.weapons.IBattlegearWeapon;
|
|
|
|
|
import tconstruct.tools.TinkerTools;
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2015-01-30 19:28:56 +01:00
|
|
|
@Optional.InterfaceList({
|
|
|
|
|
@Optional.Interface(modid = "battlegear2", iface = "mods.battlegear2.api.weapons.IBattlegearWeapon"),
|
2015-02-12 10:27:08 +01:00
|
|
|
@Optional.Interface(modid = "ZeldaItemAPI", iface = "zeldaswordskills.api.item.ISword"),
|
|
|
|
|
@Optional.Interface(modid = "DynamicSkillsAPI", iface = "dynamicswordskills.api.ISword") })
|
2022-09-22 19:51:23 +01:00
|
|
|
public abstract class Weapon extends ToolCore
|
|
|
|
|
implements IBattlegearWeapon, zeldaswordskills.api.item.ISword, dynamicswordskills.api.ISword {
|
2013-07-26 21:18:53 -07:00
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public Weapon(int baseDamage) {
|
2013-12-31 11:58:36 -05:00
|
|
|
super(baseDamage);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
protected float baseSpeed() {
|
2013-07-26 21:18:53 -07:00
|
|
|
return 1.5f;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
protected float effectiveSpeed() {
|
2013-07-26 21:18:53 -07:00
|
|
|
return 15f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public float getDigSpeed(ItemStack stack, Block block, int meta) {
|
|
|
|
|
if (!stack.hasTagCompound()) return 0f;
|
|
|
|
|
|
|
|
|
|
if (stack.getTagCompound().getCompoundTag("InfiTool").getBoolean("Broken")) return 0.1f;
|
|
|
|
|
|
2023-01-26 02:26:43 +01:00
|
|
|
for (Material material : web) {
|
|
|
|
|
if (material == 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
|
2022-09-22 19:51:23 +01:00
|
|
|
public EnumAction getItemUseAction(ItemStack par1ItemStack) {
|
2013-07-26 21:18:53 -07:00
|
|
|
return EnumAction.block;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* How long it takes to use or consume an item
|
|
|
|
|
*/
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public int getMaxItemUseDuration(ItemStack par1ItemStack) {
|
2013-07-26 21:18:53 -07:00
|
|
|
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
|
2022-09-22 19:51:23 +01:00
|
|
|
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
2013-07-26 21:18:53 -07:00
|
|
|
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
|
|
|
|
|
return stack;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side,
|
|
|
|
|
float clickX, float clickY, float clickZ) {
|
2013-07-26 21:18:53 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns if the item (tool) can harvest results from the block type.
|
|
|
|
|
*/
|
2014-02-17 00:31:43 -05:00
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public boolean canHarvestBlock(Block block, ItemStack is) {
|
2023-01-26 02:26:43 +01:00
|
|
|
for (Material material : web) {
|
|
|
|
|
if (block.getMaterial() == material) return true;
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
2014-01-16 03:57:21 -05:00
|
|
|
return super.canHarvestBlock(block, is);
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
protected Material[] getEffectiveMaterials() {
|
2013-07-26 21:18:53 -07:00
|
|
|
return web;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
2022-09-22 19:51:23 +01:00
|
|
|
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) {
|
2013-07-26 21:18:53 -07:00
|
|
|
super.onUpdate(stack, world, entity, par4, par5);
|
2022-09-22 19:51:23 +01:00
|
|
|
if (entity instanceof EntityPlayerSP) {
|
2013-07-26 21:18:53 -07:00
|
|
|
EntityPlayerSP player = (EntityPlayerSP) entity;
|
|
|
|
|
ItemStack usingItem = player.getItemInUse();
|
2022-09-22 19:51:23 +01:00
|
|
|
if (usingItem != null && usingItem.getItem() == this) {
|
2013-07-26 21:18:53 -07:00
|
|
|
player.movementInput.moveForward *= 2.5F;
|
|
|
|
|
player.movementInput.moveStrafe *= 2.5F;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2022-09-22 19:51:23 +01:00
|
|
|
public String[] getTraits() {
|
|
|
|
|
return new String[] { "weapon", "melee" };
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|
|
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
public static Material[] web = new Material[] { Material.web, Material.cloth, Material.coral, Material.cake };
|
2013-07-26 21:18:53 -07:00
|
|
|
public static Material[] none = new Material[0];
|
2013-11-10 13:57:35 -08:00
|
|
|
|
2014-12-23 14:36:07 +01:00
|
|
|
/*---- Battlegear Support START ----*/
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Optional.Method(modid = "battlegear2")
|
2022-09-22 19:51:23 +01:00
|
|
|
public boolean sheatheOnBack(ItemStack item) {
|
2014-12-23 14:36:07 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Optional.Method(modid = "battlegear2")
|
|
|
|
|
public boolean isOffhandHandDual(ItemStack off) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Optional.Method(modid = "battlegear2")
|
2022-09-22 19:51:23 +01:00
|
|
|
public boolean offhandAttackEntity(PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem,
|
|
|
|
|
ItemStack offhandItem) {
|
2014-12-23 14:36:07 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Optional.Method(modid = "battlegear2")
|
|
|
|
|
public boolean offhandClickAir(PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Optional.Method(modid = "battlegear2")
|
|
|
|
|
public boolean offhandClickBlock(PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Optional.Method(modid = "battlegear2")
|
|
|
|
|
public void performPassiveEffects(Side effectiveSide, ItemStack mainhandItem, ItemStack offhandItem) {
|
|
|
|
|
// unused
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Optional.Method(modid = "battlegear2")
|
|
|
|
|
public boolean allowOffhand(ItemStack mainhand, ItemStack offhand) {
|
2022-09-22 19:51:23 +01:00
|
|
|
if (offhand == null) return true;
|
2014-12-23 14:36:07 +01:00
|
|
|
|
2022-09-22 19:51:23 +01:00
|
|
|
return (mainhand != null && mainhand.getItem() != TinkerTools.cleaver
|
|
|
|
|
&& mainhand.getItem() != TinkerTools.battleaxe)
|
2014-12-23 14:36:07 +01:00
|
|
|
&& (offhand.getItem() != TinkerTools.cleaver && offhand.getItem() != TinkerTools.battleaxe);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*---- Battlegear Support END ----*/
|
2013-07-26 21:18:53 -07:00
|
|
|
}
|