summaryrefslogtreecommitdiff
path: root/src/api/java/mods/battlegear2/api/IOffhandDual.java
blob: 91f129325ebcfccfac441666687dcef917f5c5c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package mods.battlegear2.api;

import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import cpw.mods.fml.relauncher.Side;

public interface IOffhandDual
{
	/**
	 * Returns true if this item can be dual wielded in the offhand slot
	 * @param off The {@link ItemStack} holding this item
	 */
	public boolean isOffhandHandDual(ItemStack off);

	/**
	 * Perform any function when this item is held in the offhand and the user right clicks an entity.
	 * This is generally used to attack an entity with the offhand item.
	 * If this is the case the {@link PlayerEventChild.OffhandAttackEvent#parent} field should
	 * be canceled (or {@link PlayerEventChild.OffhandAttackEvent#cancelParent} field left at true, to prevent any default right clicking events (Eg Villager Trading)
	 *
	 * @param event        the OffhandAttackEvent that was generated
	 * @param mainhandItem the {@link ItemStack} currently being held in the right hand
	 * @param offhandItem  the {@link ItemStack} currently being held in the left hand, holding this item
	 * @return true if the off hand swing animation should be performed
	 */
	public boolean offhandAttackEntity(PlayerEventChild.OffhandAttackEvent event, ItemStack mainhandItem, ItemStack offhandItem);

	/**
	 * Perform any function when this item is held in the offhand and the user right clicks "Air".
	 * Note: Called first on client-side, then on server side if {@link PlayerInteractEvent} is not cancelled and mainhandItem is not null,
	 * following Forge rules for PlayerInteractEvent with Action==RIGHT_CLICK_AIR
	 * Note: PlayerInteractEvent is already cancelled beforehand, and will be cancelled after if this method returns false
	 * Note: Above issues will be fixed in next Minecraft versions by replacing first arg with a shallow copy
	 * @param event        the PlayerInteractEvent that was generated
	 * @param mainhandItem the {@link ItemStack} currently being held in the right hand
	 * @param offhandItem  the {@link ItemStack} currently being held in the left hand, holding this item
	 * @return true if the off hand swing animation should be performed
	 */
	public boolean offhandClickAir(PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem);

	/**
	 * Perform any function when this item is held in the offhand and the user right clicks a block.
	 * Note: this will happen prior to the activation of any activation functions of blocks
	 * Note: Called first on client-side, then on server side if {@link PlayerInteractEvent} is not cancelled
	 * Note: {@link PlayerInteractEvent#useItem} is already set on {@link Event.Result#DENY} before reaching this method, in order to avoid mainhandItem usage
	 *
	 * @param event        the PlayerInteractEvent that was generated
	 * @param mainhandItem the {@link ItemStack} currently being held in the right hand
	 * @param offhandItem  the {@link ItemStack} currently being held in the left hand, holding this item
	 * @return true if the off hand swing animation should be performed
	 */
	public boolean offhandClickBlock(PlayerInteractEvent event, ItemStack mainhandItem, ItemStack offhandItem);

	@SuppressWarnings("unused")
	/**
	 * Perform any passive effects on each game tick when this item is held in the offhand
	 * @deprecated See {@link Item#onUpdate(ItemStack, World, Entity, int, boolean)}
	 * @param effectiveSide the effective side the method was called from
	 * @param mainhandItem  the {@link ItemStack} currently being held in the right hand
	 * @param offhandItem   the {@link ItemStack} currently being held in the left hand
	 */
	public void performPassiveEffects(Side effectiveSide, ItemStack mainhandItem, ItemStack offhandItem);
}