Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

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


AGhost
 Share

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
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.

 Share



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • you need to check if the EventHandler is called
    • update Forge to the latest version 1.16.5 requires java 8
    • C:\Users\(My Name)\Desktop\Clockwise server>java -Xmx10240M -Xms10240M -jar forgeserver.jar nogui 2022-05-26 12:35:05,381 main WARN Advanced terminal features are not available in this environment [12:35:05] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher running: args [--gameDir, ., --launchTarget, fmlserver, --fml.forgeVersion, 36.1.30, --fml.mcpVersion, 20210115.111550, --fml.mcVersion, 1.16.5, --fml.forgeGroup, net.minecraftforge, nogui] [12:35:05] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher 8.0.9+86+master.3cf110c starting: java version 1.8.0_333 by Oracle Corporation [12:35:06] [main/INFO] [ne.mi.fm.lo.FixSSL/CORE]: Added Lets Encrypt root certificates as additional trust [12:35:06] [main/INFO] [mixin/]: SpongePowered MIXIN Subsystem Version=0.8.2 Source=file:/C:/Users/Joshua%20Hague/Desktop/Clockwise%20server/libraries/org/spongepowered/mixin/0.8.2/mixin-0.8.2.jar Service=ModLauncher Env=SERVER [12:35:06] [main/WARN] [ne.mi.fm.lo.FMLConfig/CORE]: Configuration file C:\Users\Joshua Hague\Desktop\Clockwise server\config\fml.toml is not correct. Correcting [12:35:06] [main/WARN] [ne.mi.fm.lo.FMLConfig/CORE]: Incorrect key [defaultConfigPath] was corrected from null to defaultconfigs [12:35:06] [main/INFO] [cp.mo.mo.LaunchServiceHandler/MODLAUNCHER]: Launching target 'fmlserver' with arguments [--gameDir, ., nogui] Exception in thread "main" [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]: java.lang.NoSuchMethodError: sun.security.util.ManifestEntryVerifier.<init>(Ljava/util/jar/Manifest;)V [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.SecureJarHandler.createCodeSource(SecureJarHandler.java:66) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.TransformingClassLoader$DelegatedClassLoader.findClass(TransformingClassLoader.java:275) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:136) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:98) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at java.lang.ClassLoader.loadClass(Unknown Source) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at java.lang.Class.forName0(Native Method) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at java.lang.Class.forName(Unknown Source) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at net.minecraftforge.fml.loading.FMLServerLaunchProvider.lambda$launchService$0(FMLServerLaunchProvider.java:51) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at net.minecraftforge.server.ServerMain$Runner.runLauncher(ServerMain.java:63) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at net.minecraftforge.server.ServerMain$Runner.access$100(ServerMain.java:60) [12:35:07] [main/INFO] [STDERR/]: [java.lang.ThreadGroup:uncaughtException:-1]:         at net.minecraftforge.server.ServerMain.main(ServerMain.java:57) C:\Users\(My Name)\Desktop\Clockwise server>PAUSE Tried it again with just Java version 8 update 333, still nothing.
    • package com.zaksen.fancydecorativeblocks; import com.zaksen.fancydecorativeblocks.screen.FancyMenuTypes; import com.zaksen.fancydecorativeblocks.screen.WoodCrateScreen; import net.minecraft.client.gui.screens.MenuScreens; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; @Mod.EventBusSubscriber(modid = FancyDecorativeBlocks.MOD_ID) public class ClientSetup { @SubscribeEvent public static void clientSetup(final FMLClientSetupEvent Event) { Runnable runnable = new Runnable() { @Override public void run() { MenuScreens.register(FancyMenuTypes.WOOD_CRATE_MENU.get(), WoodCrateScreen::new); } }; Event.enqueueWork(runnable); } } I create new class for it, but how i need call it?
    • Hey thanks for the reply So I can't exactly remove mods from the modpack without causing severe problems with the world so I just tried increasing the max-tick-time and found out it happens between these lines   [26May2022 20:15:49.384] [Server thread/DEBUG] [mixin/]: Mixing MixinNetworkItemManager from creativewirelesstransmitter.mixins.json into com.refinedmods.refinedstorage.apiimpl.network.item.NetworkItemManager [26May2022 20:19:51.050] [Server thread/DEBUG] [mixin/]: Mixing MixinBlockEntityExtension from architectury.mixins.json into me.shedaniel.architectury.extensions.BlockEntityExtension Here's the full debug.log, had to shorten it a little cause it was too big for pastebin so I cut the start out, if you need it I can also send it Also because I increased the max-tick-time it didn't crash but I dont wanna keep it that way since a 4 minute tick has to have an explanation. So any idea of how to fix this?
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.