Jump to content

[1.6.4] Entityplayer.opengui(Mod.instance,...) issue


AGhost

Recommended Posts

Hi guys,

 

im getting an issue with "opening Gui", i try to display my custom Gui. then i call this function

"player.openGui(LrtMainClass.instance, LrtGui_MiniRpgGui.GUI_ID, world, player.posX, player.posY, player.posZ);" in my PlayerTickHandler class, but im getting an error-->> "The method openGui(Object, int, World, int, int, int) in the type EntityPlayer is not applicable for the arguments (LrtMainClass, int, World, double, double, double)"

 

im stuck with this for a couple of day.  :'(

How can i solve this problem.

 

Thank you in advanced ,, and sorry for my bad English.

 

here's my code

 

//-- main mod class

package net.lrtmods;

import java.io.*;
import java.net.*;
import java.util.EnumSet;

import org.lwjgl.input.Keyboard;
import org.lwjgl.util.glu.Registry;

import net.lrtmods.Bows.LrtItemBow;
import net.lrtmods.Bows.LrtItemBow_6000;
import net.lrtmods.Gui.LrtGui_MiniRpgGui;
import net.lrtmods.ItemRenderer.LrtBowsRender;
import net.lrtmods.client.ClientProxy;
import net.lrtmods.itemSword.LrtItemsSwords;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiHopper;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.ai.attributes.AttributeInstance;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBow;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemPickaxe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.EnumHelper;
import net.minecraftforge.common.MinecraftForge;
import net.minecraft.entity.player.*;

import cpw.mods.*;
import cpw.mods.fml.client.registry.KeyBindingRegistry;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.TickType;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.FMLNetworkHandler;
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;
import cpw.mods.fml.common.registry.TickRegistry;
import cpw.mods.fml.relauncher.Side;

@Mod(modid = "lrt", name = "lrt-privatemods", version = "0.1.0")
@NetworkMod(clientSideRequired = true, serverSideRequired = true)

public class LrtMainClass{

@SidedProxy(modId="lrt", clientSide="net.lrtmods.client.ClientProxy", serverSide="net.lrtmods.CommonProxy")
public static CommonProxy proxy;

@Instance("lrt")
public static LrtMainClass instance;

public static String modid;

// (name_material,item type, item usage, str against block, damage with entity, enchant.. )
public static EnumToolMaterial HQ_Stone_Sword = EnumHelper.addToolMaterial("HQ_Stone_Sword", 101, 299, 9.0F, 1.5F, 10);
public static EnumToolMaterial Warrior_Iron_Sword = EnumHelper.addToolMaterial("Warrior_Iron_Sword", 102, 299, 9.0F, 2.5F, 10);
public static EnumToolMaterial Remnant_soldier_sword = EnumHelper.addToolMaterial("Remnant_soldier_sword", 103, 99, 9.0F, 5.5F, 10);
public static EnumToolMaterial phoenix_lv1 = EnumHelper.addToolMaterial("phoenix_lv1", 104, 1000, 9.0F, 6.5F, 10);

// initial weapon and tool //
public static Item hqStoneSword = (new LrtItemsSwords(15001, HQ_Stone_Sword).setUnlocalizedName("hqStoneSword"));
public static Item warriorIronSword = (new LrtItemsSwords(15002, Warrior_Iron_Sword).setUnlocalizedName("warrior_iron_sword"));
public static Item remnantSoldierSword = (new LrtItemsSwords(15003, Remnant_soldier_sword).setUnlocalizedName("remnant_s_sword"));
// -- Event gift sword -- //
public static Item phoenix_baby = (new LrtItemsSwords(15000, phoenix_lv1).setUnlocalizedName("PhoenixBaby_sword"));

// initial Bow //
public static LrtItemBow_6000 elfFarmerBow = (LrtItemBow_6000)(new LrtItemBow_6000(17000)).setUnlocalizedName("elf_farmer_bow").setTextureName("elf_farmer_bow");
public static LrtItemBow elfSoldierBow = (LrtItemBow)(new LrtItemBow(17001)).setUnlocalizedName("elf_soldier_bow").setTextureName("elf_soldier_bow");
//public static ItemBow bow = (ItemBow)(new ItemBow(5)).setUnlocalizedName("bow").setTextureName("bow");


@EventHandler
public void PreInit(FMLPreInitializationEvent event)
{
	//NetworkRegistry.instance().registerGuiHandler(LrtMainClass.instance, new LrtGuiHandler());
	//ConfigManager.init(event.getSuggestedConfigurationFile());
	//MinecraftForgeClient.registerItemRenderer(item.getItemID(), new LrtBowsRender());
}

@EventHandler 
public void load(FMLInitializationEvent event)
{
	// --Sword--
	registerItem(hqStoneSword, "Hq stone sword");
	registerItem(warriorIronSword, "Warrior iron sword");
	registerItem(remnantSoldierSword, "Remnant soldier's sword");

	// --Bow--
	registerItem(elfSoldierBow, "Elf Soldier's bow");
	registerItem(elfFarmerBow, "Elf Farmer's bow");

	// --Even gift--
	registerItem(phoenix_baby, "Phoenix baby sword");

	EntityPlayer player;

}

public void registerBlock(Block block, String name)
{
	GameRegistry.registerBlock(block, block.getUnlocalizedName());
	LanguageRegistry.addName(block, name);
}
public void registerItem(Item item, String name)
{
	GameRegistry.registerItem(item, item.getUnlocalizedName());
	LanguageRegistry.addName(item, name);
}

@EventHandler
public void Init(FMLInitializationEvent event)
{
	proxy.registerRenders();

	MinecraftForgeClient.registerItemRenderer(net.lrtmods.Bows.LrtItemBow.getItemID(), new LrtBowsRender());
	MinecraftForgeClient.registerItemRenderer(net.lrtmods.Bows.LrtItemBow_6000.getItemID(), new LrtBowsRender());

	NetworkRegistry.instance().registerGuiHandler(instance, new LrtGuiHandler());

	//FMLNetworkHandler.openGui(player, LrtMainClass.instance, LrtGui_MiniRpgGui.GUI_ID, world, player.posX, player.posY, player.posZ);
	// key bind register //
	KeyBinding[] key = {new KeyBinding("miniRpg", Keyboard.KEY_G)};
        boolean[] repeat = {false};
        KeyBindingRegistry.registerKeyBinding(new LrtKeyBinding(key, repeat));
        
        // regis gui //
        //NetworkRegistry.instance().registerGuiHandler(LrtMainClass.instance, new CommonProxy());
	modid = "lrt";

        // regis player tick //
	TickRegistry.registerTickHandler(new LrtPlayerTickHandler(EnumSet.of(TickType.PLAYER)), Side.SERVER);
	CheckInternetConnection();


}

@EventHandler
public void postInit(FMLPostInitializationEvent event)
{

}

//=================//
// http connection //
//=================//

public void CheckInternetConnection()
{

}
}

 

//--- GuiHandler

package net.lrtmods;

import net.lrtmods.Gui.LrtGui_MiniRpgGui;
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 LrtGuiHandler implements IGuiHandler {

@Override
    public Object getServerGuiElement ( int ID, EntityPlayer player, World world, int x, int y, int z ) {
            return null;
    }

    @Override
    public Object getClientGuiElement ( int ID, EntityPlayer player, World world, int x, int y, int z ) {
    	if ( ID == LrtGui_MiniRpgGui.GUI_ID )
            return new LrtGui_MiniRpgGui();
    	
    	return null;
    }
}

 

//--- PlayerTickHandler

package net.lrtmods;

import java.util.EnumSet;

import net.lrtmods.Gui.LrtGui_MiniRpgGui;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;

import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.TickType;
import cpw.mods.fml.common.modloader.ModLoaderGuiHelper;
import cpw.mods.fml.common.network.FMLNetworkHandler;

public class LrtPlayerTickHandler implements ITickHandler {

private final EnumSet<TickType> ticksToGet;
static World world = Minecraft.getMinecraft().theWorld;

/*
* This Tick Handler will fire for whatever TickType's you construct and register it with.
*/
public LrtPlayerTickHandler(EnumSet<TickType> ticksToGet)
{
    this.ticksToGet = ticksToGet;
}
/*
* I suggest putting all your tick Logic in EITHER of these, but staying in one
*/
@Override
public void tickStart(EnumSet<TickType> type, Object... tickData)
{
    playerTick((EntityPlayer)tickData[0]);
}
@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData)
{
}
@Override
public EnumSet<TickType> ticks()
{
    return ticksToGet;
}
@Override
public String getLabel()
{
    return "plTick";
}

public static void playerTick(EntityPlayer player)
{
	 if(LrtKeyBinding.keyPressed)
	 {
		player.openGui(LrtMainClass.instance, LrtGui_MiniRpgGui.GUI_ID, world, player.posX, player.posY, player.posZ);
         }
}
}

Link to comment
Share on other sites

Mmm.  Casting. <3

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Learn java.

 

yeah, nvm

 

.. so can u plz tell me just one thing??

 

why "NetworkRegistry.instance().registerGuiHandler(LrtMainClass.instance, new LrtGuiHandler());" work?

and "player.openGui(LrtMainClass.instance, LrtGui_MiniRpgGui.GUI_ID, world, player.posX, player.posY, player.posZ);" not!?

 

both function require 'Object mod' but why only NetworkRegistry work???

Link to comment
Share on other sites

both function require 'Object mod' but why only NetworkRegistry work???

 

Because ints aren't doubles?

 

"The method openGui(Object, int, World, int, int, int) in the type EntityPlayer is not applicable for the arguments (LrtMainClass, int, World, double, double, double)"

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

both function require 'Object mod' but why only NetworkRegistry work???

 

Because ints aren't doubles?

 

"The method openGui(Object, int, World, int, int, int) in the type EntityPlayer is not applicable for the arguments (LrtMainClass, int, World, double, double, double)"

 

:) thank you, its solve now, i think it 'll auto convert to Int like // double x = 10.5f, int y = 0,      y = x;

 

THANKS YOU! Again :)

 

 

Link to comment
Share on other sites

This is why diesieben07 said to go learn Java.

 

You'd have known that implicit casting doesn't exist for the primitive datatypes.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

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