-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathAlmostUnifiedLookup.java
106 lines (89 loc) · 3.13 KB
/
AlmostUnifiedLookup.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
package com.almostreliable.unified.api;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.ItemLike;
import javax.annotation.Nullable;
import java.util.ServiceLoader;
import java.util.Set;
public interface AlmostUnifiedLookup {
AlmostUnifiedLookup INSTANCE = ServiceLoader.load(AlmostUnifiedLookup.class).findFirst().orElseGet(Empty::new);
boolean isLoaded();
/**
* Returns the replacement item for a given {@link ItemLike}. Will return null if no configured
* tag exists that includes the item.
* <p>
* If the item is part of some stone strata, it will only check items within the same stone strata.<br>
* => e.g. "modid:deepslate_foo_ore" would not return "prio_modid:foo_ore".
*
* @param itemLike The item-like to find the replacement for
* @return The replacement item or null if there is no replacement
*/
@Nullable
Item getReplacementForItem(ItemLike itemLike);
/**
* Returns the preferred item for a given {@link TagKey}. Will return null if no configured
* tag exists that includes the item.
* <p>
* The preferred item is selected according to mod priorities, but it's possible to set a
* fixed override in the config.
*
* @param tag The tag to find the preferred item for
* @return The preferred item or null if there is no preferred item
*/
@Nullable
Item getPreferredItemForTag(TagKey<Item> tag);
/**
* Returns the preferred tag for a given {@link ItemLike} Will return null if no configured
* tag exists that includes the item.
*
* @param itemLike The item-like to find the preferred tag for
* @return The preferred tag or null if there is no preferred tag
*/
@Nullable
TagKey<Item> getPreferredTagForItem(ItemLike itemLike);
/**
* Returns all potential items which are part of a given tag.
* <p>
* Tags are only considered if they are part of the config,
* otherwise, an empty set is always returned.
*
* @param tag The tag to find the potential items for
* @return The potential items or an empty set if there are no potential items
*/
Set<Item> getPotentialItems(TagKey<Item> tag);
/**
* Returns all configured tags.
*
* @return The configured tags
*/
Set<TagKey<Item>> getConfiguredTags();
class Empty implements AlmostUnifiedLookup {
@Override
public boolean isLoaded() {
return false;
}
@Nullable
@Override
public Item getReplacementForItem(ItemLike itemLike) {
return null;
}
@Nullable
@Override
public Item getPreferredItemForTag(TagKey<Item> tag) {
return null;
}
@Nullable
@Override
public TagKey<Item> getPreferredTagForItem(ItemLike itemLike) {
return null;
}
@Override
public Set<Item> getPotentialItems(TagKey<Item> tag) {
return Set.of();
}
@Override
public Set<TagKey<Item>> getConfiguredTags() {
return Set.of();
}
}
}