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.

[1.7.10] How would you give survival mode player an item on Login/Spawn

Featured Replies

Posted

I want to give the player in survival mode a series of items when the player logs in and when he spawns after death. So far I have tried the following but it doesnt do anything

 

@SubscribeEvent
public void onJoinWorld(EntityJoinWorldEvent event) {
	if (event.entity instanceof EntityPlayer && !event.entity.worldObj.isRemote) {
		PacketOverlord.sendTo(new PacketSyncPlayerStamina((EntityPlayer) event.entity), (EntityPlayerMP) event.entity);
		//System.out.println("This is called # 1");
		if(Minecraft.getMinecraft().thePlayer != null && Minecraft.getMinecraft().currentScreen instanceof GuiInventory){
			//System.out.println("This is not called");
	        Minecraft.getMinecraft().thePlayer.inventory.addItemStackToInventory(new ItemStack(CommonProxy.itemCustom1));
				}}
}

 

Not sure what Im doing wrong

 @SubscribeEvent
public void onPlayerJoin(PlayerLoggedInEvent event)
{
if (!event.player.worldObj.isRemote)
{
	event.player.inventory.addItemStackToInventory(new ItemStack(Items.stick));
}
}

 

Ur welcome

  • 2 years later...

I tried using your code, Failender, but it didn't work. If this is outdated, how would you do this now?

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.