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.

Featured Replies

Posted

I'm trying to post a message to players, when they login, saying they need to update to the latest version. Now, I've done the whole "getting-the-version" thing. I just need to know what code to put to send the message ONLY WHEN the player logs into the game.

ย 

Thanks in advance :D

Developer of Chlod's Mod! Project Link: http://minecraft.curseforge.com/projects/chlods-mod

PlayerLoggedInEvent, though Ibelieve this event is fired only on the server side; if so and you absolutely must have an event that is fired on the client side (i.e. your mod is a client-side only mod), you can use EntityJoinWorldEvent and check for EntityPlayer before sending the message.

  • Author

PlayerLoggedInEvent, though I believe this event is fired only on the server side; if so and you absolutely must have an event that is fired on the client side (i.e. your mod is a client-side only mod), you can use EntityJoinWorldEvent and check for EntityPlayer before sending the message.

So now, what do I do to check if the Entity is a player, and how do I send the message?

ย 

EDIT: I can't find a tutorial for this exact version and topic on Google, so don't ask me to Google it. Done that already.

Developer of Chlod's Mod! Project Link: http://minecraft.curseforge.com/projects/chlods-mod

Done outside IDE, cannot guarantee if it will work from copy/paste, but the gist of it should be clear.

ย 

As this is for a client-side only mod, you could instead likely cast it directly to Minecraft#getMinecraft()#thePlayer() or whatever the structure of that is again.

public void getPlayer(EntityJoinWorldEvent event){
ย  ย  ย  ย  //Check if the entity is what we are looking for.
ย  ย  ย  ย  if(event.entity instanceof EntityPlayer){
ย  ย  ย  ย  ย  ย  ย  ย  //If its a player, cast the entity to EntityPlayer.
ย  ย  ย  ย  ย  ย  ย  ย  EntityPlayer player = (EntityPlayer) event.entity;
ย  ย  ย  ย  ย  ย  ย  ย  //Now you use "player" instead of "event.entity"
ย  ย  ย  ย  }
}

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

EntityPlayer#addChatComponentMessage to write message from client-side to client-chat.

ย 

1.7.10 is no longer supported by forge, you are on your own.

  • Author

I did it! Thanks guys! :D

Here's the results:

@EventHandler
public void getPlayer(EntityJoinWorldEvent event){
	//Credits: Matryoshika, Ernio and coolAlias on the Minecraft Forge Forums
ย  ย  ย  ย  if(event.entity instanceof EntityPlayer){
ย  ย  ย  ย  ย  ย  ย  ย  EntityPlayer player = Minecraft.getMinecraft().thePlayer; 
ย  ย  ย  ย  ย  ย  ย  ย  ย  ย  player.addChatMessage(new ChatComponentText("text));
ย  ย  ย  ย  }
}

Developer of Chlod's Mod! Project Link: http://minecraft.curseforge.com/projects/chlods-mod

This will fire anytime ANY player joins world.

You need:

if (event.entity == Minecraft#thePlayer)

And ONLY that.

1.7.10 is no longer supported by forge, you are on your own.

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.