Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This should be pasted in your main mod file under the imports!
- @Mod(modid = "Tutorials", name = "Tutorial Mod", version = "1.5.1")
- @NetworkMod(clientSideRequired = true, serverSideRequired = false, channels = {"Tutorials"})
- public class Mod_Main {
- @SidedProxy(clientSide = "erikstutorials.ClientProxy", serverSide = "erikstutorials.ServerProxy")
- public static ServerProxy proxy;
- @Instance
- public static Mod_Main instance = new Mod_Main();
- //For everything below to work you must paste the above in your main mod file.
- //This is the client proxy
- package erikstutorials;
- import erikstutorials.ServerProxy;
- public class ClientProxy extends ServerProxy {
- @Override
- public void registerRenderThings(){
- }
- }
- //This is the server proxy
- package erikstutorials;
- public class ServerProxy {
- public void registerRenderThings(){
- }
- }
- //This is the Packet Handler
- package erikstutorials;
- import java.io.ByteArrayInputStream;
- import java.io.DataInputStream;
- import java.io.IOException;
- import net.minecraft.network.INetworkManager;
- import net.minecraft.network.packet.Packet250CustomPayload;
- import cpw.mods.fml.common.network.IPacketHandler;
- import cpw.mods.fml.common.network.Player;
- public class PacketHandler implements IPacketHandler{
- @Override
- public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) {
- if(packet.channel.equals("Tutorials")){
- handlePacket(packet);
- }
- }
- public void handlePacket(Packet250CustomPayload packet){
- DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data));
- int randomInt1;
- int randomInt2;
- try{
- randomInt1 = inputStream.readInt();
- randomInt2 = inputStream.readInt();
- }catch(IOException e){
- e.printStackTrace();
- return;
- }
- System.out.println(randomInt1 + "" + randomInt2);
- }
- }
- //This is the guihandler,supports multiple guis
- package erikstutorials;
- import net.minecraft.client.gui.Gui;
- import net.minecraft.client.gui.GuiScreenBook;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.ItemStack;
- import net.minecraft.tileentity.TileEntity;
- import net.minecraft.world.World;
- import cpw.mods.fml.common.network.IGuiHandler;
- import cpw.mods.fml.common.network.OpenGuiPacket;
- public class GuiHandler implements IGuiHandler{
- @Override
- public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
- TileEntity tile_entity = world.getBlockTileEntity(x, y, z);
- switch (ID)
- {
- //case 0: return new ContainerDryingRack(player.inventory, (TileEntityDryingRack)tile_entity);
- //case 1: return ID == 1 && world.getBlockId(x, y, z) == Mystique_Main.Mod_Main.blockID ? new ContainerPrepTable(player.inventory, world, x, y, z) : null;
- }
- return null;
- }
- @Override
- public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
- TileEntity tile_entity = world.getBlockTileEntity(x, y, z);
- switch (ID)
- {
- //case 0: return new GuiDryingRack(player.inventory, (TileEntityDryingRack) tile_entity);
- //case 1: return ID == 1 && world.getBlockId(x, y, z) == Mystique_Main.Mod_Main.blockID ? new GuiPrepTable(player.inventory, world, x, y, z) : null;
- }
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment