Give item when player spawns

Started by Araa2000 on

Topic category: Advanced modding

Last seen on 12:58, 18. Dec 2015
Joined Oct 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Give item when player spawns
Fri, 04/24/2020 - 11:52 (edited)

Im planning to make a mod that has an help/guidebook which tells crafting recipes and other information about the stuff of my mod. Is there any way to give the book to player when player spawns. Hopefully you understood  im not english :).

Edited by Araa2000 on Fri, 04/24/2020 - 11:52
Last seen on 21:24, 7. Feb 2019
Joined Jan 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I dont think this is possible
Sat, 10/10/2015 - 16:26

I dont think this is possible without coding,but maybe you should try to make a "Keybind" that when you press for a example the letter H in your keyboard it do the "Add item to inventory" event,then you just set it to add the guidebook!P.S. I hope you understood im not english too xD

Last seen on 11:59, 20. Apr 2019
Joined Nov 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
i think GH127 is right
Sat, 10/10/2015 - 19:25

i think GH127 is right

Last seen on 00:02, 21. Mar 2018
Joined Mar 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Have you looked into world
Wed, 04/06/2016 - 20:26

Have you looked into world events? I want to do the same just have not got to it yet still working on world gen first

Last seen on 09:20, 22. Nov 2021
Joined Nov 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
First of all Make a variable.
Wed, 04/06/2016 - 23:03

First of all Make a variable.  NewPlayer, make this variabe logic, and set it to true.  This way whenever anyone first joins the world or server they will be defined as a NewPlayer.

1: Make a block that will at every tick give all new players the book.

2: keybind that gives everyone who is NewPlayer the book

3: When ever a NewPlayer Chats (Global Event) he/she gets the book

Now Create a GUI that

 

 

Last seen on 01:31, 15. May 2020
Joined Mar 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Make A Custom Variable…
Mon, 03/12/2018 - 05:42

Make A Custom Variable. Every tick, check if variable = 1. If it does not, give item and set variable to 2. If variable = 2, do nothing.

Last seen on 12:44, 9. Feb 2021
Joined Oct 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Go into the code editor and…
Wed, 06/27/2018 - 00:40

Go into the code editor and find: 'ClientProxytestenvironmentmod.java' should look like below.

package mod.mcreator;

public class ClientProxytestenvironmentmod extends CommonProxytestenvironmentmod {

	@Override
	public void registerRenderers(testenvironmentmod ins) {
		ins.mcreator_0.registerRenderers();

	}
}

Now paste the following into it on line 10:
 

	@SubscribeEvent
	//@SideOnly(Side.CLIENT)
	   public void JoinWorld(PlayerLoggedInEvent event) {
	      EntityPlayer player = event.player;
	      NBTTagCompound entityData = player.getEntityData();

	        	 		player.inventory.addItemStackToInventory(new ItemStack(###ITEM_GOES_HERE###));
						
		}

Like this:

 

package mod.mcreator;

public class ClientProxytestenvironmentmod extends CommonProxytestenvironmentmod {

	@Override
	public void registerRenderers(testenvironmentmod ins) {
		ins.mcreator_0.registerRenderers();

	}
    
     @SubscribeEvent
     //@SideOnly(Side.CLIENT)
        public void JoinWorld(PlayerLoggedInEvent event) {
           EntityPlayer player = event.player;
           NBTTagCompound entityData = player.getEntityData();

                         player.inventory.addItemStackToInventory(new ItemStack(###ITEM_GOES_HERE###));
                              
          }
}

Just put the Item in the ###ITEM_GOES_HERE### Like this but use your item. 

 

package mod.mcreator;

public class ClientProxytestenvironmentmod extends CommonProxytestenvironmentmod {

	@Override
	public void registerRenderers(testenvironmentmod ins) {
		ins.mcreator_0.registerRenderers();

	}
    
     @SubscribeEvent
     //@SideOnly(Side.CLIENT)
        public void JoinWorld(PlayerLoggedInEvent event) {
           EntityPlayer player = event.player;
           NBTTagCompound entityData = player.getEntityData();

                         player.inventory.addItemStackToInventory(new ItemStack(mcreator_testItem));
                              
          }
}

 

Last seen on 04:38, 22. Oct 2020
Joined Mar 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How would you make it send a…
Wed, 06/27/2018 - 00:47

How would you make it send a specific thing into the chat instead?

Last seen on 17:17, 10. Jan 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
All right, there are quite a…
Wed, 06/27/2018 - 11:09

All right, there are quite a few wrong things about this.
First of all, I have to ask why do you add the code to CLIENT proxy and also why do you even add it to proxy class at all??

That is not how are proxies intended to work. They are used to split client and server side code, and that is not what do you want, especially if you need to do the detection on the server/common side.

Now, I can not see where do you register the class as an event handler, as I do not see the registration to the EVENT_BUS and it is not a static event handler.

Now, you can see that your variable entityData of type NBTTagCompound are not used at all.

  • A) Why do you keep unused variable? If you do not need it, remove it. It is waste of resources.
  • B) You should actually use it for detecting if the player has joined for the first time or not unless you want to give him/her the item every time he/she joins and to be honest, that sounds really annoying.

To be honest, I do not really believe that this code will do anything in the game. Sure, it will recompile and it will not crash the game, but almost certainly, unless there is some code you did not show, it won't do anything.

I guess you picked up the code from some forum and edited until it recompiled successfully to you, judging by previously mentioned and the fact, that there is commented out SideOnly annotation in the tutorial.

Also to the question by NaiduBoys about sending a chat message to the player:
You can use EntityPlayer#sendMessage(ITextComponent).
As ITextComponent parse TextComponentString that takes as a parameter just the text as a string.

Last seen on 04:38, 22. Oct 2020
Joined Mar 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
thanks  
Thu, 06/28/2018 - 07:30

thanks

 

Last seen on 12:44, 9. Feb 2021
Joined Oct 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
To be honest I don't even…
Thu, 06/28/2018 - 22:29

To be honest I don't even use Mcreator, I sometimes download it to see if I can help with some things.

Last seen on 11:02, 22. Aug 2021
Joined Sep 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Sorry, I'm a completely…
Thu, 09/10/2020 - 15:25

Sorry, I'm a completely newbie, I can't find the Internet how to check a global variable, well, true or false, can you tell me how to do this?

I hope google translator did its job well, I'm in the ranks of not English!