Jump to content

Xuluf

Members
  • Posts

    7
  • Joined

  • Last visited

Posts posted by Xuluf

  1. Okay, I got an error that said that it tried to open a GUI without being a network mod. Code

     

     

    package xul.mods.adventuremod;
    
    import java.lang.annotation.Annotation;
    
    import net.minecraft.block.Block;
    import net.minecraft.client.Minecraft;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemStack;
    import net.minecraft.world.World;
    import net.minecraftforge.client.MinecraftForgeClient;
    import xul.mods.adventuremod.common.AdvCommonProxy;
    import cpw.mods.fml.common.Mod;
    import cpw.mods.fml.common.Mod.Init;
    import cpw.mods.fml.common.Mod.Instance;
    import cpw.mods.fml.common.Mod.PreInit;
    import cpw.mods.fml.common.SidedProxy;
    import cpw.mods.fml.common.event.FMLInitializationEvent;
    import cpw.mods.fml.common.event.FMLPreInitializationEvent;
    import cpw.mods.fml.common.network.IConnectionHandler;
    import cpw.mods.fml.common.network.IPacketHandler;
    import cpw.mods.fml.common.network.ITinyPacketHandler;
    import cpw.mods.fml.common.network.NetworkMod;
    import cpw.mods.fml.common.network.NetworkRegistry;
    import cpw.mods.fml.common.registry.GameRegistry;
    import cpw.mods.fml.common.registry.LanguageRegistry;
    
    @Mod(modid = "Xuluf_Adventuremod", name = "Adventuremod", version = "1.0 RC1")
    @NetworkMod(clientSideRequired = true, serverSideRequired = false, channels = {"GenericRandom"}, packetHandler = PacketHandler.class)
    
    public class Adventuremod
    {
    
    
    @Instance
    public static Adventuremod instance = new Adventuremod();
    private GuiHandler guiHandler = new GuiHandler();
    @SidedProxy(clientSide = "xul.mods.adventuremod.AdvClientProxy", serverSide = "xul.mods.adventuremod.common.AdvCommonProxy")
    public static AdvCommonProxy proxy;
    
    
    /** Weapons */
    public static Item battleaxewood;
    public static Item battleaxestone;
    public static Item battleaxeiron;
    public static Item battleaxegold;
    public static Item battleaxediamond;
    public static Item battleaxedeamon;
    
    @Init
    public void Init(FMLInitializationEvent event) 
    {
     proxy.registerRenderThings();
    
     battleaxewood = new ItemAdv(5000).setIconIndex(0).setItemName("BATTLEAXEWOOD");
     battleaxestone = new ItemAdv(5001).setIconIndex(1).setItemName("BATTLEAXESTONE");
     battleaxeiron = new ItemAdv(5002).setIconIndex(2).setItemName("BATTLEAXEIRON");
     battleaxegold = new ItemAdv(5003).setIconIndex(3).setItemName("BATTLEAXEGOLD");
     battleaxediamond = new ItemAdv(5004).setIconIndex(4).setItemName("BATTLEAXEDIAMOND");
     battleaxedeamon = new ItemAdv(5005).setIconIndex(5).setItemName("BATTLEAXEDEAMON");
    
    
    
     GameRegistry.registerItem(battleaxewood, "Wooden Battleaxe");
     LanguageRegistry.addName(battleaxewood, "Wooden Battleaxe");
    
     GameRegistry.registerItem(battleaxestone, "Stone Battleaxe");
     LanguageRegistry.addName(battleaxestone, "Stone Battleaxe");
    
     GameRegistry.registerItem(battleaxeiron, "Iron Battleaxe");
     LanguageRegistry.addName(battleaxeiron, "Iron Battleaxe");
    
     GameRegistry.registerItem(battleaxegold, "Gold Battleaxe");
     LanguageRegistry.addName(battleaxegold, "Gold Battleaxe");
    
     GameRegistry.registerItem(battleaxediamond, "Diamond Battleaxe");
     LanguageRegistry.addName(battleaxediamond, "Diamond Battleaxe");
    
     GameRegistry.registerItem(battleaxedeamon, "Deamon Battleaxe");
     LanguageRegistry.addName(battleaxedeamon, "Deamon Battleaxe");
    
     GameRegistry.addRecipe(new ItemStack(battleaxewood, 1), new Object[]{
    	"***","***","***", '*', Block.dirt 
    
     });
    
     GameRegistry.addRecipe(new ItemStack(battleaxestone, 1), new Object[]{
    	"***","*  ","***", '*', Block.dirt 
    
     });
     GameRegistry.addRecipe(new ItemStack(battleaxeiron, 1), new Object[]{
    	"* *","***","***", '*', Block.dirt 
    
     });
     GameRegistry.addRecipe(new ItemStack(battleaxegold, 1), new Object[]{
    	"***","* *","***", '*', Block.dirt 
    
     });
     GameRegistry.addRecipe(new ItemStack(battleaxediamond, 1), new Object[]{
    	"***","***","* *", '*', Block.dirt 
    
     });
     GameRegistry.addRecipe(new ItemStack(battleaxedeamon, 1), new Object[]{
    	"*", '*', Block.dirt 
    
     });
    
     MinecraftForgeClient.preloadTexture("/adventure/gui/items.png");
    
     GameRegistry.registerPlayerTracker(new PlayerTracker());
     NetworkRegistry.instance().registerGuiHandler(this, guiHandler);
    
    }
    }
    
    

     

     

     

    package xul.mods.adventuremod;
    
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.src.ModLoader;
    import net.minecraft.world.World;
    import cpw.mods.fml.common.IPlayerTracker;
    
    public class PlayerTracker implements IPlayerTracker{
    
    @Override
    public void onPlayerLogin(EntityPlayer player) {
    
    	NBTTagCompound tag = player.getEntityData();
    
    
    
    
    	if(tag.getBoolean("onceConnected") != true){
    		player.sendChatToPlayer("Hi! You just connected.");
    
    		player.openGui(Adventuremod.instance, 26, player.worldObj, 0, 0, 0);
    
    	}
    	else{
    		player.sendChatToPlayer("You are not a new player ");
    	}tag.setBoolean("onceConnected", true);
    }
    
    @Override
    public void onPlayerLogout(EntityPlayer player) {
    	// TODO Auto-generated method stub
    
    }
    
    @Override
    public void onPlayerChangedDimension(EntityPlayer player) {
    	// TODO Auto-generated method stub
    
    }
    
    @Override
    public void onPlayerRespawn(EntityPlayer player) {
    	// TODO Auto-generated method stub
    
    }
    
    }
    

     

     

     

    package xul.mods.adventuremod;
    
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.world.World;
    import cpw.mods.fml.common.network.IGuiHandler;
    
    public class GuiHandler implements IGuiHandler {
            //returns an instance of the Container you made earlier
            @Override
            public Object getServerGuiElement(int id, EntityPlayer player, World world,
                            int x, int y, int z) {
            	System.out.println("Server is working!");
                            return null;
            }
    
            //returns an instance of the Gui you made earlier
            @Override
            public Object getClientGuiElement(int id, EntityPlayer player, World world,
                            int x, int y, int z) {
            	
            	System.out.println("Client is working!");
            	
            	switch(id)
            	{
            	case 26:
            		System.out.println("Whatever");
    			return new GuiStart();
            	default:
            	 return null;
            	}
    
            }
    }

     

     

    Tell me if I forgot any class or code :)

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.