forked from desht/ModularRouters
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddModuleTargetEvent.java
61 lines (53 loc) · 1.58 KB
/
AddModuleTargetEvent.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
package me.desht.modularrouters.api.event;
import me.desht.modularrouters.item.module.ModuleItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.UseOnContext;
import net.neoforged.bus.api.Event;
import org.jetbrains.annotations.ApiStatus;
/**
* Event fired when a player attempts to add a new target to a module.
* <p>
* This event can be used to allow a module to target blocks it otherwise couldn't in conjunction with {@link ExecuteModuleEvent}.
*/
public final class AddModuleTargetEvent extends Event {
private final ModuleItem item;
private final UseOnContext context;
private boolean valid;
@ApiStatus.Internal
public AddModuleTargetEvent(ModuleItem item, UseOnContext context, boolean valid) {
this.item = item;
this.context = context;
this.valid = valid;
}
/**
* {@return the module type}
*/
public ModuleItem getModuleType() {
return item;
}
/**
* {@return the module stack}
*/
public ItemStack getModule() {
return context.getItemInHand();
}
/**
* {@return the context of the interaction}
*/
public UseOnContext getContext() {
return context;
}
/**
* {@return whether the targeted block is valid and may be selected}
*/
public boolean isValid() {
return valid;
}
/**
* Making the target {@code valid} allows the player to select the block and the router to process it.
* @see ExecuteModuleEvent
*/
public void setValid(boolean valid) {
this.valid = valid;
}
}