Advertisement
Guest User

Untitled

a guest
Aug 16th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. package com.jolteffect.justsolars.handler;
  2.  
  3. import net.minecraft.entity.player.EntityPlayer;
  4. import net.minecraft.tileentity.TileEntity;
  5. import net.minecraft.util.math.BlockPos;
  6. import net.minecraft.world.World;
  7. import net.minecraftforge.fml.common.network.IGuiHandler;
  8.  
  9. import com.jolteffect.justsolars.block.SolarPanel.ContainerSolarPanel;
  10. import com.jolteffect.justsolars.block.SolarPanel.GuiSolarPanel;
  11. import com.jolteffect.justsolars.block.SolarPanel.TileEntitySolarPanel;
  12. import com.jolteffect.justsolars.block.powercube.ContainerPowerCube;
  13. import com.jolteffect.justsolars.block.powercube.GuiPowerCube;
  14. import com.jolteffect.justsolars.block.powercube.TileEntityPowerCube;
  15.  
  16. public class GuiHandler implements IGuiHandler{
  17.  
  18. public static final int POWERCUBE = 1;
  19. public static final int SOLARPANEL = 2;
  20.  
  21.  
  22.  
  23.  
  24.  
  25. //SERVER SIDE
  26. @Override
  27. public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
  28. {
  29. BlockPos pos = new BlockPos(x, y, z);
  30. TileEntity te = world.getTileEntity(pos);
  31.  
  32. if (te != null)
  33. {
  34. if (ID == POWERCUBE)
  35. {
  36. return new ContainerPowerCube(player.inventory, (TileEntityPowerCube)te);
  37. }
  38. if (ID == SOLARPANEL)
  39. {
  40. return new ContainerSolarPanel(player.inventory, (TileEntitySolarPanel)te);
  41. }
  42.  
  43. }
  44.  
  45. return null;
  46. }
  47.  
  48.  
  49. //CLIENT SIDE
  50. @Override
  51. public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
  52. {
  53. BlockPos pos = new BlockPos(x, y, z);
  54. TileEntity te = world.getTileEntity(pos);
  55.  
  56. if (te != null)
  57. {
  58. if (ID == POWERCUBE)
  59. {
  60. TileEntityPowerCube containerTileEntity = (TileEntityPowerCube) te;
  61. return new GuiPowerCube(containerTileEntity, new ContainerPowerCube(player.inventory, containerTileEntity));
  62.  
  63. }
  64.  
  65. if (ID == SOLARPANEL)
  66. {
  67. TileEntitySolarPanel containerTileEntity = (TileEntitySolarPanel) te;
  68. return new GuiSolarPanel(containerTileEntity, new ContainerSolarPanel(player.inventory, containerTileEntity));
  69. }
  70.  
  71. }
  72.  
  73.  
  74. return null;
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement