2014-09-24 14:32:58 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
|
* Copyright (c) 2012 cpw.
|
|
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
|
* are made available under the terms of the GNU Public License v3.0
|
|
|
|
|
* which accompanies this distribution, and is available at
|
|
|
|
|
* http://www.gnu.org/licenses/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* Contributors:
|
|
|
|
|
* cpw - initial API and implementation
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
package cpw.mods.ironchest.client;
|
|
|
|
|
|
2015-05-27 23:17:59 +02:00
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
|
import net.minecraft.client.renderer.ItemModelMesher;
|
|
|
|
|
import net.minecraft.client.resources.model.ModelBakery;
|
|
|
|
|
import net.minecraft.client.resources.model.ModelResourceLocation;
|
2014-09-24 14:32:58 +02:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2015-05-27 23:17:59 +02:00
|
|
|
import net.minecraft.item.Item;
|
2014-09-24 14:32:58 +02:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
|
import net.minecraft.util.BlockPos;
|
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
import net.minecraftforge.fml.client.FMLClientHandler;
|
|
|
|
|
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
|
|
|
|
import cpw.mods.ironchest.CommonProxy;
|
2014-09-27 03:31:58 +02:00
|
|
|
import cpw.mods.ironchest.IronChest;
|
2014-09-24 14:32:58 +02:00
|
|
|
import cpw.mods.ironchest.IronChestType;
|
|
|
|
|
import cpw.mods.ironchest.TileEntityIronChest;
|
|
|
|
|
|
2015-05-27 23:17:59 +02:00
|
|
|
public class ClientProxy extends CommonProxy
|
2014-09-25 04:40:29 +02:00
|
|
|
{
|
2014-09-24 14:32:58 +02:00
|
|
|
@Override
|
|
|
|
|
public void registerRenderInformation()
|
2015-05-27 23:17:59 +02:00
|
|
|
{
|
|
|
|
|
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager().getBlockModelShapes().registerBuiltInBlocks(IronChest.ironChestBlock);
|
|
|
|
|
|
|
|
|
|
ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
|
2014-09-27 03:31:58 +02:00
|
|
|
for (IronChestType chestType : IronChestType.values())
|
|
|
|
|
{
|
|
|
|
|
if (chestType != IronChestType.WOOD)
|
|
|
|
|
{
|
2015-05-27 23:17:59 +02:00
|
|
|
Item chestItem = Item.getItemFromBlock(IronChest.ironChestBlock);
|
|
|
|
|
mesher.register(chestItem, chestType.ordinal(), new ModelResourceLocation("ironchest:chest_" + chestType.getName().toLowerCase(), "inventory"));
|
|
|
|
|
ModelBakery.addVariantName(chestItem, "ironchest:chest_" + chestType.getName().toLowerCase());
|
2014-09-27 03:31:58 +02:00
|
|
|
}
|
|
|
|
|
}
|
2014-09-24 14:32:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void registerTileEntitySpecialRenderer(IronChestType typ)
|
|
|
|
|
{
|
2014-09-26 04:45:55 +02:00
|
|
|
ClientRegistry.bindTileEntitySpecialRenderer(typ.clazz, new TileEntityIronChestRenderer());
|
2014-09-24 14:32:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public World getClientWorld()
|
|
|
|
|
{
|
|
|
|
|
return FMLClientHandler.instance().getClient().theWorld;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
|
|
|
|
{
|
|
|
|
|
TileEntity te = world.getTileEntity(new BlockPos(x, y, z));
|
|
|
|
|
if (te != null && te instanceof TileEntityIronChest)
|
|
|
|
|
{
|
|
|
|
|
return GUIChest.GUI.buildGUI(IronChestType.values()[ID], player.inventory, (TileEntityIronChest) te);
|
2015-05-27 23:17:59 +02:00
|
|
|
} else
|
2014-09-24 14:32:58 +02:00
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|