|
| 1 | +package net.ornithemc.osl.blockentities.api.client; |
| 2 | + |
| 3 | +import java.util.function.Supplier; |
| 4 | + |
| 5 | +import net.minecraft.block.entity.BlockEntity; |
| 6 | +import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher; |
| 7 | +import net.minecraft.client.render.block.entity.BlockEntityRenderer; |
| 8 | + |
| 9 | +/** |
| 10 | + * A wrapper around the {@linkplain BlockEntityRenderDispatcher} renderers map. |
| 11 | + */ |
| 12 | +@FunctionalInterface |
| 13 | +public interface BlockEntityRendererRegistry { |
| 14 | + |
| 15 | + /** |
| 16 | + * Registers the given block entity renderer for the given block entity type. |
| 17 | + * |
| 18 | + * @param <T> the block entity type for which to register the renderer. |
| 19 | + * @param type the block entity type class. |
| 20 | + * @param factory the factory for the block entity renderer to register. |
| 21 | + */ |
| 22 | + <T extends BlockEntity> void register(Class<T> type, Supplier<BlockEntityRenderer<? super T>> factory); |
| 23 | + |
| 24 | + /** |
| 25 | + * Registers the given block entity renderer for the given block entity type. |
| 26 | + * <p> |
| 27 | + * NOTE: this method only exists because generic type signatures are stripped |
| 28 | + * from all Minecraft jars from 1.8.2-pre4 and below, which makes using |
| 29 | + * {@linkplain #register(Class, Supplier)} impossible without special patches to |
| 30 | + * bring these generic type signatures back. Progress on this work is being |
| 31 | + * made, but has not yet been completed. In the meantime, this method exists to |
| 32 | + * allow block entity renderers to be registered without compile time type |
| 33 | + * safety checks. |
| 34 | + * |
| 35 | + * @param <T> the block entity type for which to register the renderer. |
| 36 | + * @param type the block entity type class. |
| 37 | + * @param factory the factory for the block entity renderer to register. |
| 38 | + * |
| 39 | + * @deprecated use {@linkplain #register(Class, Supplier)} if possible |
| 40 | + */ |
| 41 | + @SuppressWarnings({ "unchecked", "rawtypes" }) |
| 42 | + @Deprecated |
| 43 | + default <T extends BlockEntity> void registerUnsafe(Class<T> type, Supplier<BlockEntityRenderer> factory) { |
| 44 | + this.register(type, (Supplier) factory); |
| 45 | + } |
| 46 | +} |
0 commit comments