mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-26 09:38:08 -05:00
Add ItemConvertible overload for BuiltinItemRendererRegistry (#955)
Closes #953.
This commit is contained in:
parent
54fedaeb9b
commit
fc24ff24ef
3 changed files with 21 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
archivesBaseName = "fabric-rendering-v1"
|
||||
version = getSubprojectVersion(project, "1.1.2")
|
||||
version = getSubprojectVersion(project, "1.2.0")
|
||||
|
||||
dependencies {
|
||||
compile project(path: ':fabric-api-base', configuration: 'dev')
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package net.fabricmc.fabric.api.client.rendering.v1;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemConvertible;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
@ -44,4 +45,16 @@ public interface BuiltinItemRendererRegistry {
|
|||
* @throws NullPointerException if either the item or the renderer is null
|
||||
*/
|
||||
void register(Item item, BuiltinItemRenderer renderer);
|
||||
|
||||
/**
|
||||
* Registers the renderer for the item.
|
||||
*
|
||||
* <p>Note that the item's JSON model must also extend {@code minecraft:builtin/entity}.
|
||||
*
|
||||
* @param item the item
|
||||
* @param renderer the renderer
|
||||
* @throws IllegalArgumentException if the item already has a registered renderer
|
||||
* @throws NullPointerException if either the item or the renderer is null
|
||||
*/
|
||||
void register(ItemConvertible item, BuiltinItemRenderer renderer);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.Map;
|
|||
import java.util.Objects;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemConvertible;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
|
@ -49,6 +50,12 @@ public final class BuiltinItemRendererRegistryImpl implements BuiltinItemRendere
|
|||
RENDERERS.put(item, renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(ItemConvertible item, BuiltinItemRenderer renderer) {
|
||||
Objects.requireNonNull(item, "item is null");
|
||||
register(item.asItem(), renderer);
|
||||
}
|
||||
|
||||
/* @Nullable */
|
||||
public static BuiltinItemRenderer getRenderer(Item item) {
|
||||
return RENDERERS.get(item);
|
||||
|
|
Loading…
Reference in a new issue