Jump to content

Custom GUI wont open


somarani

Recommended Posts

I have a problem with trying to open a custom GUI. Here is my code

 

public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)

    {

        if (par1World.isRemote)

        {

       

            return true;

 

        }

        else

        {

            TileEntityInfuser tileEntityInfuser = (TileEntityInfuser)par1World.getBlockTileEntity(par2, par3, par4);

 

            if (tileEntityInfuser != null)

            {

    par5EntityPlayer.openGui(SoulCraft.instance, SoulCraft.guiIdInfuser, par1World, par2, par3, par4);

            }

 

            return true;

        }

    }

 

 

That wont work. The only way I can get it to work is to change the par1world.isRemote to "if(!par1World.isRemote)" This makes the gui open but breaks some other things. Any help would be greatly appreciated!

Link to comment
Share on other sites

here is my GUI handler class

 

 

package somarani.soulcraft.gui;

 

import somarani.soulcraft.common.SoulCraft;

import somarani.soulcraft.tileentity.TileEntityInfuser;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.world.World;

import cpw.mods.fml.common.network.IGuiHandler;

import cpw.mods.fml.common.network.NetworkRegistry;

 

public class GuiHandler implements IGuiHandler {

 

public GuiHandler(){

NetworkRegistry.instance().registerGuiHandler(SoulCraft.instance, this);

}

 

public Object getServerGuiElement(int ID, EntityPlayer player, World world,

int x, int y, int z) {

 

TileEntity entity = world.getBlockTileEntity(x, y, z);

 

if (entity != null)

{

switch (ID){

case SoulCraft.guiIdInfuser:

if (entity instanceof TileEntityInfuser){

return new ContainerInfuser(player.inventory, (TileEntityInfuser) entity);

}

}

}

 

return null;

}

 

 

public Object getClientGuiElement(int ID, EntityPlayer player, World world,

int x, int y, int z) {

 

TileEntity entity = world.getBlockTileEntity(x, y, z);

 

if (entity != null)

{

switch (ID){

case SoulCraft.guiIdInfuser:

if (entity instanceof TileEntityInfuser){

return new GuiInfuser(player.inventory, (TileEntityInfuser) entity);

}

 

}

}

 

return null;

}

 

}

 

Link to comment
Share on other sites

Hi here are the classes you asked for, sorry for posting incorrectly, I'm new here :)

 

Container Class - http://pastebin.com/Jjr6GbVW

 

GUI Handler Class - http://pastebin.com/x0s9Mgsk

 

Block GUI Class - http://pastebin.com/cVDvmuDJ

 

Tile Entity Class - http://pastebin.com/Zq6WQcVd

 

Also please keep in mind that all the smelting recipes, etc are still incomplete as I'm first trying to get the GUI working. If its of any help, when I change it to "if(!par1World.isRemote)" the GUI does open correctly and shows me the player inventory but doesn't allow me to move any of the items in the inventory.

 

Also what I'm attempting to do with this block is have the user place a gold ingot on top, a custom item on the bottom and it results a new item. If anyone could help with that it would be greatly appreciated.

 

Thanks for the help

Link to comment
Share on other sites

I tried outputting a message when (par1World.isRemote) and the message never showed up, but it did show up when I changed it to check if the world is remote. Could it have to do something with my Proxy classes? or my @server configuration?

Link to comment
Share on other sites

Just a side note, if I set it to check if the world is remote the GUI does open and display properly, but it doesn't allow me to pick up any of the inventory items, they snap back in place as soon as I pick them up

 

Here is my common proxy, it would be great if someone can take a look and see if something there is causing the problem.

 

http://pastebin.com/qmNNrVY6

Link to comment
Share on other sites

Thats a valid point xD. Like I said Im new to this. In my main mod class I have

 

public static CommonProxy proxy

 

and i also have

 

GuiHandler guiHandler = new GuiHandler();

 

I tried completely deleting my GUI handler class and putting everything in it inside common proxy and it still didn't work. But I feel like that may have something to do with the problem. What do you think I should do now? Thanks for all the help!

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Sorry, heres the new logs https://paste.ee/p/bTpMZ the ending crash error is the same but instead of the Minecraft crash screen saying the error for drivers its now showing -1 
    • Thanks for the advice, I am also facing this issue, I didn't thought about it before.
    • When I add a search bar to CreativeModeTab, the text box is not rendered even though it's possible to input text. Additionally, the search is performed on all items. This issue has been occurring since 1.21. Is there something missing in my code? https://github.com/mgen256/AdditionalLights/blob/1.21/src/main/java/com/mgen256/al/AdditionalLights.java
    • This question would probably best be asked wherever fabric support is given; these are the Minecraft Forge forums. They aren't the same thing
    • client version: forge-1.7.10-10.13.4.1614-1.7.10 forgegradle version:forge-1.7.10-10.13.4.1614-1.7.10   i can run my mod in forgegradle but i put my mod into a client ,it will crash  cpw.mods.fml.common.LoaderException: java.lang.NoSuchMethodError: com.example.examplemod.items.CommonItem.setUnlocalizedName(Ljava/lang/String;)Lnet/minecraft/item/Item;     at cpw.mods.fml.common.LoadController.transition(LoadController.java:163)     at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:559)     at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:243)     at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:480)     at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:878)     at net.minecraft.client.main.Main.main(SourceFile:148)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     at java.lang.reflect.Method.invoke(Method.java:497)     at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)     at net.minecraft.launchwrapper.Launch.main(Launch.java:28)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     at java.lang.reflect.Method.invoke(Method.java:497)     at oolloo.jlw.Wrapper.invokeMain(Wrapper.java:71)     at oolloo.jlw.Wrapper.main(Wrapper.java:51) Caused by: java.lang.NoSuchMethodError: com.example.examplemod.items.CommonItem.setUnlocalizedName(Ljava/lang/String;)Lnet/minecraft/item/Item;     at com.example.examplemod.items.CommonItem.<init>(CommonItem.java:10)     at com.example.examplemod.proxy.register.ItemRegister.createItem(ItemRegister.java:30)     at com.example.examplemod.proxy.register.ItemRegister.registerItems(ItemRegister.java:18)     at com.example.examplemod.proxy.CommonProxy.preInit(CommonProxy.java:12)     at com.example.examplemod.proxy.ClientProxy.preInit(ClientProxy.java:6)     at com.example.examplemod.ExampleMod.preInit(ExampleMod.java:26)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     at java.lang.reflect.Method.invoke(Method.java:497)     at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532)     at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     at java.lang.reflect.Method.invoke(Method.java:497)     at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)     at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)     at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)     at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)     at com.google.common.eventbus.EventBus.post(EventBus.java:275)     at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)     at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     at java.lang.reflect.Method.invoke(Method.java:497)     at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)     at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)     at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)     at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)     at com.google.common.eventbus.EventBus.post(EventBus.java:275)     at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119)     at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:556)     ... 16 more  
  • Topics

×
×
  • Create New...

Important Information

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