Advertisement
Guest User

GuiHandler

a guest
Feb 21st, 2015
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.44 KB | None | 0 0
  1. package com.chef.mod.handler;
  2.  
  3. import com.chef.mod.container.ContainerCookingFurnace;
  4. import com.chef.mod.gui.GuiCookingFurnace;
  5. import com.chef.mod.init.MyBlocks;
  6. import com.chef.mod.tileentity.TileEntityCookingFurnace;
  7.  
  8. import net.minecraft.entity.player.EntityPlayer;
  9. import net.minecraft.tileentity.TileEntity;
  10. import net.minecraft.util.BlockPos;
  11. import net.minecraft.world.World;
  12. import net.minecraftforge.fml.common.network.IGuiHandler;
  13.  
  14. public class GuiHandler implements IGuiHandler {
  15.  
  16.     @Override
  17.     public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
  18.         TileEntity entity = world.getTileEntity(new BlockPos(x, y, z));
  19.        
  20.         if(entity != null) {
  21.             switch(ID) {
  22.             case MyBlocks.guiID_cooking_furnace:
  23.                 if(entity instanceof TileEntityCookingFurnace) {
  24.                     return new ContainerCookingFurnace(player.inventory, (TileEntityCookingFurnace) entity);
  25.                 }
  26.                 return null;
  27.             }
  28.         }
  29.         return null;
  30.     }
  31.  
  32.     @Override
  33.     public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
  34.         TileEntity entity = world.getTileEntity(new BlockPos(x, y, z));
  35.        
  36.         if(entity != null) {
  37.             switch(ID) {
  38.            
  39.             //Cooking Furnace
  40.             case MyBlocks.guiID_cooking_furnace:
  41.                 if(entity instanceof TileEntityCookingFurnace) {
  42.                     return new GuiCookingFurnace(player.inventory, (TileEntityCookingFurnace) entity);
  43.                 }
  44.                 return null;
  45.             }
  46.         }
  47.         return null;
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement