Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.12] How to get Player entity on multiplayer client-side?
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 1
Hanashi

[1.12] How to get Player entity on multiplayer client-side?

By Hanashi, September 6, 2017 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Hanashi    0

Hanashi

Hanashi    0

  • Tree Puncher
  • Hanashi
  • Members
  • 0
  • 7 posts
Posted September 6, 2017 (edited)

Hi,

 

I need the player object client-side on multiplayer. I found "Minecraft.getMinecraft().thePlayer" in the WWW, but "thePlayer" is not a property of class "Minecraft". How can I get the local player?

 

kind regards

Hanashi

Edited September 6, 2017 by Hanashi
  • Quote

Share this post


Link to post
Share on other sites

That_Martin_Guy    7

That_Martin_Guy

That_Martin_Guy    7

  • Creeper Killer
  • That_Martin_Guy
  • Members
  • 7
  • 177 posts
Posted September 6, 2017

Minecraft.getMinecraft().player, although keep in mind that this will crash if you run it in common code.

  • Quote

Share this post


Link to post
Share on other sites

Hanashi    0

Hanashi

Hanashi    0

  • Tree Puncher
  • Hanashi
  • Members
  • 0
  • 7 posts
Posted September 6, 2017
3 minutes ago, That_Martin_Guy said:

Minecraft.getMinecraft().player, although keep in mind that this will crash if you run it in common code.

Thank you, but the result is every time "null".

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted September 6, 2017

Post more of your code. What are you trying to achieve?

  • Quote

Share this post


Link to post
Share on other sites

That_Martin_Guy    7

That_Martin_Guy

That_Martin_Guy    7

  • Creeper Killer
  • That_Martin_Guy
  • Members
  • 7
  • 177 posts
Posted September 6, 2017

Did you run it in common code? Preferably you should get the object in the ClientProxy. Can't really say much more than that since I'm pretty terrible at explaining things, honestly.

  • Quote

Share this post


Link to post
Share on other sites

Hanashi    0

Hanashi

Hanashi    0

  • Tree Puncher
  • Hanashi
  • Members
  • 0
  • 7 posts
Posted September 6, 2017
2 minutes ago, diesieben07 said:

Post more of your code. What are you trying to achieve?

Currently I tested this:

@SubscribeEvent
public void onClientConnect(FMLNetworkEvent.ClientConnectedToServerEvent e) {
	EntityPlayerSP player = Minecraft.getMinecraft().player;
	System.out.println(player);
}

I would get the player name and later in another event the position, but I need the player entity for this.

 

@That_Martin_Guy what did you mean with "common code"?

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted September 6, 2017

At that point the player is not set up yet.

Once again: What are you trying to achieve (not: How are you trying to program it)?

  • Quote

Share this post


Link to post
Share on other sites

Hanashi    0

Hanashi

Hanashi    0

  • Tree Puncher
  • Hanashi
  • Members
  • 0
  • 7 posts
Posted September 6, 2017
4 minutes ago, diesieben07 said:

At that point the player is not set up yet.

Once again: What are you trying to achieve (not: How are you trying to program it)?

I would only get the position/coordinates of the local player and print it in the console.

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted September 6, 2017

What for? Why on the client?

  • Quote

Share this post


Link to post
Share on other sites

Hanashi    0

Hanashi

Hanashi    0

  • Tree Puncher
  • Hanashi
  • Members
  • 0
  • 7 posts
Posted September 6, 2017
2 minutes ago, diesieben07 said:

What for? Why on the client?

I would create a client side wrapper for a teamspeak 3 client. For this I need the position of the local player and all other player on the server.

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted September 6, 2017

Ok. And you need that in that specific event, because...?

  • Quote

Share this post


Link to post
Share on other sites

Hanashi    0

Hanashi

Hanashi    0

  • Tree Puncher
  • Hanashi
  • Members
  • 0
  • 7 posts
Posted September 6, 2017
Just now, diesieben07 said:

Ok. And you need that in that specific event, because...?

For testing. I will use it in another event later, but currently I need this event for debugging.

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted September 6, 2017

Well, that event is before there is a player, that is why you are getting null.

  • Like 2
  • Quote

Share this post


Link to post
Share on other sites

Hanashi    0

Hanashi

Hanashi    0

  • Tree Puncher
  • Hanashi
  • Members
  • 0
  • 7 posts
Posted September 6, 2017
4 minutes ago, diesieben07 said:

Well, that event is before there is a player, that is why you are getting null.

Thank you that's the solution :D now it works (I tested with a little timer).

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • PolarBr0
      Forge 1.12.2 crashes and wont load world!

      By PolarBr0 · Posted 4 minutes ago

      I downloaded forge and got 1 mod. I watched multiple tutorials and did everything right. But in 1.12.2 when I load into my world i crashes and says something about 2048 bit is 0 or something.     The game crashed whilst exception initializing level Error: java.lang.IllegalArgumentException: ChunkNibbleArrays should be 2048 bytes not: 0
    • salvestrom
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By salvestrom · Posted 44 minutes ago

      Also, your model renderer should extend abstract horse renderer, not mob renderer.
    • salvestrom
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By salvestrom · Posted 48 minutes ago

      Remove this and put this in the constructor super "new UnicornModel<>(0)". The model file has to extend HorseModel Or you will not get the animations. In the renderer Create:      And return "unicorn" in getEntityTexture. ");
    • Oliviafrostpaw
      [1.14.4] Injecting into Existing Loot Tables, Blocks

      By Oliviafrostpaw · Posted 1 hour ago

      So, I have attempted with changing the whole class EventBusSubscriber to being Forge, which didnt trigger the event, I attempted creating a new class inside of the main class that has the Forge Subscriber, tried with having no conditions on the Mod.EventBusSubscriber, and finally tried with a whole new class, InjectionHandler.java, that has Mod.EventBusSubscriber with and without Mod.EventBusSubscriber.Bus.FORGE as a condition and just the onLootLoad function inside and still didnt trigger So Im about as lost as before. Once again, apologies for my lack of knowledge about the EventBus Intricacies. Spent the time the last few days and few hours searching for examples and other peoples questions on the topic and never came up with much conclusive
    • AdieCraft
      Santa's Christmas Sleigh (Complete with Rudolph and Reindeer)

      By AdieCraft · Posted 1 hour ago

      Hello there!   Welcome back to AdieCraft! Today's video is a festive one in the Christmas Builds series, looking at how to build a Santa's Sleigh, which you can ride in and the Reindeer pulling it. Check it out.   Watch the Santa's Christmas Sleigh video here    
  • Topics

    • PolarBr0
      0
      Forge 1.12.2 crashes and wont load world!

      By PolarBr0
      Started 4 minutes ago

    • DragonITA
      43
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA
      Started Monday at 10:06 AM

    • Oliviafrostpaw
      12
      [1.14.4] Injecting into Existing Loot Tables, Blocks

      By Oliviafrostpaw
      Started December 8

    • AdieCraft
      0
      Santa's Christmas Sleigh (Complete with Rudolph and Reindeer)

      By AdieCraft
      Started 1 hour ago

    • Grain Mush
      6
      Failed to download file

      By Grain Mush
      Started December 1

  • Who's Online (See full list)

    • DragonITA
    • diesieben07
    • Redstoneguy129
    • loordgek
    • PolarBr0
    • athy
    • J0WAY
    • Alatyami
    • PrinceRaiden
    • T_VDP
    • camramjam07
    • TehStoneMan
    • Memelord679
    • CAS_ual_TY
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.12] How to get Player entity on multiplayer client-side?
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community