Give item when player spawns

Started by Araa2000 on

Topic category: Advanced modding

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
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

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

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

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

 

 

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.

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));
                              
          }
}

 

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?

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.

Joined Mar 2018
Points:

User statistics:

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

thanks

 

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.

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!