2013-03-08 00:25:48 +00:00
|
|
|
/*
|
2016-06-23 03:49:47 +00:00
|
|
|
* Minecraft Forge
|
2018-07-01 21:17:28 +00:00
|
|
|
* Copyright (c) 2016-2018.
|
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
|
|
|
|
2016-02-12 21:48:51 +00:00
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
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;
|
2012-12-09 04:21:03 +00:00
|
|
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
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;
|
2014-09-23 05:01:24 +00:00
|
|
|
import net.minecraftforge.fml.common.registry.GameRegistry;
|
2012-08-02 04:38:30 +00:00
|
|
|
|
2016-02-12 21:48:51 +00:00
|
|
|
import java.util.Map;
|
|
|
|
|
2012-08-02 04:38:30 +00:00
|
|
|
public class ClientRegistry
|
|
|
|
{
|
2016-02-12 21:48:51 +00:00
|
|
|
private static Map<Class<? extends Entity>, ResourceLocation> entityShaderMap = Maps.newHashMap();
|
|
|
|
|
2012-08-02 04:38:30 +00:00
|
|
|
/**
|
2013-11-10 16:49:06 +00:00
|
|
|
*
|
2012-08-02 04:38:30 +00:00
|
|
|
* Utility method for registering a tile entity and it's renderer at once - generally you should register them separately
|
2013-11-10 16:49:06 +00:00
|
|
|
*
|
2012-08-02 04:38:30 +00:00
|
|
|
* @param tileEntityClass
|
|
|
|
* @param id
|
|
|
|
* @param specialRenderer
|
|
|
|
*/
|
2015-12-31 23:01:03 +00:00
|
|
|
public static <T extends TileEntity> void registerTileEntity(Class<T> tileEntityClass, String id, TileEntitySpecialRenderer<? super T> specialRenderer)
|
2012-08-02 04:38:30 +00:00
|
|
|
{
|
|
|
|
GameRegistry.registerTileEntity(tileEntityClass, id);
|
|
|
|
bindTileEntitySpecialRenderer(tileEntityClass, specialRenderer);
|
|
|
|
}
|
2013-11-10 16:49:06 +00:00
|
|
|
|
2015-12-31 23:01:03 +00:00
|
|
|
public static <T extends TileEntity> void bindTileEntitySpecialRenderer(Class<T> tileEntityClass, TileEntitySpecialRenderer<? super T> specialRenderer)
|
2012-08-02 04:38:30 +00:00
|
|
|
{
|
2017-06-18 01:06:04 +00:00
|
|
|
TileEntityRendererDispatcher.instance.renderers.put(tileEntityClass, specialRenderer);
|
2014-09-30 09:20:56 +00:00
|
|
|
specialRenderer.setRendererDispatcher(TileEntityRendererDispatcher.instance);
|
2012-08-02 04:38:30 +00:00
|
|
|
}
|
2013-12-17 04:18:00 +00:00
|
|
|
|
|
|
|
public static void registerKeyBinding(KeyBinding key)
|
|
|
|
{
|
2014-03-19 07:15:53 +00:00
|
|
|
Minecraft.getMinecraft().gameSettings.keyBindings = ArrayUtils.add(Minecraft.getMinecraft().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.
|
2016-02-12 21:48:51 +00:00
|
|
|
*
|
|
|
|
* @param entityClass
|
|
|
|
* @param shader
|
|
|
|
*/
|
|
|
|
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
|
|
|
}
|