Guest User

ModGuiHandler

a guest
Jul 29th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.72 KB | None | 0 0
  1. package com.konarjg.arcticraft;
  2.  
  3. import com.konarjg.arcticraft.blocks.tileentities.TileEntityBarrel;
  4. import com.konarjg.arcticraft.blocks.tileentities.TileEntityTheCore;
  5. import com.konarjg.arcticraft.blocks.tileentities.containers.ContainerBarrel;
  6. import com.konarjg.arcticraft.blocks.tileentities.containers.ContainerTheCore;
  7. import com.konarjg.arcticraft.blocks.tileentities.gui.GuiBarrel;
  8. import com.konarjg.arcticraft.blocks.tileentities.gui.GuiTheCore;
  9.  
  10. import net.minecraft.entity.player.EntityPlayer;
  11. import net.minecraft.inventory.Container;
  12. import net.minecraft.util.math.BlockPos;
  13. import net.minecraft.world.World;
  14. import net.minecraftforge.fml.common.network.IGuiHandler;
  15.  
  16. public class ModGuiHandler implements IGuiHandler {
  17.  
  18.     public static final int THE_CORE = 0;
  19.     public static final int BARREL = 1;
  20.    
  21.     public static ModGuiHandler mgh;
  22.    
  23.     public ModGuiHandler () {
  24.         mgh = this;
  25.     }
  26.    
  27.     @Override
  28.     public Container getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
  29.         switch (ID) {
  30.             case THE_CORE:
  31.                 return new ContainerTheCore(player.inventory, (TileEntityTheCore)world.getTileEntity(new BlockPos(x, y, z)));
  32.             case BARREL:
  33.                 return new ContainerBarrel(player.inventory, (TileEntityBarrel)world.getTileEntity(new BlockPos(x, y, z)));
  34.             default:
  35.                 return null;
  36.         }
  37.     }
  38.  
  39.     @Override
  40.     public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
  41.         switch (ID) {
  42.             case THE_CORE:
  43.                 return new GuiTheCore(getServerGuiElement(ID, player, world, x, y, z), player.inventory);
  44.             case BARREL:
  45.                 return new GuiBarrel(getServerGuiElement(ID, player, world, x, y, z), player.inventory);
  46.             default:
  47.                 return null;
  48.         }
  49.     }
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment