2013-03-08 00:25:48 +00:00
|
|
|
/*
|
2016-06-23 03:49:47 +00:00
|
|
|
* Minecraft Forge
|
2019-02-10 22:57:03 +00:00
|
|
|
* Copyright (c) 2016-2019.
|
2013-11-10 16:49:06 +00:00
|
|
|
*
|
2016-06-23 03:49:47 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation version 2.1
|
|
|
|
* of the License.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2013-03-08 00:25:48 +00:00
|
|
|
*/
|
|
|
|
|
2014-09-23 05:01:24 +00:00
|
|
|
package net.minecraftforge.fml.client.registry;
|
2012-08-02 04:38:30 +00:00
|
|
|
|
2018-08-27 17:10:07 +00:00
|
|
|
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
2016-02-12 21:48:51 +00:00
|
|
|
import net.minecraft.entity.Entity;
|
2019-12-11 02:27:07 +00:00
|
|
|
import net.minecraft.tileentity.TileEntityType;
|
2016-02-12 21:48:51 +00:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
2013-12-17 04:18:00 +00:00
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
|
|
|
|
|
|
import net.minecraft.client.Minecraft;
|
2013-12-03 04:46:42 +00:00
|
|
|
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
2013-12-17 04:18:00 +00:00
|
|
|
import net.minecraft.client.settings.KeyBinding;
|
2012-12-09 04:21:03 +00:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2012-08-02 04:38:30 +00:00
|
|
|
|
2016-02-12 21:48:51 +00:00
|
|
|
import java.util.Map;
|
2019-01-25 21:14:49 +00:00
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
2019-12-27 21:30:16 +00:00
|
|
|
import java.util.function.Function;
|
2016-02-12 21:48:51 +00:00
|
|
|
|
2012-08-02 04:38:30 +00:00
|
|
|
public class ClientRegistry
|
|
|
|
{
|
2019-01-25 21:14:49 +00:00
|
|
|
private static Map<Class<? extends Entity>, ResourceLocation> entityShaderMap = new ConcurrentHashMap<>();
|
2016-02-12 21:48:51 +00:00
|
|
|
|
2012-08-02 04:38:30 +00:00
|
|
|
/**
|
2019-01-25 21:14:49 +00:00
|
|
|
* Registers a Tile Entity renderer.
|
|
|
|
* Call this during {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}.
|
|
|
|
* This method is safe to call during parallel mod loading.
|
|
|
|
*/
|
2019-12-29 16:16:27 +00:00
|
|
|
public static synchronized <T extends TileEntity> void bindTileEntityRenderer(TileEntityType<T> tileEntityType,
|
|
|
|
Function<? super TileEntityRendererDispatcher, ? extends TileEntityRenderer<? super T>> rendererFactory)
|
2012-08-02 04:38:30 +00:00
|
|
|
{
|
2019-12-27 21:30:16 +00:00
|
|
|
TileEntityRendererDispatcher.instance.setSpecialRendererInternal(tileEntityType, rendererFactory.apply(TileEntityRendererDispatcher.instance));
|
2012-08-02 04:38:30 +00:00
|
|
|
}
|
2013-12-17 04:18:00 +00:00
|
|
|
|
2019-01-25 21:14:49 +00:00
|
|
|
/**
|
|
|
|
* Registers a KeyBinding.
|
|
|
|
* Call this during {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}.
|
|
|
|
* This method is safe to call during parallel mod loading.
|
|
|
|
*/
|
|
|
|
public static synchronized void registerKeyBinding(KeyBinding key)
|
2013-12-17 04:18:00 +00:00
|
|
|
{
|
2018-09-22 10:40:22 +00:00
|
|
|
Minecraft.getInstance().gameSettings.keyBindings = ArrayUtils.add(Minecraft.getInstance().gameSettings.keyBindings, key);
|
2013-12-17 04:18:00 +00:00
|
|
|
}
|
2016-02-12 21:48:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Register a shader for an entity. This shader gets activated when a spectator begins spectating an entity.
|
2016-03-23 14:34:48 +00:00
|
|
|
* Vanilla examples of this are the green effect for creepers and the invert effect for endermen.
|
2019-01-25 21:14:49 +00:00
|
|
|
* Call this during {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}.
|
|
|
|
* This method is safe to call during parallel mod loading.
|
2016-02-12 21:48:51 +00:00
|
|
|
*/
|
|
|
|
public static void registerEntityShader(Class<? extends Entity> entityClass, ResourceLocation shader)
|
|
|
|
{
|
|
|
|
entityShaderMap.put(entityClass, shader);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static ResourceLocation getEntityShader(Class<? extends Entity> entityClass)
|
|
|
|
{
|
|
|
|
return entityShaderMap.get(entityClass);
|
|
|
|
}
|
2012-08-02 04:38:30 +00:00
|
|
|
}
|