Advertisement
HalestormXV

GuiHandlerFinal

Mar 21st, 2016
87
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.halestormxv.guihandler;
  2.  
  3. import com.halestormxv.blocks.CelestialCraft_blocks;
  4. import com.halestormxv.gui.GuiCelestialForge;
  5. import com.halestormxv.gui.GuiCelestialFurnace;
  6. import com.halestormxv.gui.GuiCelestialKeyPouch;
  7. import com.halestormxv.inventory.ContainerCelestialForge;
  8. import com.halestormxv.inventory.ContainerCelestialFurnace;
  9. import com.halestormxv.inventory.ContainerCelestialKeypouch;
  10. import com.halestormxv.inventory.InventoryKeyPouch;
  11. import com.halestormxv.item.CelestialCraft_items;
  12. import com.halestormxv.item.keyPouch;
  13. import com.halestormxv.tile_entity.TileEntityCelestialFurnace;
  14.  
  15. import cpw.mods.fml.common.network.IGuiHandler;
  16. import net.minecraft.entity.player.EntityPlayer;
  17. import net.minecraft.item.ItemStack;
  18. import net.minecraft.tileentity.TileEntity;
  19. import net.minecraft.world.World;
  20.  
  21. public class CCGuiHandler implements IGuiHandler {
  22.  
  23.     @Override
  24.     public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
  25.         TileEntity entity = world.getTileEntity(x, y, z);
  26.         if(entity != null){
  27.             switch(ID){
  28.             case CelestialCraft_blocks.guiIDCelestialFurnace:
  29.                 if (entity instanceof TileEntityCelestialFurnace){
  30.                     return new ContainerCelestialFurnace(player.inventory, (TileEntityCelestialFurnace) entity);
  31.                 }
  32.                 return null;       
  33.             }
  34.         }
  35.  
  36.         if(ID == CelestialCraft_blocks.guiIDCelestialForge)
  37.         {
  38.             return ID == CelestialCraft_blocks.guiIDCelestialForge && world.getBlock(x, y, z) == CelestialCraft_blocks.blockCelestialForge ? new ContainerCelestialForge(player.inventory, world, x, y, z) : null;
  39.         }
  40.        
  41.         if(ID == CelestialCraft_items.guiIDKeyPouch)
  42.         {
  43.             ItemStack stack = player.inventory.getStackInSlot(x);
  44.             if (stack != null)
  45.             {
  46.             return new ContainerCelestialKeypouch(player, player.inventory, new InventoryKeyPouch(stack));
  47.             }else{
  48.             return new ContainerCelestialKeypouch(player, player.inventory, new InventoryKeyPouch(player.getHeldItem()));
  49.             }
  50.         }
  51.         return null;
  52.     }  
  53.  
  54.     @Override
  55.     public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
  56.         TileEntity entity = world.getTileEntity(x, y, z);
  57.         if(entity != null){
  58.             switch(ID){
  59.             case CelestialCraft_blocks.guiIDCelestialFurnace:
  60.                 if (entity instanceof TileEntityCelestialFurnace){
  61.                     return new GuiCelestialFurnace(player.inventory, (TileEntityCelestialFurnace) entity);
  62.                 }
  63.                 return null;       
  64.             }
  65.         }
  66.  
  67.         if(ID == CelestialCraft_blocks.guiIDCelestialForge)
  68.         {
  69.             return ID == CelestialCraft_blocks.guiIDCelestialForge && world.getBlock(x, y, z) == CelestialCraft_blocks.blockCelestialForge ? new GuiCelestialForge(player.inventory, world, x, y, z) : null;
  70.         }
  71.        
  72.         if(ID == CelestialCraft_items.guiIDKeyPouch)
  73.         {
  74.             ItemStack stack = player.inventory.getStackInSlot(x);
  75.             if (stack != null)
  76.             {
  77.             return new GuiCelestialKeyPouch((ContainerCelestialKeypouch) new ContainerCelestialKeypouch(player, player.inventory, new InventoryKeyPouch(stack)));
  78.             }else{
  79.             return new GuiCelestialKeyPouch((ContainerCelestialKeypouch) new ContainerCelestialKeypouch(player, player.inventory, new InventoryKeyPouch(player.getHeldItem())));
  80.             }  
  81.         }
  82.         return null;
  83.     }
  84.  
  85. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement