Jump to content

[1.8][clientside] getPlayerUUID


Noxyper

Recommended Posts

Good evening, ladies and gentlemen of minecraftforge.net!

I've come to you today to ask you for one thing. Help.

 

You see, I've been having troubles with my mod and I got a message from a certain UberAffe on minecraftforum.net to get help from here as he currently is unavailable to help me. What I want to do is to update a method in my armor class on the server side, and for that I need a packet. The packet has been made, but my trouble is to call it.

 

The simple process here is that you press the letter 'I' and you'll turn invisible. The advanced one is that you press the letter 'I,' the KeyHandler sends a message to my packet, updates my method on the server side and I turn invisible. My problem here is to send a message. How do I call the UUID in a keyhandler method? My current code would work, but it is asking for a GameProfile, which I don't know where to get.

 

If you need the code, my github code is here below:

 

MainClass.class

https://github.com/BlackHyp3r/GnC/blob/master/MainFile

 

Armor.class

https://github.com/BlackHyp3r/GnC/blob/master/NexiteTankArmor

 

Message.class (w/ Handler.class)

https://github.com/BlackHyp3r/GnC/blob/master/Message%2BHandler

 

EventHandler.class

https://github.com/BlackHyp3r/GnC/blob/master/EventListener

 

Hope you'll be able to help!

 

P.S. If you need to look at the original forum post, link is below

http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/modification-development/2504527-armor-with-special-powers?page=2#c21

Link to comment
Share on other sites

You can just send a message(packet) from client to server.

Then in your IMessageHandler, you can get the player instance from MessageContext.

You can make the player invisible with the instance.

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

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

Link to comment
Share on other sites

For those who don't read the original post in the link, the confusion with trying to send the player uuid in the message comes from me.

I wasn't aware that you could get the player that sent the message from the context.

 

@BlackHyp3r you don't need to send the uuid in the message, in your onmessage override you can get the player from the MessageContext variable.

Current Project: Armerger 

Planned mods: Light Drafter  | Ore Swords

Looking for help getting a mod off the ground? Coding  | Textures

Link to comment
Share on other sites

If someone really needs to know the UUID in packet, you have to convert to a String (there are other ways to skin the cat too) and back.

 

buffer.writeString(player.getUniqueID.toString()) and then UUID.fromString(buffer.getString())  - Code is probably not exactly right, but it is close enough you should be able to figure it out.

Long time Bukkit & Forge Programmer

Happy to try and help

Link to comment
Share on other sites

Also, you can simply send the player's current entityId instead of UUID, but as diesieben and others have said, you already have the player from the packet.

 

The only reason you would even want to do something like that is if you needed a DIFFERENT player in the packet, e.g. player 1 is interacting with player 2, and you need player 2 (in addition to player 1, which you will have by default) when sending the packet to player 1.

Link to comment
Share on other sites

Sorry I haven't responded on this post for the past 2 days, school started again (yay -_-) Anyways, how do I tell the onMessage method that this message will recieve information about a player? Should I follow what delpi said or is that not necessary for what I'm doing?

Link to comment
Share on other sites

Alright, let me see...

I might just be stupid here, but it seems as if 4/5 responses on this thread is about recieving the player from the message. In the EventHandler, I'm sending a message with said player. But how would I do that, and/or is that even necessary? If not, then how do I do this?

Link to comment
Share on other sites

And I'm immediatly back for more knowledge! If you couldn't tell, I'm pretty new to packets, so how do I check what message got recieved? If I send a message saying "player invisible" then how do the MessageHandler check for that specific method?

Link to comment
Share on other sites

Don't send a text for a simple action... Use an int with defined constants.

 

Even better you may not need to send anything in the payload at all. If the message is always meant to trigger a single action, just receiving the message should be enough for server. In such a case, the fromBytes() and toBytes() methods can be empty. Just need to put the code in the Handler part.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Following all of your directions it should work now... if it wasn't for the game crashing. Anyone who understands it?

 

 

[21:59:16] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:663]: ---- Minecraft Crash Report ----

// Uh... Did I do that?

 

Time: 2015-08-21 21:59

Description: Initializing game

 

java.lang.RuntimeException: java.lang.InstantiationException: minenemo.gearsandclouds.packet.GnCPacket$GnCPacketHandler

at com.google.common.base.Throwables.propagate(Throwables.java:160)

at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.instantiate(SimpleNetworkWrapper.java:116)

at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.registerMessage(SimpleNetworkWrapper.java:106)

at minenemo.gearsandclouds.GearsAndClouds.Init(GearsAndClouds.java:66)

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:483)

at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:537)

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:483)

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 net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)

at net.minecraftforge.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:483)

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 net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119)

at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:731)

at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:315)

at net.minecraft.client.Minecraft.startGame(Minecraft.java:528)

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

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

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:483)

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

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

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)

at GradleStart.main(Unknown Source)

Caused by: java.lang.InstantiationException: minenemo.gearsandclouds.packet.GnCPacket$GnCPacketHandler

at java.lang.Class.newInstance(Class.java:418)

at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.instantiate(SimpleNetworkWrapper.java:113)

... 41 more

Caused by: java.lang.NoSuchMethodException: minenemo.gearsandclouds.packet.GnCPacket$GnCPacketHandler.<init>()

at java.lang.Class.getConstructor0(Class.java:2971)

at java.lang.Class.newInstance(Class.java:403)

... 42 more

 

 

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

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

 

-- Head --

Stacktrace:

at com.google.common.base.Throwables.propagate(Throwables.java:160)

at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.instantiate(SimpleNetworkWrapper.java:116)

at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.registerMessage(SimpleNetworkWrapper.java:106)

at minenemo.gearsandclouds.GearsAndClouds.Init(GearsAndClouds.java:66)

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:483)

at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:537)

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:483)

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 net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)

at net.minecraftforge.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:483)

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 net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119)

at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:731)

at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:315)

at net.minecraft.client.Minecraft.startGame(Minecraft.java:528)

 

-- Initialization --

Details:

Stacktrace:

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

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

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:483)

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

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

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)

at GradleStart.main(Unknown Source)

 

-- System Details --

Details:

Minecraft Version: 1.8

Operating System: Windows 8.1 (amd64) version 6.3

Java Version: 1.8.0_05, Oracle Corporation

Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

Memory: 648797256 bytes (618 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)

JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0

FML: MCP v9.10 FML v8.0.99.99 Minecraft Forge 11.14.3.1450 4 mods loaded, 4 mods active

States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

UCHI mcp{9.05} [Minecraft Coder Pack] (minecraft.jar)

UCHI FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8-11.14.3.1450.jar)

UCHI Forge{11.14.3.1450} [Minecraft Forge] (forgeSrc-1.8-11.14.3.1450.jar)

UCHE gnc{0.2} [Gears N' Clouds] (bin)

Loaded coremods (and transformers):

GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 355.60' Renderer: 'GeForce GTX 760/PCIe/SSE2'

Launched Version: 1.8

LWJGL: 2.9.1

OpenGL: GeForce GTX 760/PCIe/SSE2 GL version 4.5.0 NVIDIA 355.60, NVIDIA Corporation

GL Caps: Using GL 1.3 multitexturing.

Using GL 1.3 texture combiners.

Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.

Shaders are available because OpenGL 2.1 is supported.

VBOs are available because OpenGL 1.5 is supported.

 

Using VBOs: No

Is Modded: Definitely; Client brand changed to 'fml,forge'

Type: Client (map_client.txt)

Resource Packs: []

Current Language: English (US)

Profiler Position: N/A (disabled)

[21:59:16] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:663]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\Nemo\Desktop\Programming\Gears N' Clouds 1.8\eclipse\.\crash-reports\crash-2015-08-21_21.59.16-client.txt

AL lib: (EE) alc_cleanup: 1 device not closed

Java HotSpot 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release

 

Link to comment
Share on other sites

I've localized the problem... I think...

When sneding the message I write the line like this:

    GearsAndClouds.network.sendToServer(new GnCPacket("player invisible"));

 

I think they mean that new. How do I work around that?

No, that's not it. You have to make a new instance of the message class to send it, and the error message specifically said it crashed trying to create a new instance of GnCPacketHandler, which the above is not.

 

Show your entire GnCPacket class, including the inner GnCPacketHandler class.

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

    • Hi I have an issue with a server it solved deleting the ice and fire but my friends and me really want to use it does any of these mods are causing the issue due to incompatibility  Security craft Aquaculture Architectury Artifacts Astikorcarts Baubles BetterCaves yungs BetterStrongholds yungs BetterMineshafts yungs Bountiful Byg  Callablehorses Carry on Chococraft Citadel Clumps Collective Comforts Corailrecycler Craftable horse armor Comes alive Curios forge Decocraft Dungeonsarise  Open blocks elevator Expandability Farlanders Goblin traders Hwyla  Ice and fire Infernal expansion Jei Jump over fences Mantle  Macaws bridges Macaws doors Macaws fences Macaws furniture  Macaws fencesbyg Morpheus Mouse tweaks Mowzies mobs Obfuscate Paraglider Patchouli  Pick up notifier Random village names Spartan shields Small ships Sophisticated backpacks Spartan weaponry Storage drawers straw golem Structure gel Twilight forest  Tinkers construct Two players one horse  Valhesia core  Valhesia structures  Way stones  Vehicle mod  Wall jump Wings Wolves with armor Xptome  Xaeros minimap  Yungsapi  
    • { "type": "magic_overhaul:rune_inscribing", "base": { "item": "//base item" }, "template": { "item": "//template item" }, "output": { "count": 1, "item": "//output item" } } ^ Ok, where is your recipe JSON placed in your file structure? What's it called? And paste the actual JSON you're testing with, because it needs to be valid.
    • I'm trying to run Forge 1.12.2 on Minecraft  so I can use certain mods, but this error popped up. I've seen multiple errors but I just can't figure this one out. Unable to locate the Java runtime. Error details: 0x00000000 - system: The operation completed successfully. Filename on disk:  Path: . Exists: Directory
    • https://mclo.gs/b422RFc
    • Плагин и Приват
  • Topics

×
×
  • Create New...

Important Information

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