|
4 | 4 | import net.minecraft.component.type.*;
|
5 | 5 | import net.minecraft.enchantment.*;
|
6 | 6 | import net.minecraft.item.*;
|
| 7 | +import net.minecraft.loot.*; |
7 | 8 | import net.minecraft.registry.*;
|
8 | 9 | import net.minecraft.registry.entry.*;
|
9 | 10 | import net.minecraft.util.*;
|
10 |
| -import net.minecraft.world.*; |
11 |
| - |
12 |
| -import java.util.*; |
13 | 11 |
|
14 | 12 | public class GoFishCompat {
|
15 | 13 |
|
16 |
| - public static final Identifier DEFAULT_CRATES_LOOT_TABLE_ID = Identifier.of("gofish", "gameplay/fishing/crates"); |
17 |
| - public static final Identifier NETHER_CRATES_LOOT_TABLE_ID = Identifier.of("gofish", "gameplay/fishing/nether/crates"); |
18 |
| - public static final Identifier END_CRATES_LOOT_TABLE_ID = Identifier.of("gofish", "gameplay/fishing/end/crates"); |
| 14 | + public static final String MOD_ID = "go-fish"; |
| 15 | + public static final String NAMESPACE = "gofish"; |
| 16 | + |
| 17 | + public static final RegistryKey<LootTable> DEFAULT_CRATES_LOOT_TABLE_ID = lootTableKey("gameplay/fishing/crates"); |
| 18 | + public static final RegistryKey<LootTable> NETHER_CRATES_LOOT_TABLE_ID = lootTableKey("gameplay/fishing/nether/crates"); |
| 19 | + public static final RegistryKey<LootTable> END_CRATES_LOOT_TABLE_ID = lootTableKey("gameplay/fishing/end/crates"); |
| 20 | + |
| 21 | + public static final RegistryKey<LootTable> NETHER_FISH_LOOT_TABLE_ID = lootTableKey("gameplay/fishing/nether/fish"); |
| 22 | + public static final RegistryKey<LootTable> END_FISH_LOOT_TABLE_ID = lootTableKey("gameplay/fishing/end/fish"); |
19 | 23 |
|
20 |
| - public static final Identifier NETHER_FISH_LOOT_TABLE_ID = Identifier.of("gofish", "gameplay/fishing/nether/fish"); |
21 |
| - public static final Identifier END_FISH_LOOT_TABLE_ID = Identifier.of("gofish", "gameplay/fishing/end/fish"); |
| 24 | + public static final RegistryKey<Enchantment> DEEPFRY_ENCHANTMENT_ID = RegistryKey.of(RegistryKeys.ENCHANTMENT, Identifier.of(NAMESPACE, "deepfry")); |
22 | 25 |
|
23 |
| - public static final Identifier DEEPFRY_ENCHANTMENT_ID = Identifier.of("gofish", "deepfry"); |
| 26 | + public static RegistryKey<LootTable> lootTableKey(String id) { |
| 27 | + return RegistryKey.of(RegistryKeys.LOOT_TABLE, Identifier.of(NAMESPACE, id)); |
| 28 | + } |
24 | 29 |
|
25 | 30 | public static boolean isLoaded() {
|
26 |
| - return FabricLoader.getInstance().isModLoaded("go-fish"); |
| 31 | + return FabricLoader.getInstance().isModLoaded(MOD_ID); |
27 | 32 | }
|
28 | 33 |
|
29 |
| - public static boolean hasDeepfry(World world, ItemStack itemStack) { |
| 34 | + public static boolean hasDeepfry(ItemStack itemStack) { |
30 | 35 | if (!isLoaded()) {
|
31 | 36 | return false;
|
32 | 37 | }
|
33 | 38 |
|
34 | 39 | ItemEnchantmentsComponent enchantments = itemStack.getEnchantments();
|
35 | 40 | for (RegistryEntry<Enchantment> enchantment : enchantments.getEnchantments()) {
|
36 |
| - if (isDeepfry(world, enchantment)) { |
| 41 | + if (enchantment.matchesKey(DEEPFRY_ENCHANTMENT_ID)) { |
37 | 42 | return true;
|
38 | 43 | }
|
39 | 44 | }
|
40 | 45 | return false;
|
41 | 46 | }
|
42 | 47 |
|
43 |
| - public static boolean isDeepfry(World world, RegistryEntry<Enchantment> enchantment) { |
44 |
| - Identifier id = world.getRegistryManager().get(RegistryKeys.ENCHANTMENT).getId(enchantment.value()); |
45 |
| - return id != null && id.equals(GoFishCompat.DEEPFRY_ENCHANTMENT_ID); |
46 |
| - } |
47 |
| - |
48 | 48 | }
|
0 commit comments