Give item when player spawns

Started by Araa2000 on Sat, 10/10/2015 - 14:33
Last seen on 12:58, 18. Dec 2015
Joined Oct 2014
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Give item when player spawns
Sat, 10/10/2015 - 14:33

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 :).

Last seen on 19:05, 25. Feb 2017
Joined Jan 2015
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
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 18:46, 27. Aug 2017
Joined Nov 2014
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
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
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
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 23:39, 23. Apr 2017
Joined Nov 2015
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
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 17:41, 29. Jul 2018
Joined Mar 2018
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
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 22:26, 28. Jun 2018
Joined Oct 2014
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
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 07:24, 3. Oct 2018
Joined Mar 2018
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
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 22:02, 18. Oct 2018
Joined Aug 2013
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
  • wiki contributor
  • moderator
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 07:24, 3. Oct 2018
Joined Mar 2018
User points:

Statistics:

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

thanks

 

Last seen on 22:26, 28. Jun 2018
Joined Oct 2014
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
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.