-
-
Notifications
You must be signed in to change notification settings - Fork 346
/
FishingEvent.java
108 lines (99 loc) · 4.35 KB
/
FishingEvent.java
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.api.event.action;
import org.spongepowered.api.data.DataSerializable;
import org.spongepowered.api.data.Transaction;
import org.spongepowered.api.data.type.Fish;
import org.spongepowered.api.entity.EntitySnapshot;
import org.spongepowered.api.entity.Item;
import org.spongepowered.api.entity.projectile.FishHook;
import org.spongepowered.api.event.Cancellable;
import org.spongepowered.api.event.Event;
import org.spongepowered.api.event.block.CollideBlockEvent;
import org.spongepowered.api.event.entity.ChangeEntityExperienceEvent;
import org.spongepowered.api.event.entity.TargetEntityEvent;
import org.spongepowered.api.item.ItemTypes;
import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
/**
* An event when a "fishing" action is performed. Always involves a
* {@link FishHook}.
*/
public interface FishingEvent extends Event {
/**
* Gets the original {@link FishHook}, as a {@link EntitySnapshot}.
* @return The original fish hook
*/
EntitySnapshot getOriginalFishHook();
/**
* Gets the {@link FishHook} related with this event.
*
* @return The fish hook
*/
FishHook getFishHook();
/**
* An event where the {@link FishHook} is cast.
*
* <p>This is fired before the {@link FishHook} has been spawned in the world.</p>
*/
interface Start extends FishingEvent, Cancellable {}
/**
* Fired when an {@link org.spongepowered.api.entity.Entity} is hooked.
*
* <p>{@link CollideBlockEvent} is fired when a {@link FishHook}
* becomes stuck in a block. This may be called multiple times
* before {@link Stop} is fired, such as in the case where
* the block the {@link FishHook} is stuck in is broken.</p>
*/
interface HookEntity extends FishingEvent, TargetEntityEvent, Cancellable {}
/**
* A specific {@link FishingEvent} where the {@link FishHook} is retracted
* or "reeled in".
*
* <p>If the {@link FishHook} was cast into water, an {@link ItemStack} may
* be hooken when it is retracted. If the event is not cancelled, Vanilla
* will send the @link ItemStackby spawning an {@link Item}, and sending it
* moving towards the player.
*
* If the {@link FishHook} has an entity hooked, Vanilla will pull
* the hooked entity towards the caster, if the event is not cancelled.</p>
*
* <p>In Vanilla, {@link Transaction#getOriginal() the original {@link ItemStack}}
* will usually be a {@link Fish}, or miscellaneous item.</p>
*/
interface Stop extends FishingEvent, ChangeEntityExperienceEvent, Cancellable {
/**
* Gets the {@link Transaction} that is the transaction
* involving the {@link ItemStack}, If you wish to
* change the itemstack result, use {@link Transaction#setCustom(DataSerializable)}
*
* <p>The special item type {@link ItemTypes#NONE} is used to represent
* no item being caught,</p>
*
* @return The itemstack transaction
*/
Transaction<ItemStackSnapshot> getItemStackTransaction();
}
}