Jump to content

getPlayerByUUID doesn't work ?


Armanse

Recommended Posts

Hi i have couple of question about the getPlayerByUUID method. 

First: Does the UUID change when i quit and govback into the game?

Second: when i tried to use getPlayerByUUID and i put the uuid of a player in it like that for example:

this.player = this.level.getPlayerByUUID(UUID.fromString(this.key));
this.player.kill();

My game crashes and i really don't know why.

Is there any alternatives to get a player? Am i doing it wrong ?

Furthermore my goal here is to "save" the player in a compoundTag that's why i'm using uuids. Ty for helping me

Link to comment
Share on other sites

14 minutes ago, Armanse said:

Does the UUID change when i quit and govback into the game?

the UUID is fix and unique

15 minutes ago, Armanse said:

Second: when i tried to use getPlayerByUUID and i put the uuid of a player in it like that for example:

post log

15 minutes ago, Armanse said:

Is there any alternatives to get a player? Am i doing it wrong ?

where do you need the player? show more of your code

Link to comment
Share on other sites

What i need is the player yes. When i run the game its ok but when the method player.kill() is being proccessed the game just crashes and it does that with send message, changedimension and basicly every other methode that the "player" can use that's why i think the problem comes from getPlayerByUUID. Here is the post log:

 Encountered an unexpected exception
net.minecraft.ReportedException: Ticking entity
	at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:886) ~[forge-1.17.1-37.0.103_mapped_official_1.17.1-recomp.jar%2375!:?]
	at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:818) ~[forge-1.17.1-37.0.103_mapped_official_1.17.1-recomp.jar%2375!:?]
	at net.minecraft.client.server.IntegratedServer.tickServer(IntegratedServer.java:85) ~[forge-1.17.1-37.0.103_mapped_official_1.17.1-recomp.jar%2375!:?]
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:683) ~[forge-1.17.1-37.0.103_mapped_official_1.17.1-recomp.jar%2375!:?]
	at net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:258) ~[forge-1.17.1-37.0.103_mapped_official_1.17.1-recomp.jar%2375!:?]
	at java.lang.Thread.run(Thread.java:831) [?:?]
Caused by: java.lang.NullPointerException: Cannot invoke "net.minecraft.world.entity.player.Player.kill()" because "this.player" is null
	at com.armanse.dreamy.entity.SleepingPlayerEntity.awakening(SleepingPlayerEntity.java:88) ~[%2379!:?]
	at com.armanse.dreamy.entity.SleepingPlayerEntity.tick(SleepingPlayerEntity.java:72) ~[%2379!:?]
	at net.minecraft.server.level.ServerLevel.tickNonPassenger(ServerLevel.java:623) ~[forge-1.17.1-37.0.103_mapped_official_1.17.1-recomp.jar%2375!:?]
	at net.minecraft.world.level.Level.guardEntityTick(Level.java:488) ~[forge-1.17.1-37.0.103_mapped_official_1.17.1-recomp.jar%2375!:?]
	at net.minecraft.server.level.ServerLevel.lambda$tick$5(ServerLevel.java:384) ~[forge-1.17.1-37.0.103_mapped_official_1.17.1-recomp.jar%2375!:?]
	at net.minecraft.world.level.entity.EntityTickList.forEach(EntityTickList.java:54) ~[forge-1.17.1-37.0.103_mapped_official_1.17.1-recomp.jar%2375!:?]
	at net.minecraft.server.level.ServerLevel.tick(ServerLevel.java:365) ~[forge-1.17.1-37.0.103_mapped_official_1.17.1-recomp.jar%2375!:?]
	at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:882) ~[forge-1.17.1-37.0.103_mapped_official_1.17.1-recomp.jar%2375!:?]
	... 5 more
Negative index in crash report handler (11/26)
[12:03:59] [Server thread/DEBUG] [ne.mi.fm.lo.FileUtils/CORE]: Found existing serverconfig directory : .\saves\New World\serverconfig
[12:03:59] [Server thread/DEBUG] [ne.mi.fm.co.ConfigTracker/CONFIG]: Unloading configs type SERVER
---- Minecraft Crash Report ----
// There are four lights!

Time: 13/11/2021 12:04
Description: mouseClicked event handler

java.net.ConnectException: connection refused: local:E:ef7c32f1
	at io.netty.channel.local.LocalChannel$LocalUnsafe.connect(LocalChannel.java:491) ~[netty-all-4.1.25.Final.jar%2335!:4.1.25.Final] {}
	at io.netty.channel.DefaultChannelPipeline$HeadContext.connect(DefaultChannelPipeline.java:1366) ~[netty-all-4.1.25.Final.jar%2335!:4.1.25.Final] {}
	at io.netty.channel.AbstractChannelHandlerContext.invokeConnect(AbstractChannelHandlerContext.java:545) ~[netty-all-4.1.25.Final.jar%2335!:4.1.25.Final] {}
	at io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChannelHandlerContext.java:530) ~[netty-all-4.1.25.Final.jar%2335!:4.1.25.Final] {}
	at io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChannelHandlerContext.java:512) ~[netty-all-4.1.25.Final.jar%2335!:4.1.25.Final] {}
	at io.netty.channel.DefaultChannelPipeline.connect(DefaultChannelPipeline.java:1024) ~[netty-all-4.1.25.Final.jar%2335!:4.1.25.Final] {}
	at io.netty.channel.AbstractChannel.connect(AbstractChannel.java:259) ~[netty-all-4.1.25.Final.jar%2335!:4.1.25.Final] {}
	at io.netty.bootstrap.Bootstrap$3.run(Bootstrap.java:252) ~[netty-all-4.1.25.Final.jar%2335!:4.1.25.Final] {}
	at io.netty.channel.DefaultEventLoop.run(DefaultEventLoop.java:54) ~[netty-all-4.1.25.Final.jar%2335!:4.1.25.Final] {}
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884) ~[netty-all-4.1.25.Final.jar%2335!:4.1.25.Final] {}
	at java.lang.Thread.run(Thread.java:831) ~[?:?] {}


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

-- Head --
Thread: Render thread
Stacktrace:
	at net.minecraft.client.gui.screens.Screen.wrapScreenError(Screen.java:533) ~[forge-1.17.1-37.0.103_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
-- Affected screen --
Details:
	Screen name: net.minecraft.client.gui.screens.worldselection.SelectWorldScreen
Stacktrace:
	at net.minecraft.client.gui.screens.Screen.wrapScreenError(Screen.java:533) ~[forge-1.17.1-37.0.103_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.MouseHandler.onPress(MouseHandler.java:85) ~[forge-1.17.1-37.0.103_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.MouseHandler.lambda$setup$4(MouseHandler.java:181) ~[forge-1.17.1-37.0.103_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.util.thread.BlockableEventLoop.execute(BlockableEventLoop.java:90) ~[forge-1.17.1-37.0.103_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.client.MouseHandler.lambda$setup$5(MouseHandler.java:180) ~[forge-1.17.1-37.0.103_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading,pl:runtimedistcleaner:A}
	at org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:36) ~[lwjgl-glfw-3.2.2.jar%2354!:build 10] {}
	at org.lwjgl.system.JNI.invokeV(Native Method) ~[lwjgl-3.2.2.jar%2360!:build 10] {}
	at org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:3101) ~[lwjgl-glfw-3.2.2.jar%2354!:build 10] {}
	at com.mojang.blaze3d.systems.RenderSystem.flipFrame(RenderSystem.java:139) ~[forge-1.17.1-37.0.103_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading,pl:runtimedistcleaner:A}
	at com.mojang.blaze3d.platform.Window.updateDisplay(Window.java:333) ~[forge-1.17.1-37.0.103_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.runTick(Minecraft.java:1062) ~[forge-1.17.1-37.0.103_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.run(Minecraft.java:659) ~[forge-1.17.1-37.0.103_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.main.Main.main(Main.java:186) ~[forge-1.17.1-37.0.103_mapped_official_1.17.1-recomp.jar%2375!:?] {re:classloading,pl:runtimedistcleaner:A}
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?] {}
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}
	at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?] {}
	at net.minecraftforge.fml.loading.targets.ForgeClientUserdevLaunchHandler.lambda$launchService$0(ForgeClientUserdevLaunchHandler.java:38) ~[fmlloader-1.17.1-37.0.103.jar%233!:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-9.0.7.jar%238!:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-9.0.7.jar%238!:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) [modlauncher-9.0.7.jar%238!:?] {}
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) [modlauncher-9.0.7.jar%238!:?] {}
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-9.0.7.jar%238!:?] {}
	at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-9.0.7.jar%238!:?] {}
	at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-9.0.7.jar%238!:?] {}
	at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:90) [bootstraplauncher-0.1.17.jar:?] {}


-- Last reload --
Details:
	Reload number: 1
	Reload reason: initial
	Finished: Yes
	Packs: Default, Mod Resources
Link to comment
Share on other sites

Hi!

As you can see here:

1 hour ago, Armanse said:
Caused by: java.lang.NullPointerException: Cannot invoke "net.minecraft.world.entity.player.Player.kill()" because "this.player" is null
this.level.getPlayerByUUID(UUID.fromString(this.key));

is null and I think that 

this.key

is causing the problem.

Try adding a null test:

this.player = this.level.getPlayerByUUID(UUID.fromString(this.key));
if (this.player != null) {
  this.player.kill();
} else {
  System.out.println("Player is null!")
}

 

Sorry if my Posts are weird sometimes, I just try to help and learn as much as I can :D

Also: PLEASE use SPOILERS for logs!

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.



×
×
  • Create New...

Important Information

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