-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed item search using wrong cache keys, added render-icons query pa…
…ram, custom item name providers
- Loading branch information
1 parent
5162282
commit 622bdad
Showing
8 changed files
with
292 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/dev/latvian/mods/kubejs/util/NameProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package dev.latvian.mods.kubejs.util; | ||
|
||
import net.minecraft.core.RegistryAccess; | ||
import net.minecraft.network.chat.Component; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.function.Consumer; | ||
|
||
public interface NameProvider<T> { | ||
interface Registry<K, T> { | ||
void register(K key, NameProvider<T> provider); | ||
|
||
default void register(List<K> keys, NameProvider<T> provider) { | ||
for (var key : keys) { | ||
register(key, provider); | ||
} | ||
} | ||
} | ||
|
||
static <K, T> Map<K, NameProvider<T>> create(Consumer<Registry<K, T>> registry) { | ||
var map = new HashMap<K, NameProvider<T>>(); | ||
registry.accept(map::put); | ||
return map; | ||
} | ||
|
||
@Nullable | ||
Component getName(RegistryAccess registries, T value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.