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
|
2016-05-19 01:47:25 +02:00
|
|
|
* <p>
|
2014-09-24 14:32:58 +02:00
|
|
|
* Contributors:
|
2016-05-19 01:47:25 +02:00
|
|
|
* cpw - initial API and implementation
|
2014-09-24 14:32:58 +02:00
|
|
|
******************************************************************************/
|
|
|
|
|
package cpw.mods.ironchest.client;
|
|
|
|
|
|
2016-05-19 01:47:25 +02:00
|
|
|
import cpw.mods.ironchest.ChestChangerType;
|
2016-03-21 17:44:27 +01:00
|
|
|
import cpw.mods.ironchest.CommonProxy;
|
|
|
|
|
import cpw.mods.ironchest.IronChest;
|
|
|
|
|
import cpw.mods.ironchest.IronChestType;
|
|
|
|
|
import cpw.mods.ironchest.TileEntityIronChest;
|
|
|
|
|
import net.minecraft.client.renderer.block.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;
|
2016-03-21 17:44:27 +01:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
2014-09-24 14:32:58 +02:00
|
|
|
import net.minecraft.world.World;
|
2016-05-19 01:47:25 +02:00
|
|
|
import net.minecraftforge.client.model.ModelLoader;
|
2014-09-24 14:32:58 +02:00
|
|
|
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
2016-05-19 01:47:25 +02:00
|
|
|
import net.minecraftforge.fml.common.FMLCommonHandler;
|
|
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2014-09-24 14:32:58 +02:00
|
|
|
|
2016-05-19 01:47:25 +02:00
|
|
|
@SideOnly(Side.CLIENT)
|
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
|
|
|
{
|
2016-05-19 01:47:25 +02:00
|
|
|
Item chestItem = Item.getItemFromBlock(IronChest.ironChestBlock);
|
2015-05-27 23:17:59 +02:00
|
|
|
|
2016-05-19 01:47:25 +02:00
|
|
|
for (IronChestType type : IronChestType.values())
|
2014-09-27 03:31:58 +02:00
|
|
|
{
|
2016-05-19 01:47:25 +02:00
|
|
|
if (type != IronChestType.WOOD)
|
2014-09-27 03:31:58 +02:00
|
|
|
{
|
2016-05-19 01:47:25 +02:00
|
|
|
ModelLoader.setCustomModelResourceLocation(chestItem, type.ordinal(),
|
|
|
|
|
new ModelResourceLocation(new ResourceLocation(IronChest.MOD_ID, "chest_" + type.getName()), "inventory"));
|
2014-09-27 03:31:58 +02:00
|
|
|
}
|
2014-09-24 14:32:58 +02:00
|
|
|
|
2016-05-19 01:47:25 +02:00
|
|
|
ClientRegistry.bindTileEntitySpecialRenderer(type.clazz, new TileEntityIronChestRenderer());
|
|
|
|
|
}
|
2014-09-24 14:32:58 +02:00
|
|
|
|
2016-05-19 01:47:25 +02:00
|
|
|
for (ChestChangerType type : ChestChangerType.VALUES)
|
|
|
|
|
{
|
|
|
|
|
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT)
|
|
|
|
|
{
|
|
|
|
|
ModelLoader.setCustomModelResourceLocation(type.item, 0,
|
|
|
|
|
new ModelResourceLocation(new ResourceLocation(IronChest.MOD_ID, type.itemName), "inventory"));
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-09-24 14:32:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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);
|
2016-03-21 17:44:27 +01:00
|
|
|
}
|
|
|
|
|
else
|
2014-09-24 14:32:58 +02:00
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|