Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I'm getting an error on player.openGui I've seen it on multiple gui tuts. but its not working for me

 

common proxy:

package com.example.gammacraft.Proxy;

import com.example.gammacraft.gui.ProcessorGui;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.IGuiHandler;

public class ProxyCommon implements IGuiHandler{
   public void registerRenderers(){
   }

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

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

 

for the main file I put

NetworkRegistry.INSTANCE.registerGuiHandler(Instance, proxy);

in my init function

 

and the block file is:

package com.example.gammacraft.blocks;

import com.example.gammacraft.TileEntity.BluePrintTableTileEntity;
import com.example.gammacraft.gui.BluePrintTableGui;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;

public class BluePrintTable extends BlockContainer{



@SideOnly(Side.CLIENT)
public static IIcon top;
@SideOnly(Side.CLIENT)
public static IIcon side;


public BluePrintTable(int i, Material p_i45386_1_) {
	super(p_i45386_1_);
	this.setBlockName("BluePrintTable");
	this.setCreativeTab(CreativeTabs.tabMisc);
}

@Override
public TileEntity createNewTileEntity(World var1, int var2) {
	return new BluePrintTableTileEntity();
}


public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int metadata, float Hitx, float Hity, float Hitz) {

player.openGui(BluePrintTableGui.class, 20, world, x, y, z);
    return true;
}


}

 

the guiScreen is:

package com.example.gammacraft.gui;



import com.example.gammacraft.TileEntity.BluePrintTableTileEntity;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.util.ResourceLocation;

public class BluePrintTableGui extends GuiScreen{
public static final int GUI_ID = 20;


public static final ResourceLocation texture = new ResourceLocation("gammacraft","textures/BluePrintTable.png");

  public BluePrintTableGui() {}
      
      @Override
      public void drawScreen(int par1, int par2, float par3) {
              this.drawDefaultBackground();
              this.drawRect(50, 50, 100, 100, 5);
      }


}

 

the stacktrace is

---- Minecraft Crash Report ----

// Don't be sad, have a hug! <3

 

Time: 9/12/14 7:19 PM

Description: Unexpected error

 

java.lang.NullPointerException: Unexpected error

at cpw.mods.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:263)

at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:93)

at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2255)

at com.example.gammacraft.blocks.BluePrintTable.onBlockActivated(BluePrintTable.java:44)

at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerRightClick(PlayerControllerMP.java:349)

at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1442)

at net.minecraft.client.Minecraft.runTick(Minecraft.java:1949)

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:953)

at net.minecraft.client.Minecraft.run(Minecraft.java:870)

at net.minecraft.client.main.Main.main(Main.java:103)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- Head --

Stacktrace:

at cpw.mods.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:263)

at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:93)

at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2255)

at com.example.gammacraft.blocks.BluePrintTable.onBlockActivated(BluePrintTable.java:44)

at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerRightClick(PlayerControllerMP.java:349)

at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1442)

 

-- Affected level --

Details:

Level name: MpServer

All players: 1 total; [EntityClientPlayerMP['Player867'/221, l='MpServer', x=276.37, y=78.62, z=652.86]]

Chunk stats: MultiplayerChunkCache: 225, 225

Level seed: 0

Level generator: ID 00 - default, ver 1. Features enabled: false

Level generator options:

Level spawn location: World: (248,64,248), Chunk: (at 8,4,8 in 15,15; contains blocks 240,0,240 to 255,255,255), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)

Level time: 39191 game time, 39191 day time

Level dimension: 0

Level storage version: 0x00000 - Unknown?

Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)

Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false

Forced entities: 58 total; [EntityClientPlayerMP['Player867'/221, l='MpServer', x=276.37, y=78.62, z=652.86], EntityBat['Bat'/400, l='MpServer', x=344.75, y=48.10, z=683.25], EntitySheep['Sheep'/401, l='MpServer', x=338.47, y=70.00, z=683.44], EntityPig['Pig'/287, l='MpServer', x=203.50, y=67.00, z=715.31], EntityPig['Pig'/395, l='MpServer', x=344.61, y=69.00, z=627.08], EntityPig['Pig'/394, l='MpServer', x=338.36, y=71.00, z=616.26], EntityPig['Pig'/393, l='MpServer', x=342.84, y=72.00, z=609.84], EntityPig['Pig'/392, l='MpServer', x=349.28, y=70.00, z=614.47], EntityBat['Bat'/399, l='MpServer', x=347.22, y=47.10, z=681.94], EntityBat['Bat'/398, l='MpServer', x=336.13, y=47.10, z=685.34], EntityMinecartChest['entity.MinecartChest.name'/397, l='MpServer', x=342.50, y=38.50, z=680.50], EntityMinecartChest['entity.MinecartChest.name'/396, l='MpServer', x=337.50, y=38.50, z=669.50], EntitySheep['Sheep'/385, l='MpServer', x=329.50, y=80.00, z=677.33], EntityPig['Pig'/384, l='MpServer', x=322.50, y=81.00, z=666.31], EntitySquid['Squid'/307, l='MpServer', x=232.33, y=56.16, z=587.08], EntityBat['Bat'/309, l='MpServer', x=235.49, y=19.66, z=670.56], EntityBat['Bat'/308, l='MpServer', x=237.25, y=51.10, z=668.47], EntityChicken['Chicken'/310, l='MpServer', x=228.41, y=75.00, z=718.56], EntitySheep['Sheep'/315, l='MpServer', x=248.38, y=72.00, z=646.47], EntityBat['Bat'/314, l='MpServer', x=249.75, y=29.10, z=625.75], EntityBat['Bat'/317, l='MpServer', x=249.93, y=12.98, z=663.66], EntityBat['Bat'/316, l='MpServer', x=249.99, y=12.10, z=657.67], EntitySheep['Sheep'/319, l='MpServer', x=245.84, y=77.00, z=671.44], EntityBat['Bat'/318, l='MpServer', x=248.37, y=21.56, z=667.28], EntityPig['Pig'/288, l='MpServer', x=201.03, y=67.00, z=713.84], EntityPig['Pig'/292, l='MpServer', x=215.69, y=76.00, z=691.09], EntityPig['Pig'/293, l='MpServer', x=221.53, y=73.00, z=702.47], EntityPig['Pig'/294, l='MpServer', x=220.69, y=74.00, z=718.50], EntityChicken['Chicken'/295, l='MpServer', x=208.81, y=69.00, z=704.25], EntityChicken['Chicken'/296, l='MpServer', x=209.81, y=68.00, z=717.16], EntityPig['Pig'/297, l='MpServer', x=209.96, y=69.00, z=715.58], EntityPig['Pig'/351, l='MpServer', x=285.50, y=67.00, z=686.84], EntityPig['Pig'/350, l='MpServer', x=281.28, y=70.00, z=677.50], EntityPig['Pig'/349, l='MpServer', x=277.52, y=77.00, z=655.44], EntityPig['Pig'/348, l='MpServer', x=283.53, y=73.00, z=667.44], EntityPig['Pig'/347, l='MpServer', x=274.32, y=78.00, z=638.50], EntityPig['Pig'/346, l='MpServer', x=277.69, y=78.00, z=638.50], EntityBat['Bat'/326, l='MpServer', x=258.75, y=50.10, z=628.25], EntityBat['Bat'/327, l='MpServer', x=261.28, y=48.10, z=626.75], EntityBat['Bat'/325, l='MpServer', x=261.38, y=35.74, z=595.95], EntityPig['Pig'/334, l='MpServer', x=258.84, y=65.00, z=712.06], EntityPig['Pig'/335, l='MpServer', x=270.16, y=64.00, z=708.38], EntityPig['Pig'/332, l='MpServer', x=258.50, y=68.00, z=678.03], EntityPig['Pig'/333, l='MpServer', x=262.78, y=71.00, z=674.50], EntitySheep['Sheep'/330, l='MpServer', x=270.13, y=76.00, z=638.53], EntityPig['Pig'/331, l='MpServer', x=260.50, y=71.00, z=672.16], EntityBat['Bat'/328, l='MpServer', x=262.50, y=48.10, z=626.75], EntityBat['Bat'/329, l='MpServer', x=258.72, y=50.10, z=628.25], EntityPig['Pig'/369, l='MpServer', x=315.78, y=66.00, z=682.88], EntityPig['Pig'/368, l='MpServer', x=304.88, y=81.00, z=658.75], EntitySheep['Sheep'/383, l='MpServer', x=331.50, y=82.00, z=669.66], EntityPig['Pig'/382, l='MpServer', x=320.05, y=85.00, z=654.12], EntityPig['Pig'/352, l='MpServer', x=286.46, y=64.69, z=690.58], EntityPig['Pig'/353, l='MpServer', x=283.53, y=64.00, z=694.78], EntityPig['Pig'/354, l='MpServer', x=275.94, y=64.00, z=710.97], EntityPig['Pig'/364, l='MpServer', x=292.61, y=65.47, z=684.72], EntitySheep['Sheep'/365, l='MpServer', x=290.59, y=70.00, z=672.31], EntityPig['Pig'/363, l='MpServer', x=301.47, y=66.00, z=680.31]]

Retry entities: 0 total; []

Server brand: fml,forge

Server type: Integrated singleplayer server

Stacktrace:

at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:384)

at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2433)

at net.minecraft.client.Minecraft.run(Minecraft.java:899)

at net.minecraft.client.main.Main.main(Main.java:103)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

 

The proud(ish) developer of Ancients

That's because you are returning null in your gui handler for client.

Return gui for client and container for server.

  • Author

hmm... odd even though I hard-wired it to return my guiscreen class I still crash

The proud(ish) developer of Ancients

My guess is either the player or the world is null at the time of error, maybe its being called early? Try a

 

if(player != null)

and a

if(world != null)

 

in onBlockActivated. Separately, one at a time, for debug purposes. Ultimately I would check for both to ensure no null errors during runtime down the road. Just a shot.

I'll need help, and I'll give help. Just ask, you know I will!

What tutorial did you follow? It is a lousy one if it did not show there are two components to a containerblock GUI. Client component is a regular GUIscreen, server component is a GuiContainer. One is returned in ClientProxy, the other in CommonProxy (or ServerProxy if you have one).

 

Yes, if it has no need of a server element, you can return null for the getServerGuiElement value;

 

edit: To clarify

Wait a sec, not all guis need a container. GuiContainer does need a container, but GuiScreen doesn't (at least not always?). In my gui handler I return (client side) the guis, and server side the container only if needed. BTW, where is ProcessorGui? I can't find it in your code.. Also, there's no way that, at onBlockActivated, player or world are null idk.

Check out my blog!

http://www.whov.altervista.org

You can return null container for server, but you can't return null gui for client.

  • Author

I realized I was returning an earlier attempt at a gui, I replaced it with the correct class but I still crashed. Also I was following ScratchForFun's windmill gui tutorial

The proud(ish) developer of Ancients

I too got a NPE when returning null in my gui handler for the container.  I found that it was giving me the NPE due to no slots in the container, even though I was not calling it.  I changed my block class from extending BlockContainer to just extend Block.  Then I didn't need to worry about the container I wasn't using anyway.

 

  • Author

Yeah but it needs to be a BlockContainer because it's a tileEntity :/ or do you not need a BlockContainer for tileEntities?

The proud(ish) developer of Ancients

It depends what are you doing with your tileentity. Check BlockContainer, it has only few things overriden.

If you have updated your code, could you post the latest? And are you now returning gui for client instead of null?

  • Author

Now in the proxy it is returning new BluePrintTableGui() and also I set it so it returns it o the client instead of the server

The proud(ish) developer of Ancients

  • Author

Someone please help me? I've spent atleast 20 hours trying to figure this out and have made no progress...

The proud(ish) developer of Ancients

They've told you all you need.

A. Your returning null on the gui, thats the clientElement. You cant return null there.

B. Your returning a gui in the serverElement. dont want that

C. You can return serverElement null UNLESS your gui extends GuiContainer. Your clientElement must return a gui class.

D. I wouldnt call this your common proxy class. Its your guihandler. The common and client proxies are different.

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Guest
This topic is now closed to further replies.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.