Jump to content

[1.7.10][Solved]GUI that chnges tile entity variables doesn't work


Recommended Posts

Posted

Hi.

I have a block called Password Lock that when you set up your code and receiver for it, when you type right code, receiver sends a redstone signel. For receiver, I have done this through metadata.

And the password lock through tile entity. But there isn's this problem. Problem is in it's gui. I opened it through

Minecraft.getMinecraft().displayGuiScreen(new PasswordLockScreen(world, x, y, z))

and it worked fine, but when I tried it in Lan(First player,(Me from first window, and opened LAN through this window) and second player playing through another window(All on one computer)

When first player opened it's GUI, it displayed to him, but when second player tried this, nothing happens to him, but it displayed to first player.

Then, I tried this using player.openGUI() <Through GUI Handler> and GUI opens, but when I typed right password and clicked UNLOCK, nothing happened.

I think it is because it has to be opened on server side, but GUI screen opens on client side and this block has no container because it has no slots.

And when you decide to delete my topic, please send me a reason.

In my code I currently use MainLib.openGui(new PasswordLockScreen(world, x, y, z)) that does Minecraft.getMinecraft().displayGuiScreen(new PasswordLockScreen(world, x, y, z));

This blocks also has a feature for changing password, that is PasswordChangeScreen.java

 

Here is my code.

 

  Reveal hidden contents

 

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

Posted

What.. You should use this method: 'EntityPlayerMP#openGui',

  because it needs interaction between the Server World and the Client.

As you already set up your Gui Handler, what you need to do is just setting your container for the PasswordLockScreen.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

But what I write into container?

 

And, What is EntityPlayerMP?

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

Posted

You just need to follow some tutorials.. There are tons of tutorials about containers and guis for basic tileentity on Internet.

Just take one and follow that.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

I followed one tutorial, but I know Containers are used to create slots in Gui. And I don't need any slots in this gui. And when I make some slots I just made cheat machine, because I had problem with container with item duplication and administrators deleted these 3 topics about it. I posted it first time, they deleted it, I posted, they deleted it and the same at third time. I really don't know why they deleted the first topic about it.

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

Posted

And when I searched for tutorials, I found only one, but it was fo 1.6.4. Then, I followed it and then looked at cpw's ironchest code.

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

Posted

You don't need a container for this, you need to send a packet to the server to change the password in the TileEntity. TO open the gui, use [/code]EntityPlayer#openGui(parameters)[/code] on the client side (world.isRemote =

true

), and in your IGuiHandler, return the proper gui for the proper guiID, and return null for the container.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

Ok, but how can I send packet?

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

Posted

Well, thanks.

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

Posted

I have still problems with that.

I have seen You (diesieben07) wrote to one member: You can't simply change tile entity variables. It's used to prevent from hacks.

What did you mean at "hacks"?

If it is true, how could some modders made this?

And, I followed your tutorial and created this class.

There can be two errors: handler's method onMessage does not work or I wrong coded sender.

I used this for sending this packet.

MainRegistry.packets is SimpleNetworkWrapper as showed in your tutorial.

MainRegistry.packets.sendToServer(new PacketMessage("unlock", x, y, z));

 

Here is my code for this packet.

 

  Reveal hidden contents

 

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

Posted
  On 3/29/2015 at 4:37 PM, Enginecrafter said:

I have seen You (diesieben07) wrote to one member: You can't simply change tile entity variables. It's used to prevent from hacks.

 

Sorry for that.

 

And what method can I use as replacement for ByteBufUtils.readUTF8String(buf)?

And I added System.out.println(something) to onMessage and it does nothing.

 

And when I said "sender" I meant  MainRegistry.packets.sendToServer(new PacketMessage("unlock", x, y, z))

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

Posted

Registering packet and SimpleNetworkWrapper(Main mod class)

public static SimpleNetworkWrapper packets = NetworkRegistry.INSTANCE.newSimpleChannel("MyChannel");
@EventHandler
public static void preLoad(FMLPreInitializationEvent PreEvent)
{
	packets.registerMessage(PacketMessage.Handler.class, PacketMessage.class, 0, Side.SERVER);
}

 

*Don't think I have only packet in my mod. I have some other things in my mod.

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

Posted

Yes and No, I am not sure, if it was sent.

Here is code where it sends packet.

Currently, I didn't modify lines with mc.displayGuiScreen or MainLib.openGui.

I change them when we solve this problem.

 

 

  Reveal hidden contents

 

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

Posted

Ohhh, sorry, it was working, but I pressed wrong button in the GUI.

And when I pressed right button and closed GUI, it disconnected me from my single-player world and writes on screen: A fatal error occured, exited this connection.

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

Posted

Ok, I found the error. The error was in my PacketMessage.java where in both fromBytes and ToBytes I checked if the password is required using this: if(!password.equals("not set")) and when it was null, it throwed me exception. :-)

I repaired it with adding boolean isPasswordRequired and in second constructor(first must be default) setted this variable to false and in third constructor(only for changing password) setted it to true.

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

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



×
×
  • Create New...

Important Information

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