SerriniaCorp

Tutorial Package w/o foods,crops

Jun 6th, 2013
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //This should be pasted in your main mod file under the imports!
  2.     @Mod(modid = "Tutorials", name = "Tutorial Mod", version = "1.5.1")
  3.     @NetworkMod(clientSideRequired = true, serverSideRequired = false, channels = {"Tutorials"})
  4.    
  5.     public class Mod_Main {
  6.        
  7.         @SidedProxy(clientSide = "erikstutorials.ClientProxy", serverSide = "erikstutorials.ServerProxy")
  8.         public static ServerProxy proxy;
  9.  
  10.        
  11.         @Instance
  12.         public static Mod_Main instance = new Mod_Main();
  13.  
  14. //For everything below to work you must paste the above in your main mod file.
  15.  
  16. //This is the client proxy
  17. package erikstutorials;
  18.  
  19. import erikstutorials.ServerProxy;
  20.  
  21. public class ClientProxy extends ServerProxy {
  22.    
  23.     @Override
  24.     public void registerRenderThings(){
  25.        
  26.     }
  27.  
  28. }
  29.  
  30. //This is the server proxy
  31. package erikstutorials;
  32.  
  33. public class ServerProxy {
  34.  
  35.     public void registerRenderThings(){
  36.        
  37.     }
  38. }
  39.  
  40. //This is the Packet Handler
  41. package erikstutorials;
  42.  
  43. import java.io.ByteArrayInputStream;
  44. import java.io.DataInputStream;
  45. import java.io.IOException;
  46.  
  47. import net.minecraft.network.INetworkManager;
  48. import net.minecraft.network.packet.Packet250CustomPayload;
  49. import cpw.mods.fml.common.network.IPacketHandler;
  50. import cpw.mods.fml.common.network.Player;
  51.  
  52. public class PacketHandler implements IPacketHandler{
  53.  
  54.     @Override
  55.     public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) {
  56.         if(packet.channel.equals("Tutorials")){
  57.             handlePacket(packet);
  58.         }
  59.        
  60.     }
  61.    
  62.     public void handlePacket(Packet250CustomPayload packet){
  63.         DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data));
  64.        
  65.         int randomInt1;
  66.         int randomInt2;
  67.        
  68.         try{
  69.             randomInt1 = inputStream.readInt();
  70.             randomInt2 = inputStream.readInt();
  71.         }catch(IOException e){
  72.             e.printStackTrace();
  73.             return;
  74.         }
  75.        
  76.         System.out.println(randomInt1 + "" + randomInt2);
  77.     }
  78.  
  79. }
  80.  
  81. //This is the guihandler,supports multiple guis
  82.  
  83. package erikstutorials;
  84.  
  85. import net.minecraft.client.gui.Gui;
  86. import net.minecraft.client.gui.GuiScreenBook;
  87. import net.minecraft.entity.player.EntityPlayer;
  88. import net.minecraft.item.ItemStack;
  89. import net.minecraft.tileentity.TileEntity;
  90. import net.minecraft.world.World;
  91. import cpw.mods.fml.common.network.IGuiHandler;
  92. import cpw.mods.fml.common.network.OpenGuiPacket;
  93.  
  94. public class GuiHandler implements IGuiHandler{
  95.  
  96.     @Override
  97.     public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
  98.         TileEntity tile_entity = world.getBlockTileEntity(x, y, z);
  99.        
  100.        
  101.         switch (ID)
  102.         {
  103.        
  104.         //case 0:   return new ContainerDryingRack(player.inventory, (TileEntityDryingRack)tile_entity);
  105.         //case 1: return ID == 1 && world.getBlockId(x, y, z) == Mystique_Main.Mod_Main.blockID  ? new ContainerPrepTable(player.inventory, world, x, y, z) : null;
  106.         }
  107.        
  108.         return null;
  109.     }
  110.  
  111.     @Override
  112.     public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
  113.         TileEntity tile_entity = world.getBlockTileEntity(x, y, z);
  114.         switch (ID)
  115.         {
  116.         //case 0: return new GuiDryingRack(player.inventory, (TileEntityDryingRack) tile_entity);
  117.         //case 1:   return ID == 1 && world.getBlockId(x, y, z) == Mystique_Main.Mod_Main.blockID ? new GuiPrepTable(player.inventory, world, x, y, z) : null;
  118.         }
  119.        
  120.         return null;
  121.     }
  122.     }
Advertisement
Add Comment
Please, Sign In to add comment