terraya Posted December 23, 2016 Share Posted December 23, 2016 Hello Dear Community, i got 2 questions, how to make "Starter Items" , what i mean with "Starter Items" is that when a "new" player joins the server he get items i select. another thing, im doing a "Devil fruits" mod with many new sword/armors etc .. BUT well, how 2 code an item and on "rightclick" i eat it or i use it and it will give me some new items. so well "On Rightclick" ... but i cant find any function or any tut. for this kind of thing and as i know there is no item in Minecraft which does what i need Quote Link to comment Share on other sites More sharing options...
Choonster Posted December 23, 2016 Share Posted December 23, 2016 how to make "Starter Items" , what i mean with "Starter Items" is that when a "new" player joins the server he get items i select. There are two parts to this: Storing whether a player has received the item Giving the item to a player when they log in To store per-player data, you can either use the EntityPlayer.PERSISTED_NBT_TAG sub-compound of Entity#getEntityData or the Capability System. The entity NBT should only be used to store simple data like a flag that's only set once; for anything more complex or frequently accessed you should use capabilities instead. To do something when a player logs in, use PlayerEvent.PlayerLoggedInEvent . I have an example of this using entity NBT here. im doing a "Devil fruits" mod with many new sword/armors etc .. BUT well, how 2 code an item and on "rightclick" i eat it or i use it and it will give me some new items. ItemSoup does this by overriding Item#onItemUseFinish to call the super method and then return an ItemStack of Items.BOWL , replacing the original ItemStack in the player's inventory. If you need to give the player multiple items or your food stacks, simply add the items to their inventory from this method instead of returning a new ItemStack . Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future. Link to comment Share on other sites More sharing options...
terraya Posted December 23, 2016 Author Share Posted December 23, 2016 Thanks CHoonster, the NBT Work, now i wanna see if i can make an "ItemSoup" Quote Link to comment Share on other sites More sharing options...
terraya Posted December 23, 2016 Author Share Posted December 23, 2016 so i want to make him get "Multiple Items" , this works so far: @Override public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) { super.onItemUseFinish(stack, worldIn, entityLiving); return new ItemStack(Items.BOW); } but what do you mean by " this method instead of returning a new ItemStack" , everytime i remove "return" it just show me an error up Quote Link to comment Share on other sites More sharing options...
Animefan8888 Posted December 23, 2016 Share Posted December 23, 2016 so i want to make him get "Multiple Items" , this works so far: @Override public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) { super.onItemUseFinish(stack, worldIn, entityLiving); return new ItemStack(Items.BOW); } but what do you mean by " this method instead of returning a new ItemStack" , everytime i remove "return" it just show me an error up if (entityLiving instanceof EntityPlayer) { ((EntityPlayer) entityLiving).inventory.addItemStackToInventory(new ItemStack(...); } Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
Choonster Posted December 23, 2016 Share Posted December 23, 2016 so i want to make him get "Multiple Items" , this works so far: @Override public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) { super.onItemUseFinish(stack, worldIn, entityLiving); return new ItemStack(Items.BOW); } but what do you mean by " this method instead of returning a new ItemStack" , everytime i remove "return" it just show me an error up Add the item(s) to the player's inventory, then return the ItemStack argument instead of creating and returning a new ItemStack . Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future. Link to comment Share on other sites More sharing options...
Recommended Posts
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.