Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit 087c16c

Browse files
committed
Entity rendering registry
1 parent 9457fe7 commit 087c16c

2 files changed

Lines changed: 68 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Minecraft Forge, Patchwork Project
3+
* Copyright (c) 2016-2020, 2019-2020
4+
*
5+
* This library is free software; you can redistribute it and/or
6+
* modify it under the terms of the GNU Lesser General Public
7+
* License as published by the Free Software Foundation version 2.1
8+
* of the License.
9+
*
10+
* This library is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this library; if not, write to the Free Software
17+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
package net.minecraftforge.fml.client.registry;
21+
22+
import net.minecraft.client.render.entity.EntityRenderer;
23+
import net.minecraft.client.render.entity.EntityRenderDispatcher;
24+
import net.minecraft.entity.Entity;
25+
26+
public interface IRenderFactory<T extends Entity> {
27+
EntityRenderer<? super T> createRenderFor(EntityRenderDispatcher manager);
28+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Minecraft Forge, Patchwork Project
3+
* Copyright (c) 2016-2020, 2019-2020
4+
*
5+
* This library is free software; you can redistribute it and/or
6+
* modify it under the terms of the GNU Lesser General Public
7+
* License as published by the Free Software Foundation version 2.1
8+
* of the License.
9+
*
10+
* This library is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this library; if not, write to the Free Software
17+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
package net.minecraftforge.fml.client.registry;
21+
22+
import net.minecraft.client.render.entity.EntityRenderDispatcher;
23+
import net.minecraft.entity.Entity;
24+
25+
import net.fabricmc.fabric.api.client.render.EntityRendererRegistry;
26+
27+
public class RenderingRegistry {
28+
/**
29+
* Register an entity rendering handler. This will, after mod initialization, be inserted into the main
30+
* render map for entities.
31+
* Call this during {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}.
32+
* This method is safe to call during parallel mod loading.
33+
*/
34+
public static <T extends Entity> void registerEntityRenderingHandler(Class<T> entityClass, IRenderFactory<? super T> renderFactory) {
35+
EntityRendererRegistry.INSTANCE.register(entityClass, (dispatcher, context) -> renderFactory.createRenderFor(dispatcher));
36+
}
37+
38+
// This is here just in case a mod calls it, entity renderers are loaded by the Fabric API
39+
public static void loadEntityRenderers(EntityRenderDispatcher manager) { }
40+
}

0 commit comments

Comments
 (0)