Guest User

Gui Handler

a guest
Nov 18th, 2014
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. package com.Looke81.BioWarfare.handler;
  2.  
  3. import com.Looke81.BioWarfare.BioWarfare;
  4. import com.Looke81.BioWarfare.container.ContainerMicrobeExtractor;
  5. import com.Looke81.BioWarfare.gui.GuiMicrobeExtractor;
  6. import com.Looke81.BioWarfare.tileentity.TileEntityMicrobeExtractor;
  7.  
  8. import coolalias.inventoryitem.ContainerItem;
  9. import coolalias.inventoryitem.InventoryItem;
  10. import net.minecraft.entity.player.EntityPlayer;
  11. import net.minecraft.item.ItemStack;
  12. import net.minecraft.tileentity.TileEntity;
  13. import net.minecraft.world.World;
  14. import cpw.mods.fml.common.network.IGuiHandler;
  15.  
  16. public class GuiHandler1 implements IGuiHandler {
  17.  
  18.  
  19. @Override
  20. public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
  21. //System.out.println("This occurrs (client)" + id);
  22. if(id == 0) {
  23. TileEntity tileEntity = world.getTileEntity(x, y, z);
  24. if(tileEntity instanceof TileEntityMicrobeExtractor){
  25. return new ContainerMicrobeExtractor(player.inventory, (TileEntityMicrobeExtractor) tileEntity);
  26. }
  27. }
  28. else if(id == 1) {
  29.  
  30. return new ContainerItem(player, player.inventory, new InventoryItem(player.getHeldItem()));
  31.  
  32. }
  33. return null;
  34. }
  35.  
  36. //returns an instance of the Gui you made earlier
  37. @Override
  38. public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
  39. if(id == 0) {
  40. TileEntity tileEntity = world.getTileEntity(x, y, z);
  41. if(tileEntity instanceof TileEntityMicrobeExtractor){
  42. return new ContainerMicrobeExtractor(player.inventory, (TileEntityMicrobeExtractor) tileEntity);
  43. }
  44. }
  45. else if(id == 1) {
  46.  
  47. return new ContainerItem(player, player.inventory, new InventoryItem(player.getHeldItem()));
  48.  
  49. }
  50. return null;
  51. }
  52.  
  53. } package com.Looke81.BioWarfare.handler;
  54.  
  55. import com.Looke81.BioWarfare.BioWarfare;
  56. import com.Looke81.BioWarfare.container.ContainerMicrobeExtractor;
  57. import com.Looke81.BioWarfare.gui.GuiMicrobeExtractor;
  58. import com.Looke81.BioWarfare.tileentity.TileEntityMicrobeExtractor;
  59.  
  60. import coolalias.inventoryitem.ContainerItem;
  61. import coolalias.inventoryitem.InventoryItem;
  62. import net.minecraft.entity.player.EntityPlayer;
  63. import net.minecraft.item.ItemStack;
  64. import net.minecraft.tileentity.TileEntity;
  65. import net.minecraft.world.World;
  66. import cpw.mods.fml.common.network.IGuiHandler;
  67.  
  68. public class GuiHandler1 implements IGuiHandler {
  69.  
  70.  
  71. @Override
  72. public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
  73. //System.out.println("This occurrs (client)" + id);
  74. if(id == 0) {
  75. TileEntity tileEntity = world.getTileEntity(x, y, z);
  76. if(tileEntity instanceof TileEntityMicrobeExtractor){
  77. return new ContainerMicrobeExtractor(player.inventory, (TileEntityMicrobeExtractor) tileEntity);
  78. }
  79. }
  80. else if(id == 1) {
  81.  
  82. return new ContainerItem(player, player.inventory, new InventoryItem(player.getHeldItem()));
  83.  
  84. }
  85. return null;
  86. }
  87.  
  88. //returns an instance of the Gui you made earlier
  89. @Override
  90. public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
  91. if(id == 0) {
  92. TileEntity tileEntity = world.getTileEntity(x, y, z);
  93. if(tileEntity instanceof TileEntityMicrobeExtractor){
  94. return new ContainerMicrobeExtractor(player.inventory, (TileEntityMicrobeExtractor) tileEntity);
  95. }
  96. }
  97. else if(id == 1) {
  98.  
  99. return new ContainerItem(player, player.inventory, new InventoryItem(player.getHeldItem()));
  100.  
  101. }
  102. return null;
  103. }
  104.  
  105. }
Advertisement
Add Comment
Please, Sign In to add comment