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.

[1.5.2]A mod tried to open a gui on the server without being a network mod

Featured Replies

  • Author

new TileEntityCharacter()

 

...Really.  A new tile entity.  No no no no.

 

You have a tile entity somewhere that is involved.  Generally when the player right clicks it is when you open a gui for it.  That method is inside a tile entity and has reference to itself.

 

Unfortunately with the code you have supplied I'm not sure you even HAVE a tile entity anywhere.  So I don't know why you're trying to reference it at all.

 

I think I figured out, but it crashes with a NPE:

 

private void openCharacterGui(Packet250CustomPayload packet,
		EntityPlayer player) {
	DataInputStream inputStream = new DataInputStream(
			new ByteArrayInputStream(packet.data));
	TileEntity tileEntity = player.worldObj.getBlockTileEntity((int)player.posX, (int)player.posY, (int)player.posZ);
			player.openGui(
			ExoWorld_Client.instance, GuiRegistry.guiCharacter,
			player.worldObj, tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); //<------------------------ Here
	System.out.println("Gui Aperto!");
}

 

I think because xCoord, yCoord and zCoord are empty

I am not going to repeat myself, so i'll quote Draco:

floor, ceiling, round...none of those are going to locate a tile entity that encases the player's feet.

You should get the location of the tile entity from itself and pass the xyz in the packet.

And add that question: what is TileEntityCharacter supposed to do, and why do you insist on locating it inside the player ?

 

No:

 

TileEntity tileEntity = player.worldObj.getBlockTileEntity((int)player.posX, (int)player.posY, (int)player.posZ);

 

Your tileEntity is null.  Because there's no tile entity AT that location.  This has been your problem from the beginning.  There is not, will not, never has been a tile entity at the player's feet because THERE IS NO ENTITY THERE so stop trying to reference it.

 

You get a crash on that line because null does not have an xCoord value.

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.

  • Author

No:

 

TileEntity tileEntity = player.worldObj.getBlockTileEntity((int)player.posX, (int)player.posY, (int)player.posZ);

 

Your tileEntity is null.  Because there's no tile entity AT that location.  This has been your problem from the beginning.  There is not, will not, never has been a tile entity at the player's feet because THERE IS NO ENTITY THERE so stop trying to reference it.

 

You get a crash on that line because null does not have an xCoord value.

 

I think I need to change everything, because my intention was a new inventory gui (not like the standard one, but like the inventory character of every RPG) here's the screen:

MNGk0cZ.png

I need to delete tileentity, make a NEW container and a NEW gui (I delete the old ones) and then open it with "Minecraft.getMinecraft().displayGuiScreen();" right?

Yes.

 

Delete the tile entity.

 

You're not using a tile entity.  At all.  Anywhere.  Get rid of it.  Player inventory screen is not a tile entity.

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.

I need to delete tileentity, make a NEW container and a NEW gui (I delete the old ones) and then open it with "Minecraft.getMinecraft().displayGuiScreen();" right?

You can keep your GuiCharacter and ContainerCharacter. Just delete anything related to TileEntityCharacter.

  • Author

Finally, it works! It opens the gui, but it isn't resized as well. I'm fixing this problem right now, if you can help me then do it :D

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

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.